|  |  |  | 
|---|
|  |  |  | //当前节点 入库质检 | 
|---|
|  |  |  | var layer; | 
|---|
|  |  |  | var laydate; | 
|---|
|  |  |  | var form; | 
|---|
|  |  |  | var table; | 
|---|
|  |  |  | var scanCodeTag = false; | 
|---|
|  |  |  | var page = 1; | 
|---|
|  |  |  | var limit = 10; | 
|---|
|  |  |  | var curCheckData = null;// 当前编辑数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | layer = layui.layer; | 
|---|
|  |  |  | form = layui.form; | 
|---|
|  |  |  | table = layui.table; | 
|---|
|  |  |  | var laydate = layui.laydate; | 
|---|
|  |  |  | laydate = layui.laydate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | laydate.render({ | 
|---|
|  |  |  | elem: '#start', | 
|---|
|  |  |  | 
|---|
|  |  |  | laydate.render({ | 
|---|
|  |  |  | elem: '#foodYear', | 
|---|
|  |  |  | theme: '#7b8e9f', | 
|---|
|  |  |  | type: 'year', | 
|---|
|  |  |  | value: foodYear, | 
|---|
|  |  |  | type: 'year' | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | laydate.render({ | 
|---|
|  |  |  | elem: '#checkTime', | 
|---|
|  |  |  | theme: '#7b8e9f', | 
|---|
|  |  |  | format: 'yyyy-MM-dd HH:mm:ss', | 
|---|
|  |  |  | type: 'datetime' | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 初始化表单数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | table.on('tool(tableData)', function (obj) { | 
|---|
|  |  |  | if (obj.event === 'edit') { | 
|---|
|  |  |  | //更新仓库下拉列表 | 
|---|
|  |  |  | updateSelect(obj); | 
|---|
|  |  |  | updateSelect(); | 
|---|
|  |  |  | //展示数据 | 
|---|
|  |  |  | showDetail(obj); | 
|---|
|  |  |  | showDetail(obj.data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //监听粮食品种 | 
|---|
|  |  |  | //监听粮食品种,获取化验项 | 
|---|
|  |  |  | layui.form.on('select(select_foodVariety)', function (data) { | 
|---|
|  |  |  | updateFoodVariety(data.value); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //监听粮食等级,获取粮食定价 | 
|---|
|  |  |  | layui.form.on('select(select_foodLevel)', function (data) { | 
|---|
|  |  |  | getPriceByFoodLevel(data.value); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //监听化验结果单填写数据,并给出提示结果 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //显示入库流程 | 
|---|
|  |  |  | showProgress(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 初始化WebSocket | 
|---|
|  |  |  | //initInoutWS(deptId, bizType, progress, userId); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | window.onbeforeunload = function () { | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | window.onunload = function () { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | window.onload = function () { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //扫描枪自动回车事件 | 
|---|
|  |  |  | $('#checkId').bind('keyup', function (event) { | 
|---|
|  |  |  | if (event.keyCode == "13") { | 
|---|
|  |  |  | // //去掉焦点,防止刷新页面 | 
|---|
|  |  |  | // $('#checkId').blur(); | 
|---|
|  |  |  | getDataByCheckId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // socket信息返回處理 | 
|---|
|  |  |  | function socketOnMessage(packet) { | 
|---|
|  |  |  | layer.alert(packet.data); | 
|---|
|  |  |  | window.parent.sysNotify(packet.data); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //控制流程环节显示 | 
|---|
|  |  |  | function showProgress() { | 
|---|
|  |  |  | 
|---|
|  |  |  | var limit = data.upperLimit; | 
|---|
|  |  |  | //运算符 | 
|---|
|  |  |  | var symbol = data.operaSymbol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (symbol && limit) { | 
|---|
|  |  |  | if (">=" == symbol) { | 
|---|
|  |  |  | if (newValue < limit) { | 
|---|
|  |  |  | data.remarks = "不合格"; | 
|---|
|  |  |  | data.result = "0"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | data.remarks = "合格"; | 
|---|
|  |  |  | data.result = "1"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if ("<=" == symbol) { | 
|---|
|  |  |  | if (newValue > limit) { | 
|---|
|  |  |  | data.remarks = "不合格"; | 
|---|
|  |  |  | data.result = "0"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | data.remarks = "合格"; | 
|---|
|  |  |  | data.result = "1"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if ("==" == symbol) { | 
|---|
|  |  |  | if (newValue != limit) { | 
|---|
|  |  |  | data.remarks = "不合格"; | 
|---|
|  |  |  | data.result = "0"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | data.remarks = "合格"; | 
|---|
|  |  |  | data.result = "1"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //动态更换仓库下拉列表 | 
|---|
|  |  |  | function updateSelect(obj) { | 
|---|
|  |  |  | function updateSelect() { | 
|---|
|  |  |  | $('#depotId option').remove(); | 
|---|
|  |  |  | var dat = obj.data; | 
|---|
|  |  |  | for (var i = 0; i < listDepot.length; i++) { | 
|---|
|  |  |  | $('#depotId').append('<option value="' + listDepot[i].id + '">' + listDepot[i].name + '</option>'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | form.render('select'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据选择仓库显示粮食品种 | 
|---|
|  |  |  | //根据品种获取化验项 | 
|---|
|  |  |  | function updateFoodVariety(foodVariety) { | 
|---|
|  |  |  | if (null == foodVariety || "" == foodVariety) return; | 
|---|
|  |  |  | form.val("form-detail", { | 
|---|
|  |  |  | 
|---|
|  |  |  | form.render(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | flushCheckItem(foodVariety); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据选择仓库显示粮食品种 | 
|---|
|  |  |  | function getPriceByFoodLevel(foodLevel) { | 
|---|
|  |  |  | if (null == foodLevel || "" == foodLevel) return; | 
|---|
|  |  |  | form.val("form-detail", { | 
|---|
|  |  |  | foodLevel: foodLevel | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | form.render(); | 
|---|
|  |  |  | var data = form.val("form-detail"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../basic/inout/get-price", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | data: JSON.stringify(data), | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.msg(result.msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | $("#check-result-tip2").text("粮食定价:" + result.data.price + "元/公斤"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.msg("后台异常,请重试或者联系管理员!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查询 | 
|---|
|  |  |  | 
|---|
|  |  |  | // window.parent.openTab(url, "化验结果导出", "checkDataExport"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 根据模式启动开始扦样 | 
|---|
|  |  |  | function checkExe(type) { | 
|---|
|  |  |  | checkDto.type = type; | 
|---|
|  |  |  | var param = JSON.stringify(checkDto); | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../api/check/check-exe", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | data: param, | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.alert(result.msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg("操作命令发送成功!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | layer.alert("后台异常,操作命令发送失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 关闭扦样机器 | 
|---|
|  |  |  | function checkStop() { | 
|---|
|  |  |  | var param = JSON.stringify(checkDto); | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../api/check/stop", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | data: param, | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.alert(result.msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg("操作命令发送成功!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | layer.alert("后台异常,操作命令发送失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 扦样机复位 | 
|---|
|  |  |  | function checkReset() { | 
|---|
|  |  |  | var param = JSON.stringify(checkDto); | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../api/check/reset", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | data: param, | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.alert(result.msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg("操作命令发送成功!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | layer.alert("后台异常,操作命令发送失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | // 扦样机解除急停 | 
|---|
|  |  |  | function checkResetStop() { | 
|---|
|  |  |  | var param = JSON.stringify(checkDto); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //隐藏信息--替换为* | 
|---|
|  |  |  | function replaceStr(str) { | 
|---|
|  |  |  | if (!str) { | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var split = str.split(""); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (split.length == 1) { | 
|---|
|  |  |  | return "*"; | 
|---|
|  |  |  | // 更新化验结果提醒,只做提醒,不做自动判断 | 
|---|
|  |  |  | function updateCheckResultTip() { | 
|---|
|  |  |  | if (!curCheckItems || curCheckItems.length == 0) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (split.length == 2 || split.length == 3) { | 
|---|
|  |  |  | return str.slice(0, 1) + "**" | 
|---|
|  |  |  | if (curCheckData.checkStatus != "NONE") { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return str.slice(0, 1) + "***" + str.slice(split.length - 1); | 
|---|
|  |  |  | var msg; | 
|---|
|  |  |  | $.each(curCheckItems, function (index, data) { | 
|---|
|  |  |  | if (!data.result) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.result == "0") { | 
|---|
|  |  |  | msg = "不合格"; | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.result == "1") { | 
|---|
|  |  |  | msg = "合格"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (msg) { | 
|---|
|  |  |  | $("#check-result-tip").text("质检结果:" + msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | $("#check-result-tip").text("质检结果:#"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function showDetail(obj) { | 
|---|
|  |  |  | curCheckData = obj.data; | 
|---|
|  |  |  | // console.log(curCheckData); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 渲染表格 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | function renderTableCheckItem() { | 
|---|
|  |  |  | // 清空数据 | 
|---|
|  |  |  | $("#tableCheckItem").empty(); | 
|---|
|  |  |  | table.render({ | 
|---|
|  |  |  | elem: '#tableCheckItem', | 
|---|
|  |  |  | data: curCheckItems, | 
|---|
|  |  |  | page: false, | 
|---|
|  |  |  | // skin: 'line', | 
|---|
|  |  |  | even: true, | 
|---|
|  |  |  | cols: [[{ | 
|---|
|  |  |  | field: 'standardName', | 
|---|
|  |  |  | title: '检验项目', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'value', | 
|---|
|  |  |  | title: '检验值', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'operaSymbolValue', | 
|---|
|  |  |  | title: '标准值', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'unit', | 
|---|
|  |  |  | title: '单位', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'deNum', | 
|---|
|  |  |  | title: '扣重', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'addNum', | 
|---|
|  |  |  | title: '增重', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'dePrice', | 
|---|
|  |  |  | title: '扣价', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'addPrice', | 
|---|
|  |  |  | title: '增价', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'result', | 
|---|
|  |  |  | title: '检验结果', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | if (item.result == null) { | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (item.result == '0') { | 
|---|
|  |  |  | return "不合格"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (item.result == '1') { | 
|---|
|  |  |  | return "合格"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'remarks', | 
|---|
|  |  |  | title: '备注说明', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }]] | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | curCheckData.foodYear = dateFtt("yyyy", new Date()); | 
|---|
|  |  |  | curCheckData.checkUser = checkUser; | 
|---|
|  |  |  | if (curCheckData.checkStatus == "NONE") { | 
|---|
|  |  |  | //隐藏车牌部分信息 | 
|---|
|  |  |  | curCheckData.plateNum = replaceStr(curCheckData.plateNum); | 
|---|
|  |  |  | $("thead tr").css({ | 
|---|
|  |  |  | "border-bottom": "2px solid #53adce", | 
|---|
|  |  |  | "background": "#eff4f6" | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function showDetail(data) { | 
|---|
|  |  |  | curCheckData = data; | 
|---|
|  |  |  | if (!curCheckData.checkTime) { | 
|---|
|  |  |  | curCheckData.checkTime = dateFtt("yyyy-MM-dd hh:mm:ss", new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | curCheckData.checkUser = checkUser; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 赋值 | 
|---|
|  |  |  | form.val("form-detail", curCheckData); | 
|---|
|  |  |  | 
|---|
|  |  |  | layer.open({ | 
|---|
|  |  |  | type: 1, | 
|---|
|  |  |  | title: "化验单明细", | 
|---|
|  |  |  | area: ['1400px', '650px'], | 
|---|
|  |  |  | area: ['1400px', '700px'], | 
|---|
|  |  |  | shade: 0, | 
|---|
|  |  |  | content: $('#checkDetail'), | 
|---|
|  |  |  | btnAlign: 'c', | 
|---|
|  |  |  | btn: ['保存提交', '关闭取消'], | 
|---|
|  |  |  | btn: ['仅保存', '保存提交', '关闭取消'], | 
|---|
|  |  |  | yes: function () { | 
|---|
|  |  |  | // 更新到页面 | 
|---|
|  |  |  | var data = form.val("form-detail"); | 
|---|
|  |  |  | obj.update(data); | 
|---|
|  |  |  | // 合并更新當前编辑数据 | 
|---|
|  |  |  | Object.assign(curCheckData, data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | submit(); | 
|---|
|  |  |  | saveCheckData(); | 
|---|
|  |  |  | if (scanCodeTag) { | 
|---|
|  |  |  | showScanCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, btn2: function () { | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | // 更新到页面 | 
|---|
|  |  |  | var data = form.val("form-detail"); | 
|---|
|  |  |  | // 合并更新當前编辑数据 | 
|---|
|  |  |  | Object.assign(curCheckData, data); | 
|---|
|  |  |  | submit(); | 
|---|
|  |  |  | if (scanCodeTag) { | 
|---|
|  |  |  | showScanCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, btn3: function () { | 
|---|
|  |  |  | parent.layer.closeAll(); | 
|---|
|  |  |  | if (scanCodeTag) { | 
|---|
|  |  |  | showScanCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | closeBtn: 0 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取化验项信息 | 
|---|
|  |  |  | flushCheckItem(null); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | flushCheckItem(curCheckData.foodVariety); | 
|---|
|  |  |  | getPriceByFoodLevel(curCheckData.foodLevel); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 刷新化验结果项 | 
|---|
|  |  |  | 
|---|
|  |  |  | function flushCheckItem(foodVariety) { | 
|---|
|  |  |  | curCheckItems = null; | 
|---|
|  |  |  | $("#check-result-tip").text("检验结果:#"); | 
|---|
|  |  |  | $("#price-result-tip2").text("粮食定价:#元/公斤"); | 
|---|
|  |  |  | curCheckData.foodVariety = foodVariety; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新化验结果提醒,只做提醒,不做自动判断 | 
|---|
|  |  |  | function updateCheckResultTip() { | 
|---|
|  |  |  | if (!curCheckItems || curCheckItems.length == 0) { | 
|---|
|  |  |  | //仅保存 | 
|---|
|  |  |  | function saveCheckData() { | 
|---|
|  |  |  | if (!curCheckData.foodVariety) { | 
|---|
|  |  |  | layer.alert("请确认粮食品种!!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (curCheckData.checkStatus != "NONE") { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var msg; | 
|---|
|  |  |  | $.each(curCheckItems, function (index, data) { | 
|---|
|  |  |  | if (!data.remarks) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.remarks == "不合格") { | 
|---|
|  |  |  | msg = "不合格"; | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.remarks == "合格") { | 
|---|
|  |  |  | msg = "合格"; | 
|---|
|  |  |  | curCheckData.checkItems = curCheckItems; | 
|---|
|  |  |  | var index1 = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../basic/inout/submit-checkItem", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | async: false, | 
|---|
|  |  |  | data: JSON.stringify(curCheckData), | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.close(index1); | 
|---|
|  |  |  | notify(result.msg, result.data); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | curCheckData = null; | 
|---|
|  |  |  | notify("数据保存成功", result.data); | 
|---|
|  |  |  | flushData(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.close(index1); | 
|---|
|  |  |  | layer.alert("保存失败,请重新尝试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (msg) { | 
|---|
|  |  |  | $("#check-result-tip").text("检验结果:" + msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | $("#check-result-tip").text("检验结果:合格"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 渲染表格 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | function renderTableCheckItem() { | 
|---|
|  |  |  | // 清空数据 | 
|---|
|  |  |  | $("#tableCheckItem").empty(); | 
|---|
|  |  |  | table.render({ | 
|---|
|  |  |  | elem: '#tableCheckItem', | 
|---|
|  |  |  | data: curCheckItems, | 
|---|
|  |  |  | page: false, | 
|---|
|  |  |  | // skin: 'line', | 
|---|
|  |  |  | even: true, | 
|---|
|  |  |  | cols: [[{ | 
|---|
|  |  |  | field: 'standardName', | 
|---|
|  |  |  | title: '化验项目', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '20%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'value', | 
|---|
|  |  |  | title: '化验结果', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '20%', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'unit', | 
|---|
|  |  |  | title: '单位', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '10%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'standardValue', | 
|---|
|  |  |  | title: '化验标准', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | width: '15%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'remarks', | 
|---|
|  |  |  | title: '说  明', | 
|---|
|  |  |  | align: 'center', | 
|---|
|  |  |  | edit: 'text' | 
|---|
|  |  |  | }]] | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $("thead tr").css({ | 
|---|
|  |  |  | "border-bottom": "2px solid #53adce", | 
|---|
|  |  |  | "background": "#eff4f6" | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 当前完成 | 
|---|
|  |  |  | //保存提交 | 
|---|
|  |  |  | function submit() { | 
|---|
|  |  |  | if (curCheckData.checkStatus == "NONE" || curCheckData.checkStatus == "NONE2") { | 
|---|
|  |  |  | layer.alert("请确认化验结果!!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!curCheckData.depotId) { | 
|---|
|  |  |  | layer.alert("请选择装卸仓库!!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!curCheckData.foodVariety) { | 
|---|
|  |  |  | layer.alert("请确认粮食品种!!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!curCheckData.foodYear) { | 
|---|
|  |  |  | layer.alert("请确认粮食年份!!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!curCheckData.foodLevel) { | 
|---|
|  |  |  | 
|---|
|  |  |  | layer.alert("请确认粮食定价,如不考虑定价,请填写0.0"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | curCheckData.checkItems = curCheckItems; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../basic/inout/update-check", | 
|---|
|  |  |  | url: "../../basic/inout/submit-check", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | async: false, | 
|---|
|  |  |  | data: JSON.stringify(curCheckData), | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | //layer.alert(result.msg); | 
|---|
|  |  |  | notify(result.msg, result.data); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | parent.layer.closeAll(); | 
|---|
|  |  |  | curCheckData = null; | 
|---|
|  |  |  | //layer.alert("数据提交成功!"); | 
|---|
|  |  |  | notify("数据提交成功", result.data); | 
|---|
|  |  |  | flushData(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | layer.alert("提交失败,请重新尝试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //扫码弹窗 | 
|---|
|  |  |  | function showScanCode() { | 
|---|
|  |  |  | //清空表单 | 
|---|
|  |  |  | $("#form-sacnCodeDetail")[0].reset(); | 
|---|
|  |  |  | form.render(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //扫码弹窗-赋值true | 
|---|
|  |  |  | scanCodeTag = true; | 
|---|
|  |  |  | layer.open({ | 
|---|
|  |  |  | type: 1, | 
|---|
|  |  |  | title: "扫码信息", | 
|---|
|  |  |  | area: ['700px', '320px'], | 
|---|
|  |  |  | shade: 0, | 
|---|
|  |  |  | content: $('#scanCodeDetail'), | 
|---|
|  |  |  | success: function () { | 
|---|
|  |  |  | document.getElementById('checkId').focus(); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | btnAlign: 'c', | 
|---|
|  |  |  | btn: ['查询', '关闭取消'], | 
|---|
|  |  |  | yes: function () { | 
|---|
|  |  |  | getDataByCheckId(); | 
|---|
|  |  |  | }, btn2: function () { | 
|---|
|  |  |  | scanCodeTag = false; | 
|---|
|  |  |  | layer.closeAll(); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | closeBtn: 0 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据质检单号获取信息 | 
|---|
|  |  |  | function getDataByCheckId() { | 
|---|
|  |  |  | var param = form.val("form-sacnCodeDetail"); | 
|---|
|  |  |  | if (!param.checkId) { | 
|---|
|  |  |  | layer.alert("质检单号为空,请扫码或输入质检单号"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var index = layer.load(); | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | type: "POST", | 
|---|
|  |  |  | url: "../../basic/inout/inout-check-scan-code", | 
|---|
|  |  |  | dataType: "json", | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | data: JSON.stringify(param), | 
|---|
|  |  |  | success: function (result) { | 
|---|
|  |  |  | if (result.code != "0000") { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | $("#form-sacnCodeDetail")[0].reset(); | 
|---|
|  |  |  | form.render(); | 
|---|
|  |  |  | notify(result.msg, result.data); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | updateSelect(); | 
|---|
|  |  |  | showDetail(result.data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | error: function () { | 
|---|
|  |  |  | layer.close(index); | 
|---|
|  |  |  | $("#form-sacnCodeDetail")[0].reset(); | 
|---|
|  |  |  | form.render(); | 
|---|
|  |  |  | alertError("保存失败,请重新尝试!") | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 渲染表单数据 | 
|---|
|  |  |  | function renderTable() { | 
|---|
|  |  |  | 
|---|
|  |  |  | contentType: "application/json;charset=UTF-8", | 
|---|
|  |  |  | cols: [[{ | 
|---|
|  |  |  | field: 'checkId', | 
|---|
|  |  |  | title: '检验单号', | 
|---|
|  |  |  | width: '13%', | 
|---|
|  |  |  | title: '质检单号', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | style: 'color: #f67d06;font-weight: bold' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'plateNum', | 
|---|
|  |  |  | title: '车船号', | 
|---|
|  |  |  | width: '11%', | 
|---|
|  |  |  | style: 'font-weight: bold', | 
|---|
|  |  |  | field: 'registerTime', | 
|---|
|  |  |  | title: '登记时间', | 
|---|
|  |  |  | width: '15%', | 
|---|
|  |  |  | style: 'font-weight: bold' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'sampleStatus', | 
|---|
|  |  |  | title: '是否扦样', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | if (item.checkStatus != "NONE") { | 
|---|
|  |  |  | return item.plateNum; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | var result = replaceStr(item.plateNum); | 
|---|
|  |  |  | return result == null ? "" : result; | 
|---|
|  |  |  | if (item.sampleStatus == null) { | 
|---|
|  |  |  | return "未扦样"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (item.sampleStatus == 'NONE') { | 
|---|
|  |  |  | return "未扦样"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (item.sampleStatus == 'SAMPLE') { | 
|---|
|  |  |  | return "已扦样"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'customerName', | 
|---|
|  |  |  | title: '往来单位', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | if (item.checkStatus != "NONE") { | 
|---|
|  |  |  | return item.customerName; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | var result = replaceStr(item.customerName); | 
|---|
|  |  |  | return result == null ? "" : result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | field: 'sampleUser', | 
|---|
|  |  |  | title: '扦样人', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | style: 'font-weight: bold' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'sampleTime', | 
|---|
|  |  |  | title: '扦样时间', | 
|---|
|  |  |  | width: '15%', | 
|---|
|  |  |  | style: 'font-weight: bold' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'foodVariety', | 
|---|
|  |  |  | title: '粮食品种', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | width: '11%', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | var result = item.foodVariety; | 
|---|
|  |  |  | $.each(listFoodVariety, function (index, data) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'depotId', | 
|---|
|  |  |  | title: '装卸仓库', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | width: '11%', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | var result = item.depotId; | 
|---|
|  |  |  | $.each(listDepot, function (index, data) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'checkStatus', | 
|---|
|  |  |  | title: '检验结果', | 
|---|
|  |  |  | width: '10%', | 
|---|
|  |  |  | style: 'font-weight: bold', | 
|---|
|  |  |  | templet: function (item) { | 
|---|
|  |  |  | if (item.checkStatus == 'NONE') { | 
|---|
|  |  |  | 
|---|
|  |  |  | return item.checkStatus == null ? "" : item.checkStatus; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: 'registerTime', | 
|---|
|  |  |  | title: '登记时间', | 
|---|
|  |  |  | width: '14%' | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | field: '', | 
|---|
|  |  |  | title: '操作', | 
|---|
|  |  |  | width: '9%', | 
|---|
|  |  |  | width: '8%', | 
|---|
|  |  |  | toolbar: "#barControl" | 
|---|
|  |  |  | }]], | 
|---|
|  |  |  | where: param, | 
|---|
|  |  |  | 
|---|
|  |  |  | "border-bottom": "2px solid #53adce", | 
|---|
|  |  |  | "background": "#eff4f6" | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 表单清空 | 
|---|
|  |  |  | function resetForm() { | 
|---|
|  |  |  | $("#form-param")[0].reset(); | 
|---|
|  |  |  | 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']}); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // ---------------------------粮食产地 -开始 -------------------// | 
|---|
|  |  |  | // 弹出粮食产地下拉框 | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 弹出提醒框 | 
|---|
|  |  |  | * @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']}); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // ---------------------------粮食产地 -结束 -------------------// | 
|---|