From 84073105b42601bf08a45b58a3781580c922199f Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期一, 14 四月 2025 14:29:33 +0800
Subject: [PATCH] 1.产品绑定核对送检

---
 H5/Cpbd.aspx    |    2 
 H5/Js/Cpbd.js   |    6 
 H5/Js/Cpbdsj.js |  170 +++++++++++++++++++++++++++++++++++++++++
 H5/Cpdbsj.aspx  |   40 ++++++---
 4 files changed, 198 insertions(+), 20 deletions(-)

diff --git a/H5/Cpbd.aspx b/H5/Cpbd.aspx
index 6e1dade..fa882d2 100644
--- a/H5/Cpbd.aspx
+++ b/H5/Cpbd.aspx
@@ -154,5 +154,5 @@
 </asp:Content>
 
 <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
-    <script src="Js/Cpbd.js?<%=121112 %>"></script>
+    <script src="Js/Cpbd.js?<%=1211121 %>"></script>
 </asp:Content>
\ No newline at end of file
diff --git a/H5/Cpdbsj.aspx b/H5/Cpdbsj.aspx
index 38c2311..5c378ed 100644
--- a/H5/Cpdbsj.aspx
+++ b/H5/Cpdbsj.aspx
@@ -51,9 +51,6 @@
         flex: 1; /* 绛夊垎鍓╀綑绌洪棿 */
         min-width: 0; /* 闃叉鍐呭婧㈠嚭 */
     }
-
-
-
 </style>
 </asp:Content>
 
@@ -85,14 +82,16 @@
                     <div class="si-status__left">
                       <span class="si-status__label">鍙鏁�</span>
                     </div>
-                    <div  class="si-status__right">{{KbBarInfo.oldqty}}</div>
+                    <div  class="si-status__right">{{KbBarInfo.oldqty??0}}</div>
                   </div>
 
                   <div class="si-status-box si-status--error">
                     <div class="si-status__left">
                       <span class="si-status__label">寰呰鏁�</span>
                     </div>
-                    <div class="si-status__right">{{KbBarInfo.ySum}}</div>
+                    <div class="si-status__right">
+                      {{ ((+(KbBarInfo.oldqty ?? 0) - +(KbBarInfo.ySum ?? 0)) || 0) }}
+                    </div>
                   </div>
                 </div>
                 
@@ -117,10 +116,21 @@
                 </van-field>
                 
                 <van-field
-                    ref="LsBar"
-                    v-model="LsBar"
+                    ref="DAA001"
+                    v-model="DAA001"
+                    label="鎸囦护宸ュ崟"
+                    placeholder="鎸囦护宸ュ崟"
+                    autofocus="true"
+                    readonly
+                    >
+                </van-field>
+
+                <van-field
+                    ref="XBar"
+                    v-model="XBar"
                     label="绠辨潯鐮�"
                     placeholder="璇锋壂澶栫鐮�"
+                    @keyup.enter.native="getXBarInfo" 
                     autofocus="true">
                 </van-field>
 
@@ -129,16 +139,17 @@
                     v-model="LsBar"
                     label="浜у搧鏉$爜"
                     placeholder="璇锋壂浜у搧鏉$爜"
+                    @keyup.enter.native="checkProductBarcode"
                     autofocus="true">
                 </van-field>
                 
-                <van-field
+<%--                <van-field
                     ref="LsBar"
                     v-model="LsBar"
                     label="绾垮埆"
                     placeholder="璇烽�夋嫨绾垮埆"
                     autofocus="true">
-                </van-field>
+                </van-field>--%>
                <!-- 淇敼鍚庣殑鎸夐挳瀹瑰櫒 -->
                 <div class="button-container">
                   <van-button 
@@ -148,6 +159,7 @@
                   <van-button 
                     type="info" 
                     class="action-button submit-button"
+                    @click.native="handleSubmit"
                   >閫佹</van-button>
                 </div>
 
@@ -162,8 +174,11 @@
                     <van-col span="7" class="text-left padding-left">瑙勬牸</van-col>
                     <van-col span="3" >鏁伴噺</van-col>
                 </van-row>
-                <van-row v-for="(itm,index) in KbBarMxInfo" :key="index">
-                    <van-col span="7" class="text-left padding-left" >{{itm.iteM_BARCODE}}</van-col>
+                <van-row 
+                    v-for="(itm,index) in XbarInfo" 
+                    :key="index"
+                    :style="{ background: itm.is_hedui === '1' ? '#e8f5e9 !important' : 'transparent' }">
+                    <van-col span="7" class="text-left padding-left">{{itm.iteM_BARCODE}}</van-col>
                     <van-col span="7" class="text-left padding-left">
                         <div class="blue-text">{{itm.item_no}}</div>
                         <div>{{itm.item_name}}</div>
