| 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(tableInoutRecord)', function (obj) { | 
|             if (obj.event === 'edit') { | 
|                 //结束流程 | 
|                 toComplete(obj); | 
|             } | 
|         }); | 
|         // 监听行工具事件 | 
|         table.on('tool(tableInoutRecordItems)', function (obj) { | 
|             if (obj.event === 'edit') { | 
|                 //删除车辆信息 | 
|                 toDelCar(obj); | 
|             } | 
|         }); | 
|     }); | 
|   | 
|     //显示称重弹窗流程 | 
|     showProgress(); | 
|   | 
|     // 监听比例值填写 | 
|     $(".weight").blur(function () { | 
|         deAutoByWeight(); | 
|     }); | 
|     //初始化WebSocket | 
|     initInoutWS(companyId, bizType, progress, userId); | 
| }); | 
|   | 
| window.onload = function () { | 
|     //自动连接地磅信息,2.5秒获取一次地磅重量信息 | 
|     clearInterval(timerWeight); | 
|     timerWeight = setInterval(function () { | 
|         flushWeight(); | 
|     }, 2500); | 
|     // 加载视频 | 
|     initVideo(snapDto1, snapDto2, snapDto3); | 
|   | 
|     //设置地磅 | 
|     $("#scaleName").val(weightDto.sort); | 
|   | 
|     //监听地磅选择 | 
|     $("#scaleName").change(function () { | 
|         layer.confirm('调整地磅需重新加载页面,确定调整?', { | 
|             btn: ['确定', '取消'] | 
|         }, function () { | 
|             updateWeight(); | 
|         }); | 
|     }); | 
| }; | 
|   | 
| /** | 
|  * 车辆绑定确认 | 
|  * @param data | 
|  */ | 
| function carRegisterSubmit() { | 
|     var data = form.val("form-register"); | 
|     data.type = type; | 
|     if (!data.plateNum) { | 
|         notify("请选择船运号!"); | 
|         return; | 
|     } | 
|     if (!data.carNum) { | 
|         notify("请选择运输车辆!"); | 
|         return; | 
|     } | 
|     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); | 
|                 //清空表单 | 
|                 $("#form-register")[0].reset(); | 
|                 form.render(); | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("车辆提登记失败,请重新尝试!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //流程环节显示 | 
| 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"); | 
|     } | 
|     //根据配置信息设置地磅是否可编辑 | 
|     if(weightEditTag && weightEditTag == 'N'){ | 
|         $("#fullWeight").addClass("rkbk-search-input"); | 
|         $("#fullWeight").attr("disabled", true); | 
|   | 
|         $("#emptyWeight").addClass("rkbk-search-input"); | 
|         $("#emptyWeight").attr("disabled", true); | 
|     } | 
| } | 
|   | 
| /*-----------------------称重操作-开始------------------------------*/ | 
| //发送请求获取称重数据 | 
| 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").text(data); | 
|             $("#img_scale_statule").attr("src", "../../static/images/icon-gree.png"); | 
|         }, | 
|         error: function () { | 
|             weightDto.weight = 0.0; | 
|             $("#weightValue").text("0.0"); | 
|             $("#img_scale_statule").attr("src", "../../static/images/icon-red.png"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //点击称重 | 
| function weight() { | 
|     // 没有业务数据不可执行 | 
|     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 != snapDto1) ? snapDto1.id : null, | 
|         id2: (null != snapDto2) ? snapDto2.id : null, | 
|         id3: (null != snapDto3) ? snapDto3.id : null, | 
|   | 
|         sort: $("#scaleName").val(), | 
|         weight: weightDto.weight | 
|     }; | 
|   | 
|     //当前AJAX服务为同步服务,返回数据包装照片信息 | 
|     var index = layer.load(); | 
|     $.ajax({ | 
|         sync: false, | 
|         type: "POST", | 
|         url: "../../inout/api/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) { | 
|         deAutoByWeight(); | 
|     } | 
|     flushBtn("btn-weight"); | 
| } | 
|   | 
| // 自动计算 | 
| function deAutoByWeight() { | 
|     var curData = form.val("form-weight"); | 
|     var netWeight = 0, de = 0, settleWeight = 0, recordWeight = 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); | 
|     recordWeight = settleWeight; | 
|     form.val("form-weight", { | 
|         netWeight: netWeight, | 
|         deSum: de, | 
|         recordWeight: recordWeight, | 
|         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); | 
|   | 
|         $("#form-weight")[0].reset(); | 
|         form.render(); | 
|     } | 
| } | 
|   | 
| //完成称重 | 
| 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; | 
|     recordData.type = type; | 
|   | 
|     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 { | 
|                 layer.closeAll(); | 
|                 notify("数据提交成功!", result.data); | 
|                 // 更新按钮显示 | 
|                 flushBtn("btn-submit"); | 
|             } | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("提交失败,请重新尝试!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| /*-----------------------称重操作-结束------------------------------*/ | 
|   | 
| /*-----------------------全部完成-开始------------------------------*/ | 
| /** | 
|  * 弹出全部完成弹窗 | 
|  */ | 
| function showToComplete() { | 
|     $("#tableInoutRecord").empty(); | 
|     var param = {"type": type}; | 
|     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" | 
|         }]], | 
|         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 | 
|                 } | 
|             } | 
|         } | 
|     }); | 
|     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 param = {"type": type}; | 
|     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; | 
|             } | 
|         }]], | 
|         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(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, | 
|         type: type | 
|     }; | 
|     table.reload('tablePlateNum', { | 
|         url: "../../basic/inout/un-ship-inout-record", | 
|         where: param, | 
|         done: function (res) { | 
|             if (key) { | 
|                 $("#key").val(key); | 
|             } | 
|         } | 
|     }); | 
| } | 
|   | 
| //车辆绑定---显示船运车辆信息 | 
| function showShipCar1() { | 
|   | 
|     var index = layer.load(); | 
|     // 渲染车船号列表 | 
|     table.render({ | 
|         elem: '#tableShipCar1', | 
|         url: '../../basic/inout/list-Ship-Car', | 
|         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(tableShipCar1)', function (obj) { | 
|         var data = obj.data; | 
|         // 赋值 | 
|         form.val("form-register", { | 
|             carNum: null, | 
|             carName: null | 
|         }); | 
|         //验证车辆是否在流程中 | 
|         checkCarNum(data); | 
|         // 关闭 | 
|         layer.close(index2); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     var index2 = layer.open({ | 
|         type: 1, | 
|         title: "选择船运车辆", | 
|         area: ['600px', '480px'], | 
|         shade: 0, | 
|         content: $('#listShipCar1'), | 
|         btn: 0, | 
|         btn: ['取消'], | 
|         yes: function () { | 
|             layer.close(index2); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| //车辆称重---显示船运车辆信息 | 
| function showShipCar2() { | 
|     var index = layer.load(); | 
|     // 渲染车船号列表 | 
|     table.render({ | 
|         elem: '#tableShipCar2', | 
|         url: '../../basic/inout/list-Ship-Car', | 
|         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(tableShipCar2)', function (obj) { | 
|         var data = obj.data; | 
|         // 赋值 | 
|         form.val("form-weight", { | 
|             carNum: data.sort, | 
|             carName: data.name | 
|         }); | 
|         getRecordItemData(); | 
|         // 关闭 | 
|         layer.close(index2); | 
|     }); | 
|   | 
|     // 弹出对话框 | 
|     var index2 = layer.open({ | 
|         type: 1, | 
|         title: "选择船运车辆", | 
|         area: ['600px', '480px'], | 
|         shade: 0, | 
|         content: $('#listShipCar2'), | 
|         btn: 0, | 
|         btn: ['取消'], | 
|         yes: function () { | 
|             layer.close(index2); | 
|         }, | 
|         closeBtn: 0 | 
|     }); | 
| } | 
|   | 
| function toDelCar(obj) { | 
|     var index = layer.load(); | 
|     var data = obj.data; | 
|     // if(InoutProgress.RECORD == data.progress){ | 
|     //     layer.msg("流程已完成,不支持删除!"); | 
|     //     layer.close(index); | 
|     //     return; | 
|     // } | 
|     layer.confirm('确定要删除此车辆信息?', {icon: 3, title:'提示'}, function(index){ | 
|         toDelItem(data); | 
|         layer.close(index); | 
|     }); | 
| } | 
|   | 
| function toDelItem(data) { | 
|     $.ajax({ | 
|         type : "POST", | 
|         url : "../../basic/inout/del-ship-item", | 
|         dataType : "json", | 
|         contentType : "application/json;charset=UTF-8", | 
|         data : JSON.stringify(data), | 
|         success : function(result) { | 
|             if (result.code != "0000") { | 
|                 layer.msg(result.msg); | 
|             } else { | 
|                 layer.msg("删除成功!"); | 
|                 layer.closeAll(); | 
|             } | 
|         }, | 
|         error : function() { | 
|             layer.close(index); | 
|             layer.msg("后台异常,请重试或者联系管理员!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //根据运输车辆序号查询车辆流程信息 | 
| function getRecordItemData() { | 
|     var index = layer.load(); | 
|     var curData = form.val("form-weight"); | 
|     //清空表单 | 
|     recordData = null; | 
|     $("#form-weight")[0].reset(); | 
|     form.render(); | 
|     var param = { | 
|         carNum: curData.carNum | 
|     }; | 
|   | 
|     $.ajax({ | 
|         type: "POST", | 
|         url: "../../basic/inout/get-inout-record-item", | 
|         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; | 
|                 // console.log(recordData); | 
|                 if(recordData.type == "OUT"){ | 
|                     layer.close(index); | 
|                     layer.alert("当前车辆在出库流程中!!"); | 
|                     return; | 
|                 } | 
|                 // 返回的数据进行赋值 | 
|                 updateEditAndProgress(); | 
|                 form.val("form-weight", recordData); | 
|                 form.render(); | 
|             } | 
|             layer.close(index); | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("查询失败,请重新尝试!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| //根据运输车辆序号验证车辆是否在流程中 | 
| function checkCarNum(data) { | 
|     var index = layer.load(); | 
|     var param = { | 
|         carNum: data.sort | 
|     }; | 
|     $.ajax({ | 
|         type: "POST", | 
|         url: "../../basic/inout/check-car-num", | 
|         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 { | 
|                 // 赋值 | 
|                 form.val("form-register", { | 
|                     carNum: data.sort, | 
|                     carName: data.name | 
|                 }); | 
|             } | 
|             layer.close(index); | 
|         }, | 
|         error: function () { | 
|             layer.close(index); | 
|             layer.alert("查询失败,请重新尝试!!"); | 
|         } | 
|     }); | 
| } | 
|   | 
| /** | 
|  * 弹出船运车辆流程详细信息 | 
|  */ | 
| function showInoutRecordItems() { | 
|     $("#tableInoutRecordItems").empty(); | 
|     var param = {"type": type}; | 
|     table.render({ | 
|         elem: '#tableInoutRecordItems', | 
|         url: '../../basic/inout/list-inout-record-item', | 
|         page: false, | 
|         even: true, | 
|         method: 'POST', | 
|         contentType: "application/json;charset=UTF-8", | 
|         cols: [[{ | 
|             type: 'numbers', | 
|             title: '序号' | 
|         }, { | 
|             field: 'recordId', | 
|             title: '单据号', | 
|             width: '14%', | 
|             style: 'color: #f67d06;font-weight: bold' | 
|         }, { | 
|             field: 'customerName', | 
|             title: '往来单位', | 
|             width: '8%' | 
|         }, { | 
|             field: 'carNum', | 
|             title: '车序号', | 
|             width: '7%', | 
|             style: 'font-weight: bold' | 
|         }, { | 
|             field: 'carName', | 
|             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: '7%' | 
|         }, { | 
|             field: 'emptyWeight', | 
|             title: '皮量', | 
|             width: '7%' | 
|         }, { | 
|             field: 'netWeight', | 
|             title: '净重', | 
|             width: '7%' | 
|         }, { | 
|             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 : '7%', | 
|             toolbar : "#barDelCar" | 
|         }]], | 
|         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 | 
|                 } | 
|             } | 
|         } | 
|     }); | 
|     layer.open({ | 
|         type: 1, | 
|         title: "船运车辆流程信息", | 
|         area: ['1200px', '600px'], | 
|         offset: ['80px', '80px'], | 
|         shade: 0, | 
|         content: $('#inoutRecordItems'), | 
|         btnAlign: 'c', | 
|         btn: [ '关闭'], | 
|         btn1: function () { | 
|             layer.closeAll(); | 
|         }, | 
|         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']}); | 
|     } | 
| } |