From ca4a0e7ffc11dc6f4c19b75f625444b06768ea15 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期三, 12 十一月 2025 08:51:30 +0800
Subject: [PATCH] 提交

---
 项目代码/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue |  190 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 177 insertions(+), 13 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
index 899297b..ef26541 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
@@ -48,6 +48,14 @@
                   :disabled="!currentLockInfo"
                 />
               </el-form-item>
+
+              <!-- 鐗╂枡淇℃伅鏄剧ず -->
+              <el-form-item label="鐗╂枡缂栫爜" v-if="currentMaterialInfo">
+                <el-input v-model="currentMaterialInfo.materielCode" readonly />
+              </el-form-item>
+              <el-form-item label="鐗╂枡鍚嶇О" v-if="currentMaterialInfo">
+                <el-input v-model="currentMaterialInfo.materielName" readonly />
+              </el-form-item>
             </el-form>
 
             <div class="current-info" v-if="currentPallet">
@@ -141,6 +149,7 @@
       },
       currentPallet: null,
       currentLockInfo: null,
+      currentMaterialInfo: null, // 鏂板锛氬綋鍓嶇墿鏂欎俊鎭�
       pickedList: [],
       pickedColumns: [
         { field: 'barcode', title: '鐗╂枡鏉$爜', width: 150 },
@@ -153,7 +162,8 @@
         { field: 'action', title: '鎿嶄綔', width: 80, slot: true }
       ],
       splitVisible: false,
