From 8c34a52416d4177173d13d6856b7cd4ad3084095 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期日, 12 十一月 2023 18:40:55 +0800 Subject: [PATCH] # --- src/main/webapp/static/js/order/order.js | 337 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 320 insertions(+), 17 deletions(-) diff --git a/src/main/webapp/static/js/order/order.js b/src/main/webapp/static/js/order/order.js index 24f5ed3..b4b43ba 100644 --- a/src/main/webapp/static/js/order/order.js +++ b/src/main/webapp/static/js/order/order.js @@ -1,7 +1,9 @@ var insTbCount = 0; layui.config({ base: baseUrl + "/static/layui/lay/modules/" -}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate'], function () { +}).extend({ + notice: 'notice/notice', +}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate', 'tableMerge', 'notice'], function () { var $ = layui.jquery; var layer = layui.layer; var form = layui.form; @@ -10,6 +12,30 @@ var admin = layui.admin; var xmSelect = layui.xmSelect; var layDate = layui.laydate; + var laytpl = layui.laytpl; + var tableMerge = layui.tableMerge; + var notice = layui.notice; + + // 娓叉煋鎼滅储妯℃澘 + $.ajax({ + url: baseUrl+"/docType/list/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + limit: 9999 + }, + method: 'POST', + success: function (res) { + if (res.code === 200){ + let template = Handlebars.compile($('#docTypeTpl').html()); + $('#docType-query').html(template(res.data)); + layui.form.render('select'); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }) // 娓叉煋琛ㄦ牸 var insTb = table.render({ @@ -20,13 +46,13 @@ cellMinWidth: 100, cols: [[ {type: 'numbers'}, - {field: 'orderNo', title: '鍗曟嵁缂栧彿'}, + {field: 'orderNo', title: '鍗曟嵁缂栧彿', templet: '#orderNoTpl'}, {field: 'docType$', align: 'center', title: '绫诲瀷', minWidth: 160, width: 160}, {align: 'center', title: '鏄庣粏', toolbar: '#tbLook', minWidth: 160, width: 160}, {field: 'createTime$', title: '鍒涘缓鏃堕棿', minWidth: 200, width: 200}, {field: 'settle$', align: 'center', title: '鐘舵��', templet: '#settleTpl', minWidth: 160, width: 160}, {field: 'memo', align: 'center',title: '澶囨敞', hide: true}, - {align: 'center', title: '鎿嶄綔', toolbar: '#operate', width: 180} + {align: 'center', title: '鎿嶄綔', toolbar: '#operate', width: 240} ]], request: { pageName: 'curr', @@ -68,10 +94,18 @@ var layEvent = obj.event; if (layEvent === 'edit') { showEditModel(data); + } else if (layEvent === 'wrkTrace') { + showWrkTrace(data.id); } else if (layEvent === 'del') { doDel(data.id); + } else if (layEvent === 'labelUp') { + //涓婁紶鏍囩 + layer.msg('鏈畬鎴�', {icon: 2}); + } else if (layEvent === 'refundLoc') { + //閫�搴� + pakoutPreview([data.id]); } else if (layEvent === 'complete') { - doModify(data.id, 4); + doModify(data.id, data.orderNo, 4); } else if (layEvent === 'look') { var $a = $(obj.tr).find('a[lay-event="look"]'); var offset = $a.offset(); @@ -80,7 +114,7 @@ layer.open({ type: 1, title: false, - area: '820px', + area: '1020px', offset: [top + 'px', (left - 530 + $a.outerWidth()) + 'px'], shade: .01, shadeClose: true, @@ -98,12 +132,13 @@ cellMinWidth: 100, cols: [[ {type: 'numbers'}, - {field: 'matnr', title: '鍟嗗搧缂栫爜'}, + {field: 'matnr', title: '鍟嗗搧缂栫爜', width: 160}, {field: 'maktx', title: '鍟嗗搧鍚嶇О', width: 160}, - {field: 'batch', title: '鎵瑰彿'}, - {field: 'anfme', title: '鏁伴噺'}, - {field: 'qty', title: '浣滀笟鏁伴噺', style: 'font-weight: bold'}, - {field: 'unit', title: '鍗曚綅'}, + {field: 'batch', title: '绠卞彿'}, + {field: 'anfme', title: '鏈ㄧ涓摐绠旀暟閲�'}, + // {field: 'workQty', title: '浣滀笟鏁伴噺'}, + + // {field: 'unit', title: '鍗曚綅'}, // { // field: 'createTime$', title: '鍒涘缓鏃堕棿', sort: true, templet: function (d) { // return util.toDateString(d.createTime); @@ -111,7 +146,9 @@ // }, // {field: 'inQty', title: '宸插叆搴撻噺'}, // {field: 'color', title: '棰滆壊'}, - {field: 'specs', title: '瑙勬牸'} + {field: 'specs', title: '瑙勬牸'}, + {field: 'qty$', title: '鐘舵��', style: 'font-weight: bold'}, + {field: 'source$', title: '鏄惁纭', style: 'font-weight: bold'} ]], request: { pageName: 'curr', @@ -166,6 +203,10 @@ layer.msg('鏄庣粏淇敼鏁伴噺涓嶅悎娉�', {icon: 2}); return false; } + if (nList[xi].anfme < nList[xi].workQty){ + layer.msg('鏁伴噺涓嶈兘灏忎簬宸蹭綔涓氭暟閲�', {icon: 2}); + return false; + } } layer.load(2); $.ajax({ @@ -207,11 +248,11 @@ {type: 'numbers', title: '#'}, {field: 'matnr', title: '鍟嗗搧缂栫爜', width: 160}, {field: 'maktx', title: '鍟嗗搧鍚嶇О', width: 200}, - {field: 'batch', title: '鎵瑰彿', edit: true}, + {field: 'batch', title: '绠卞彿', edit: true}, {field: 'specs', title: '瑙勬牸'}, {field: 'anfme', title: '鏁伴噺(淇敼)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110}, - // {field: 'inQty', title: '宸插叆搴撻噺', minWidth: 100, width: 100}, - {field: 'unit', title: '鍗曚綅', width: 80}, + {field: 'workQty', title: '浣滀笟鏁伴噺', minWidth: 100, width: 100}, + // {field: 'unit', title: '鍗曚綅', width: 80}, {field: 'memo', title: '澶囨敞' , edit: true}, {align: 'center', title: '鎿嶄綔', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'} ]], @@ -246,6 +287,10 @@ if (layEvent === 'edit') { showEditModel2(data); } else if (layEvent === 'del') { + if(data.workQty > 0){ + layer.msg("宸插瓨鍦ㄤ綔涓氭暟閲忥紝涓嶈兘鍒犻櫎", {icon: 2}); + return; + } layer.confirm('纭畾瑕佸垹闄ゅ悧锛�', { shade: .1, skin: 'layui-layer-admin' @@ -273,6 +318,14 @@ } else { if (vle <= 0) { layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2}); + // data[obj.field] = 0; + // insTbSSXM.reload({data: xxDataList}); + return false; + } + if(obj.value < data.workQty){ + layer.msg("杈撳叆鏁伴噺涓嶈兘灏忎簬浣滀笟涓暟閲�", {icon: 2}); + // data[obj.field] = 0; + // insTbSSXM.reload({data: xxDataList}); return false; } } @@ -290,11 +343,10 @@ admin.open({ type: 1, offset: '150px', - area: '480px', + area: '680px', title: (exp ? '淇敼' : '娣诲姞') + '鏄庣粏', content: $('#matEditDialog').html(), success: function (layero, dIndex) { - $(layero).children('.layui-layer-content').css('overflow', 'visible'); // 鍥炴樉鏁版嵁 form.val('matEditForm', exp); // 琛ㄥ崟鎻愪氦浜嬩欢 @@ -398,7 +450,7 @@ } // 淇敼璁㈠崟鐘舵�� - function doModify(orderId, settle) { + function doModify(orderId, orderNo, settle) { layer.confirm('纭畾瑕佹墜鍔ㄥ畬缁撳悧锛�', { shade: .1, skin: 'layui-layer-admin' @@ -412,6 +464,7 @@ headers: {'token': localStorage.getItem('token')}, data: { id: orderId, + orderNo: orderNo, settle: settle }, method: 'POST', @@ -434,9 +487,259 @@ }); } + // 浠诲姟杩芥函 + function showWrkTrace(orderId) { + let loadIndex = layer.msg('璇锋眰涓�...', {icon: 16, shade: 0.01, time: false}); + $.ajax({ + url: baseUrl+"/order/wrk/trace/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + orderId: orderId + }, + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200){ + laytpl(wrkTraceDialog.innerHTML).render(res.data, function (html) { + admin.open({ + type: 1, + title: '浠诲姟杩芥函', + area: ['800px', '450px'], + shadeClose: true, + content: html, + success: function (layero, dIndex) { + $(layero).children('.layui-layer-content').css('overflow', 'visible'); + /** 缁熻鍥捐〃 */ + var traceCharts = echarts.init(document.getElementById('wrkTraceCharts')); + var traceOptions = { + title: { + text: '鎬婚噺/浣滀笟/瀹屾垚', x: 'center', y: '38%', + textStyle: {fontSize: 18, color: '#262626', fontWeight: 'normal'}, + subtextStyle: {fontSize: 36, color: '#10B4E8'}, + itemGap: 20 + }, + color: ['#10B4E8', '#E0E0E0', '#FF0000'], + tooltip: {trigger: 'item'}, + series: [{name: '绠卞瓙鏁伴噺', type: 'pie', radius: ['75%', '80%'], label: {normal: {show: false}}}] + }; + traceCharts.setOption(traceOptions); + // 璧嬪�� + traceCharts.setOption({ + title: { + subtext: res.data.totalQty+"/"+res.data.wrkQty+"/"+res.data.endQty + }, + series: [ + { + data: [ + {name: '宸蹭綔涓�', value: res.data.wrkQty}, + {name: '鏈綔涓�', value: res.data.totalQty-res.data.wrkQty-res.data.lackQty}, + {name: '搴撳瓨涓嶈冻', value: res.data.lackQty}, + ] + } + ] + }); + } + }); + }); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + }else { + layer.msg(res.msg, {icon: 2}); + } + } + }) + } + layDate.render({ elem: '.layui-laydate-range' ,type: 'datetime' ,range: true }); + + function pakoutPreview(ids) { + let loadIndex = layer.load(2); + $.ajax({ + url: baseUrl + "/out/refund/loc/preview/auth", + headers: {'token': localStorage.getItem('token')}, + contentType: 'application/json;charset=UTF-8', + data: JSON.stringify(ids), + method: 'POST', + success: function (res) { + layer.close(loadIndex); + var tableCache; + if (res.code === 200){ + layer.open({ + type: 1 + ,title: false + ,closeBtn: false + ,offset: '50px' + ,area: ['1500px', '700px'] + ,shade: 0.5 + ,shadeClose: false + ,btn: ['鐢熸垚閫�搴撳崟', '绋嶅悗澶勭悊'] + ,btnAlign: 'c' + ,moveType: 1 //鎷栨嫿妯″紡锛�0鎴栬��1 + ,content: $('#pakoutPreviewBox').html() + ,success: function(layero, index){ + stoPreTabIdx = table.render({ + elem: '#stoPreTab', + data: res.data, + height: 520, + page: false, + limit: Number.MAX_VALUE, + cellMinWidth: 100, + cols: [[ + {type: 'checkbox'}, + // {type: 'checkbox', merge: ['orderNo']}, + {field: 'orderNo', title: '鍗曟嵁缂栧彿', align: 'center'}, + // {field: 'orderNo', title: '鍗曟嵁缂栧彿', merge: true, align: 'center'}, + {field: 'title', title: '鍟嗗搧', align: 'center', width: 350}, + // {field: 'title', title: '鍟嗗搧', merge: true, align: 'center', width: 350}, + {field: 'batch', title: '绠卞彿', align: 'center'}, + {field: 'model', title: '鎵规', align: 'center'}, + {field: 'specs', title: '瑙勬牸', align: 'center'}, + {field: 'brand', title: '鏈ㄧ绫诲瀷', align: 'center'}, + {field: 'zpallet', title: '鎵樼洏鐮�', align: 'center'}, + {field: 'anfme', title: '鏈ㄧ涓摐绠旀暟閲�', align: 'center', width: 90, style: 'font-weight: bold'}, + {field: 'count', title: '鏈ㄧ涓摐绠旀暟閲�', align: 'center', width: 90, style: 'font-weight: bold'}, + {field: 'locNo', title: '璐т綅', align: 'center', width: 100, templet: '#locNoTpl'}, + // {field: 'staNos', align: 'center', title: '鍑哄簱绔�', merge: ['locNo'], templet: '#tbBasicTbStaNos'}, + // {type: 'checkbox', merge: ['locNo']}, + ]], + done: function (res) { + tableMerge.render(this); + $('.layui-table-body.layui-table-main').css("overflow", "auto"); + tableCache = tableData = table.cache.stoPreTab; + } + }); + // 淇敼鍑哄簱绔� + form.on('select(tbBasicTbStaNos)', function (obj) { + let index = obj.othis.parents('tr').attr("data-index"); + let data = tableCache[index]; + for (let i = 0; i<tableCache.length; i++) { + if (tableCache[i].locNo === data.locNo) { + tableCache[i]['staNo'] = Number(obj.elem.value); + } + } + obj.othis.children().find("input").css("color", "blue"); + return false; + }); + // 鎵归噺淇敼鍑哄簱绔� + form.on('submit(batchModifySta)', function () { + let stoPreTabData = layui.table.checkStatus('stoPreTab').data; + if (stoPreTabData.length < 1) { + layer.msg("璇疯嚦灏戦�夋嫨涓�鏉′互涓婂悎骞舵暟鎹�", {icon: 7}); + return false; + } + modifySta(stoPreTabData); + }); + // 鎵归噺淇敼鍑哄簱绔� - 绔欑偣閫夋嫨 + function modifySta(stoPreTabData) { + // 鍑哄簱绔欏彇浜ら泦 + let staBatchSelectVal = []; + for(let i = 0; i<stoPreTabData.length; i++) { + let staNos = stoPreTabData[i].staNos; + if (staNos !== null) { + if (staBatchSelectVal.length === 0) { + staBatchSelectVal = staNos; + } else { + staBatchSelectVal = staBatchSelectVal.filter(val => + { + return new Set(staNos).has(val) + } + ) + } + } + } + if (staBatchSelectVal.length === 0) { + layer.msg("鍑哄簱绔欐病鏈変氦闆嗭紝鏃犳硶鎵归噺淇敼", {icon: 2}); + return; + } + admin.open({ + type: 1, + area: '300px', + offset: 'auto', + title: '璇烽�夋嫨绔欑偣', + content: $('#staBatchSelectDialog').html(), + success: function (layero, ddIndex) { + // 娓叉煋涓嬫媺妗� + let template = Handlebars.compile($('#batchStaSelectTpl').html()); + $('#batchSelectStaBox').html(template({list: staBatchSelectVal})); + // 纭 + form.on('submit(staBatchSelectConfirm)', function (obj) { + let loadIdx = layer.load(2); + let batchSta = Number(obj.field.batchSta); + let arr = []; + for (let j = 0; j<stoPreTabData.length; j++) { + for (let i = 0; i<tableCache.length; i++) { + if (tableCache[i].orderNo === stoPreTabData[j].orderNo + && tableCache[i].matnr === stoPreTabData[j].matnr + && tableCache[i].locNo === stoPreTabData[j].locNo) { + tableCache[i]['staNo'] = batchSta; + arr.push(i); + } + } + } + stoPreTabIdx.reload({data: tableCache}); + arr.forEach(item => { + $('div[lay-id=stoPreTab] tr[data-index="' + item + '"] .order-sta-select').val(batchSta); + }); + layui.form.render('select'); + arr.forEach(item => { + $('div[lay-id=stoPreTab] tr[data-index="' + item + '"] .layui-select-title').find("input").css("color", "blue"); + }); + layer.close(loadIdx); layer.close(ddIndex); + return false; + }); + // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯 + $(layero).children('.layui-layer-content').css('overflow', 'visible'); + layui.form.render('select'); + }, + }) + } + + } + ,yes: function(index, layero){ + //鎸夐挳銆愰��搴撱�戠殑鍥炶皟 + pakout(tableCache, index); + } + ,btn2: function(index, layero){ + //鎸夐挳銆愮◢鍚庡鐞嗐�戠殑鍥炶皟 + layer.close(index) + //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴 + } + }); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }) + } + + function pakout(tableCache, layerIndex) { + // let loadIndex = layer.load(2); + notice.msg('姝e湪鐢熸垚鍑哄簱浠诲姟......', {icon: 4}); + $.ajax({ + url: baseUrl + "/out/refund/loc/auth", + headers: {'token': localStorage.getItem('token')}, + contentType: 'application/json;charset=UTF-8', + data: JSON.stringify(tableCache), + method: 'POST', + success: function (res) { + notice.destroy(); + if (res.code === 200) { + layer.close(layerIndex); + layer.msg(res.msg, {icon: 1}); + insTb.reload({where: null}); + insTb2.reload({where: null, page: {curr: 1}}); + } else if (res.code === 403) { + top.location.href = baseUrl + "/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }); + } }); -- Gitblit v1.9.1