From 1204e1ae66a50ec99b4dea80e839c1264c36ef48 Mon Sep 17 00:00:00 2001 From: Demo <Demo@DESKTOP-CPA90BF> Date: 星期一, 19 二月 2024 13:24:30 +0800 Subject: [PATCH] 修改标签因单据条件生成重复问题,前端防止重复点击问题 --- Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs | 28 ++++++++----- HTML/views/ASNSetting/LabelPrint.html | 61 +++++++++++++++++------------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/HTML/views/ASNSetting/LabelPrint.html b/HTML/views/ASNSetting/LabelPrint.html index 7c4577e..2519584 100644 --- a/HTML/views/ASNSetting/LabelPrint.html +++ b/HTML/views/ASNSetting/LabelPrint.html @@ -119,38 +119,47 @@ var expirationTime = getQueryString('ExpirationTime'); var storeTime = getQueryString('StoreTime'); + var doing = true; // console.log(productionTime); // console.log(expirationTime); // console.log(storeTime); //鐢熸垚 $('#btnAdd').on('click', function () { - var param = { - Id: parseInt(id), - IsReset:reset, - ArriveQty:arriveQty, - ProductionTime:productionTime, - ExpirationTime:expirationTime, - StoreTime:storeTime - }; - // console.log(param); - synData(IP + "/BllAsn/AddLabelBox", param , 'post', function (res) { - if (res.code == 0) { //鎴愬姛 - layer.msg(res.msg, { - icon: 1, - time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級 - }, function () { - parent.location.reload(); - parent.layer.close(layer.index); - }); - - } else { //涓嶆垚鍔� - layer.msg(res.msg, { - icon: 2, - time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級 - }, function () { }); - } - }); + if(doing){ + doing= false; + + + var param = { + Id: parseInt(id), + IsReset:reset, + ArriveQty:arriveQty, + ProductionTime:productionTime, + ExpirationTime:expirationTime, + StoreTime:storeTime + }; + // console.log(param); + synData(IP + "/BllAsn/AddLabelBox", param , 'post', function (res) { + if (res.code == 0) { //鎴愬姛 + layer.msg(res.msg, { + icon: 1, + time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級 + }, function () { + parent.location.reload(); + parent.layer.close(layer.index); + doing = true; + }); + + } else { //涓嶆垚鍔� + layer.msg(res.msg, { + icon: 2, + time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級 + }, function () { + doing = true; + }); + } + }); + } }); //鎵撳嵃 $('#btnPrint').on('click', function () { diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs index 870b0e8..9c0ad7a 100644 --- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs +++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs @@ -576,7 +576,7 @@ packStr += "-" + pack.L5Num + "/" + pack.L5Name; } //鏍囩琛� - var label = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNDetailNo == imId).ToList(); + var label = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.Origin == "WMS鐢熸垚").ToList(); #endregion @@ -661,15 +661,16 @@ string maxBoxCode = ""; //绠辩爜鍙� // 鐢熸垚鑷紪鎵瑰彿 string toDayTime = DateTime.Now.ToString("yyyyMMdd"); - - - var maxLotNo = label.Max(a => a.LotNo); - var maxBoxNo = label.Max(a => a.BoxNo); + if (isReset == "0") { - - maxLotNoStr = maxLotNo; - maxBoxCode = maxBoxNo; + var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); + if (labelCount.Count <=0) + { + throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱"); + } + maxLotNoStr = label.Max(a => a.LotNo); + maxBoxCode = label.Max(a => a.BoxNo); if (string.IsNullOrWhiteSpace(maxLotNoStr)) { maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; @@ -725,7 +726,7 @@ } //鑾峰彇绠辩爜 - if (maxBoxCode == "") + if (string.IsNullOrWhiteSpace(maxBoxCode)) { var str = "B"+maxLotNoStr + "000001"; //鎵瑰彿+ 娴佹按 2302010001000001 maxBoxCode = str; @@ -813,6 +814,11 @@ string toDayTime2 = DateTime.Now.ToString("yyyyMMdd"); if (isReset == "0") { + var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); + if (labelCount.Count <= 0) + { + throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱"); + } var maxCode = label.Max(a => a.LotNo); var boxCode1 = label.Max(a => a.BoxNo);//绠卞彿 var boxCode2 = label.Max(a => a.BoxNo3);//鏀彿 @@ -875,7 +881,7 @@ } //鑾峰彇绠辩爜 - if (maxboxcode2 == "") + if (string.IsNullOrWhiteSpace(maxboxcode2)) { maxboxcode2 = "B"+maxCodestr2 + "000001"; // 绠卞彿 鎵瑰彿+绗嚑绠� } @@ -919,7 +925,7 @@ } } - if (maxboxcode3 == "") + if (string.IsNullOrWhiteSpace(maxboxcode3)) { maxboxcode3 = "Z"+maxCodestr2 + "0001"; // 鏀彿 鎵瑰彿+绗嚑绠� } -- Gitblit v1.8.0