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 = '
';
str += '| prev next ' + json.count + ' |
';
str += '| id | name | alias | application | operate |
';
$.each(json.data, function(index, item) {
str += '';
str += '| ' + item.id + ' | ';
str += '' + item.name + ' | ';
str += '' + item.alias + ' | ';
str += '' + item.application + ' | ';
str += '';
str += 'edit ';
str += 'delete';
str += ' | ';
str += '
';
});
str += '
';
$('#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 = '';
$('#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 = '';
$('#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 = '';
$('#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 = '';
$('#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 = '';
str += '| id | name | alias | application | operate |
';
$.each(json.data, function(index, item) {
str += '';
str += '| ' + item.id + ' | ';
str += '' + item.name + ' | ';
str += '' + item.alias + ' | ';
str += '' + item.application + ' | ';
str += '';
str += 'edit ';
str += 'delete';
str += ' | ';
str += '
';
});
str += '
';
$('#gird').html(str);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}