| var initCountVal = 0; | 
| var initAnfmeVal = "-"; | 
| var matCodeData = []; | 
| var currLocNo; | 
| var matCodeLayerIdx; | 
| var data = []; | 
| var checkStatus = []; | 
| function getCol() { | 
|     var cols = [ | 
|         {field: 'id', title: 'id', align: 'center',hide:true} | 
|         ,{type: 'checkbox'} | 
|         ,{field: 'pakinTime', title: '入库时间', align: 'center'} | 
|         ,{field: 'batch', align: 'center',title: '批号'} | 
|         ,{field: 'packageNo', align: 'center',title: '包号'} | 
|         ,{field: 'brand', align: 'center',title: '牌号'} | 
|         ,{field: 'weight', align: 'center',title: '重量(KG)', hide:true} | 
|         ,{field: 'workshop', align: 'center',title: '生产车间', hide:true} | 
|         ,{field: 'line', align: 'center',title: '生产线', hide:true} | 
|         ,{field: 'packageType', align: 'center',title: '包装类型', hide:true} | 
|         ,{field: 'zpalletType', align: 'center',title: '托盘类型', hide:true} | 
|         ,{field: 'fingerMelting', align: 'center',title: '熔指(g/10min)'} | 
|         ,{field: 'fusingPoint', align: 'center',title: '熔点(℃)'} | 
|         ,{field: 'vadf1', align: 'center',title: '挥发份1(%)', hide:true} | 
|         ,{field: 'vadf2', align: 'center',title: '挥发份2(%)', hide:true} | 
|         ,{field: 'yellowness', align: 'center',title: '黄度',  hide:true} | 
|         ,{field: 'opacity', align: 'center',title: '不透明度(0-100%)', hide:true} | 
|         ,{field: 'water', align: 'center',title: '水分(ppm)', hide:true} | 
|         ,{field: 'massState', align: 'center',title: '质量状态', hide:true} | 
|         ,{field: 'problem', align: 'center',title: '质量问题', hide:true} | 
|         ,{field: 'stash', align: 'center',title: '仓库', edit:true} | 
|         ,{field: 'locNo', align: 'center',title: '库位', edit:true} | 
|     ]; | 
|     return cols; | 
| } | 
|   | 
| layui.config({ | 
|     base: baseUrl + "/static/layui/lay/modules/" | 
| }).use(['table','laydate', 'form', 'admin'], function() { | 
|     var table = layui.table; | 
|     var $ = layui.jquery; | 
|     var layer = layui.layer; | 
|     var layDate = layui.laydate; | 
|     var form = layui.form; | 
|     var admin = layui.admin; | 
|   | 
|     // 数据渲染 | 
|     tableIns = table.render({ | 
|         elem: '#waitingPakinTable', | 
|         headers: {token: localStorage.getItem('token')}, | 
|         url: baseUrl+'/pla/list/auth?step=2', | 
|         page: true, | 
|         limit: 16, | 
|         limits: [16, 30, 50, 100, 200, 500], | 
|         even: true, | 
|         toolbar: '#toolbar', | 
|         cellMinWidth: 50, | 
|         cols: [getCol()], | 
|         request: { | 
|             pageName: 'curr', | 
|             pageSize: 'limit' | 
|         }, | 
|         parseData: function (res) { | 
|             console.log(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+"/"; | 
|             } | 
|             tableData = table.cache.locDetl; | 
|             console.log(tableData); | 
|             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'; | 
|                 } | 
|             }); | 
|         } | 
|     }); | 
|   | 
|   | 
|     // 重置事件 | 
|     form.on('submit(reset)', function (data) { | 
|         reset(); | 
|     }); | 
|   | 
|     function reset() { | 
|         clearFormVal($('#search-box')); | 
|         matCodeData = []; | 
|         tableReload(); | 
|         locTips(false); | 
|     } | 
|   | 
|     // 重载表格 | 
|     function tableReload() { | 
|         tableIns.reload({data: matCodeData}); | 
|     } | 
|   | 
|   | 
|   | 
|     $(document).on('click','#add', function () { | 
|         var now = dateToStr(new Date()) | 
|         var newRow = {ioTime : now}; | 
|         data = table.cache.waitingPakinTable; | 
|         data.push(newRow); | 
|         table.reload('waitingPakinTable',{ | 
|             data: data | 
|         }) | 
|     }) | 
|   | 
|     $(document).on('click','#delete', function () { | 
|         let dataNew = []; | 
|         let data = table.cache.waitingPakinTable; | 
|         for(var i=0; i<data.length; i++){ | 
|             if(!data[i].LAY_CHECKED){ | 
|                 dataNew.push(data[i]); | 
|             } | 
|         } | 
|         table.reload('waitingPakinTable',{ | 
|             data: dataNew | 
|         }) | 
|     }) | 
|   | 
|     $(document).on('click','#submit', function () { | 
|         let data = table.cache.waitingPakinTable; | 
|         let dataSave = []; | 
|         let dataOld = []; | 
|         for(var i=0; i<data.length; i++){ | 
|             if(data[i].LAY_CHECKED){ | 
|                 if(!data[i].batch){ | 
|                     layer.msg("有未填写字段"); | 
|                     return; | 
|                 } | 
|                 data[i].status = "待入库"; | 
|                 data[i].weightAnfme = data[i].weight; | 
|                 dataSave.push(data[i]); | 
|             }else { | 
|                 dataOld.push(data[i]); | 
|             } | 
|         } | 
|         $.ajax({ | 
|             url: baseUrl+"/pla/update/auth", | 
|             headers: {'token': localStorage.getItem('token')}, | 
|             data: JSON.stringify(dataSave), | 
|             contentType:'application/json;charset=UTF-8', | 
|             method: 'POST', | 
|             async: false, | 
|             success: function (res) { | 
|                 if (res.code === 200){ | 
|                     layer.msg("提交成功"); | 
|                     table.reload('waitingPakinTable',{ | 
|                         data: dataOld | 
|                     }) | 
|                 } else if (res.code === 403){ | 
|   | 
|                 }else { | 
|                     layer.msg(res.msg, {icon: 2}) | 
|                 } | 
|             } | 
|         }) | 
|     }) | 
|   | 
| }) |