var pageCurr;
|
var wrkNo;
|
layui.use(['table', 'form'], function(){
|
var table = layui.table;
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var form = layui.form;
|
|
$("#wrkNo").val(parent.wrkNo)
|
// 数据渲染
|
tableIns = table.render({
|
elem: '#commandManage',
|
headers: {token: localStorage.getItem('token')},
|
url: baseUrl+'/commandInfo/list/auth',
|
where: {wrk_no: parent.wrkNo},
|
page: true,
|
limit: 16,
|
limits: [16, 30, 50, 100, 200, 500],
|
even: true,
|
toolbar: '#toolbar',
|
cellMinWidth: 50,
|
cols: [[
|
{field: 'id', align: 'center',title: '指令编号',event: 'wrkNo', sort: true}
|
,{field: 'wrkNo', align: 'center',title: '工作号',event: 'wrkNo', sort: true}
|
,{field: 'commandStatus$', align: 'center',title: '指令状态'}
|
,{field: 'durationTime', align: 'center',title: '持续时长', width: 160}
|
,{field: 'commandType', align: 'center',title: '指令类型'}
|
,{field: 'device', align: 'center',title: '设备'}
|
,{field: 'deviceLog', align: 'center',title: '设备执行信息'}
|
,{field: 'commandDesc', align: 'center',title: '命令描述'}
|
,{field: 'startTime$', align: 'center',title: '开始时间'}
|
,{field: 'endTime$', align: 'center',title: '结束时间'}
|
,{field: 'command', align: 'center',title: '命令报文'}
|
|
,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120}
|
]],
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
return {
|
'code': res.code,
|
'msg': res.msg,
|
'count': res.data.total,
|
'data': res.data.records
|
}
|
},
|
response: {
|
statusCode: 200
|
},
|
done: function(res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
}
|
pageCurr=curr;
|
limit();
|
form.on('checkbox(tableCheckbox)', function (data) {
|
var _index = $(data.elem).attr('table-index')||0;
|
if(data.elem.checked){
|
res.data[_index][data.value] = 'Y';
|
}else{
|
res.data[_index][data.value] = 'N';
|
}
|
});
|
}
|
});
|
|
// 监听排序事件
|
table.on('sort(commandManage)', function (obj) {
|
var searchData = {};
|
$.each($('#search-box [name]').serializeArray(), function() {
|
searchData[this.name] = this.value;
|
});
|
searchData['orderByField'] = obj.field;
|
searchData['orderByType'] = obj.type;
|
tableIns.reload({
|
where: searchData,
|
page: {
|
curr: 1
|
},
|
done: function (res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
}
|
pageCurr=curr;
|
limit();
|
}
|
});
|
});
|
|
// 监听头工具栏事件
|
table.on('toolbar(commandManage)', function (obj) {
|
var checkStatus = table.checkStatus(obj.config.id);
|
switch(obj.event) {
|
case 'refreshData':
|
tableIns.reload({
|
page: {
|
curr: pageCurr
|
}
|
});
|
limit();
|
break;
|
}
|
});
|
|
// 监听行工具事件
|
table.on('tool(commandManage)', function(obj){
|
var data = obj.data;
|
switch (obj.event) {
|
// 任务信息展示
|
case 'wrkMastShow':
|
wrkNo = data.wrkNo;
|
layer.open({
|
type: 2,
|
title: 'WMS任务',
|
maxmin: true,
|
area: [top.detailWidth, top.detailHeight],
|
shadeClose: true,
|
content: '../wrkMast/wrkMast.html',
|
success: function(layero, index){
|
}
|
});
|
break;
|
}
|
});
|
|
// 搜索栏搜索事件
|
form.on('submit(search)', function (data) {
|
pageCurr = 1;
|
tableReload(false);
|
});
|
|
// 搜索栏重置事件
|
form.on('submit(reset)', function (data) {
|
pageCurr = 1;
|
clearFormVal($('#search-box'));
|
tableReload(false);
|
});
|
|
});
|
|
// 关闭动作
|
$(document).on('click','#data-detail-close', function () {
|
parent.layer.closeAll();
|
});
|
|
function tableReload(child) {
|
var searchData = {};
|
$.each($('#search-box [name]').serializeArray(), function() {
|
searchData[this.name] = this.value;
|
});
|
(child ? parent.tableIns : tableIns).reload({
|
where: searchData,
|
page: {
|
curr: pageCurr
|
},
|
done: function (res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
}
|
pageCurr=curr;
|
if (res.data.length === 0 && count !== 0) {
|
tableIns.reload({
|
where: searchData,
|
page: {
|
curr: pageCurr-1
|
}
|
});
|
pageCurr -= 1;
|
}
|
limit(child);
|
}
|
});
|
}
|
|
function setFormVal(el, data, showImg) {
|
for (var val in data) {
|
var find = el.find(":input[id='" + val + "']");
|
if (find[0]!=null){
|
if (find[0].type === 'checkbox'){
|
if (data[val]==='Y'){
|
find.attr("checked","checked");
|
find.val('Y');
|
} else {
|
find.remove("checked");
|
find.val('N');
|
}
|
continue;
|
}
|
}
|
find.val(data[val]);
|
if (showImg){
|
var next = find.next();
|
if (next.get(0)){
|
if (next.get(0).localName === "img") {
|
find.hide();
|
next.attr("src", data[val]);
|
next.show();
|
}
|
}
|
}
|
}
|
}
|
|
function clearFormVal(el) {
|
$(':input', el)
|
.val('')
|
.removeAttr('checked')
|
.removeAttr('selected');
|
}
|
|
function detailScreen(index) {
|
var detail = layer.getChildFrame('#data-detail', index);
|
var height = detail.height()+60;
|
if (height > ($(window).height()*0.9)) {
|
height = ($(window).height()*0.8);
|
}
|
layer.style(index, {
|
// top: (($(window).height()-height)/3)+"px",
|
height: height+'px'
|
});
|
}
|
|
$('body').keydown(function () {
|
if (event.keyCode === 13) {
|
$("#search").click();
|
}
|
});
|