From a72aff44170536c56d1441eb94c46d15912849e3 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 19 一月 2026 10:19:57 +0800
Subject: [PATCH] 采购台账中涉及到价格、数量等输入框时,限制为大于等于0的数字输入

---
 src/views/procurementManagement/procurementLedger/index.vue |   64 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 8a3ea73..9b86624 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -393,7 +393,7 @@
                            width="150" />
           <el-table-column label="鏄惁璐ㄦ"
                            prop="isChecked"
-                           width="150" >
+                           width="150">
             <template #default="scope">
               <el-tag :type="scope.row.isChecked ? 'success' : 'info'">
                 {{ scope.row.isChecked ? '鏄�' : '鍚�' }}
@@ -531,6 +531,7 @@
               <el-input-number v-model="productForm.taxInclusiveUnitPrice"
                                :precision="2"
                                :step="0.1"
+                               :min="0"
                                clearable
                                style="width: 100%"
                                @change="mathNum" />
@@ -542,6 +543,7 @@
               <el-input-number :step="0.1"
                                clearable
                                :precision="2"
+                               :min="0"
                                style="width: 100%"
                                v-model="productForm.quantity"
                                placeholder="璇疯緭鍏�"
@@ -556,6 +558,7 @@
               <el-input-number v-model="productForm.taxInclusiveTotalPrice"
                                :precision="2"
                                :step="0.1"
+                               :min="0"
                                clearable
                                style="width: 100%"
                                @change="reverseMathNum('taxInclusiveTotalPrice')" />
@@ -564,8 +567,13 @@
           <el-col :span="12">
             <el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�"
                           prop="taxExclusiveTotalPrice">
-              <el-input v-model="productForm.taxExclusiveTotalPrice"
-                        @change="reverseMathNum('taxExclusiveTotalPrice')" />
+              <el-input-number v-model="productForm.taxExclusiveTotalPrice"
+                               :precision="2"
+                               :step="0.1"
+                               :min="0"
+                               clearable
+                               style="width: 100%"
+                               @change="reverseMathNum('taxExclusiveTotalPrice')" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -589,6 +597,7 @@
               <el-input-number v-model="productForm.warnNum"
                                :precision="2"
                                :step="0.1"
+                               :min="0"
                                clearable
                                style="width: 100%" />
             </el-form-item>
@@ -596,10 +605,13 @@
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
-            <el-form-item label="鏄惁璐ㄦ锛�" prop="isChecked">
+            <el-form-item label="鏄惁璐ㄦ锛�"
+                          prop="isChecked">
               <el-radio-group v-model="productForm.isChecked">
-                <el-radio label="鏄�" :value="true"/>
-                <el-radio label="鍚�" :value="false"/>
+                <el-radio label="鏄�"
+                          :value="true" />
+                <el-radio label="鍚�"
+                          :value="false" />
               </el-radio-group>
             </el-form-item>
           </el-col>
@@ -1066,7 +1078,7 @@
       taxExclusiveTotalPrice: "",
       invoiceType: "",
       warnNum: "",
-      isChecked:true
+      isChecked: true,
     },
     productRules: {
       productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1661,6 +1673,20 @@
     }
     const taxRate = Number(productForm.value.taxRate);
     if (!taxRate) return;
+
+    // 纭繚杈撳叆鍊间笉涓鸿礋鏁�
+    if (
+      field === "taxInclusiveTotalPrice" ||
+      field === "taxExclusiveTotalPrice"
+    ) {
+      const value = Number(productForm.value[field]);
+      if (value < 0) {
+        productForm.value[field] = "0";
+        proxy.$modal.msgWarning("鍊间笉鑳藉皬浜�0");
+        return;
+      }
+    }
+
     if (field === "taxInclusiveTotalPrice") {
       // 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环
       if (productForm.value.quantity) {
@@ -1668,6 +1694,10 @@
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.quantity)
         ).toFixed(2);
+        // 纭繚缁撴灉涓嶄负璐熸暟
+        if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
+          productForm.value.taxInclusiveUnitPrice = "0";
+        }
       }
       // 宸茬煡鍚◣鎬讳环鍜屽惈绋庡崟浠凤紝鍙嶇畻鏁伴噺
       else if (productForm.value.taxInclusiveUnitPrice) {
@@ -1675,24 +1705,40 @@
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.taxInclusiveUnitPrice)
         ).toFixed(2);
+        // 纭繚缁撴灉涓嶄负璐熸暟
+        if (Number(productForm.value.quantity) < 0) {
+          productForm.value.quantity = "0";
+        }
       }
       // 鍙嶇畻涓嶅惈绋庢�讳环
       productForm.value.taxExclusiveTotalPrice = (
         Number(productForm.value.taxInclusiveTotalPrice) /
         (1 + taxRate / 100)
       ).toFixed(2);
+      // 纭繚缁撴灉涓嶄负璐熸暟
+      if (Number(productForm.value.taxExclusiveTotalPrice) < 0) {
+        productForm.value.taxExclusiveTotalPrice = "0";
+      }
     } else if (field === "taxExclusiveTotalPrice") {
       // 鍙嶇畻鍚◣鎬讳环
       productForm.value.taxInclusiveTotalPrice = (
         Number(productForm.value.taxExclusiveTotalPrice) *
         (1 + taxRate / 100)
       ).toFixed(2);
+      // 纭繚缁撴灉涓嶄负璐熸暟
+      if (Number(productForm.value.taxInclusiveTotalPrice) < 0) {
+        productForm.value.taxInclusiveTotalPrice = "0";
+      }
       // 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠�
       if (productForm.value.quantity) {
         productForm.value.taxInclusiveUnitPrice = (
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.quantity)
         ).toFixed(2);
+        // 纭繚缁撴灉涓嶄负璐熸暟
+        if (Number(productForm.value.taxInclusiveUnitPrice) < 0) {
+          productForm.value.taxInclusiveUnitPrice = "0";
+        }
       }
       // 宸茬煡鍚◣鍗曚环锛屽弽绠楁暟閲�
       else if (productForm.value.taxInclusiveUnitPrice) {
@@ -1700,6 +1746,10 @@
           Number(productForm.value.taxInclusiveTotalPrice) /
           Number(productForm.value.taxInclusiveUnitPrice)
         ).toFixed(2);
+        // 纭繚缁撴灉涓嶄负璐熸暟
+        if (Number(productForm.value.quantity) < 0) {
+          productForm.value.quantity = "0";
+        }
       }
     }
   };

--
Gitblit v1.9.3