//当前节点 入库质检 var layer; var laydate; var form; var table; var page = 1; var limit = 10; var curCheckData = null;// 当前编辑数据 var curCheckItems = null;// 当前数据的检查项信息 $(function () { layui.use(['layer', 'laydate', 'form', 'table'], function () { layer = layui.layer; form = layui.form; table = layui.table; laydate = layui.laydate; laydate.render({ elem: '#start', theme: '#7b8e9f', value: startTime }); laydate.render({ elem: '#end', theme: '#7b8e9f', value: endTime }); // 监听行工具事件 table.on('tool(tableData)', function (obj) { if (obj.event === 'edit') { //展示数据 showDetail(obj.data); } }); // 初始化表单数据 renderTable(); }); //显示入库流程 showProgress(); }); /** * 控制流程环节显示 */ 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("CARD_BACK") == -1) { $("#progress-cardBack").css("display", "none"); } } // 查询 function flushData() { var index = layer.load(); var param = form.val("form-param"); table.reload('tableData', { url: "/basic/inout/page-inout-data", where: param, }); $("thead tr").css({ "border-bottom": "2px solid #53adce", "background": "#eff4f6" }); layer.close(index); } function showDetail(data) { curCheckData = data; // 赋值 form.val("form-detail", data); form.render(); layer.open({ type: 1, title: "填写化验信息", area: ['1400px', '700px'], shade: 0, content: $('#checkDetail'), btnAlign: 'c', btn: ['保存提交', '关闭取消'], yes: function () { // 更新到页面 var data = form.val("form-detail"); // 合并更新當前编辑数据 Object.assign(curCheckData, data); submit(); }, btn2: function () { parent.layer.closeAll(); }, closeBtn: 0 }); } //保存提交 function submit() { if (!curCheckData.perWet) { layer.alert("请填写质检水分信息!!"); return; } if (!curCheckData.perImpurity) { layer.alert("请填写质检杂质信息!!"); return; } var index = layer.load(); $.ajax({ type: "POST", 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); notify(result.msg, result.data); } else { parent.layer.closeAll(); curCheckData = null; notify("数据提交成功", result.data); flushData(); } }, error: function () { layer.close(index); layer.alert("提交失败,请重新尝试!"); } }); } /** * 渲染表单数据 */ function renderTable() { var param = form.val("form-param"); // 清空数据 $("#tableData").empty(); table.render({ elem: '#tableData', url: '/basic/inout/page-inout-data', page: true, limit: limit, even: true, method: 'POST', contentType: "application/json;charset=UTF-8", cols: [[{ type: 'numbers', title: '序号' },{ field: 'id', title: '单据号', width: '10%', style: 'color: #f67d06;font-weight: bold' }, { field: 'plateNum', title: '车牌号', width: '8%', style: 'font-weight: bold' }, { field: 'type', title: '类型', width: '6%', templet: function (item) { var result = item.type; return result == "IN" ? "入库" : "出库"; } },{ field: 'customerName', title: '往来单位' }, { field: 'depotId', title: '装卸仓库', width: '10%', 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: 'foodVariety', title: '粮食品种', width: '10%', 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: 'perWet', title: '水分', width: '8%' }, { field: 'perImpurity', title: '杂质', width: '8%' }, { field: 'progress', title: '流程进度', width: '10%', style: 'font-weight: bold', templet: function (item) { return INOUT_PROGRESS_MSG(item.progress); } }, { field: '', title: '操作', width: '9%', 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 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']}); } } // ---------------------------粮食产地 -结束 -------------------//