@@ -171,7 +186,6 @@
                     <van-col span="7" class="text-left padding-left">
                         <div>{{itm.item_model}}</div>
                     </van-col>
-                    
                     <van-col span="3" class="blue-text">{{itm.quantity}}</van-col>
                 </van-row>
             </van-tab>
@@ -205,5 +219,5 @@
 </asp:Content>
 
 <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
-    <script src="Js/Cpbdsj.js?<%=11111 %>"></script>
+    <script src="Js/Cpbdsj.js?<%=111111111 %>"></script>
 </asp:Content>
\ No newline at end of file
diff --git a/H5/Js/Cpbd.js b/H5/Js/Cpbd.js
index ece0de9..ec4b01b 100644
--- a/H5/Js/Cpbd.js
+++ b/H5/Js/Cpbd.js
@@ -80,13 +80,13 @@
                         that.$notify({ type: 'success', message: json.message });
                         that.$refs.ZsBar.focus();
                         that.ZsBar = null;
-                        that.ZsBar = null;
+                        that.LsBar = null;
                     }
                     else {
                         that.$toast.fail(json.message);
                         that.$refs.ZsBar.focus();
                         that.ZsBar = null;
-                        that.ZsBar = null;
+                        that.LsBar = null;
                     }
                     
                     that.isLoading = false;
@@ -96,7 +96,7 @@
                     that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
                     that.$refs.ZsBar.focus();
                     that.ZsBar = null;
-                    that.ZsBar = null;
+                    that.LsBar = null;
                 });
         },
         //鎵撳嵃鏈烘敞閲�
diff --git a/H5/Js/Cpbdsj.js b/H5/Js/Cpbdsj.js
index 8569726..56f1231 100644
--- a/H5/Js/Cpbdsj.js
+++ b/H5/Js/Cpbdsj.js
@@ -9,12 +9,14 @@
             },
             KbBar: "",//鍗℃澘鏉$爜
             LsBar: "",//鍚庣洊娴佹按鏉$爜
+            XBar: "",//绠辨潯鐮�
             UserName: Cookies.get('loginName'),//鐢ㄦ埛鍚嶇О
             KbBarInfo: [],
             KbBarMxInfo: [],
             GX: "G007:鏍稿閫佹",
             Xvalue:4,
