$.pageLoad(function () {
JobList.init();
});
var JobList = {
init: function () {
var self = this;
self.initControls();
},
initControls: function () {
var self = this;
$('#wrapper')._layout({
border: false,
fit: true
});
$('#northBox')._panel({
border: true,
fit: true
});
$('#ui-form')._form();
$('#name')._textbox({
//required: true,
//validType: 'email'
});
$('#startTime')._datetimebox({
onChange: function (newVal, oldVal) {
if ($.isNullOrEmpty(newVal)) {
return;
}
//var v =$('#startTime').datetimebox('getValue');
var d = moment(newVal, "YYYY-MM-DD HH:mm:ss").toDate();
$('#endTime').datetimebox('calendar').calendar({
validator: function (date) {
return d < date;
}
});
}
});
$('#endTime')._datetimebox({
onChange: function (newVal, oldVal) {
if ($.isNullOrEmpty(newVal)) {
return;
}
//var v =$('#endTime').datetimebox('getValue');
var d = moment(newVal, "YYYY-MM-DD HH:mm:ss").toDate();
$('#startTime').datetimebox('calendar').calendar({
validator: function (date) {
return d > date;
}
});
}
});
$('#enabled')._combobox({
editable: false,
panelHeight: 66,
data: [
{ text: '是', value: 'true' },
{ text: '否', value: 'false' }
],
width:427
});
$('#btnReset')._linkbutton({
onClick: function () {
self.reset();
}
});
$('#btnQuery')._linkbutton({
onClick: function () {
self.load();
}
});
$('#create')._linkbutton({
onClick: function () {
self.create();
}
});
$('#update')._linkbutton({
onClick: function () {
self.update();
}
});
$('#del')._linkbutton({
onClick: function () {
self.del();
}
});
$('#export')._linkbutton({
onClick:function () {
self.export();
}
});
$('#dg')._datagrid({
fit: true,
rownumbers: true,
pagination: true,
fitColumns: true,
striped: true,
singleSelect: true,
toolbar: '#toolbar',
pageSize: 10,
loader: function (param, success, error) {
var getInput = self.getQueryData(param);
$.ajax({
showLoading: false,
url: '../api/job',
type: 'GET',
data: getInput,
// contentType: 'application/json',
headers: {
Authorization: $.cookie('EL-ADMIN-TOEKN')
},
success: function (data) {
success({ total: data.totalElements, rows:data.content });
},
error: error,
});
},
columns: [[
{ field: 'name', title: '岗位名称', width: 20 },
{ field: 'jobSort', title: '岗位排序', width: 10 },
{ field:'enabled',title: '是否启用',width: 20,align: 'center',
formatter: function (val, row, index) {
if (val == null) {
return '';
}
return val ? '<div class="ui-normal">是</div>' : '否';
}
},
{ field: 'createTime', title: '创建时间', width: 15 }
]],
/*var n ={name:"",enabled:"",createTime:""};
delete n.name;
delete n.enabled;
delete n.createTime;*/
});
$.initControls();
$.hidePageLoading();
},
getQueryData: function (param) {
var data = { size: param.rows, page: (param.page - 1) , sort: 'jobSort,asc'};
$.extend(data, $('#mainForm').form('get'));
return data;
},
reload: function () {
$('#dg').datagrid('reload');
},
load: function () {
$('#dg').datagrid('load');
},
create: function () {
$.openPage('新建岗位管理', 'jobCreate.html', self.reload, null, 1200, 360);
},
update: function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.alert('警告', '未选中一行', 'warning');
return;
}
$.openPage('编辑岗位管理', 'jobCreate.html?id=' +row.id, self.reload, null, 1200, 360);
},
del: function () {
var self = this;
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.alert('警告', '未选中一行', 'warning');
return;
}
$.confirm('确认', '您确认要删除选中的记录吗?', function (r) {
if (r) {
$.ajax({
showLoading: false,
url: '../api/job',
data: JSON.stringify([row.id]) ,
type: 'DELETE',
contentType:'application/json',
headers: {
Authorization: $.cookie('EL-ADMIN-TOEKN')
},
success: function (d) {
if (d.Success && d.Result) {
$.show('操作成功');
self.reload();
}
}
});
}
});
},
export: function () {
//导出数据表格
$('#dg').datagrid('toExcel','岗位管理.xls');//导出
//$('#dg').datagrid('print','岗位管理.xls');//打印
},
reset: function () {
$('#mainForm').form('reset');
}
};
查询