From d2d931816da9f6de4da1f3a7f3f6e596128c6f14 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期五, 13 三月 2026 17:10:51 +0800
Subject: [PATCH] style(views): 统一检测项目对话框输入框宽度并居中表单

---
 src/views/inventoryManagement/stockManagement/New.vue |  134 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 122 insertions(+), 12 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/New.vue b/src/views/inventoryManagement/stockManagement/New.vue
index 8243748..001e897 100644
--- a/src/views/inventoryManagement/stockManagement/New.vue
+++ b/src/views/inventoryManagement/stockManagement/New.vue
@@ -37,11 +37,79 @@
           <el-input v-model="formState.unit"  disabled />
         </el-form-item>
 
+        <!-- productType === 0锛氬師鏉愭枡 -->
         <el-form-item
-            label="鏁伴噺"
-            prop="qualitity"
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="杞︾墝鍙�"
+            prop="licensePlateNo"
         >
-          <el-input-number v-model="formState.qualitity" :step="1" :min="0" style="width: 100%" />
+          <el-input v-model="formState.licensePlateNo" />
+        </el-form-item>
+
+        <el-form-item
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="姣涢噸(鍚�)"
+            prop="grossWeight"
+        >
+          <el-input-number
+              v-model="formState.grossWeight"
+              :step="0.01"
+              :min="0"
+              style="width: 100%"
+              @change="computeNetWeight"
+          />
+        </el-form-item>
+
+        <el-form-item
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="鐨噸(鍚�)"
+            prop="tareWeight"
+        >
+          <el-input-number
+              v-model="formState.tareWeight"
+              :step="0.01"
+              :min="0"
+              style="width: 100%"
+              @change="computeNetWeight"
+          />
+        </el-form-item>
+
+        <el-form-item
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="鍑�閲�(鍚�)"
+            prop="netWeight"
+        >
+          <el-input-number
+              v-model="formState.netWeight"
+              :step="0.01"
+              :min="0"
+              style="width: 100%"
+              disabled
+          />
+        </el-form-item>
+
+        <el-form-item
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="杩囩鏃ユ湡"
+            prop="weighingDate"
+        >
+          <el-date-picker
+              style="width: 100%"
+              v-model="formState.weighingDate"
+              value-format="YYYY-MM-DD HH:mm:ss"
+              format="YYYY-MM-DD HH:mm:ss"
+              type="datetime"
+              placeholder="璇烽�夋嫨杩囩鏃ユ湡"
+              clearable
+          />
+        </el-form-item>
+
+        <el-form-item
+            v-if="type === 'qualified' && formState.productType === 0"
+            label="杩囩鍛�"
+            prop="weighingOperator"
+        >
+          <el-input v-model="formState.weighingOperator" />
         </el-form-item>
 
         <el-form-item label="澶囨敞" prop="remark">
@@ -69,11 +137,18 @@
 import {ref, computed, getCurrentInstance} from "vue";
 import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
 import {createStockInventory} from "@/api/inventoryManagement/stockInventory.js";
+import {createStockUnInventory} from "@/api/inventoryManagement/stockUninventory.js";
 
 const props = defineProps({
   visible: {
     type: Boolean,
     required: true,
+  },
+
+  type: {
+    type: String,
+    required: true,
+    default: 'qualified',
   },
 });
 
@@ -86,7 +161,14 @@
   productName: "",
   productModelName: "",
   unit: "",
-  qualitity: 0,
+  productType: undefined,
+  // 杩囩鐩稿叧瀛楁锛堜粎鍘熸潗鏂欏悎鏍煎搧浣跨敤锛�
+  licensePlateNo: "",
+  grossWeight: undefined,
+  tareWeight: undefined,
+  netWeight: undefined,
+  weighingDate: undefined,
+  weighingOperator: "",
   remark: '',
 });
 
@@ -117,17 +199,34 @@
 
 // 浜у搧閫夋嫨澶勭悊
 const handleProductSelect = async (products) => {
+  formState.value.weighingDate = undefined;
+  formState.value.grossWeight = undefined;
+  formState.value.tareWeight = undefined;
+  formState.value.netWeight = undefined;
   if (products && products.length > 0) {
     const product = products[0];
-    console.log(product)
     formState.value.productId = product.productId;
     formState.value.productName = product.productName;
     formState.value.productModelName = product.model;
     formState.value.productModelId = product.id;
     formState.value.unit = product.unit;
+    formState.value.productType = product.productType;
     showProductSelectDialog.value = false;
     // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
     proxy.$refs["formRef"]?.validateField('productModelId');
+  }
+};
+
+// 鍑�閲� = 姣涢噸 - 鐨噸
+const computeNetWeight = () => {
+  const { grossWeight, tareWeight } = formState.value;
+  if (grossWeight != null && tareWeight != null) {
+    const net = Number(grossWeight) - Number(tareWeight);
+    // 淇濈暀涓や綅灏忔暟锛屼笖涓嶄负璐�
+    const safeNet = Number(net.toFixed(2));
+    formState.value.netWeight = safeNet > 0 ? safeNet : 0;
+  } else {
+    formState.value.netWeight = undefined;
   }
 };
 
@@ -143,13 +242,24 @@
         proxy.$modal.msgError("璇烽�夋嫨瑙勬牸");
         return;
       }
-      createStockInventory(formState.value).then(res => {
-        // 鍏抽棴妯℃�佹
-        isShow.value = false;
-        // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
-        emit('completed');
-        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-      })
+      if (props.type === 'qualified') {
+        createStockInventory(formState.value).then(res => {
+          // 鍏抽棴妯℃�佹
+          isShow.value = false;
+          // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+          emit('completed');
+          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+        })
+      } else {
+        createStockUnInventory(formState.value).then(res => {
+          // 鍏抽棴妯℃�佹
+          isShow.value = false;
+          // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+          emit('completed');
+          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+        })
+      }
+
     }
   })
 };

--
Gitblit v1.9.3