let form, table, element; let tableIns; let pageNum = 1; // 定义分页 layui.use(["form", "table"], function () { form = layui.form; table = layui.table; element = layui.element; element.render(); initTable(); getStatistics(); }); // 数据概览 function getStatistics() { let url = dataUrl + 'backstage/planOut/getStatistics'; ajaxRequest(url, "POST", null, true, function () { }, function (result) { if (result.code === 200) { setNum(result.data); } }, function (xhr, status, error) { errorFn(xhr, status, error) }, null); // 数据概览赋值 function setNum(obj) { $('#totalNum').html(obj.needNum); $('#dfhNum').html(obj.dfhNum); $('#fhNum').html(obj.fhNum); $('#overNum').html(obj.overNum); $('#noPlanNum').html(obj.noPlanNum); } } // 查询/重置 function queryTable(type) { if (type === 1) { let proName = $('#proName').val(); let flag = checkValue(proName); if (flag) { $('#proName').val(''); return layer.msg('工程名称查询包含特殊字符,请重新输入', { icon: 2 }); } reloadTable(1); } else if (type === 2) { $('#proName').val(''); $('#status').val(''); layui.form.render(); reloadTable(1); } } // 刷新页面数据 function reloadData() { reloadTable(1); getStatistics(); } // 重载表格 function reloadTable(pageNum) { table.reload("currentTableId", { page: { curr: pageNum ? pageNum : 1, }, where: { encryptedData: JSON.stringify({ 'proName': $('#proName').val(), 'status': $('#status').val() }), }, }, ); } // 初始化表格 function initTable() { tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', headers: { authorization: sessionStorage.getItem("gz-token"), }, height: "full-300", url: dataUrl + "backstage/planOut/getProPlanPage", where: { encryptedData: JSON.stringify({ 'proName': $('#proName').val(), 'status': $('#status').val() }), }, request: { pageName: 'pageNum', limitName: 'pageSize' }, parseData: function (res) { // res 即为原始返回的数据 if (res.code === 401) { closeWindowOpen(); } return { "code": 0, // 解析接口状态 "msg": '获取成功', // 解析提示文本 "count": res.total, // 解析数据长度 "data": res.list // 解析数据列表 }; }, cols: [ [ { width: '5%', title: "序号", align: "center", templet: function (d) { return d.LAY_NUM; }, }, { field: "proName", width: '20%', title: "工程名称", unresize: true, align: "center", sort:true, }, { field: "planNum", width: '10%', title: "需求计划数量", unresize: true, align: "center", sort:true, templet: function (d) { let html = ""; html += "" + setNumColor(d.planNum) + ""; return html; }, }, { field: "recordNum", width: '10%', title: "出库单数量 ", unresize: true, align: "center", sort:true, templet: function (d) { return setNumColor(d.recordNum); }, }, { field: "status", title: "发货状态", width: '10%', unresize: true, align: "center", sort:true, templet: function (d) { return setStatusColor(d.status); }, }, { field: "lastDay", width: '15%', title: "最后发货时间", unresize: true, align: "center", sort:true, }, { field: "progress", width: '19.85%', title: "发货进度", unresize: true, align: "center", templet: schedule, }, { title: "操作", width: '10%', align: "center", unresize: true, templet: function (d) { let html = ""; html += "详情"; // html += "