From c52a0824baaa86a719da04fba3ff65fc48a70422 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 19 三月 2026 17:37:05 +0800
Subject: [PATCH] fix: 入库数量必填

---
 src/pages/inventoryManagement/stockManagement/add.vue |   98 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 73 insertions(+), 25 deletions(-)

diff --git a/src/pages/inventoryManagement/stockManagement/add.vue b/src/pages/inventoryManagement/stockManagement/add.vue
index c27d958..cbfdbd1 100644
--- a/src/pages/inventoryManagement/stockManagement/add.vue
+++ b/src/pages/inventoryManagement/stockManagement/add.vue
@@ -23,26 +23,34 @@
         </view>
       </view>
 
-      <!-- 杩囩鐩稿叧瀛楁 -->
-      <view class="form-section">
+      <!-- 鎴愬搧锛氬彧闇�瑕佹暟閲� -->
+      <view v-if="isFinishedProduct" class="form-section">
+        <view class="form-row">
+          <text class="form-label required">鏁伴噺</text>
+          <up-input v-model="form.qualitity" type="number" placeholder="璇疯緭鍏ユ暟閲�" />
+        </view>
+      </view>
+
+      <!-- 鍘熸潗鏂欙細杩囩鐩稿叧瀛楁 -->
+      <view v-else class="form-section">
         <view class="section-title">杩囩淇℃伅</view>
         <view class="form-row">
-          <text class="form-label">杞︾墝鍙�</text>
+          <text class="form-label required">杞︾墝鍙�</text>
           <up-input v-model="form.licensePlateNo" placeholder="璇疯緭鍏ヨ溅鐗屽彿" />
         </view>
         <view class="form-row">
-          <text class="form-label">姣涢噸(鍚�)</text>
+          <text class="form-label required">姣涢噸(鍚�)</text>
           <up-input
             v-model="form.grossWeight"
-            type="number"
+            type="digit"
             placeholder="璇疯緭鍏ユ瘺閲�"
           />
         </view>
         <view class="form-row">
-          <text class="form-label">鐨噸(鍚�)</text>
+          <text class="form-label required">鐨噸(鍚�)</text>
           <up-input
             v-model="form.tareWeight"
-            type="number"
+            type="digit"
             placeholder="璇疯緭鍏ョ毊閲�"
           />
         </view>
@@ -50,13 +58,13 @@
           <text class="form-label">鍑�閲�(鍚�)</text>
           <up-input
             v-model="form.netWeight"
-            type="number"
+            type="digit"
             disabled
             placeholder="鑷姩璁$畻"
           />
         </view>
         <view class="form-row">
-          <text class="form-label">杩囩鏃ユ湡</text>
+          <text class="form-label required">杩囩鏃ユ湡</text>
           <view class="selector-trigger" @click="openWeighingDatePicker">
             <text class="selector-text" :class="{ placeholder: !form.weighingDate }">
               {{ form.weighingDate || '璇烽�夋嫨杩囩鏃ユ湡' }}
@@ -65,16 +73,12 @@
           </view>
         </view>
         <view class="form-row">
-          <text class="form-label">杩囩鍛�</text>
+          <text class="form-label required">杩囩鍛�</text>
           <up-input v-model="form.weighingOperator" placeholder="璇疯緭鍏ヨ繃纾呭憳" />
         </view>
       </view>
 
       <view class="form-section">
-        <!-- <view class="form-row">
-          <text class="form-label required">鏁伴噺</text>
-          <up-input v-model="form.qualitity" type="number" placeholder="璇疯緭鍏ユ暟閲�" />
-        </view> -->
         <view class="form-row">
           <text class="form-label">澶囨敞</text>
           <up-input v-model="form.remark" type="textarea" placeholder="閫夊~" />
@@ -154,6 +158,7 @@
   productModelName: '',
   unit: '',
   productType: undefined,
+  parentName: '',
   licensePlateNo: '',
   grossWeight: '',
   tareWeight: '',
@@ -166,6 +171,7 @@
 
 const type = ref('0') // 鍥哄畾鍚堟牸搴撳瓨
 const isQualified = computed(() => true)
+const isFinishedProduct = computed(() => form.parentName === '鎴愬搧')
 
 const showProductPopup = ref(false)
 const productQuery = reactive({
@@ -223,6 +229,19 @@
   form.productModelName = item.model
   form.unit = item.unit
   form.productType = item.productType
+  form.parentName = parentName
+
+  // 鍒囨崲浜у搧鍚庯紝鎸夌被鍨嬫竻鐞嗘棤鍏冲瓧娈�
+  if (parentName === '鎴愬搧') {
+    form.licensePlateNo = ''
+    form.grossWeight = ''
+    form.tareWeight = ''
+    form.netWeight = ''
+    form.weighingDate = ''
+    form.weighingOperator = ''
+  } else {
+    form.qualitity = ''
+  }
   showProductPopup.value = false
 }
 
@@ -264,25 +283,54 @@
     uni.showToast({ title: '璇烽�夋嫨浜у搧', icon: 'none' })
     return
   }
-  // if (!form.qualitity || Number(form.qualitity) <= 0) {
-  //   uni.showToast({ title: '璇疯緭鍏ユ暟閲�', icon: 'none' })
-  //   return
-  // }
-  const payload = {
+  if (isFinishedProduct.value) {
+    if (!form.qualitity || Number(form.qualitity) <= 0) {
+      uni.showToast({ title: '璇疯緭鍏ユ暟閲�', icon: 'none' })
+      return
+    }
+  } else {
+    if (!form.licensePlateNo) {
+      uni.showToast({ title: '璇疯緭鍏ヨ溅鐗屽彿', icon: 'none' })
+      return
+    }
+    if (!form.grossWeight || Number(form.grossWeight) <= 0) {
+      uni.showToast({ title: '璇疯緭鍏ユ瘺閲�', icon: 'none' })
+      return
+    }
+    if (!form.tareWeight || Number(form.tareWeight) <= 0) {
+      uni.showToast({ title: '璇疯緭鍏ョ毊閲�', icon: 'none' })
+      return
+    }
+    if (!form.weighingDate) {
+      uni.showToast({ title: '璇烽�夋嫨杩囩鏃ユ湡', icon: 'none' })
+      return
+    }
+    if (!form.weighingOperator) {
+      uni.showToast({ title: '璇疯緭鍏ヨ繃纾呭憳', icon: 'none' })
+      return
+    }
+  }
+
+  const base = {
     productId: form.productId,
     productModelId: form.productModelId,
     productName: form.productName,
     productModelName: form.productModelName,
     unit: form.unit,
     productType: form.productType,
-    licensePlateNo: form.licensePlateNo,
-    grossWeight: form.grossWeight,
-    tareWeight: form.tareWeight,
-    netWeight: form.netWeight,
-    weighingDate: form.weighingDate,
-    weighingOperator: form.weighingOperator,
     remark: form.remark
   }
+  const payload = isFinishedProduct.value
+    ? { ...base, qualitity: Number(form.qualitity) }
+    : {
+        ...base,
+        licensePlateNo: form.licensePlateNo,
+        grossWeight: form.grossWeight,
+        tareWeight: form.tareWeight,
+        netWeight: form.netWeight,
+        weighingDate: form.weighingDate,
+        weighingOperator: form.weighingOperator
+      }
   createStockInventory(payload)
     .then(() => {
       uni.showToast({ title: '鏂板鎴愬姛', icon: 'success' })

--
Gitblit v1.9.3