|  |  |  | 
|---|
|  |  |  | var layDate = layui.laydate; | 
|---|
|  |  |  | var laytpl = layui.laytpl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // // 渲染搜索模板 | 
|---|
|  |  |  | // $.ajax({ | 
|---|
|  |  |  | //     url: baseUrl+"/docType/page/auth", | 
|---|
|  |  |  | //     headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | //     data: { | 
|---|
|  |  |  | //         limit: 9999 | 
|---|
|  |  |  | //     }, | 
|---|
|  |  |  | //     method: 'POST', | 
|---|
|  |  |  | //     success: function (res) { | 
|---|
|  |  |  | //         if (res.code === 200){ | 
|---|
|  |  |  | //             let template = Handlebars.compile($('#docTypeTpl').html()); | 
|---|
|  |  |  | //             $('#docType-query').html(template(res.data)); | 
|---|
|  |  |  | //             layui.form.render('select'); | 
|---|
|  |  |  | //         } else if (res.code === 403){ | 
|---|
|  |  |  | //             top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | //         } else { | 
|---|
|  |  |  | //             layer.msg(res.msg, {icon: 2}) | 
|---|
|  |  |  | //         } | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | // }) | 
|---|
|  |  |  | // 渲染搜索模板 | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/docType/page/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | limit: 9999 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | if (res.code === 200){ | 
|---|
|  |  |  | let template = Handlebars.compile($('#docTypeTpl').html()); | 
|---|
|  |  |  | $('#docType-query').html(template(res.data)); | 
|---|
|  |  |  | layui.form.render('select'); | 
|---|
|  |  |  | } else if (res.code === 403){ | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg(res.msg, {icon: 2}) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let docName = getQueryVariable('docName') | 
|---|
|  |  |  | let where = {}; | 
|---|
|  |  |  | if (docName != false) { | 
|---|
|  |  |  | where.docName = decodeURI(docName); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | console.log(where) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 渲染表格 | 
|---|
|  |  |  | var insTb = table.render({ | 
|---|
|  |  |  | 
|---|
|  |  |  | where: where, | 
|---|
|  |  |  | limit: 16, | 
|---|
|  |  |  | limits: [16, 30, 50, 100, 200, 500], | 
|---|
|  |  |  | toolbar: '#toolbar', | 
|---|
|  |  |  | cols: [[ | 
|---|
|  |  |  | {type: 'checkbox', width: 70}, | 
|---|
|  |  |  | {type: 'numbers'}, | 
|---|
|  |  |  | {field: 'orderNo', title: '单据编号', templet: '#orderNoTpl'}, | 
|---|
|  |  |  | {field: 'docType$', align: 'center', title: '类型',  minWidth: 160, width: 160}, | 
|---|
|  |  |  | {field: 'orderNo', title: '单据编号', templet: '#orderNoTpl',sort:true}, | 
|---|
|  |  |  | {field: 'docType$', align: 'center', title: '类型',  minWidth: 160, width: 160,sort:true}, | 
|---|
|  |  |  | {align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160}, | 
|---|
|  |  |  | {field: 'createTime$', title: '创建时间', minWidth: 200, width: 200}, | 
|---|
|  |  |  | {field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl',  minWidth: 160, width: 160}, | 
|---|
|  |  |  | {field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl',  minWidth: 160, width: 160,sort:true}, | 
|---|
|  |  |  | {field: 'memo', align: 'center',title: '备注', hide: true}, | 
|---|
|  |  |  | {align: 'center', title: '操作', toolbar: '#operate', width: 280} | 
|---|
|  |  |  | ]], | 
|---|
|  |  |  | 
|---|
|  |  |  | $("#orderAddBtn").click(function () { | 
|---|
|  |  |  | showEditModel(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | // Excel导出 | 
|---|
|  |  |  | // 监听头工具栏事件 | 
|---|
|  |  |  | table.on('toolbar(order)', function (obj) { | 
|---|
|  |  |  | var data = table.checkStatus(obj.config.id).data; | 
|---|
|  |  |  | switch (obj.event) { | 
|---|
|  |  |  | case 'exportData': | 
|---|
|  |  |  | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ | 
|---|
|  |  |  | var titles=[]; | 
|---|
|  |  |  | var fields=[]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | titles.push("订单编号"); | 
|---|
|  |  |  | titles.push("品号"); | 
|---|
|  |  |  | titles.push("品名"); | 
|---|
|  |  |  | titles.push("订单数量"); | 
|---|
|  |  |  | titles.push("完成数量"); | 
|---|
|  |  |  | titles.push("作业中数量"); | 
|---|
|  |  |  | titles.push("创建时间"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fields.push("orderNo"); | 
|---|
|  |  |  | fields.push("matnr"); | 
|---|
|  |  |  | fields.push("maktx"); | 
|---|
|  |  |  | fields.push("anfme"); | 
|---|
|  |  |  | fields.push("qty"); | 
|---|
|  |  |  | fields.push("workQty"); | 
|---|
|  |  |  | fields.push("createTime$"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var orderNos = []; | 
|---|
|  |  |  | data.forEach(function(elem) { | 
|---|
|  |  |  | console.log("elem="+elem.settle); | 
|---|
|  |  |  | if(elem.payType >0) { | 
|---|
|  |  |  | co = 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderNos.push(elem.orderNo); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | var param = { | 
|---|
|  |  |  | 'orderNo': orderNos, | 
|---|
|  |  |  | 'fields' : fields | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/order/export/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: JSON.stringify(param), | 
|---|
|  |  |  | dataType:'json', | 
|---|
|  |  |  | contentType:'application/json;charset=UTF-8', | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | table.exportFile(titles,res.data,'xls'); | 
|---|
|  |  |  | } else if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg(res.msg) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | $("#orderExcel").click(function () { | 
|---|
|  |  |  | var checkStatus = table.checkStatus(obj.config.id); | 
|---|
|  |  |  | var data = checkStatus.data; | 
|---|
|  |  |  | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ | 
|---|
|  |  |  | if (data.length === 0){ | 
|---|
|  |  |  | layer.msg('请选择数据'); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | var titles=[]; | 
|---|
|  |  |  | var fields=[]; | 
|---|
|  |  |  | data.config.cols[0].map(function (col) { | 
|---|
|  |  |  | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { | 
|---|
|  |  |  | titles.push(col.title); | 
|---|
|  |  |  | fields.push(col.field); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | var exportData = {}; | 
|---|
|  |  |  | $.each($('#search-box [name]').serializeArray(), function() { | 
|---|
|  |  |  | exportData[this.name] = this.value; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | var param = { | 
|---|
|  |  |  | 'wrkMast': exportData, | 
|---|
|  |  |  | 'fields': fields | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/order/export/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: JSON.stringify(param), | 
|---|
|  |  |  | dataType:'json', | 
|---|
|  |  |  | contentType:'application/json;charset=UTF-8', | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | table.exportFile(titles,res.data,'xls'); | 
|---|
|  |  |  | } else if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg(res.msg) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 工具条点击事件 | 
|---|
|  |  |  | table.on('tool(order)', function (obj) { | 
|---|
|  |  |  | 
|---|
|  |  |  | showWrkTrace(data.id); | 
|---|
|  |  |  | } else if (layEvent === 'del') { | 
|---|
|  |  |  | doDel(data.id); | 
|---|
|  |  |  | } else if (layEvent === 'dy') { | 
|---|
|  |  |  | doDy(data.id); | 
|---|
|  |  |  | } else if (layEvent === 'complete') { | 
|---|
|  |  |  | doModify(data.id, 4); | 
|---|
|  |  |  | } else if (layEvent === 'cancel') { | 
|---|
|  |  |  | 
|---|
|  |  |  | cellMinWidth: 100, | 
|---|
|  |  |  | cols: [[ | 
|---|
|  |  |  | {type: 'numbers'}, | 
|---|
|  |  |  | {field: 'matnr', title: '商品编码', width: 160}, | 
|---|
|  |  |  | {field: 'matnr', title: '品号', width: 160}, | 
|---|
|  |  |  | {field: 'maktx', title: '商品名称', width: 160}, | 
|---|
|  |  |  | {field: 'batch', title: '序列码'}, | 
|---|
|  |  |  | {field: 'anfme', title: '数量'}, | 
|---|
|  |  |  | {field: 'qty', title: '作业数量', style: 'font-weight: bold'}, | 
|---|
|  |  |  | // {field: 'unit', title: '单位'}, | 
|---|
|  |  |  | {field: 'workQty', title: '作业数量', style: 'font-weight: bold'}, | 
|---|
|  |  |  | {field: 'qty', title: '完成数量'}, | 
|---|
|  |  |  | // { | 
|---|
|  |  |  | //     field: 'createTime$', title: '创建时间', sort: true, templet: function (d) { | 
|---|
|  |  |  | //         return util.toDateString(d.createTime); | 
|---|
|  |  |  | 
|---|
|  |  |  | // }, | 
|---|
|  |  |  | // {field: 'inQty', title: '已入库量'}, | 
|---|
|  |  |  | // {field: 'color', title: '颜色'}, | 
|---|
|  |  |  | {field: 'origin', title: '仓库号'} | 
|---|
|  |  |  | {field: 'threeCode', title: '仓库号'} | 
|---|
|  |  |  | ]], | 
|---|
|  |  |  | request: { | 
|---|
|  |  |  | pageName: 'curr', | 
|---|
|  |  |  | 
|---|
|  |  |  | area: '1300px', | 
|---|
|  |  |  | success: function (layero, dIndex) { | 
|---|
|  |  |  | $(layero).children('.layui-layer-content').css('overflow', 'visible'); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl + "/docTypeQuery/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | condition: decodeURI(docName) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | if (res.code == 200) { | 
|---|
|  |  |  | if (res.data.length > 0) { | 
|---|
|  |  |  | $("#docType").val(res.data[0].id); | 
|---|
|  |  |  | $(document.getElementById("docType$")).val(res.data[0].value) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var isExpAdd = !expTpe; | 
|---|
|  |  |  | // 回显数据 | 
|---|
|  |  |  | form.val('editForm', expTpe); | 
|---|
|  |  |  | 
|---|
|  |  |  | cellMinWidth: 100, | 
|---|
|  |  |  | cols: [[ | 
|---|
|  |  |  | {type: 'numbers', title: '#'}, | 
|---|
|  |  |  | {field: 'matnr', title: '商品编码', width: 160}, | 
|---|
|  |  |  | {field: 'maktx', title: '商品名称', width: 200}, | 
|---|
|  |  |  | {field: 'matnr', title: '品号', width: 160}, | 
|---|
|  |  |  | {field: 'maktx', title: '名称', width: 200}, | 
|---|
|  |  |  | {field: 'batch', title: '序列码', edit: true}, | 
|---|
|  |  |  | {field: 'specs', title: '规格'}, | 
|---|
|  |  |  | {field: 'anfme', title: '数量(修改)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110}, | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 打印 | 
|---|
|  |  |  | function doDy(orderId) { | 
|---|
|  |  |  | layer.confirm('确定要打印吗?', { | 
|---|
|  |  |  | shade: .1, | 
|---|
|  |  |  | skin: 'layui-layer-admin' | 
|---|
|  |  |  | }, function (i) { | 
|---|
|  |  |  | layer.close(i); | 
|---|
|  |  |  | layer.load(2); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/order/dy", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | orderId: orderId | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | layer.closeAll('loading'); | 
|---|
|  |  |  | if (res.code === 200){ | 
|---|
|  |  |  | if (insTbCount === 0) { | 
|---|
|  |  |  | insTb.reload({page: {curr: 1}}); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | $(".layui-laypage-btn")[0].click(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | layer.msg(res.msg, {icon: 1}); | 
|---|
|  |  |  | } else if (res.code === 403){ | 
|---|
|  |  |  | top.location.href = baseUrl+"/"; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | layer.msg(res.msg, {icon: 2}); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 修改订单状态 | 
|---|
|  |  |  | function doModify(orderId, settle) { | 
|---|
|  |  |  | 
|---|
|  |  |  | var traceCharts = echarts.init(document.getElementById('wrkTraceCharts')); | 
|---|
|  |  |  | var traceOptions = { | 
|---|
|  |  |  | title: { | 
|---|
|  |  |  | text: '作业/总量', x: 'center', y: '38%', | 
|---|
|  |  |  | text: '总量/作业/完成', x: 'center', y: '38%', | 
|---|
|  |  |  | textStyle: {fontSize: 18, color: '#262626', fontWeight: 'normal'}, | 
|---|
|  |  |  | subtextStyle: {fontSize: 36, color: '#10B4E8'}, | 
|---|
|  |  |  | itemGap: 20 | 
|---|
|  |  |  | 
|---|
|  |  |  | // 赋值 | 
|---|
|  |  |  | traceCharts.setOption({ | 
|---|
|  |  |  | title: { | 
|---|
|  |  |  | subtext: res.data.wrkQty+"/"+res.data.totalQty | 
|---|
|  |  |  | subtext: res.data.totalQty+"/"+res.data.wrkQty+"/"+res.data.endQty | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | series: [ | 
|---|
|  |  |  | { | 
|---|