| | |
| | | var pageCurr; |
| | | var wrkNo; |
| | | var ioTime; |
| | | var tableIns; |
| | | layui.use(['table', 'laydate', 'form'], function () { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#taskLog', |
| | | headers: { token: localStorage.getItem('token') }, |
| | | url: baseUrl + '/taskLog/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | // AGV工作档日志:工作状态多选(与AGV任务管理一致),默认 7、8、9 |
| | | function updateTaskLogWrkStsFromCheckbox() { |
| | | var ids = [], texts = []; |
| | | $('#taskLogWrkStsCheckboxWrap input:checkbox:checked').each(function () { |
| | | var $input = $(this); |
| | | ids.push($input.val()); |
| | | var text = $input.data('text') || $input.closest('label').clone().children().remove().end().text().trim() || $input.val(); |
| | | texts.push(text); |
| | | }); |
| | | $('#taskLogWrkSts').val(ids.join(',')); |
| | | $('#taskLogWrkStsDisp').val(texts.join(', ')); |
| | | } |
| | | $(document).on('change', '#taskLogWrkStsCheckboxWrap input:checkbox', updateTaskLogWrkStsFromCheckbox); |
| | | |
| | | function initTaskLogWrkStsThenTable() { |
| | | $.ajax({ |
| | | url: baseUrl + '/basWrkStatusQueryAgv/auth', |
| | | headers: { token: localStorage.getItem('token') }, |
| | | data: { condition: '' }, |
| | | method: 'POST', |
| | | traditional: true, |
| | | success: function (res) { |
| | | var $wrap = $('#taskLogWrkStsCheckboxWrap'); |
| | | $wrap.empty(); |
| | | var defaultIds = { '7': true, '8': true, '9': true }; |
| | | if (res.code === 200 && res.data && res.data.length) { |
| | | res.data.forEach(function (item) { |
| | | var id = String(item.id); |
| | | var text = item.value || id; |
| | | var checked = defaultIds[id] ? ' checked' : ''; |
| | | $wrap.append( |
| | | '<label class="taskLog-wrksts-cb-label" style="display: inline-block; margin: 4px 12px 4px 0; cursor: pointer;"><input type="checkbox" value="' + id + '" data-text="' + (text.replace(/"/g, '"')) + '"' + checked + '> ' + text + '</label>' |
| | | ); |
| | | }); |
| | | updateTaskLogWrkStsFromCheckbox(); |
| | | } |
| | | $('#taskLogWrkStsDisp').off('click').on('click', function () { |
| | | $('#taskLogWrkStsWindow').toggle(); |
| | | }); |
| | | var initialWhere = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | initialWhere[this.name] = this.value; |
| | | }); |
| | | renderTaskLogTable(initialWhere); |
| | | }, |
| | | error: function () { |
| | | renderTaskLogTable({}); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function renderTaskLogTable(initialWhere) { |
| | | tableIns = table.render({ |
| | | elem: '#taskLog', |
| | | headers: { token: localStorage.getItem('token') }, |
| | | url: baseUrl + '/taskLog/list/auth', |
| | | where: initialWhere || {}, |
| | | page: true, |
| | | limit: 15, |
| | | limits: [15, 30, 50, 100, 200, 500], |
| | | even: true, |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | height: 'full-120', |
| | | cols: [[ |
| | | // {field: 'id', align: 'center', title: 'id'} |
| | | { field: 'wrkNo', align: 'center', title: '工作号', sort: true, width: 105 } |
| | | , { field: 'ioTime$', align: 'center', title: '工作时间', } |
| | | , { field: 'wrkSts$', align: 'center', title: '工作状态', } |
| | | , { field: 'agvWrkNo', align: 'center', title: 'AGV工作号', width: 180 } |
| | | , { field: 'ioTime$', align: 'center', title: '工作时间', width: 160 } |
| | | , { field: 'wrkSts$', align: 'center', title: '工作状态', width: 150 } |
| | | , { field: 'ioType$', align: 'center', title: '入出库类型', width: 150 } |
| | | , { field: 'ioPri', align: 'center', title: '优先级', width: 80 } |
| | | , { field: 'taskType$', align: 'center', title: '任务类型', width: 120 } |
| | |
| | | , { field: 'staNo$', align: 'center', title: '目标站', width: 120 } |
| | | , { field: 'locNo', align: 'center', title: '目标库位', width: 120 } |
| | | , { field: 'barcode', align: 'center', title: '条码', width: 110 } |
| | | , { field: 'errorMemo', align: 'center', title: 'AGV回复报文', width: 200, hide: true } |
| | | , { field: 'errorMemo2', align: 'center', title: 'AGV回复报文2', width: 200, hide: true } |
| | | , { field: 'errorTime$', align: 'center', title: '错误时间', width: 160, hide: true } |
| | | , { field: 'preHave', align: 'center', title: '先入品', hide: true } |
| | | , { field: 'takeNone', align: 'center', title: '空操作', hide: true } |
| | | , { field: 'modiUser$', align: 'center', title: '修改人员', hide: true } |
| | | , { field: 'modiTime$', align: 'center', title: '修改时间', hide: true, width: 160 } |
| | | , { fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 200 } |
| | | , { fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 250 } |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | // 安全检查,防止res.data为undefined |
| | | if (!res || !res.data) { |
| | | return { |
| | | 'code': res ? res.code : 500, |
| | | 'msg': res ? res.msg : '数据格式错误', |
| | | 'count': 0, |
| | | 'data': [] |
| | | }; |
| | | } |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | 'count': res.data.total || 0, |
| | | 'data': res.data.records || [] |
| | | } |
| | | }, |
| | | response: { |
| | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | initTaskLogWrkStsThenTable(); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(taskLog)', function (obj) { |
| | |
| | | form.on('submit(reset)', function (data) { |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | $('#taskLogWrkStsCheckboxWrap input:checkbox').prop('checked', false); |
| | | $('#taskLogWrkSts').val(''); |
| | | $('#taskLogWrkStsDisp').val(''); |
| | | tableReload(false); |
| | | }); |
| | | |
| | |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var ins = child ? parent.tableIns : tableIns; |
| | | if (!ins) return; |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | | ins.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr |
| | |
| | | } |
| | | pageCurr = curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | | ins.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr - 1 |