| //称重-包括空车和满车称重 | 
| var layer; | 
| var form; | 
| var table; | 
| var recordData = null;// 业务数据信息 | 
| var selectData = null;  //单选费用的流水的信息 | 
| var snapData;//系统抓拍对象信息 | 
| var completeCardBack = false;// 卡片是否已经执行回收 | 
| var timerWeight; | 
|   | 
| $(function() { | 
|     layui.use([ 'layer', 'laydate', 'form', 'table', 'util'], function() { | 
|         var util = layui.util; | 
|         layer = layui.layer; | 
|         form = layui.form; | 
|         table = layui.table; | 
|         layui.laydate.render({ | 
|             elem : '#test1', | 
|             theme : '#7b8e9f' | 
|         }); | 
|   | 
|         // 右下角添加固定信息 | 
|         util.fixbar({ | 
|             bar1: true, | 
|             css: { | 
|                 right: 10, | 
|                 bottom: 20 | 
|             }, | 
|             bgcolor: '#53adce', | 
|             click: function (type) { | 
|                 if (type === 'bar1') { | 
|                     layer.closeAll(); | 
|                     layer.open({ | 
|                         type: 2, | 
|                         title: false, | 
|                         shadeClose: true, | 
|                         shade: 0.3, | 
|                         closeBtn: 2, | 
|                         area: ['1000px', '640px'], | 
|                         content: '../../basic/inout/inout-progress?type=' + type + "&t=" + Math.random() | 
|                     }); | 
|                 } | 
|             } | 
|         }); | 
|   | 
|         // 监听仓库选择,选择后自动调用仓库的粮品种和产地信息 | 
|         form.on('select(select_depotId)', function(obj) { | 
|             updateFoodVarietyByDepot(obj.value); | 
|         }); | 
|     }); | 
|   | 
|     //显示流程环节 | 
|     showProgress(); | 
|   | 
|     // 监听比例值填写 | 
|     $(".per").blur(function() { | 
|         deAutoByPer(); | 
|     }); | 
|   | 
|     // 监听比例值填写 | 
|     $(".weight").blur(function() { | 
|         deAutoByWeight(); | 
|     }); | 
|   | 
|     // 初始化WebSocket | 
|     initWS(deptId, bizType, progress, userId); | 
| }); | 
|   | 
| window.onload = function(){ | 
|     //自动连接地磅信息,2.5秒获取一次地磅重量信息 | 
|     clearInterval(timerWeight); | 
|     timerWeight = setInterval(function () { | 
|         flushWeight(); | 
|     }, 2500); | 
|   | 
|     // 加载视频 | 
|     initVideo(lprDto,snapDto1,snapDto2); | 
| }; | 
|   | 
| // socket信息返回處理 | 
| function socketOnMessage(packet) { | 
|     var packetData = packet.data; | 
|     // 车牌识别-根据Sn进行匹配,车牌进行匹配,如果匹配失败则弹出提示信息 | 
|     if (packet.userData == "PLATE_NUM") { | 
|         if (packetData.sn == lprDto.sn) { | 
|             if (recordData.plateNum && packetData.plateNum != recordData.plateNum) { | 
|                 layer.alert("请注意:系统检测车牌为:" + packetData.plateNum + ",与当前卡片信息不符合,请核对!"); | 
|             } | 
|             window.parent.sysNotify("车牌识别结果:" + packetData.plateNum); | 
|         } | 
|     } | 
| } | 
|   | 
| // 根据当前操作的按钮ID更新其他按钮状态 | 
| function flushBtn(btnId) { | 
|     if ("btn-weight" == btnId) {// 称重后可以点击完成称重 | 
|         $("#btn-submit").removeClass("layui-btn-disabled"); | 
|         $("#btn-submit").attr("disabled", false); | 
|     } | 
|   | 
|     if ("btn-submit" == btnId) { | 
|         $("#btn-submit").addClass("layui-btn-disabled"); | 
|         $("#btn-submit").attr("disabled", true); | 
|   | 
|         if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {// 出库,如果是空车称重,完成收直接刷新页面 | 
|             resetForm(); | 
|         } else { | 
|             // 完成称重后控制按钮 | 
|             $("#btn-weight").addClass("layui-btn-disabled"); | 
|             $("#btn-weight").attr("disabled", true); | 
|   | 
|             $("#btn-printBill").removeClass("layui-btn-disabled"); | 
|             $("#btn-printBill").attr("disabled", false); | 
|             addDisabled(); | 
|         } | 
|     } | 
|     if ("btn-printBill" == btnId) {// 打印过磅单,说明业务完成 | 
|         $("#btn-weight").removeClass("layui-btn-disabled"); | 
|         $("#btn-weight").attr("disabled", false); | 
|   | 
|         $("#btn-submit").addClass("layui-btn-disabled"); | 
|         $("#btn-submit").attr("disabled", true); | 
|   | 
|         $("#btn-printBill").addClass("layui-btn-disabled"); | 
|         $("#btn-printBill").attr("disabled", true); | 
|         delDisabled(); | 
|         resetForm(); | 
|     } | 
| } | 
|   | 
| //控制流程环节显示 | 
| function showProgress() { | 
|     if(!inoutProgress){ | 
|         return; | 
|     } | 
|   | 
|     if(inoutProgress.indexOf("REGISTER") == -1){ | 
|         $("#progress-register").css("display", "none"); | 
|     } | 
|     if(inoutProgress.indexOf("WEIGHT_FULL") == -1){ | 
|         $("#progress-fullWeight").css("display", "none"); | 
|     } | 
|     if(inoutProgress.indexOf("HANDLE") == -1){ | 
|         $("#progress-hand").css("display", "none"); | 
|     } | 
|     if(inoutProgress.indexOf("WEIGHT_EMPTY") == -1){ | 
|         $("#progress-emptyWeight").css("display", "none"); | 
|     } | 
|     if(inoutProgress.indexOf("CARD_BACK") == -1){ | 
|         $("#progress-cardBack").css("display", "none"); | 
|     } | 
| } | 
|   | 
| //更改扣重信息框不可编辑 | 
| function addDisabled() { | 
|     //杂质 | 
|     $("#impurity").attr("disabled",true); | 
|     $("#deImpurity").attr("disabled",true); | 
|     //水分 | 
|     $("#wet").attr("disabled",true); | 
|     $("#deWet").attr("disabled",true); | 
|     //值仓 | 
|     $("#deHandle").attr("disabled",true); | 
|     //其他 | 
|     $("#deOther").attr("disabled",true); | 
| } | 
| //恢复扣重信息框编辑状态 | 
| function delDisabled() { | 
|     //杂质 | 
|     $("#impurity").attr("disabled",false); | 
|     $("#deImpurity").attr("disabled",false); | 
|     //水分 | 
|     $("#wet").attr("disabled",false); | 
|     $("#deWet").attr("disabled",false); | 
|     //值仓 | 
|     $("#deHandle").attr("disabled",false); | 
|     //其他 | 
|     $("#deOther").attr("disabled",false); | 
| } | 
|   | 
| // 点击称重 | 
| function weight() { | 
|     // 没有业务数据不可执行 | 
|     if (!recordData) { | 
|         layer.alert("没有查询到业务数据,执行被拒绝!!"); | 
|         return; | 
|     } | 
|   | 
|     // 如果是空车称重 | 
|     if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { | 
|         form.val("form-data", { | 
|             emptyWeight : weightDto.weight | 
|         }); | 
|     } | 
|     // 满车称重后 | 
|     if (InoutProgress.WEIGHT_FULL == recordData.progress) { | 
|         form.val("form-data", { | 
|             fullWeight : weightDto.weight | 
|         }); | 
|     } | 
|     form.render(); | 
|   | 
|     // 点击称重时候自动抓拍数据 | 
|     layer.msg("系统自动抓拍保留记录……"); | 
|     snapData = { | 
|         companyId: companyId, | 
|         deptId: deptId, | 
|         bizTag: recordData.progress, | 
|         bizType: bizType, | 
|         plateNum: recordData.plateNum, | 
|   | 
|         id1: (null != lprDto) ? lprDto.id : null, | 
|         id2: (null != snapDto1) ? snapDto1.id : null, | 
|         id3: (null != snapDto2) ? snapDto2.id : null | 
|     }; | 
|   | 
|     //当前AJAX服务为同步服务,返回数据包装照片信息 | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         sync: false, | 
|         type: "POST", | 
|         url: "../../basic/inout/snap-img", | 
|         dataType: "json", | 
|         contentType: "application/json;charset=UTF-8", | 
|         data: JSON.stringify(snapData), | 
|         success: function (result) { | 
|             layer.close(index); | 
|             if (result.code != "0000") { | 
|                 layer.alert(result.msg); | 
|             } else { | 
|                 snapData = result.data; | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.msg("后台调用截图失败,请重新尝试!!"); | 
|         } | 
|     }); | 
|   | 
|     // 出库第二次称重后,进行计算 | 
|     if (InoutProgress.WEIGHT_FULL == recordData.progress) { | 
|         deAutoByPer(); | 
|     } | 
|   | 
|     // 刷新状态 | 
|     flushBtn("btn-weight"); | 
| } | 
|   | 
| // 自动计算,需要注意的是出库过程中,水分重量是加到扣重后净值,根据百分比调整 | 
| function deAutoByPer() { | 
|     var curData = form.val("form-data"); | 
|   | 
|     var netWeight = 0, deImpurity = 0, deWet = 0,  deSum = 0, settleWeight = 0; | 
|   | 
|     if (curData.fullWeight == 0 || curData.emptyWeight == 0) { | 
|         return; | 
|     } | 
|     // 计算净重 | 
|     netWeight = curData.fullWeight - curData.emptyWeight; | 
|   | 
|     if (netWeight <= 0){ | 
|         layer.msg("净重小于等于0,当前计算不正确!"); | 
|         return; | 
|     } | 
|   | 
|     // 杂质扣重 | 
|     if (curData.impurity > 0) { | 
|         deImpurity = (netWeight * curData.impurity / 100.00).toFixed(0); | 
|     } | 
|     // 水分增重 | 
|     if (curData.wet > 0) { | 
|         deWet = (netWeight * curData.wet / 100.00).toFixed(0); | 
|     } | 
|   | 
|   | 
|     // 总扣重 | 
|     deSum = Number(deImpurity)  + Number(curData.deOther) | 
|         + Number(curData.deHandle); | 
|     deSum = deSum.toFixed(0); | 
|   | 
|     // 结算净重,把水分添加近来 | 
|     settleWeight = Number(netWeight) - Number(deSum) + Number(deWet); | 
|     settleWeight = settleWeight.toFixed(0); | 
|   | 
|     form.val("form-data", { | 
|         netWeight : netWeight, | 
|         deImpurity : deImpurity, | 
|         deWet : deWet, | 
|         deSum : deSum, | 
|         settleWeight : settleWeight | 
|     }); | 
|     form.render(); | 
| } | 
|   | 
| // 自动计算 | 
| function deAutoByWeight() { | 
|     var curData = form.val("form-data"); | 
|   | 
|     var netWeight = 0, impurity = 0, wet = 0,  deSum = 0, settleWeight = 0; | 
|   | 
|     if (curData.fullWeight == 0 || curData.emptyWeight == 0) { | 
|         return; | 
|     } | 
|     // 净重 | 
|     netWeight = curData.fullWeight - curData.emptyWeight; | 
|   | 
|     if (netWeight <= 0){ | 
|         layer.msg("净重小于等于0,当前计算不正确!"); | 
|         return; | 
|     } | 
|   | 
|     // 杂质-百分比 | 
|     if (curData.deImpurity > 0) { | 
|         impurity = (curData.deImpurity / netWeight * 100).toFixed(2); | 
|     } | 
|     // 水分 -百分比 | 
|     if (curData.deWet > 0) { | 
|         wet = (curData.deWet / netWeight * 100).toFixed(2); | 
|     } | 
|   | 
|     // 总扣重= 杂质扣重 + 不完善扣重 + 气体扣重 + 值仓扣重 + 包装扣重 | 
|     deSum = Number(curData.deImpurity) | 
|         + Number(curData.deOther) + Number(curData.deHandle); | 
|   | 
|     deSum = deSum.toFixed(0); | 
|   | 
|     // 结算净重,把水分添加近来 | 
|     settleWeight = Number(netWeight) - Number(deSum) + Number(curData.deWet); | 
|     settleWeight = settleWeight.toFixed(0); | 
|   | 
|     form.val("form-data", { | 
|         netWeight : netWeight, | 
|         impurity : impurity, | 
|         wet : wet, | 
|         deSum : deSum, | 
|         settleWeight : settleWeight | 
|     }); | 
|     form.render(); | 
| } | 
|   | 
| //新的读卡方式 | 
| function flushICCard() { | 
|     $("#intelCard").val(null); | 
|     $("#form-data")[0].reset(); | 
|     form.render(); | 
|     recordData = null; | 
|     $.ajax({ | 
|         type: "GET", | 
|         async: true, | 
|         url: "http://127.0.0.1:9111/ICCARD", | 
|         data: {}, | 
|         dataType: "jsonp", | 
|         jsonp: "callback", | 
|         jsonpCallback: "jsonpCallback", | 
|         success: function (json) { | 
|             //console.log(json); | 
|             var data = json.no; | 
|             //console.log(data); | 
|             if (data === "not found") { | 
|                 layer.alert("请重新读卡!", {offset: ['300px', '300px']}); | 
|             } else { | 
|                 $("#intelCard").val(data); | 
|                 flushData(); | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.alert("IC卡读取出错!", {offset: ['300px', '300px']}); | 
|         } | 
|     }); | 
| } | 
|   | 
| // 使用插件获取省份证 | 
| function flushIdCard() { | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         type: "GET", | 
|         async: true, | 
|         url: "http://127.0.0.1:9111/IDCARD", | 
|         data: {}, | 
|         dataType: "jsonp", | 
|         jsonp: "callback", | 
|         jsonpCallback: "jsonpCallback", | 
|         success: function (json) { | 
|             layer.close(index); | 
|             var data = json.content; | 
|             if (data === "not found") { | 
|                 layer.alert("没有读取到身份证信息,请手动录入!", { | 
|                     offset: ['300px', '300px'] | 
|                 }); | 
|                 return; | 
|             } | 
|             $("#userId").val(data.idNum); | 
|             flushData(); | 
|         }, | 
|         error: function () { | 
|             layer.alert("身份证读取失败,请手动录入!", { | 
|                 offset: ['300px', '300px'] | 
|             }); | 
|             layer.close(index); | 
|         } | 
|     }); | 
| } | 
|   | 
| function flushWeight() { | 
|     $.ajax({ | 
|         type: "GET", | 
|         async: true, | 
|         timeout: 2000, | 
|         url: "http://127.0.0.1:9111/WEIGHT", | 
|         data: {}, | 
|         dataType: "jsonp", | 
|         jsonp: "callback", | 
|         jsonpCallback: "jsonpCallback", | 
|         success: function (json) { | 
|             var data = json.content; | 
|             if(!data) data = 0.0; | 
|             weightDto.weight = data; | 
|             $("#weightValue").html(data + "<em>KG</em>"); | 
|             $("#img_scale_statule").attr("src", "../../static/images/icon-gree.png"); | 
|         }, | 
|         error: function () { | 
|             weightDto.weight = 0.0; | 
|             $("#weightValue").html("<em>0.0KG</em>"); | 
|             $("#img_scale_statule").attr("src", "../../static/images/icon-red.png"); | 
|         } | 
|     }); | 
| } | 
|   | 
| // 打印过磅单 | 
| function printBill() { | 
|     if (!recordData) { | 
|         layer.alert("没有获取到业务数据,不支持打印!"); | 
|         return; | 
|     } | 
|     // 从后台获取模版并打印 | 
|     var data = form.val("form-data"); | 
|     // 合并更新當前编辑数据 | 
|     Object.assign(recordData, data); | 
|   | 
|     printBillStep2(); | 
| } | 
|   | 
| // 点击打印,先执行系统默认执行完成卡回收 | 
| function printBillStep2() { | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         type : "POST", | 
|         url : "../../basic/inout-report/inout-bill-weight", | 
|         dataType : "json", | 
|         contentType : "application/json;charset=UTF-8", | 
|         data : JSON.stringify(recordData), | 
|         success : function(result) { | 
|             if (result.code != "0000") { | 
|                 layer.msg(result.msg); | 
|             } else { | 
|                 layer.msg("开始渲染打印单……"); | 
|                 if(companyId && companyId == "5016"){ | 
|                     print5016Weight(result.data); | 
|                     console.log("5016"); | 
|                 }else { | 
|                     printWeight(result.data); | 
|                 } | 
|                 // 刷新按钮 | 
|                 flushBtn("btn-printBill"); | 
|             } | 
|             layer.close(index); | 
|         }, | 
|         error : function() { | 
|             layer.close(index); | 
|             layer.msg("获取打印模版失败,请联系管理员查看原因!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| // 表单清空 | 
| function resetForm() { | 
|     $("#form-data")[0].reset(); | 
|     form.render(); | 
|     recordData = null; | 
|     weightDto.weight = 0.0; | 
|   | 
|     $("#weightValue").html("0.0<em>KG</em>"); | 
|     $("#img_scale_statule").attr("src", "../../static/images/icon-red.png"); | 
|   | 
|     //称重可以复用 | 
|     $("#btn-weight").removeClass("layui-btn-disabled"); | 
|     $("#btn-weight").attr("disabled", false); | 
|   | 
|     //空车和满车被重置 | 
|     updateEditAndProgress(); | 
|   | 
|     //扣重信息框恢复为可编辑 | 
|     delDisabled(); | 
| } | 
|   | 
| function flushPage() { | 
|     resetForm(); | 
|     layer.msg("页面重置完成,请重新操作……"); | 
| } | 
|   | 
| function flushData() { | 
|     var index = layer.load(); | 
|     var userId2 = $("#userId").val(); | 
|     var intelCard = $("#intelCard").val(); | 
|     var plateNum = $("#plateNum").val(); | 
|     var param = { | 
|         type : type, | 
|         progress : progress, | 
|         intelCard: intelCard, | 
|         userId: userId2, | 
|         plateNum : plateNum | 
|     }; | 
|   | 
|     $.ajax({ | 
|         type : "POST", | 
|         url : "../../basic/inout/inout-query", | 
|         dataType : "json", | 
|         contentType : "application/json;charset=UTF-8", | 
|         data : JSON.stringify(param), | 
|         success : function(result) { | 
|             if (result.code != "0000") { | 
|                 notify(result.msg,result.data); | 
|             } else { | 
|                 recordData = result.data; | 
|                 // 返回的数据进行赋值 | 
|                 form.val("form-data", recordData); | 
|                 form.render(); | 
|   | 
|                 updateEditAndProgress(); | 
|             } | 
|             layer.close(index); | 
|         }, | 
|         error : function() { | 
|             layer.close(index); | 
|             layer.alert("查询失败,请重新尝试!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| /** | 
|  * 更新页面可编辑字段和流程引导说明 | 
|  */ | 
| function updateEditAndProgress() { | 
|     if (recordData) { | 
|         if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { | 
|             $("#emptyWeight").removeClass("rkbk-search-input"); | 
|             $("#emptyWeight").attr("disabled", false); | 
|   | 
|             $("#progress-hand").removeClass("active"); | 
|             $("#progress-fullWeight").removeClass("active"); | 
|   | 
|             $("#fullWeight").addClass("rkbk-search-input"); | 
|             $("#fullWeight").attr("disabled", true); | 
|         } | 
|   | 
|         if (InoutProgress.WEIGHT_FULL == recordData.progress) { | 
|             $("#fullWeight").removeClass("rkbk-search-input"); | 
|             $("#fullWeight").attr("disabled", false); | 
|   | 
|             $("#progress-hand").addClass("active"); | 
|             $("#progress-fullWeight").addClass("active"); | 
|   | 
|             $("#emptyWeight").addClass("rkbk-search-input"); | 
|             $("#emptyWeight").attr("disabled", true); | 
|         } | 
|     } else { | 
|         $("#fullWeight").addClass("rkbk-search-input"); | 
|         $("#fullWeight").attr("disabled", true); | 
|   | 
|         $("#emptyWeight").addClass("rkbk-search-input"); | 
|         $("#emptyWeight").attr("disabled", true); | 
|   | 
|         $("#progress-hand").removeClass("active"); | 
|         $("#progress-fullWeight").removeClass("active"); | 
|     } | 
|     //根据配置信息设置地磅是否可编辑 | 
|     if(weightEditTag && weightEditTag == 'N'){ | 
|         $("#fullWeight").addClass("rkbk-search-input"); | 
|         $("#fullWeight").attr("disabled", true); | 
|   | 
|         $("#emptyWeight").addClass("rkbk-search-input"); | 
|         $("#emptyWeight").attr("disabled", true); | 
|     } | 
| } | 
|   | 
| // 当前完成 | 
| function submit(data) { | 
|     if (null == recordData) { | 
|         notify("没有数据可以提交",null); | 
|         return; | 
|     } | 
|     var data = form.val("form-data"); | 
|     // 校验-出库空车 | 
|     if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { | 
|         if (data.emptyWeight <= 0.0) { | 
|             notify("空车称重信息必填",null); | 
|             return; | 
|         } | 
|         if (!data.depotId) { | 
|             notify("仓库信息必填",null); | 
|             return; | 
|         } | 
|         if (!data.customerName) { | 
|             notify("往来单位信息必填",null); | 
|             return; | 
|         } | 
|     } else { | 
|         if (data.fullWeight <= 0.0) { | 
|             notify("满车称重信息必填",null); | 
|             return; | 
|         } | 
|         if (!data.foodVariety) { | 
|             notify("粮食品种必填",null); | 
|             return; | 
|         } | 
|         if (!data.settleWeight || data.settleWeight <= 0.0) { | 
|             notify("扣重后净信息不正确,请核实计算",null); | 
|             return; | 
|         } | 
|     } | 
|   | 
|     // 合并更新當前编辑数据 | 
|     Object.assign(recordData, data); | 
|   | 
|     // 获取照片 | 
|     var files = [{ | 
|         fileName: snapData.fileName1 | 
|     }, { | 
|         fileName: snapData.fileName2 | 
|     }, { | 
|         fileName: snapData.fileName3 | 
|     }]; | 
|     recordData.files = files; | 
|   | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         type : "POST", | 
|         url : "../../basic/inout/inout-next-step", | 
|         dataType : "json", | 
|         contentType : "application/json;charset=UTF-8", | 
|         data : JSON.stringify(recordData), | 
|         success : function(result) { | 
|             if (result.code != "0000") { | 
|                 //layer.msg(result.msg); | 
|                 notify(result.msg,result.data); | 
|             } else { | 
|                 notify("数据提交成功",result.data); | 
|                 // 更新按钮显示 | 
|                 flushBtn("btn-submit"); | 
|             } | 
|             layer.close(index); | 
|         }, | 
|         error : function() { | 
|             layer.close(index); | 
|             notify("提交失败,请重新尝试",null); | 
|         } | 
|     }); | 
| } | 
|   | 
| //根据选择的仓库信息,更新粮食品种 | 
| function updateFoodVarietyByDepot(selectId) { | 
|     var selectDepot; | 
|     $.each(listDepot, function (index, data) { | 
|         if (data.id === selectId) { | 
|             selectDepot = data; | 
|             return false; | 
|         } | 
|     }); | 
|   | 
|     if (selectDepot) { | 
|         form.val("form-data", { | 
|             foodVariety: selectDepot.foodVariety, | 
|             foodLocation: selectDepot.foodLocation, | 
|             foodLevel: selectDepot.foodLevel | 
|         }); | 
|         form.render(); | 
|     } | 
| } | 
|   | 
| /** | 
|  * 弹出提醒框 | 
|  * @param msg 提醒信息 | 
|  * @param data 数据信息,可能为空 | 
|  */ | 
| function notify(msg, data) { | 
|     if (data) { | 
|         //赋值 | 
|         $("#resultMsg").text(msg); | 
|         $("#resultUserName").text(data.userName); | 
|         $("#resultPlateNum").text(data.plateNum); | 
|         if ("IN" == data.type) { | 
|             $("#resultType").text("入库-" + INOUT_PROGRESS_MSG(data.progress)); | 
|         } else { | 
|             $("#resultType").text("出库-" + INOUT_PROGRESS_MSG(data.progress)); | 
|         } | 
|         $("#resultIntelCard").text(data.intelCard); | 
|   | 
|         layer.open({ | 
|             type: 1, | 
|             offset: ['150px', '200px'], | 
|             area: '450px;', | 
|             shade: 0.8, | 
|             id: 'dialog_notify_info', | 
|             btn: ['确定'], | 
|             content: $('#dialog-from-notify'), | 
|             yes: function (index) { | 
|                 layer.closeAll(); | 
|             } | 
|         }); | 
|     } else { | 
|         layer.alert(msg, {offset: ['300px', '300px']}); | 
|     } | 
| } | 
|   | 
| // ---------------------------往来人员操作-开始 -------------------// | 
| // 弹出往来单位下拉框 | 
| function showCustomer() { | 
|     var index = layer.load(); | 
|     // 渲染往来单位列表 | 
|     table.render({ | 
|         elem : '#tableCustomer', | 
|         url : '../../basic/inout/list-out-customer', | 
|         page : false, | 
|         // skin : "nob", | 
|         // size : 'sm', | 
|         toolbar : '#toolbarCustomer', | 
|         even : true, | 
|         method : 'POST', | 
|         contentType : "application/json;charset=UTF-8", | 
|         cols : [ [ { | 
|             field : 'id', | 
|             title : '编码', | 
|         }, { | 
|             field : 'name', | 
|             title : '名称', | 
|             width : '75%' | 
|         } ] ], | 
|         // where : param, | 
|         parseData : function(res) { | 
|             if ("0000" == res.code) { | 
|                 return { | 
|                     "code" : "0", | 
|                     "msg" : res.msg, | 
|                     "data" : res.data | 
|                 } | 
|             } else { | 
|                 return { | 
|                     "code" : "1", | 
|                     "msg" : res.msg | 
|                 } | 
|             } | 
|         }, | 
|         done : function(res) { | 
|             layer.close(index); | 
|         } | 
|     }); | 
|   | 
|     //双击显示选中数据 | 
|     table.on('rowDouble(tableCustomer)', function(obj){ | 
|         var data = obj.data; | 
|         // 赋值 | 
|         form.val("form-data", { | 
|             customerId : data.id, | 
|             customerName : data.name, | 
|             noticeId: data.noticeId | 
|         }); | 
|         // 关闭 | 
|         layer.closeAll(); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     layer.open({ | 
|         type : 1, | 
|         title : "选择往来单位", | 
|         area : [ '600px', '600px' ], | 
|         shade : 0, | 
|         content : $('#listCustomer'), | 
|         btn : 0, | 
|         btn : [ '取消' ], | 
|         yes : function() { | 
|             layer.closeAll(); | 
|         }, | 
|         closeBtn : 0 | 
|     }); | 
| } | 
|   | 
| // 刷新往来单位数据 | 
| function flushCustomer() { | 
|     var key = $("#key").val(); | 
|     table.reload('tableCustomer', { | 
|         url : "../../basic/inout/list-out-customer", | 
|         where : { | 
|             key : key | 
|         }, | 
|         done : function(res) { | 
|             if (key) { | 
|                 $("#key").val(key); | 
|             } | 
|         } | 
|     }); | 
| } | 
|   | 
| // ---------------------------往来人员操作 -结束 -------------------// | 
|   | 
| // ---------------------------粮食产地 -开始 -------------------// | 
| // 弹出往来单位下拉框 | 
| function showFoodLocation() { | 
|     var index = layer.load(); | 
|     // 渲染往来单位列表 | 
|     table.render({ | 
|         elem : '#tableFoodLoaction', | 
|         url : '../../basic/common/page-food-location', | 
|         page : false, | 
|         // limit : limit, | 
|         // skin : "nob", | 
|         // size : 'sm', | 
|         toolbar : '#toolbarFoodLocaton', | 
|         even : true, | 
|         method : 'POST', | 
|         contentType : "application/json;charset=UTF-8", | 
|         cols : [ [ { | 
|             field : 'code', | 
|             title : '编码', | 
|         }, { | 
|             field : 'simple', | 
|             title : '简拼', | 
|         }, { | 
|             field : 'name', | 
|             title : '名称', | 
|             width : '60%' | 
|         } ] ], | 
|         where : { | 
|             "page" : 1, | 
|             "limit" : 100 | 
|         }, | 
|         parseData : function(res) { | 
|             if ("0000" == res.code) { | 
|                 return { | 
|                     "code" : "0", | 
|                     "msg" : res.msg, | 
|                     "count" : res.data.total, | 
|                     "data" : res.data.records | 
|                 } | 
|             } else { | 
|                 return { | 
|                     "code" : "1", | 
|                     "msg" : res.msg | 
|                 } | 
|             } | 
|         }, | 
|         done : function(res) { | 
|             layer.close(index); | 
|         } | 
|     }); | 
|   | 
|     //双击显示选中数据 | 
|     table.on('rowDouble(tableFoodLoaction)', function(obj){ | 
|         var data = obj.data; | 
|         // 赋值 | 
|         // 赋值 | 
|         form.val("form-data", { | 
|             foodLocation : data.name, | 
|         }); | 
|         // 关闭 | 
|         layer.closeAll(); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     layer.open({ | 
|         type : 1, | 
|         title : "选择粮产地", | 
|         area : [ '600px', '600px' ], | 
|         shade : 0, | 
|         content : $('#listFoodLocation'), | 
|         btn : 0, | 
|         btn : [ '取消' ], | 
|         yes : function() { | 
|             layer.closeAll(); | 
|         }, | 
|         closeBtn : 0 | 
|     }); | 
| } | 
|   | 
| // 刷新 | 
| function flushFoodLocation() { | 
|     var key = $("#key2").val(); | 
|     table.reload('tableFoodLoaction', { | 
|         url : "../../basic/common/page-food-location", | 
|         where : { | 
|             key : key | 
|         }, | 
|         done : function(res) { | 
|             if (key) { | 
|                 $("#key2").val(key); | 
|             } | 
|         } | 
|     }); | 
| } | 
| // ---------------------------粮食产地 -结束 -------------------// |