From 6acdfc2c867d8fde898a4cc67bdefa2b97f03e3e Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期三, 09 七月 2025 10:58:54 +0800
Subject: [PATCH] 1.条码入库前拆分优化 2.其他入库优化

---
 H5/Js/Cpbdsj.js |  127 ++++++++++++++++++++++++++++++++---------
 1 files changed, 98 insertions(+), 29 deletions(-)

diff --git a/H5/Js/Cpbdsj.js b/H5/Js/Cpbdsj.js
index 2d92457..e6e21c6 100644
--- a/H5/Js/Cpbdsj.js
+++ b/H5/Js/Cpbdsj.js
@@ -15,7 +15,17 @@
             KbBarMxInfo: [],
             GX: "G007:鏍稿閫佹",
             Xvalue:4,
-            XbarInfo: [],
+            XbarInfo: [
+                //{
+                //    iteM_BARCODE: "",      // 鏉$爜
+                //    item_no: "",           // 鐗╂枡缂栧彿
+                //    item_name: "",         // 鐗╂枡鍚嶇О
+                //    item_model: "",        // 瑙勬牸鍨嬪彿
+                //    quantity: 0,           // 鏁伴噺
+                //    is_hedui: "0",          // 鏄惁鏍稿(1:宸叉牳瀵� 0:鏈牳瀵�),
+                //    weight: ""          // 浜у搧閲嶉噺
+                //}
+            ],
             DAA001: [],
         }
     },
