| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- queryView_parameter = {
- first : '(0)',
- last : '(0)',
- count : 20
- };
- function queryView_list_next(id) {
- $('#result').html('');
- $('#content').html('');
- var id = (id ? id : queryView_parameter.last);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/queryview/list/' + id + '/next/' + queryView_parameter.count,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- queryView_parameter.first = json.data[0].id;
- queryView_parameter.last = json.data[json.data.length - 1].id;
- } else {
- queryView_parameter.first = '(0)';
- }
- $('#content').html(queryView_list_grid(json));
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_list_prev(id) {
- $('#result').html('');
- $('#content').html('');
- var id = (id ? id : queryView_parameter.first);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/queryview/list/' + id + '/prev/' + queryView_parameter.count,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- queryView_parameter.first = json.data[0].id;
- queryView_parameter.last = json.data[json.data.length - 1].id;
- } else {
- queryView_parameter.last = '(0)';
- }
- queryView_list_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_list_grid(json) {
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="5"> <a href="#" id="prev">prev</a> <a href="#" id="next">next</a> <span id="total">' + json.count + '</span></td></tr>';
- str += '<tr><th>id</th><th>name</th><th>alias</th><th>application</th><th>operate</th></tr>';
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.alias + '</td>';
- str += '<td>' + item.application + '</td>';
- str += '<td>';
- str += '<a href="#" onclick="queryView_edit(\'' + item.id + '\')">edit</a> ';
- str += '<a href="#" onclick="queryView_delete(\'' + item.id + '\')">delete</a>';
- str += '</td>';
- str += '</tr>';
- });
- str += '</table>';
- $('#content').html(str);
- $('#next').click(function() {
- queryView_list_next();
- });
- $('#prev').click(function() {
- queryView_list_prev();
- });
- }
- function queryView_simulate_init() {
- $('#result').html('');
- $('#content').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="simulate">simulate</a> <a href="#" id="get">get</a></td></tr>';
- str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
- str += '<tr><td>filter:</td><td><input type="text" id="filter" style="width:95%"/></td></tr>';
- str += '<tr><td>where:</td><td><input type="text" id="where" style="width:95%"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#simulate').click(function() {
- queryView_simulate($('#id').val());
- });
- $('#flag').click(function() {
- queryView_get($('#id').val());
- });
- }
- function queryView_simulate(id) {
- $.ajax({
- type : 'put',
- dataType : 'json',
- url : '../jaxrs/queryview/' + id + '/simulate?' + Math.random(),
- contentType : 'application/json; charset=utf-8',
- data : JSON.stringify({
- filter : $('#filter').val(),
- where : $('#where').val()
- }),
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_create() {
- $('#result').html('');
- $('#content').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="post">post</a></td></tr>';
- str += '<tr><td>application:</td><td><input type="text" id="application" style="width:95%"/></td></tr>';
- str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
- str += '<tr><td>alias:</td><td><input type="text" id="alias" style="width:95%"/></td></tr>';
- str += '<tr><td>description:</td><td><input type="text" id="description" style="width:95%"/></td></tr>';
- str += '<tr><td>allowPersonList:</td><td><textarea id="allowPersonList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowIdentityList:</td><td><textarea id="allowIdentityList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowDepartmentList:</td><td><textarea id="allowDepartmentList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowCompanyList:</td><td><textarea id="allowCompanyList" style="width:95%"/></td></tr>';
- str += '<tr><td colspan="2">data:</td></tr>';
- str += '<tr><td colspan="2"><textarea id="data" style="width:95%;height:500px"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#post').click(function() {
- queryView_post();
- });
- }
- function queryView_post() {
- $.ajax({
- type : 'post',
- dataType : 'json',
- contentType : 'application/json; charset=utf-8',
- url : '../jaxrs/queryview',
- data : JSON.stringify({
- application : $('#application').val(),
- name : $('#name').val(),
- alias : $('#alias').val(),
- description : $('#description').val(),
- allowPersonList : splitValue($('#allowPersonList').val()),
- allowIdentityList : splitValue($('#allowIdentityList').val()),
- allowDepartmentList : splitValue($('#allowDepartmentList').val()),
- allowCompanyList : splitValue($('#allowCompanyList').val()),
- data : $('#data').val()
- }),
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_edit(id) {
- $('#result').html('');
- $('#content').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
- str += '<tr><td>createTime:</td><td id="createTime"> </td></tr>';
- str += '<tr><td>updateTime:</td><td id="updateTime"> </td></tr>';
- str += '<tr><td>sequence:</td><td id="sequence"> </td></tr>';
- str += '<tr><td>id:</td><td id="id"> </td></tr>';
- str += '<tr><td>lastUpdatePerson:</td><td id="lastUpdatePerson"> </td></tr>';
- str += '<tr><td>lastUpdateTime:</td><td id="lastUpdateTime"> </td></tr>';
- str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
- str += '<tr><td>alias:</td><td><input type="text" id="alias" style="width:95%"/></td></tr>';
- str += '<tr><td>description:</td><td><input type="text" id="description" style="width:95%"/></td></tr>';
- str += '<tr><td>allowPersonList:</td><td><textarea id="allowPersonList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowIdentityList:</td><td><textarea id="allowIdentityList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowDepartmentList:</td><td><textarea id="allowDepartmentList" style="width:95%"/></td></tr>';
- str += '<tr><td>allowCompanyList:</td><td><textarea id="allowCompanyList" style="width:95%"/></td></tr>';
- str += '<tr><td colspan="2">data:</td></tr>';
- str += '<tr><td colspan="2"><textarea id="data" style="width:95%;height:500px"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#put').click(function() {
- queryView_put(id);
- });
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/queryview/' + id,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- if (json.type == 'success') {
- $('#createTime').html(json.data.createTime);
- $('#updateTime').html(json.data.updateTime);
- $('#sequence').html(json.data.sequence);
- $('#id').html(json.data.id);
- $('#lastUpdatePerson').html(json.data.lastUpdatePerson);
- $('#lastUpdateTime').html(json.data.lastUpdateTime);
- $('#name').val(json.data.name);
- $('#application').val(json.data.application);
- $('#description').val(json.data.description);
- $('#allowPersonList').val(joinValue(json.data.allowPersonList));
- $('#allowIdentityList').val(joinValue(json.data.allowIdentityList));
- $('#allowDepartmentList').val(joinValue(json.data.allowDepartmentList));
- $('#allowCompanyList').val(joinValue(json.data.allowCompanyList));
- $('#data').val(json.data.data);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_put(id) {
- $.ajax({
- type : 'put',
- dataType : 'json',
- url : '../jaxrs/queryview/' + id,
- contentType : 'application/json; charset=utf-8',
- data : JSON.stringify({
- application : $('#application').val(),
- name : $('#name').val(),
- alias : $('#alias').val(),
- description : $('#description').val(),
- allowPersonList : splitValue($('#allowPersonList').val()),
- allowIdentityList : splitValue($('#allowIdentityList').val()),
- allowDepartmentList : splitValue($('#allowDepartmentList').val()),
- allowCompanyList : splitValue($('#allowCompanyList').val()),
- data : $('#data').val()
- }),
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_delete(id) {
- $.ajax({
- type : 'delete',
- dataType : 'json',
- url : '../jaxrs/queryview/' + id,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_get(id) {
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/queryview/' + id,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function queryView_listWithApplication_init() {
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="list">list</a></td></tr>';
- str += '<tr><td>application flag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
- str += '<tr><td colspan="2" id="gird"> </td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#post').click(function() {
- queryView_listWithApplication($('#applicationFlag').val());
- });
- }
- function queryView_listWithApplication(id) {
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/queryview/list/application/' + id,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- var str = '<table border="1" width="100%">';
- str += '<tr><th>id</th><th>name</th><th>alias</th><th>application</th><th>operate</th></tr>';
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.alias + '</td>';
- str += '<td>' + item.application + '</td>';
- str += '<td>';
- str += '<a href="#" onclick="queryView_edit(\'' + item.id + '\')">edit</a> ';
- str += '<a href="#" onclick="queryView_delete(\'' + item.id + '\')">delete</a>';
- str += '</td>';
- str += '</tr>';
- });
- str += '</table>';
- $('#gird').html(str);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
|