| var layer; | 
| var form; | 
| var table; | 
| var page = 1; | 
| var limit = 14; | 
| var recordData = null; | 
| var snapData;//系统抓拍对象信息 | 
| var timerWeight; | 
|   | 
| $(function () { | 
|     layui.use(['layer', 'form', 'table'], function () { | 
|         layer = layui.layer; | 
|         form = layui.form; | 
|         table = layui.table; | 
|   | 
|         // 监听行工具事件 | 
|         table.on('tool(tableData)', function (obj) { | 
|             if (obj.event === 'edit') { | 
|                 //展示弹窗 | 
|                 weightWindows(obj); | 
|             } | 
|             if(obj.event === 'detail'){ | 
|                 //展示弹窗 | 
|                 showDetail(obj); | 
|             } | 
|         }); | 
|         // 监听行工具事件 | 
|         table.on('tool(tableInoutRecord)', function (obj) { | 
|             if (obj.event === 'edit') { | 
|                 //展示弹窗 | 
|                 toComplete(obj); | 
|             } | 
|         }); | 
|   | 
|         // 初始化表单数据 | 
|         renderTable(); | 
|     }); | 
|   | 
|     //显示称重弹窗流程 | 
|     showProgress(); | 
|   | 
|     // 监听比例值填写 | 
|     $(".per").blur(function () { | 
|         deAutoByPer(); | 
|     }); | 
|   | 
|     // 监听比例值填写 | 
|     $(".weight").blur(function () { | 
|         deAutoByWeight(); | 
|     }); | 
|     //初始化WebSocket | 
|     initWS(deptId, bizType, progress, userId); | 
| }); | 
|   | 
| window.onload = function () { | 
|     // 加载视频 | 
|     initVideo(lprDto, snapDto1, snapDto2); | 
| }; | 
|   | 
| /** | 
|  * 弹出车辆登记弹窗 | 
|  */ | 
| function carRegister() { | 
|     $("#form-register")[0].reset(); | 
|   | 
|     layer.open({ | 
|         type: 1, | 
|         title: "车辆登记", | 
|         area: ['900px', '600px'], | 
|         offset: ['120px', '200px'], | 
|         shade: 0, | 
|         content: $('#carRegister'), | 
|         btnAlign: 'c', | 
|         btn: ['确定登记', '关闭取消'], | 
|         yes: function () { | 
|             var data = form.val("form-register"); | 
|   | 
|             if (null == data.plateNum) { | 
|                 notify("请选择车船号!"); | 
|                 return; | 
|             } | 
|   | 
|             carRegisterSubmit(data); | 
|         }, | 
|         btn2: function () {// 读取化验结果 | 
|             layer.closeAll(); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| /** | 
|  * 车辆登记提交 | 
|  * @param data | 
|  */ | 
| function carRegisterSubmit(data) { | 
|   | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         type: "POST", | 
|         url: "../../basic/inout/inout-ship-next-step", | 
|         dataType: "json", | 
|         contentType: "application/json;charset=UTF-8", | 
|         data: JSON.stringify(data), | 
|         success: function (result) { | 
|             if (result.code != "0000") { | 
|                 layer.close(index); | 
|                 notify(result.msg, result.data); | 
|             } else { | 
|                 layer.closeAll(); | 
|                 notify("车辆登记成功!", result.data); | 
|                 flushData(); | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("车辆提登记失败,请重新尝试!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //根据条件查询数据、刷新数据 | 
| function flushData() { | 
|     var index = layer.load(); | 
|     var param = form.val("form-param"); | 
|     table.reload('tableData', { | 
|         url: "../../basic/inout/page-inout-ship-item", | 
|         where: param | 
|     }); | 
|     $("thead tr").css({ | 
|         "border-bottom": "2px solid #53adce", | 
|         "background": "#eff4f6" | 
|     }); | 
|     layer.close(index); | 
| } | 
|   | 
| //表单清空 | 
| function resetForm() { | 
|     $("#form-param")[0].reset(); | 
|     form.render(); | 
|     flushData(); | 
| } | 
|   | 
| // 渲染表单数据 | 
| function renderTable() { | 
|     var param = form.val("form-param"); | 
|     // 清空数据 | 
|     $("#tableData").empty(); | 
|     table.render({ | 
|         elem: '#tableData', | 
|         url: '../../basic/inout/page-inout-ship-item', | 
|         page: true, | 
|         limit: limit, | 
|         even: true, | 
|         method: 'POST', | 
|         contentType: "application/json;charset=UTF-8", | 
|         cols: [[{ | 
|             type: 'numbers', | 
|             title: '序号' | 
|         }, { | 
|             field: 'recordId', | 
|             title: '单据号', | 
|             width: '13%', | 
|             style: 'color: #f67d06;font-weight: bold' | 
|         }, { | 
|             field: 'customerName', | 
|             title: '往来单位', | 
|             width: '8%' | 
|         }, { | 
|             field: 'carNum', | 
|             title: '车牌', | 
|             width: '7%', | 
|             style: 'font-weight: bold' | 
|         }, { | 
|             field: 'foodVariety', | 
|             title: '品种', | 
|             width: '8%', | 
|             templet: function (item) { | 
|                 var result = item.foodVariety; | 
|                 $.each(listFoodVariety, function (index, data) { | 
|                     if (item.foodVariety == data.code) { | 
|                         result = data.name; | 
|                         return true; | 
|                     } | 
|                 }); | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field: 'depotId', | 
|             title: '装卸仓库', | 
|             width: '8%', | 
|             templet: function (item) { | 
|                 var result = item.depotId; | 
|                 $.each(listDepot, function (index, data) { | 
|                     if (item.depotId == data.id) { | 
|                         result = data.name; | 
|                         return true; | 
|                     } | 
|                 }); | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field: 'fullWeight', | 
|             title: '满车重量', | 
|             width: '8%' | 
|         }, { | 
|             field: 'emptyWeight', | 
|             title: '空车重量', | 
|             width: '8%' | 
|         }, { | 
|             field: 'netWeight', | 
|             title: '净重', | 
|             width: '7%' | 
|         }, { | 
|             field: 'de', | 
|             title: '扣重', | 
|             width: '6%' | 
|         }, { | 
|             field: 'settleWeight', | 
|             title: '结算重量', | 
|             width: '8%' | 
|         }, { | 
|             field: 'progress', | 
|             width : '8%', | 
|             title: '流程进度', | 
|             templet: function (item) { | 
|                 var result = item.progress; | 
|                 if(InoutProgress.WEIGHT_FULL == result){ | 
|                     result = "满车称重"; | 
|                 }else if(InoutProgress.WEIGHT_EMPTY == result){ | 
|                     result = "空车称重"; | 
|                 }else if(InoutProgress.RECORD == result){ | 
|                     result = "已完成"; | 
|                 } | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field: '', | 
|             title: '操作', | 
|             width: '8%', | 
|             toolbar: "#barControl" | 
|         }]], | 
|         where: param, | 
|         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 | 
|                 } | 
|             } | 
|         } | 
|     }); | 
|     $("thead tr").css({ | 
|         "border-bottom": "2px solid #53adce", | 
|         "background": "#eff4f6" | 
|     }); | 
| } | 
|   | 
| /*-----------------------弹窗显示渲染-开始------------------------------*/ | 
|   | 
| //显示查看操作弹窗 | 
| function showDetail(obj) { | 
|     var data = obj.data; | 
|     //表单数据重置 | 
|     form.val("form-show", data); | 
|     layer.open({ | 
|         type: 1, | 
|         title: "详细信息", | 
|         area: ['1080px', '645px'], | 
|         closeBtn: 1, | 
|         shade: 0, | 
|         scrollbar: 0, | 
|         content: $('#showDetail'), | 
|         offset: ['60px', '100px'] | 
|     }); | 
|   | 
| } | 
| //显示称重操作弹窗 | 
| function weightWindows(obj) { | 
|     timerGetWeight(); | 
|     recordData = obj.data; | 
|     console.log(recordData); | 
|     var progress = recordData.progress; | 
|     //称重操作弹窗 | 
|     var pro = '满车称重'; | 
|     if (progress == 'WEIGHT_EMPTY') { | 
|         pro = '空车称重'; | 
|     } | 
|     updateEditAndProgress(); | 
|     flushPage(); | 
|     layer.open({ | 
|         type: 1, | 
|         title: "入库" + pro + " - 车牌号:" + recordData.carNum, | 
|         area: ['1200px', '720px'], | 
|         closeBtn: 1, | 
|         shade: 0, | 
|         scrollbar: 0, | 
|         content: $('#weightDetail'), | 
|         offset: ['25px', '70px'] | 
|     }); | 
|   | 
| } | 
|   | 
| //称重弹窗中流程环节显示 | 
| function showProgress() { | 
|     if (!inoutProgress) { | 
|         return; | 
|     } | 
|     if (inoutProgress.indexOf("REGISTER") == -1) { | 
|         $("#progress-register").css("display", "none"); | 
|     } | 
|     if (inoutProgress.indexOf("CHECK") == -1) { | 
|         $("#progress-check").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("PAY") == -1) { | 
|         $("#progress-pay").css("display", "none"); | 
|     } | 
|     if (inoutProgress.indexOf("CARD_BACK") == -1) { | 
|         $("#progress-cardBack").css("display", "none"); | 
|     } | 
| } | 
|   | 
| //称重弹窗中更新流程节点 | 
| function updateEditAndProgress() { | 
|     if (recordData) { | 
|         if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { | 
|             $("#emptyWeight").removeClass("rkbk-search-input"); | 
|             $("#emptyWeight").attr("disabled", false); | 
|   | 
|             $("#progress-emptyWeight").addClass("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-emptyWeight").removeClass("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-emptyWeight").removeClass("active"); | 
|     } | 
| } | 
|   | 
| /*-----------------------弹窗显示渲染-结束------------------------------*/ | 
|   | 
| /*-----------------------称重操作-开始------------------------------*/ | 
|   | 
| //自动连接地磅信息,2.5秒获取一次地磅重量信息 | 
| function timerGetWeight() { | 
|     clearInterval(timerWeight); | 
|     timerWeight = setInterval(function () { | 
|         flushWeight(); | 
|     }, 2500); | 
| } | 
|   | 
| //发送请求获取称重数据 | 
| 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 weight() { | 
|     console.log(recordData); | 
|     // 没有业务数据不可执行 | 
|     if (!recordData) { | 
|         layer.alert("没有查询到业务数据,执行被拒绝!!"); | 
|         return; | 
|     } | 
|     // 如果是空车称重 | 
|     if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { | 
|         form.val("form-weight", { | 
|             emptyWeight: weightDto.weight | 
|         }); | 
|     } | 
|     // 如果是满车称重 | 
|     if (InoutProgress.WEIGHT_FULL == recordData.progress) { | 
|         form.val("form-weight", { | 
|             fullWeight: weightDto.weight | 
|         }); | 
|     } | 
|     form.render(); | 
|     snapData == null; | 
|   | 
|     //点击称重时候自动抓拍数据 | 
|     layer.msg("系统自动抓拍保留记录……"); | 
|     snapData = { | 
|         companyId: companyId, | 
|         deptId: deptId, | 
|         bizTag: recordData.progress, | 
|         bizType: bizType, | 
|         plateNum: recordData.plateNum + "-" + recordData.carNum, | 
|   | 
|         id1: (null != lprDto) ? lprDto.id : null, | 
|         id2: (null != snapDto1) ? snapDto1.id : null, | 
|         id3: (null != snapDto2) ? snapDto2.id : null | 
|     }; | 
|     // console.log(snapData); | 
|   | 
|     //当前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_EMPTY == recordData.progress) { | 
|         deAutoByPer(); | 
|     } | 
|     flushBtn("btn-weight"); | 
| } | 
|   | 
| // 自动计算,注意:出库水分是 +,入库水分需要 - | 
| function deAutoByPer() { | 
|     var curData = form.val("form-weight"); | 
|     var netWeight = 0, deImpurity = 0, deWet = 0, de = 0, settleWeight = 0; | 
|     if (curData.fullWeight == 0 || curData.emptyWeight == 0) { | 
|         return; | 
|     } | 
|     // 计算净重 | 
|     netWeight = curData.fullWeight - curData.emptyWeight; | 
|     if(curData.de){ | 
|         de = curData.de; | 
|     } | 
|     if (netWeight <= 0) { | 
|         layer.msg("净重小于等于0,当前计算不正确!"); | 
|         return; | 
|     } | 
|   | 
|     // 结算净重 | 
|     settleWeight = Number(netWeight) - Number(de); | 
|     settleWeight = settleWeight.toFixed(0); | 
|   | 
|     form.val("form-weight", { | 
|         netWeight: netWeight, | 
|         de: de, | 
|         settleWeight: settleWeight | 
|     }); | 
|     form.render(); | 
| } | 
|   | 
| // 自动计算 | 
| function deAutoByWeight() { | 
|     var curData = form.val("form-weight"); | 
|     var netWeight = 0, de = 0, settleWeight = 0; | 
|   | 
|     if (curData.fullWeight == 0 || curData.emptyWeight == 0) { | 
|         return; | 
|     } | 
|   | 
|     //净重 | 
|     netWeight = curData.fullWeight - curData.emptyWeight; | 
|     if(curData.de){ | 
|         de = curData.de; | 
|     } | 
|     if (netWeight <= 0) { | 
|         layer.msg("净重小于等于0,当前计算不正确!"); | 
|         return; | 
|     } | 
|   | 
|     // 结算净重 | 
|     settleWeight = Number(netWeight) - Number(de); | 
|     settleWeight = settleWeight.toFixed(0); | 
|   | 
|     form.val("form-weight", { | 
|         netWeight: netWeight, | 
|         deSum: de, | 
|         settleWeight: settleWeight | 
|     }); | 
|   | 
|     form.render(); | 
| } | 
|   | 
| //根据当前操作的按钮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); | 
|         flushData(); | 
|         if (InoutProgress.WEIGHT_FULL == recordData.progress) {// 如果是满车称重,则直接当前节点完成 | 
|             layer.closeAll(); | 
|         } else { | 
|             // 完成称重后控制按钮 | 
|             $("#btn-weight").addClass("layui-btn-disabled"); | 
|             $("#btn-weight").attr("disabled", true); | 
|   | 
|             flushData(); | 
|         } | 
|     } | 
| } | 
|   | 
| //完成称重 | 
| function submitWeight() { | 
|     if (null == recordData) { | 
|         notify("没有数据可以提交", null); | 
|         return; | 
|     } | 
|     var data = form.val("form-weight"); | 
|     if (!data.depotId) { | 
|         notify("装卸仓库必须填写", null); | 
|         return; | 
|     } | 
|     // 校验-入库满车称重 | 
|     if (InoutProgress.WEIGHT_FULL == recordData.progress) { | 
|         if (data.fullWeight <= 0.0) { | 
|             notify("满车称重信息必填", null); | 
|             return; | 
|         } | 
|         if (!data.depotId) { | 
|             notify("仓库信息必填", null); | 
|             return; | 
|         } | 
|     } else { | 
|         if (data.emptyWeight <= 0.0) { | 
|             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-ship-next-step", | 
|         dataType: "json", | 
|         contentType: "application/json;charset=UTF-8", | 
|         data: JSON.stringify(recordData), | 
|         success: function (result) { | 
|             layer.close(index); | 
|             if (result.code != "0000") { | 
|                 notify(result.msg, result.data); | 
|             } else { | 
|                 clearInterval(timerWeight); | 
|                 layer.alert("数据提交成功!!"); | 
|                 // 更新按钮显示 | 
|                 flushBtn("btn-submit"); | 
|                 layer.closeAll(); | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("提交失败,请重新尝试!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //重新称重时,表单不清空,按钮重置 | 
| function flushPage() { | 
|     weightDto.weight = 0.0; | 
|     $("#weightValue").html("0.0<em>KG</em>"); | 
|     $("#img_scale_statule").attr("src", "../../static/images/icon-red.png"); | 
|     timerGetWeight(); | 
|     $("#btn-weight").removeClass("layui-btn-disabled"); | 
|     $("#btn-weight").attr("disabled", false); | 
|     $("#btn-submit").addClass("layui-btn-disabled"); | 
|     $("#btn-submit").attr("disabled", true); | 
|   | 
|     //表单数据重置 | 
|     form.val("form-base", recordData); | 
|     form.val("form-weight", recordData); | 
|     form.render(); | 
| } | 
|   | 
| /*-----------------------称重操作-结束------------------------------*/ | 
|   | 
| /*-----------------------全部完成-开始------------------------------*/ | 
| /** | 
|  * 弹出全部完成弹窗 | 
|  */ | 
| function showToComplete() { | 
|     $("#tableInoutRecord").empty(); | 
|     table.render({ | 
|         elem: '#tableInoutRecord', | 
|         url: '../../basic/inout/ship-inout-record', | 
|         page: false, | 
|         even: true, | 
|         method: 'POST', | 
|         contentType: "application/json;charset=UTF-8", | 
|         cols: [[{ | 
|             field: 'recordId', | 
|             title: '单据号', | 
|             width : '20%', | 
|             style : 'color: #f67d06;font-weight: bold' | 
|         }, { | 
|             field: 'plateNum', | 
|             width : '15%', | 
|             title: '车船号' | 
|         }, { | 
|             field: 'customerName', | 
|             width : '18%', | 
|             title: '往来单位' | 
|         }, { | 
|             field: 'foodVariety', | 
|             width : '12%', | 
|             title: '粮食品种', | 
|             templet: function (item) { | 
|                 var result = item.foodVariety; | 
|                 $.each(listFoodVariety, function (index, data) { | 
|                     if (item.foodVariety == data.code) { | 
|                         result = data.name; | 
|                         return true; | 
|                     } | 
|                 }); | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field: 'depotId', | 
|             width : '10%', | 
|             title: '装卸仓库', | 
|             templet: function (item) { | 
|                 var result = item.depotId; | 
|                 $.each(listDepot, function (index, data) { | 
|                     if (item.depotId == data.id) { | 
|                         result = data.name; | 
|                         return true; | 
|                     } | 
|                 }); | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field: 'progress', | 
|             width : '10%', | 
|             title: '流程进度', | 
|             templet: function (item) { | 
|                 var result = item.progress; | 
|                 if(InoutProgress.WEIGHT_TAG == result){ | 
|                     result = "称重"; | 
|                 }else if(InoutProgress.RECORD == result){ | 
|                     result = "已完成"; | 
|                 } | 
|                 return result == null ? "" : result; | 
|             } | 
|         }, { | 
|             field : '', | 
|             title : '结束流程', | 
|             width : '15%', | 
|             toolbar : "#barToComplete" | 
|         }]], | 
|         parseData: function (res) { | 
|             if ("0000" == res.code) { | 
|                 return { | 
|                     "code": "0", | 
|                     "msg": res.msg, | 
|                     "data": res.data | 
|                 } | 
|             } else { | 
|                 return { | 
|                     "code": "1", | 
|                     "msg": res.msg | 
|                 } | 
|             } | 
|         } | 
|     }); | 
|     layer.open({ | 
|         type: 1, | 
|         title: "全部完成", | 
|         area: ['900px', '600px'], | 
|         offset: ['120px', '200px'], | 
|         shade: 0, | 
|         content: $('#inoutRecord'), | 
|         btnAlign: 'c', | 
|         btn: [ '关闭'], | 
|         btn1: function () { | 
|             layer.closeAll(); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| function toComplete(obj) { | 
|     var data = obj.data; | 
|     if(InoutProgress.RECORD == data.progress){ | 
|         layer.confirm('流程已完成,确定要进行二次统计吗?', {icon: 3, title:'提示'}, function(index){ | 
|             //do something | 
|             toComplete2(data); | 
|             layer.close(index); | 
|         }); | 
|     }else { | 
|         toComplete2(data); | 
|     } | 
| } | 
|   | 
| function toComplete2(data) { | 
|     console.log(data); | 
|     var index = layer.load(); | 
|   | 
|     $.ajax({ | 
|         type : "POST", | 
|         url : "../../basic/inout/ship-to-complete", | 
|         dataType : "json", | 
|         contentType : "application/json;charset=UTF-8", | 
|         data : JSON.stringify(data), | 
|         success : function(result) { | 
|             layer.close(index); | 
|             if (result.code != "0000") { | 
|                 layer.msg(result.msg); | 
|             } else { | 
|                 layer.msg("更新成功!"); | 
|                 layer.closeAll(); | 
|                 showToComplete() | 
|             } | 
|         }, | 
|         error : function() { | 
|             layer.close(index); | 
|             layer.msg("后台异常,请重试或者联系管理员!!"); | 
|         } | 
|     }); | 
| } | 
| // ---------------------------全部完成-结束 -------------------// | 
|   | 
| // ---------------------------显示车船列表--开始 -------------------// | 
| // 弹出往来单位下拉框 | 
| function showPlateNum() { | 
|   | 
|     var index = layer.load(); | 
|     // 渲染车船号列表 | 
|     table.render({ | 
|         elem: '#tablePlateNum', | 
|         url: '../../basic/inout/un-ship-inout-record', | 
|         page: false, | 
|         // skin : "nob", | 
|         // size : 'sm', | 
|         toolbar: '#toolbarPlateNum', | 
|         even: true, | 
|         method: 'POST', | 
|         contentType: "application/json;charset=UTF-8", | 
|         cols: [[{ | 
|             field: 'plateNum', | 
|             title: '车船号' | 
|         }, { | 
|             field: 'customerName', | 
|             title: '客户名称' | 
|         }, { | 
|             field: 'foodVariety', | 
|             title: '粮食品种', | 
|             templet: function (item) { | 
|                 var result = item.foodVariety; | 
|                 $.each(listFoodVariety, function (index, data) { | 
|                     if (item.foodVariety == data.code) { | 
|                         result = data.name; | 
|                         return true; | 
|                     } | 
|                 }); | 
|                 return result == null ? "" : result; | 
|             } | 
|         }]], | 
|         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(tablePlateNum)', function (obj) { | 
|         var data = obj.data; | 
|         // 赋值 | 
|         form.val("form-register", { | 
|             plateNum: data.plateNum, | 
|             recordId: data.recordId, | 
|             customerName: data.customerName, | 
|             depotId: data.depotId, | 
|             foodVariety: data.foodVariety, | 
|             foodLevel: data.foodLevel | 
|         }); | 
|         // 关闭 | 
|         layer.close(index2); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     var index2 = layer.open({ | 
|         type: 1, | 
|         title: "选择车船号", | 
|         area: ['600px', '600px'], | 
|         shade: 0, | 
|         content: $('#listPlateNum'), | 
|         btn: 0, | 
|         btn: ['取消'], | 
|         yes: function () { | 
|             layer.close(index2); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| // 刷新往来单位数据 | 
| function flushPlateNum() { | 
|     var key = $("#key").val(); | 
|     var param = { | 
|         key: key | 
|     }; | 
|     table.reload('tablePlateNum', { | 
|         url: "../../basic/inout/un-ship-inout-record", | 
|         where: param, | 
|         done: function (res) { | 
|             if (key) { | 
|                 $("#key").val(key); | 
|             } | 
|         } | 
|     }); | 
| } | 
|   | 
| //显示船运车辆信息 | 
| function showShipCar() { | 
|   | 
|     var index = layer.load(); | 
|     // 渲染车船号列表 | 
|     table.render({ | 
|         elem: '#tableShipCar', | 
|         url: '../../basic/inout/listShipCar', | 
|         page: false, | 
|         even: true, | 
|         method: 'POST', | 
|         contentType: "application/json;charset=UTF-8", | 
|         cols: [[{ | 
|             field: 'sort', | 
|             title: '车序号' | 
|         }, { | 
|             field: 'name', | 
|             title: '名称' | 
|         }, { | 
|             field: 'plateNum', | 
|             title: '车牌号' | 
|         }]], | 
|         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(tableShipCar)', function (obj) { | 
|         var data = obj.data; | 
|         // 赋值 | 
|         form.val("form-register", { | 
|             carNum: data.sort, | 
|             carName: data.name | 
|         }); | 
|         // 关闭 | 
|         layer.close(index2); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     var index2 = layer.open({ | 
|         type: 1, | 
|         title: "选择船运车辆", | 
|         area: ['600px', '480px'], | 
|         shade: 0, | 
|         content: $('#listShipCar'), | 
|         btn: 0, | 
|         btn: ['取消'], | 
|         yes: function () { | 
|             layer.close(index2); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| // ---------------------------往来单位操作--结束-------------------// | 
|   | 
| /** | 
|  * 弹出提醒框 | 
|  * @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']}); | 
|     } | 
| } |