queryStat_parameter = {
first : '(0)',
last : '(0)',
count : 20
};
function queryStat_list_next(id) {
$('#result').html('');
$('#content').html('');
var id = (id ? id : queryStat_parameter.last);
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/querystat/list/' + id + '/next/' + queryStat_parameter.count,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
if (json.data.length > 0) {
queryStat_parameter.first = json.data[0].id;
queryStat_parameter.last = json.data[json.data.length - 1].id;
} else {
queryStat_parameter.first = '(0)';
}
$('#content').html(queryStat_list_grid(json));
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_list_prev(id) {
$('#result').html('');
$('#content').html('');
var id = (id ? id : queryStat_parameter.first);
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/querystat/list/' + id + '/prev/' + queryStat_parameter.count,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
if (json.data.length > 0) {
queryStat_parameter.first = json.data[0].id;
queryStat_parameter.last = json.data[json.data.length - 1].id;
} else {
queryStat_parameter.last = '(0)';
}
queryStat_list_grid(json);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_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() {
queryStat_list_next();
});
$('#prev').click(function() {
queryStat_list_prev();
});
}
function queryStat_simulate_init() {
$('#result').html('');
$('#content').html('');
var str = '';
str += '| simulate get |
';
str += '| id: | |
';
str += '| date: | |
';
str += '| sample |
';
str += '';
str += '{ ';
str += '"dateRangeType":"", ';
str += '//year, season, month, week, date, range, none ';
str += '"dateEffectType":"", ';
str += '//start, completed ';
str += '"start":"", ';
str += '"completed":"", ';
str += '"year":"", ';
str += '"month":"", ';
str += '"date":"", ';
str += '"season":0, ';
str += '"week":0, ';
str += '"adjust":0 ';
str += '}';
str += ' |
';
str += '| application: | |
';
str += '| process: | |
';
str += '| company: | |
';
str += '| department: | |
';
str += '| identity: | |
';
str += '| person: | |
';
str += '| filter: | |
';
str += '| sample |
';
str += '';
str += '{ ';
str += '"path":"", ';
str += '"value":"", ';
str += '"formatType":"", ';
str += '//textValue, numberValue, booleanValue, dateTimeValue ';
str += '"logic":"", ';
str += '//and,or ';
str += '"comparison":"", ';
str += '//equals,notEquals,greaterThan,greaterThanOrEqualTo,lessThan,lessThanOrEqualTo,like,notLike ';
str += '}';
str += ' |
';
str += '
';
$('#content').html(str);
$('#simulate').click(function() {
queryStat_simulate($('#id').val());
});
$('#get').click(function() {
queryStat_get($('#id').val());
});
}
function queryStat_simulate(id) {
data = {};
if ($('#date').val() != '') {
data.date = JSON.parse($('#date').val());
}
data.application = splitValue($('#application').val());
data.process = splitValue($('#process').val());
data.company = splitValue($('#company').val());
data.department = splitValue($('#department').val());
data.identity = splitValue($('#identity').val());
data.person = splitValue($('#person').val());
if ($('#filter').val() != '') {
data.filter = JSON.parse($('#filter').val());
}
$.ajax({
type : 'put',
dataType : 'json',
url : '../jaxrs/querystat/' + id + '/simulate?' + Math.random(),
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(data),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_create() {
$('#result').html('');
$('#content').html('');
var str = '';
str += '| post |
';
str += '| application: | |
';
str += '| name: | |
';
str += '| alias: | |
';
str += '| description: | |
';
str += '| availablePersonList: | |
';
str += '| availableIdentityList: | |
';
str += '| availableDepartmentList: | |
';
str += '| availableCompanyList: | |
';
str += '| queryView: | |
';
str += '| data: |
';
str += ' |
';
str += '| sample |
';
str += '';
str += '{ ';
str += '"calculate":[ ';
str += '{ ';
str += '"column":"", ';
str += '"displayName":"", ';
str += '"calculateType":"",//sum, average, count, groupSum, groupAverage, groupCount ';
str += '"orderType":"",//desc, asc, original ';
str += '"orderEffectType":"",//key, value ';
str += '"id":"" ';
str += '} ';
str += ']';
str += '}';
str += ' |
';
str += '
';
$('#content').html(str);
$('#post').click(function() {
queryStat_post();
});
}
function queryStat_post() {
var data = {};
data.application = $('#application').val();
data.name = $('#name').val();
data.alias = $('#alias').val();
data.description = $('#description').val();
data.availablePersonList = splitValue($('#availablePersonList').val());
data.availableIdentityList = splitValue($('#availableIdentityList').val());
data.availableDepartmentList = splitValue($('#availableDepartmentList').val());
data.availableCompanyList = splitValue($('#availableCompanyList').val());
data.queryView = $('#queryView').val();
if ($('#data').val() != '') {
data.data = $('#data').val();
}
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/querystat',
data : JSON.stringify(data),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_edit(id) {
$('#result').html('');
$('#content').html('');
var str = '';
str += '| put |
';
str += '| createTime: | |
';
str += '| updateTime: | |
';
str += '| sequence: | |
';
str += '| id: | |
';
str += '| lastUpdatePerson: | |
';
str += '| lastUpdateTime: | |
';
str += '| application: | |
';
str += '| name: | |
';
str += '| alias: | |
';
str += '| description: | |
';
str += '| availablePersonList: | |
';
str += '| availableIdentityList: | |
';
str += '| availableDepartmentList: | |
';
str += '| availableCompanyList: | |
';
str += '| queryView: | |
';
str += '| queryViewName: | |
';
str += '| queryViewAlias: | |
';
str += '| data: |
';
str += ' |
';
str += '| sample |
';
str += '';
str += '{ ';
str += '"calculate":[ ';
str += '{ ';
str += '"column":"", ';
str += '"displayName":"", ';
str += '"calculateType":"",//sum, average, count, groupSum, groupAverage, groupCount ';
str += '"orderType":"",//desc, asc, original ';
str += '"orderEffectType":"",//key, value ';
str += '"id":"" ';
str += '} ';
str += ']';
str += '}';
str += ' |
';
str += '
';
$('#content').html(str);
$('#put').click(function() {
queryStat_put(id);
});
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/querystat/' + 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);
$('#availablePersonList').val(joinValue(json.data.availablePersonList));
$('#availableIdentityList').val(joinValue(json.data.availableIdentityList));
$('#availableDepartmentList').val(joinValue(json.data.availableDepartmentList));
$('#availableCompanyList').val(joinValue(json.data.availableCompanyList));
$('#data').val(json.data.data);
$('#queryView').val(json.data.queryView);
$('#queryViewName').html(json.data.queryViewName);
$('#queryViewAlias').html(json.data.queryViewAlias);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_put(id) {
var data = {};
data.application = $('#application').val();
data.name = $('#name').val();
data.alias = $('#alias').val();
data.description = $('#description').val();
data.availablePersonList = splitValue($('#availablePersonList').val());
data.availableIdentityList = splitValue($('#availableIdentityList').val());
data.availableDepartmentList = splitValue($('#availableDepartmentList').val());
data.availableCompanyList = splitValue($('#availableCompanyList').val());
data.queryView = $('#queryView').val();
if ($('#data').val() != '') {
data.data = $('#data').val();
}
$.ajax({
type : 'put',
dataType : 'json',
url : '../jaxrs/querystat/' + id,
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(data),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_delete(id) {
$.ajax({
type : 'delete',
dataType : 'json',
url : '../jaxrs/querystat/' + id,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_get(id) {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/querystat/' + id,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function queryStat_listWithApplication_init() {
var str = '';
$('#content').html(str);
$('#post').click(function() {
queryStat_listWithApplication($('#applicationFlag').val());
});
}
function queryStat_listWithApplication(id) {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/querystat/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));
});
}