|  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     }) | 
 |  |  |      | 
 |  |  |      | 
 |  |  |      | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 渲染表格 | 
 |  |  |     var insTb = table.render({ | 
 |  |  | 
 |  |  |         showEditModel(); | 
 |  |  |     }); | 
 |  |  |  | 
 |  |  |     // 添加指定订单 | 
 |  |  |     $("#KingOrderAddBtn").click(function () { | 
 |  |  |         KingShowEditModel(); | 
 |  |  |     }); | 
 |  |  |  | 
 |  |  |     // 工具条点击事件 | 
 |  |  |     table.on('tool(order)', function (obj) { | 
 |  |  |         var data = obj.data; | 
 |  |  | 
 |  |  |         } else if (layEvent === 'del') { | 
 |  |  |             doDel(data.id); | 
 |  |  |         } else if (layEvent === 'complete') { | 
 |  |  |             doModify(data.id, 4); | 
 |  |  |             doModify(data.id, data.orderNo, 4); | 
 |  |  |         } else if (layEvent === 'look') { | 
 |  |  |             var $a = $(obj.tr).find('a[lay-event="look"]'); | 
 |  |  |             var offset = $a.offset(); | 
 |  |  | 
 |  |  |                             {type: 'numbers'}, | 
 |  |  |                             {field: 'matnr', title: '商品编码', width: 160}, | 
 |  |  |                             {field: 'maktx', title: '商品名称', width: 160}, | 
 |  |  |                             {field: 'batch', title: '序列码'}, | 
 |  |  |                             {field: 'batch', title: '批号'}, | 
 |  |  |                             {field: 'anfme', title: '数量'}, | 
 |  |  |                             {field: 'workQty', title: '作业数量'}, | 
 |  |  |                             {field: 'qty', title: '完成数量', style: 'font-weight: bold'}, | 
 |  |  | 
 |  |  |                             layer.msg('明细修改数量不合法', {icon: 2}); | 
 |  |  |                             return false; | 
 |  |  |                         } | 
 |  |  |                         if (nList[xi].anfme < nList[xi].workQty){ | 
 |  |  |                             layer.msg('数量不能小于已作业数量', {icon: 2}); | 
 |  |  |                             return false; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     layer.load(2); | 
 |  |  |                     $.ajax({ | 
 |  |  | 
 |  |  |                         {type: 'numbers', title: '#'}, | 
 |  |  |                         {field: 'matnr', title: '商品编码', width: 160}, | 
 |  |  |                         {field: 'maktx', title: '商品名称', width: 200}, | 
 |  |  |                         {field: 'batch', title: '序列码', edit: true}, | 
 |  |  |                         {field: 'batch', title: '批号', edit: true}, | 
 |  |  |                         {field: 'specs', title: '规格'}, | 
 |  |  |                         {field: 'anfme', title: '数量(修改)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110}, | 
 |  |  |                         // {field: 'inQty', title: '已入库量',  minWidth: 100, width: 100}, | 
 |  |  |                         {field: 'workQty', title: '作业数量',  minWidth: 100, width: 100}, | 
 |  |  |                         // {field: 'unit', title: '单位', width: 80}, | 
 |  |  |                         {field: 'memo', title: '备注' , edit: true}, | 
 |  |  |                         {align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'} | 
 |  |  | 
 |  |  |                     if (layEvent === 'edit') { | 
 |  |  |                         showEditModel2(data); | 
 |  |  |                     } else if (layEvent === 'del') { | 
 |  |  |                         if(data.workQty > 0){ | 
 |  |  |                             layer.msg("已存在作业数量,不能删除", {icon: 2}); | 
 |  |  |                             return; | 
 |  |  |                         } | 
 |  |  |                         layer.confirm('确定要删除吗?', { | 
 |  |  |                             shade: .1, | 
 |  |  |                             skin: 'layui-layer-admin' | 
 |  |  | 
 |  |  |                         } else { | 
 |  |  |                             if (vle <= 0) { | 
 |  |  |                                 layer.msg("数量必须大于零", {icon: 2}); | 
 |  |  |                                 // data[obj.field] = 0; | 
 |  |  |                                 // insTbSSXM.reload({data: xxDataList}); | 
 |  |  |                                 return false; | 
 |  |  |                             } | 
 |  |  |                             if(obj.value < data.workQty){ | 
 |  |  |                                 layer.msg("输入数量不能小于作业中数量", {icon: 2}); | 
 |  |  |                                 // data[obj.field] = 0; | 
 |  |  |                                 // insTbSSXM.reload({data: xxDataList}); | 
 |  |  |                                 return false; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  | 
 |  |  |                                     }); | 
 |  |  |                                 } | 
 |  |  |                             }) | 
 |  |  |                              | 
 |  |  |                             // 弹窗不出现滚动条 | 
 |  |  |                             $(layero).children('.layui-layer-content').css('overflow', 'visible'); | 
 |  |  |                             layui.form.render('select'); | 
 |  |  |                         } | 
 |  |  |                     }); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     function KingShowEditModel(expTpe) { | 
 |  |  |         console.log(expTpe) | 
 |  |  |         admin.open({ | 
 |  |  |             type: 1, | 
 |  |  |             title: '添加指定单据', | 
 |  |  |             content: $('#KingEditDialog').html(), | 
 |  |  |             area: '1300px', | 
 |  |  |             success: function (layero, dIndex) { | 
 |  |  |                 $(layero).children('.layui-layer-content').css('overflow', 'visible'); | 
 |  |  |                 var isExpAdd = !expTpe; | 
 |  |  |                 // 回显数据 | 
 |  |  |                 form.val('KingEditForm', expTpe); | 
 |  |  |                 if (expTpe) { | 
 |  |  |                     $('#orderNo').attr("disabled", "disabled"); | 
 |  |  |                 } | 
 |  |  |                 // 表单提交事件 | 
 |  |  |                 form.on('submit(orderEditSubmit1)', function (data) { | 
 |  |  |                     let nList = admin.util.deepClone(xxDataList); | 
 |  |  |                     layer.load(2); | 
 |  |  |                     $.ajax({ | 
 |  |  |                         url: baseUrl+"/order/form/KingDeeadd/authtest", | 
 |  |  |                         headers: {'token': localStorage.getItem('token')}, | 
 |  |  |                         data: JSON.stringify({ | 
 |  |  |                             orderId: Number(data.field.id), | 
 |  |  |                             docType: Number(data.field.docType), | 
 |  |  |                             orderNo: data.field.orderNo, | 
 |  |  |                             orderDetlList: nList | 
 |  |  |                         }), | 
 |  |  |                         contentType:'application/json;charset=UTF-8', | 
 |  |  |                         method: 'POST', | 
 |  |  |                         success: function (res) { | 
 |  |  |                             layer.closeAll('loading'); | 
 |  |  |                             if (res.code === 200){ | 
 |  |  |                                 layer.close(dIndex); | 
 |  |  |                                 $(".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}); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     }) | 
 |  |  |                     return false; | 
 |  |  |                 }); | 
 |  |  |                 // 明细表格 | 
 |  |  |                 var xxDataList = []; | 
 |  |  |                 var tbOptions = { | 
 |  |  |                     elem: '#formSSXMTable', | 
 |  |  |                     headers: {token: localStorage.getItem('token')}, | 
 |  |  |                     data: xxDataList, | 
 |  |  |                     page: true, | 
 |  |  |                     height: '350px;', | 
 |  |  |                     cellMinWidth: 100, | 
 |  |  |                     cols: [[ | 
 |  |  |                         {type: 'numbers', title: '#'}, | 
 |  |  |                         {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}, | 
 |  |  |                         {field: 'workQty', title: '作业数量',  minWidth: 100, width: 100}, | 
 |  |  |                         // {field: 'unit', title: '单位', width: 80}, | 
 |  |  |                         {field: 'memo', title: '备注' , edit: true}, | 
 |  |  |                         {align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'} | 
 |  |  |                     ]], | 
 |  |  |                     done: function (res) { | 
 |  |  |                         $(layero).find('.layui-table-view').css('margin', '0'); | 
 |  |  |                     }, | 
 |  |  |                     size: '' | 
 |  |  |                 }; | 
 |  |  |                 if (!isExpAdd) { | 
 |  |  |                     $.ajax({ | 
 |  |  |                         url: baseUrl+"/order/detl/all/auth?orderId=" + expTpe.id, | 
 |  |  |                         headers: {'token': localStorage.getItem('token')}, | 
 |  |  |                         method: 'GET', | 
 |  |  |                         async: false, | 
 |  |  |                         success: function (res) { | 
 |  |  |                             if (res.code === 200){ | 
 |  |  |                                 xxDataList = res.data; | 
 |  |  |                                 tbOptions.data = xxDataList; | 
 |  |  |                             } else if (res.code === 403){ | 
 |  |  |                                 top.location.href = baseUrl+"/"; | 
 |  |  |                             }else { | 
 |  |  |                                 layer.msg(res.msg, {icon: 2}) | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     }) | 
 |  |  |                 } | 
 |  |  |                 var insTbSSXM = table.render(tbOptions); | 
 |  |  |                 // 工具条点击事件 | 
 |  |  |                 table.on('tool(formSSXMTable)', function (obj) { | 
 |  |  |                     var data = obj.data; | 
 |  |  |                     var layEvent = obj.event; | 
 |  |  |                     if (layEvent === 'edit') { | 
 |  |  |                         showEditModel2(data); | 
 |  |  |                     } else if (layEvent === 'del') { | 
 |  |  |                         if(data.workQty > 0){ | 
 |  |  |                             layer.msg("已存在作业数量,不能删除", {icon: 2}); | 
 |  |  |                             return; | 
 |  |  |                         } | 
 |  |  |                         layer.confirm('确定要删除吗?', { | 
 |  |  |                             shade: .1, | 
 |  |  |                             skin: 'layui-layer-admin' | 
 |  |  |                         }, function (i) { | 
 |  |  |                             layer.close(i); | 
 |  |  |                             for (var j = 0; j < xxDataList.length; j++) { | 
 |  |  |                                 if (xxDataList[j].matnr === data.matnr && xxDataList[j].batch === data.batch) { | 
 |  |  |                                     xxDataList.splice(j, 1); | 
 |  |  |                                     break; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                             insTbSSXM.reload({data: xxDataList, page: {curr: 1}}); | 
 |  |  |                         }); | 
 |  |  |                     } | 
 |  |  |                 }); | 
 |  |  |                 // 明细数据修改 | 
 |  |  |                 table.on('edit(formSSXMTable)', function (obj) { | 
 |  |  |                     let index = obj.tr.attr("data-index"); | 
 |  |  |                     let data = xxDataList[index]; | 
 |  |  |                     if (obj.field === 'anfme'){ | 
 |  |  |                         let vle = Number(obj.value); | 
 |  |  |                         if (isNaN(vle)) { | 
 |  |  |                             layer.msg("请输入数字", {icon: 2}); | 
 |  |  |                             return false; | 
 |  |  |                         } else { | 
 |  |  |                             if (vle <= 0) { | 
 |  |  |                                 layer.msg("数量必须大于零", {icon: 2}); | 
 |  |  |                                 // data[obj.field] = 0; | 
 |  |  |                                 // insTbSSXM.reload({data: xxDataList}); | 
 |  |  |                                 return false; | 
 |  |  |                             } | 
 |  |  |                             if(obj.value < data.workQty){ | 
 |  |  |                                 layer.msg("输入数量不能小于作业中数量", {icon: 2}); | 
 |  |  |                                 // data[obj.field] = 0; | 
 |  |  |                                 // insTbSSXM.reload({data: xxDataList}); | 
 |  |  |                                 return false; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     data[obj.field] = obj.value; | 
 |  |  |                     insTbSSXM.reload({data: xxDataList}); | 
 |  |  |                 }); | 
 |  |  |  | 
 |  |  |                 $('#matAddBtnComment').click(function () { | 
 |  |  |                     showEditModel2(); | 
 |  |  |                 }); | 
 |  |  |  | 
 |  |  |                 // 显示添加明细表单弹窗 | 
 |  |  |                 function showEditModel2(exp) { | 
 |  |  |                     admin.open({ | 
 |  |  |                         type: 1, | 
 |  |  |                         offset: '150px', | 
 |  |  |                         area: '680px', | 
 |  |  |                         title: (exp ? '修改' : '添加') + '明细', | 
 |  |  |                         content: $('#matEditDialog').html(), | 
 |  |  |                         success: function (layero, dIndex) { | 
 |  |  |                             // 回显数据 | 
 |  |  |                             form.val('matEditForm', exp); | 
 |  |  |                             // 表单提交事件 | 
 |  |  |                             form.on('submit(matEditSubmit)', function (data) { | 
 |  |  |                                 let selectList = matXmSelect.getValue(); | 
 |  |  |                                 for (let i = 0; i<selectList.length; i++) { | 
 |  |  |                                     let item = selectList[i]; | 
 |  |  |                                     // 查询物料详情 | 
 |  |  |                                     $.ajax({ | 
 |  |  |                                         url: baseUrl+"/mat/covert/"+item.value+"/auth", | 
 |  |  |                                         headers: {'token': localStorage.getItem('token')}, | 
 |  |  |                                         method: 'GET', | 
 |  |  |                                         async: false, | 
 |  |  |                                         success: function (res) { | 
 |  |  |                                             if (res.code === 200){ | 
 |  |  |                                                 xxDataList.push(res.data); | 
 |  |  |                                                 insTbSSXM.reload({data: xxDataList, page: {curr: 1}}); | 
 |  |  |                                             } else if (res.code === 403){ | 
 |  |  |                                                 top.location.href = baseUrl+"/"; | 
 |  |  |                                             }else { | 
 |  |  |                                                 layer.msg(res.msg, {icon: 2}) | 
 |  |  |                                             } | 
 |  |  |                                         } | 
 |  |  |                                     }) | 
 |  |  |                                 } | 
 |  |  |                                 layer.close(dIndex); | 
 |  |  |                                 return false; | 
 |  |  |                             }); | 
 |  |  |                             // 渲染物料选择 | 
 |  |  |                             var matXmSelect = xmSelect.render({ | 
 |  |  |                                 el: '#mat', | 
 |  |  |                                 style: { | 
 |  |  |                                     width: '340px', | 
 |  |  |                                 }, | 
 |  |  |                                 autoRow: true, | 
 |  |  |                                 toolbar: { show: true }, | 
 |  |  |                                 filterable: true, | 
 |  |  |                                 remoteSearch: true, | 
 |  |  |                                 remoteMethod: function(val, cb, show){ | 
 |  |  |                                     $.ajax({ | 
 |  |  |                                         url: baseUrl+"/mat/all/get/kv", | 
 |  |  |                                         headers: {'token': localStorage.getItem('token')}, | 
 |  |  |                                         data: { | 
 |  |  |                                             condition: val | 
 |  |  |                                         }, | 
 |  |  |                                         method: 'POST', | 
 |  |  |                                         success: function (res) { | 
 |  |  |                                             if (res.code === 200){ | 
 |  |  |                                                 cb(res.data) | 
 |  |  |                                             } else { | 
 |  |  |                                                 cb([]); | 
 |  |  |                                                 layer.msg(res.msg, {icon: 2}); | 
 |  |  |                                             } | 
 |  |  |                                         } | 
 |  |  |                                     }); | 
 |  |  |                                 } | 
 |  |  |                             }) | 
 |  |  |  | 
 |  |  |                             // 弹窗不出现滚动条 | 
 |  |  |                             $(layero).children('.layui-layer-content').css('overflow', 'visible'); | 
 |  |  |                             layui.form.render('select'); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 修改订单状态 | 
 |  |  |     function doModify(orderId, settle) { | 
 |  |  |     function doModify(orderId, orderNo, settle) { | 
 |  |  |         layer.confirm('确定要手动完结吗?', { | 
 |  |  |             shade: .1, | 
 |  |  |             skin: 'layui-layer-admin' | 
 |  |  | 
 |  |  |                 headers: {'token': localStorage.getItem('token')}, | 
 |  |  |                 data: { | 
 |  |  |                     id: orderId, | 
 |  |  |                     orderNo: orderNo, | 
 |  |  |                     settle: settle | 
 |  |  |                 }, | 
 |  |  |                 method: 'POST', |