-      maxPickQuantity: 0
+      maxPickQuantity: 0,
+      allLockInfos: [] // 鏂板锛氫繚瀛樻墍鏈夐攣瀹氫俊鎭紝鐢ㄤ簬鏉$爜鍖归厤
     }
   },
   computed: {
@@ -174,7 +184,7 @@
       if (!orderId) return
 
       try {
-        const result = await this.http.post(`api/OutboundOrder/GetById?id=${orderId}`)
+        const result = await this.http.get(`api/OutboundOrder/GetById?id=${orderId}`)
         if (result.status) {
           this.orderInfo = result.data
         }
@@ -195,7 +205,7 @@
         )
         if (result.status) {
           this.currentPallet = result.data
-          this.loadPalletLockInfo()
+          await this.loadPalletLockInfo()
           this.$message.success(`鎵樼洏 ${this.scanForm.palletCode} 璇嗗埆鎴愬姛`)
         } else {
           this.$message.error(result.message)
@@ -212,42 +222,148 @@
         const result = await this.http.get(
           `api/OutboundPicking/GetPalletLockInfos?palletCode=${this.currentPallet.palletCode}`
         )
-        if (result.status && result.data.length > 0) {
-          this.currentLockInfo = result.data[0]
-          this.maxPickQuantity = this.currentLockInfo.assignQuantity - this.currentLockInfo.pickedQty
+        if (result.status) {
+          this.allLockInfos = result.data
+          // 榛樿閫夋嫨绗竴涓攣瀹氫俊鎭�
+          if (this.allLockInfos.length > 0) {
+            this.currentLockInfo = this.allLockInfos[0]
+            this.currentMaterialInfo = {
+              materielCode: this.currentLockInfo.materielCode,
+              materielName: this.currentLockInfo.materielName
+            }
+            this.maxPickQuantity = this.currentLockInfo.assignQuantity - this.currentLockInfo.pickedQty
+          }
         }
       } catch (error) {
         console.error('鍔犺浇閿佸畾淇℃伅澶辫触:', error)
       }
     },
 
+    // 鏍规嵁鏉$爜鏌ユ壘瀵瑰簲鐨勯攣瀹氫俊鎭拰鐗╂枡淇℃伅
+    findLockInfoByBarcode(barcode) {
+      if (!this.allLockInfos || this.allLockInfos.length === 0) {
+        return null
+      }
+      
+      // 棣栧厛绮剧‘鍖归厤褰撳墠鏉$爜
+      let lockInfo = this.allLockInfos.find(x => x.currentBarcode === barcode)
+      if (lockInfo) {
+        return lockInfo
+      }
+      
+      // 濡傛灉娌℃湁绮剧‘鍖归厤锛屾煡鎵捐鏉$爜瀵瑰簲鐨勭墿鏂欐槸鍚﹀湪閿佸畾淇℃伅涓�
+      // 杩欓噷闇�瑕佽皟鐢ㄥ悗绔帴鍙i獙璇佹潯鐮佸搴旂殑鐗╂枡
+      return null
+    },
+
     async handleBarcodeScan() {
-      // 瀹炵幇鎵爜纭閫昏緫
       if (!this.scanForm.barcode) {
         this.$message.warning('璇疯緭鍏ョ墿鏂欐潯鐮�')
         return
       }
 
+      if (!this.currentPallet) {
+        this.$message.warning('璇峰厛鎵弿鎵樼洏鏉$爜')
+        return
+      }
+
+      if (this.scanForm.quantity <= 0) {
+        this.$message.warning('璇疯緭鍏ユ湁鏁堢殑鎷i�夋暟閲�')
+        return
+      }
+
       try {
+        // 楠岃瘉鏉$爜骞惰幏鍙栫墿鏂欎俊鎭�
+        const materialInfo = await this.validateBarcode(this.scanForm.barcode)
+        if (!materialInfo) {
+          this.$message.error('鏃犳晥鐨勭墿鏂欐潯鐮�')
+          return
+        }
+
+        // 鏌ユ壘瀵瑰簲鐨勯攣瀹氫俊鎭�
+        const targetLockInfo = this.findLockInfoByBarcodeAndMaterial(this.scanForm.barcode, materialInfo.materielCode)
+        if (!targetLockInfo) {
+          this.$message.error('璇ョ墿鏂欐潯鐮佷笉鍦ㄥ綋鍓嶆墭鐩樼殑閿佸畾淇℃伅涓�')
+          return
+        }
+
+        // 妫�鏌ユ嫞閫夋暟閲�
+        const availableQuantity = targetLockInfo.assignQuantity - targetLockInfo.pickedQty
+        if (this.scanForm.quantity > availableQuantity) {
+          this.$message.error(`鎷i�夋暟閲忚秴杩囧彲鐢ㄦ暟閲忥紝鍓╀綑鍙嫞閫夛細${availableQuantity}`)
+          return
+        }
+
+        // 鍑嗗璇锋眰鏁版嵁
         const request = {
+          orderDetailId: targetLockInfo.orderDetailId,
           barcode: this.scanForm.barcode,
-          quantity: this.scanForm.quantity,
+          materielCode: materialInfo.materielCode, // 浼犻�掔墿鏂欑紪鐮�
+          pickQuantity: this.scanForm.quantity,
+          locationCode: this.currentPallet.locationCode,
           palletCode: this.currentPallet.palletCode,
-          orderId: this.orderInfo.id
+          stockId: targetLockInfo.stockId,
+          outStockLockInfoId: targetLockInfo.id // 浼犻�掗攣瀹氫俊鎭疘D
         }
 
         const result = await this.http.post('api/OutboundPicking/ConfirmPicking', request)
         if (result.status) {
           this.$message.success('鎷i�夌‘璁ゆ垚鍔�')
+          
+          // 閲嶇疆琛ㄥ崟
           this.scanForm.barcode = ''
           this.scanForm.quantity = 1
-          this.loadPickedHistory()
+          this.currentMaterialInfo = null
+          
+          // 鍒锋柊鏁版嵁
           this.loadOrderInfo()
+          this.loadPickedHistory()
+          this.loadPalletLockInfo()
         } else {
           this.$message.error(result.message)
         }
       } catch (error) {
-        this.$message.error('鎷i�夌‘璁ゅけ璐�')
+        this.$message.error('鎷i�夌‘璁ゅけ璐�: ' + (error.message || '鏈煡閿欒'))
+      }
+    },
+
+    // 鏍规嵁鏉$爜鍜岀墿鏂欑紪鐮佹煡鎵鹃攣瀹氫俊鎭�
+    findLockInfoByBarcodeAndMaterial(barcode, materielCode) {
+      if (!this.allLockInfos || this.allLockInfos.length === 0) {
+        return null
+      }
+      
+      // 棣栧厛灏濊瘯绮剧‘鍖归厤鏉$爜
+      let lockInfo = this.allLockInfos.find(x => 
+        x.currentBarcode === barcode && x.materielCode === materielCode
+      )
+      
+      if (lockInfo) {
+        return lockInfo
+      }
+      
+      // 濡傛灉绮剧‘鍖归厤澶辫触锛屽彧鍖归厤鐗╂枡缂栫爜锛堝厑璁镐粠鍚屼竴鐗╂枡鐨勪笉鍚屾潯鐮佹嫞閫夛級
+      lockInfo = this.allLockInfos.find(x => 
+        x.materielCode === materielCode && 
+        (x.assignQuantity - x.pickedQty) > 0
+      )
+      
+      return lockInfo
+    },
+
+    // 楠岃瘉鏉$爜骞惰幏鍙栫墿鏂欎俊鎭�
+    async validateBarcode(barcode) {
+      try {
+        const result = await this.http.get(`api/OutboundPicking/ValidateBarcode?barcode=${barcode}`)
+        if (result.status) {
+          return result.data
+        } else {
+          this.$message.error(result.message)
+          return null
+        }
+      } catch (error) {
+        this.$message.error('鏉$爜楠岃瘉澶辫触')
+        return null
       }
     },
 
@@ -261,7 +377,8 @@
 
         const result = await this.http.post('api/BackToStock/GenerateBackToStockTask', {
           palletCode: this.currentPallet.palletCode,
-          currentLocation: '鎷i�変綅'
+          currentLocation: '鎷i�変綅',
+          operator: '褰撳墠鐢ㄦ埛'
         })
 
         if (result.status) {
@@ -311,6 +428,8 @@
     resetCurrentPallet() {
       this.currentPallet = null
       this.currentLockInfo = null
+      this.currentMaterialInfo = null
+      this.allLockInfos = []
       this.scanForm.palletCode = ''
     },
 
@@ -351,4 +470,49 @@
     this.loadPickedHistory()
   }
 }
-</script>
\ No newline at end of file
+</script>
+
+<style scoped>
+.picking-confirm {
+  padding: 20px;
+}
+
+.page-header {
+  margin-bottom: 20px;
+}
+
+.title {
+  font-size: 18px;
+  font-weight: bold;
+}
+
+.scan-section {
+  margin-bottom: 20px;
+}
+
+.action-buttons {
+  display: flex;
+  flex-direction: column;
+  gap: 10px;
+}
+
+.action-buttons .el-button {
+  width: 100%;
+}
+
+.current-info {
+  margin-top: 15px;
+  padding: 10px;
+  background-color: #f5f7fa;
+  border-radius: 4px;
+}
+
+.current-info p {
+  margin: 5px 0;
+  font-size: 14px;
+}
+
+.summary-info {
+  margin-bottom: 15px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3