-            ItemDetail:[],
+            XbarInfo: [],
+            DAA001: [],
         }
     },
     mounted() {
@@ -35,10 +37,12 @@
                 .then(function (res) {
                     var json = res;
                     if (json.status == 0) {
-
-                        that.$refs.LsBar.focus();
                         that.KbBarInfo = json.data.tbBillList.kbBarInfo[0];
+                        that.DAA001 = that.KbBarInfo.daA001;
                         that.KbBarMxInfo = json.data.tbBillList.kbBarMxInfo;
+                        that.$refs.XBar.focus();
+                        that.XbarInfo = [];
+                        that.XBar = "";
                     }
                     else {
                         that.$toast.fail(json.message);
@@ -50,8 +54,66 @@
                 .catch(function (error) {
                     that.isLoading = false;
                     that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
+                    that.$refs.KbBar.focus();
+                    that.KbBar = "";
                 });
         },
+        getXBarInfo() {
+            var that = this;
+            if (that.KbBar.length <= 0) {
+                that.$toast.fail("鍗℃澘鏉$爜涓嶈兘涓虹┖锛�");
+                that.$refs.KbBar.focus();
+                that.XBar = "";
+                return;
+            }
+
+            if (that.DAA001.length <= 0) {
+                that.$toast.fail("鎸囦护宸ュ崟涓嶈兘涓虹┖锛�");
+                that.$refs.KbBar.focus();
+                that.XBar = "";
+                return;
+            }
+
+            // 妫�鏌ユ槸鍚﹁秴杩囪绠辨暟
+            if (that.XbarInfo.length >= that.Xvalue) {
+                that.$toast.fail(`宸茶揪鍒拌绠辨暟闄愬埗(${that.Xvalue})`);
+                that.XBar = "";
+                return;
+            }
+
+            // 妫�鏌ユ潯鐮佹槸鍚﹀凡瀛樺湪
+            const isExist = that.XbarInfo.some(item => item.iteM_BARCODE === that.XBar);
+            if (isExist) {
+                that.$toast.fail("璇ョ鏉$爜宸插瓨鍦紝璇峰嬁閲嶅鎵弿");
+                that.XBar = "";
+                return;
+            }
+
+            that.isLoading = true;
+            that.AxiosHttp("post", 'Womdaa/getXBarInfo', {
+                Kbbarcode: that.KbBar,
+                DAA001: that.DAA001,
+                Xbarcode: that.XBar
+            }, false)
+                .then(function (res) {
+                    var json = res;
+                    if (json.status == 0) {
+                        that.XbarInfo.push(json.data.tbBillList.xBarInfo[0]);
+                        that.$refs.XBar.focus();
+                        that.XBar = "";
+                    }
+                    else {
+                        that.$toast.fail(json.message);
+                    }
+                    that.isLoading = false;
+                })
+                .catch(function (error) {
+                    that.isLoading = false;
+                    that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
+                });
+        },
+
+
         productBinding() {
             var that = this;
             if (that.ZsBar.length <= 0) {
@@ -111,5 +173,107 @@
         //onPrinterSelected(value) {
         //    console.log('褰撳墠閫変腑鐨勬墦鍗版満缂栧彿:', value);
         //},
+        checkProductBarcode() {
+            var that = this;
+            if (!that.LsBar) {
+                that.$toast.fail("璇疯緭鍏ヤ骇鍝佹潯鐮�");
+                return;
+            }
+            
+            // 鍦╔barInfo涓煡鎵惧尮閰嶇殑鏉$爜
+            const matchedItem = that.XbarInfo.find(item => 
+                item.iteM_BARCODE === that.LsBar
+            );
+            
+            if (matchedItem) {
+                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();
+                    }
+                }
+            } else {
+                that.$toast.fail("鏈壘鍒板尮閰嶇殑绠辨潯鐮�");
+            }
+            
+            that.LsBar = ""; // 娓呯┖杈撳叆妗�
+        },
+
+        // 鏂板鏂规硶锛氭彁浜ゆ墍鏈夊凡鏍稿鐨勬暟鎹�
+        submitAllChecked() {
+            var that = this;
+            that.isLoading = true;
+            
+            that.AxiosHttp("post", 'Womdaa/submitAllChecked', {
+                XbarInfo: that.XbarInfo,
+                KbBar: that.KbBar,
+                userName: that.userInfo.loginAccount
+            }, false)
+                .then(function (res) {
+                    var json = res;
+                    if (json.status == 0) {
+                        that.$notify({ type: 'success', message: json.message });
+                        that.getKbBarInfo();
+                    } else {
+                        that.$toast.fail(json.message);
+                        that.XbarInfo = [];
+                        that.XBar = "";
+                        that.LsBar = "";
+                        that.$refs.XBar.focus();
+                    }
+                    that.isLoading = false;
+                })
+                .catch(function (error) {
+                    that.isLoading = false;
+                    that.$toast.fail("缁戝畾澶辫触锛岃閲嶈瘯锛�");
+                });
+        },
+        handleSubmit() {
+            var that = this;
+            if (!that.KbBar) {
+                that.$toast.fail("璇峰厛鎵弿鍗℃澘鏉$爜");
+                return;
+            }
+    
+            // 璁$畻鍙鏁板拰宸茶鏁�
+            const oldqty = +(that.KbBarInfo.oldqty ?? 0);
+            const ySum = +(that.KbBarInfo.ySum ?? 0);
+            
+            if (oldqty !== ySum) {
+                that.$toast.fail(`瑁呮澘鏈畬鎴愶紝寰呰鏁帮細${oldqty - ySum}`);
+                return;
+            }
+    
+            that.isLoading = true;
+            that.AxiosHttp("post", 'Womdaa/submitInspection', {
+                KbBar: that.KbBar,
+                userAccount: that.userInfo.loginAccount
+            }, false)
+                .then(function (res) {
+                    var json = res;
+                    if (json.status == 0) {
+                        that.$notify({ type: 'success', message: json.tbBillList.message });
+                        // 娓呯┖鏁版嵁
+                        that.KbBar = "";
+                        that.XbarInfo = [];
+                        that.KbBarInfo = [];
+                        that.$refs.KbBar.focus();
+                    } else {
+                        that.$toast.fail(json.message);
+                    }
+                    that.isLoading = false;
+                })
+                .catch(function (error) {
+                    that.isLoading = false;
+                    that.$toast.fail("鎻愪氦澶辫触锛岃閲嶈瘯锛�");
+                    that.$refs.KbBar.focus();
+                });
+        },
     }
 })
\ No newline at end of file

--
Gitblit v1.9.3