@@ -45,6 +55,7 @@
                         that.XBar = "";
                     }
                     else {
+                        that.$playSound('error');
                         that.$toast.fail(json.message);
                         that.$refs.KbBar.focus();
                         that.KbBar = "";
@@ -53,6 +64,7 @@
                 })
                 .catch(function (error) {
                     that.isLoading = false;
+                    that.$playSound('error');
                     that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
                     that.$refs.KbBar.focus();
                     that.KbBar = "";
@@ -61,6 +73,7 @@
         getXBarInfo() {
             var that = this;
             if (that.KbBar.length <= 0) {
+                that.$playSound('error');
                 that.$toast.fail("鍗℃澘鏉$爜涓嶈兘涓虹┖锛�");
                 that.$refs.KbBar.focus();
                 that.XBar = "";
@@ -68,6 +81,7 @@
             }
 
             if (that.DAA001.length <= 0) {
+                that.$playSound('error');
                 that.$toast.fail("鎸囦护宸ュ崟涓嶈兘涓虹┖锛�");
                 that.$refs.KbBar.focus();
                 that.XBar = "";
@@ -76,7 +90,18 @@
 
             // 妫�鏌ユ槸鍚﹁秴杩囪绠辨暟
             if (that.XbarInfo.length >= that.Xvalue) {
+                that.$playSound('error');
                 that.$toast.fail(`宸茶揪鍒拌绠辨暟闄愬埗(${that.Xvalue})`);
+                that.XBar = "";
+                return;
+            }
+
+            //寰呰鏁�
+            var Dvalue = (that.KbBarInfo.oldqty || 0) - +(that.KbBarInfo.ySum || 0)
+            // 妫�鏌ユ槸鍚﹁秴杩囪绠辨暟
+            if (that.Xvalue > Dvalue) {
+                that.$playSound('error');
+                that.$toast.fail(`瑁呯鏁�(${that.Xvalue}) 涓嶈兘澶т簬 鍗℃澘寰呰鏁�(${Dvalue})`);
                 that.XBar = "";
                 return;
             }
@@ -84,6 +109,7 @@
             // 妫�鏌ユ潯鐮佹槸鍚﹀凡瀛樺湪
             const isExist = that.XbarInfo.some(item => item.iteM_BARCODE === that.XBar);
             if (isExist) {
+                that.$playSound('error');
                 that.$toast.fail("璇ョ鏉$爜宸插瓨鍦紝璇峰嬁閲嶅鎵弿");
                 that.XBar = "";
                 return;
@@ -91,8 +117,9 @@
 
             that.isLoading = true;
             that.AxiosHttp("post", 'Womdaa/getXBarInfo', {
-                Kbbarcode: that.KbBar,
+                KbBar: that.KbBar,
                 DAA001: that.DAA001,
+                userName: that.userInfo.loginAccount,
                 Xbarcode: that.XBar
             }, false)
                 .then(function (res) {
@@ -103,24 +130,31 @@
                         that.XBar = "";
                     }
                     else {
+                        that.$playSound('error');
                         that.$toast.fail(json.message);
                     }
                     that.isLoading = false;
                 })
                 .catch(function (error) {
                     that.isLoading = false;
+                    that.$playSound('error');
                     that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
                 });
         },
-
-
         productBinding() {
+
+            if (this.isLoading) {
+                return;
+            }
+
             var that = this;
             if (that.ZsBar.length <= 0) {
+                that.$playSound('error');
                 that.$toast.fail("杩芥函鐮佷笉鑳戒负绌猴紒");
                 return;
             }
             if (that.LsBar.length <= 0) {
+                that.$playSound('error');
                 that.$toast.fail("鍚庣洊鐮佷笉鑳戒负绌猴紒");
                 return;
             }
@@ -135,12 +169,14 @@
                     var json = res;
                     if (json.status == 0) {
                         // that.scanInfo = json.data.tbBillList;
+                        that.$playSound('success');
                         that.$notify({ type: 'success', message: json.message });
                         that.$refs.ZsBar.focus();
                         that.ZsBar = null;
                         that.ZsBar = null;
                     }
                     else {
+                        that.$playSound('error');
                         that.$toast.fail(json.message);
                         that.$refs.ZsBar.focus();
                         that.ZsBar = null;
@@ -151,31 +187,18 @@
                 })
                 .catch(function (error) {
                     that.isLoading = false;
+                    that.$playSound('error');
                     that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
                     that.$refs.ZsBar.focus();
                     that.ZsBar = null;
                     that.ZsBar = null;
                 });
         },
-        //鎵撳嵃鏈烘敞閲�
-        //selectPrinter(printer) {
-        //    this.selectedPrinter = printer.printerId; // 鏇存柊閫変腑鐨勬墦鍗版満缂栧彿
-        //},
-        //confirmSelection() {
-        //    if (this.selectedPrinter) {
-        //        alert(`鎮ㄩ�夋嫨浜嗘墦鍗版満锛�${this.selectedPrinter}`);
-        //        // 鍦ㄨ繖閲屽鐞嗛�夋嫨缁撴灉锛屼緥濡傝皟鐢ㄦ帴鍙f垨鏇存柊鐘舵��
-        //        this.isPrinterPopupVisible = false; // 鍏抽棴寮圭獥
-        //    } else {
-        //        alert('璇烽�夋嫨涓�涓墦鍗版満锛�');
-        //    }
-        //},
-        //onPrinterSelected(value) {
-        //    console.log('褰撳墠閫変腑鐨勬墦鍗版満缂栧彿:', value);
-        //},
         checkProductBarcode() {
+
             var that = this;
             if (!that.LsBar) {
+                that.$playSound('error');
                 that.$toast.fail("璇疯緭鍏ヤ骇鍝佹潯鐮�");
                 return;
             }
@@ -189,24 +212,57 @@
                 if (matchedItem.is_hedui === "1") {
                     that.$toast("宸叉牳瀵�");
                 } else {
-                    that.$set(matchedItem, 'is_hedui', "1");
-                    that.$notify({ type: 'success', message: "鏍稿鎴愬姛" });
-                    that.LsBar = "";
-                    // 妫�鏌ユ槸鍚︽墍鏈夎閮藉凡鏍稿
-                    const allChecked = that.XbarInfo.every(item => item.is_hedui === "1");
-                    if (allChecked && that.XbarInfo.length > 0) {
-                        that.submitAllChecked();
-                    }
+
+                    that.AxiosHttp("post", 'Womdaa/GetWeightByXt', {
+                        LsBar: that.LsBar,
+                        userName: that.userInfo.loginAccount
+                    }, false)
+                        .then(function (res) {
+                            var json = res;
+                            if (json.status == 0) {
+                                var weigth = json.data.tbBillList.weight;
+                                that.$set(matchedItem, 'is_hedui', "1");
+                                that.$set(matchedItem, 'weight', weigth);
+                                that.$playSound('success');
+                                that.$notify({ type: 'success', message: "鏍稿鎴愬姛" });
+                                that.LsBar = "";
+                                // 妫�鏌ユ槸鍚︽墍鏈夎閮藉凡鏍稿
+                                const allChecked = that.XbarInfo.every(item => item.is_hedui === "1");
+                                if (allChecked && that.XbarInfo.length > 0 && that.XbarInfo.length === that.Xvalue) {
+                                    that.submitAllChecked();
+                                }
+                            }
+                            else {
+                                that.$playSound('error');
+                                that.$toast.fail(json.message);
+                            }
+                            that.isLoading = false;
+                        })
+                        .catch(function (error) {
+                            that.isLoading = false;
+                            that.$playSound('error');
+                            that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
+                        });
                 }
             } else {
+                that.$playSound('error');
                 that.$toast.fail("鏈壘鍒板尮閰嶇殑绠辨潯鐮�");
             }
             
             that.LsBar = ""; // 娓呯┖杈撳叆妗�
         },
 
+        GetWeightByXt() {
+            
+        },
+
         // 鏂板鏂规硶锛氭彁浜ゆ墍鏈夊凡鏍稿鐨勬暟鎹�
         submitAllChecked() {
+
+            if (this.isLoading) {
+                return;
+            }
+
             var that = this;
             that.isLoading = true;
             
@@ -218,9 +274,11 @@
                 .then(function (res) {
                     var json = res;
                     if (json.status == 0) {
+                        that.$playSound('success');
                         that.$notify({ type: 'success', message: json.message });
                         that.getKbBarInfo();
                     } else {
+                        that.$playSound('error');
                         that.$toast.fail(json.message);
                         that.XbarInfo = [];
                         that.XBar = "";
@@ -231,12 +289,19 @@
                 })
                 .catch(function (error) {
                     that.isLoading = false;
+                    that.$playSound('error');
                     that.$toast.fail("缁戝畾澶辫触锛岃閲嶈瘯锛�");
                 });
         },
         handleSubmit() {
+
+            if (this.isLoading) {
+                return;
+            }
+
             var that = this;
             if (!that.KbBar) {
+                that.$playSound('error');
                 that.$toast.fail("璇峰厛鎵弿鍗℃澘鏉$爜");
                 return;
             }
@@ -246,6 +311,7 @@
             const ySum = +(that.KbBarInfo.ySum || 0);
             
             if (oldqty !== ySum) {
+                that.$playSound('error');
                 that.$toast.fail(`瑁呮澘鏈畬鎴愶紝寰呰鏁帮細${oldqty - ySum}`);
                 return;
             }
@@ -258,19 +324,22 @@
                 .then(function (res) {
                     var json = res;
                     if (json.status == 0) {
-                        that.$notify({ type: 'success', message: json.tbBillList.message });
+                        that.$playSound('success');
+                        that.$notify({ type: 'success', message: json.message });
                         // 娓呯┖鏁版嵁
                         that.KbBar = "";
                         that.XbarInfo = [];
                         that.KbBarInfo = [];
                         that.$refs.KbBar.focus();
                     } else {
+                        that.$playSound('error');
                         that.$toast.fail(json.message);
                     }
                     that.isLoading = false;
                 })
                 .catch(function (error) {
                     that.isLoading = false;
+                    that.$playSound('error');
                     that.$toast.fail("鎻愪氦澶辫触锛岃閲嶈瘯锛�");
                     that.$refs.KbBar.focus();
                 });

--
Gitblit v1.9.3