From 170e43cd3509a33be7db74e5f3dbd7a71bd9ffd1 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 27 一月 2026 14:46:57 +0800
Subject: [PATCH] 湟水峡 1.修改采购台账没有税率的时候计算问题

---
 src/views/procurementManagement/procurementLedger/index.vue |   53 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 73b56af..fdfe1fb 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -103,7 +103,6 @@
         />
         <el-table-column
           label="渚涘簲鍟嗗悕绉�"
-          width="240"
           prop="supplierName"
           show-overflow-tooltip
         />
@@ -116,7 +115,6 @@
         <el-table-column
           label="鍚堝悓閲戦(鍏�)"
           prop="contractAmount"
-           width="200"
           show-overflow-tooltip
           :formatter="formattedNumber"
         />
@@ -273,14 +271,6 @@
                 placeholder="璇烽�夋嫨"
                 clearable
               />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鏄惁寮�绁�" prop="isInvoice">
-              <el-select v-model="form.isInvoice" placeholder="璇烽�夋嫨" clearable>
-                <el-option label="鏄�" :value="1" />
-                <el-option label="鍚�" :value="2" />
-              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -718,7 +708,6 @@
     supplierId: "",
     paymentMethod: "",
 		executionDate: "",
-    isInvoice: "",
   },
   rules: {
     purchaseContractNumber: [
@@ -728,7 +717,6 @@
     supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
 		entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
 		executionDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-    isInvoice: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
   },
 });
 const {  form, rules } = toRefs(data);
@@ -1182,6 +1170,13 @@
   const day = String(today.getDate()).padStart(2, "0");
   return `${year}-${month}-${day}`;
 }
+// 绋庣巼鍙兘涓虹┖锛氳繑鍥� number 鎴� null
+const getTaxRateNumberOrNull = () => {
+  const raw = productForm.value?.taxRate;
+  if (raw === null || raw === undefined || raw === "") return null;
+  const n = Number(raw);
+  return Number.isFinite(n) ? n : null;
+};
 const mathNum = () => {
 	// if (!productForm.value.taxRate) {
 	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
@@ -1199,12 +1194,19 @@
       productForm.value.taxInclusiveUnitPrice,
       productForm.value.quantity
     );
-    // 涓嶅惈绋庢�讳环璁$畻
+
+  // 涓嶅惈绋庢�讳环璁$畻锛堢◣鐜囧彲鑳戒负绌猴級
+  const taxRate = getTaxRateNumberOrNull();
+  if (taxRate === null) {
+    // 鏈~鍐欑◣鐜囨椂锛氭寜鈥滃惈绋�/涓嶅惈绋庝竴鑷粹�濆鐞嗭紝閬垮厤鍑虹幇 NaN
+    productForm.value.taxExclusiveTotalPrice = productForm.value.taxInclusiveTotalPrice;
+  } else {
     productForm.value.taxExclusiveTotalPrice =
       proxy.calculateTaxExclusiveTotalPrice(
         productForm.value.taxInclusiveTotalPrice,
-        productForm.value.taxRate
+        taxRate
       );
+  }
   // if (productForm.value.taxRate) {
   //   // 涓嶅惈绋庢�讳环璁$畻
   //   productForm.value.taxExclusiveTotalPrice =
@@ -1219,8 +1221,7 @@
 	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
 	// 	return;
 	// }
-  const taxRate = productForm.value.taxRate?Number(productForm.value.taxRate):0;
-  // if (!taxRate) return;
+  const taxRate = getTaxRateNumberOrNull();
   if (field === 'taxInclusiveTotalPrice') {
     // 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环
     if (productForm.value.quantity) {
@@ -1232,13 +1233,21 @@
       productForm.value.quantity =
         (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
     }
-    // 鍙嶇畻涓嶅惈绋庢�讳环
-    productForm.value.taxExclusiveTotalPrice =
-      (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2);
+    // 鍙嶇畻涓嶅惈绋庢�讳环锛堢◣鐜囧彲鑳戒负绌猴級
+    if (taxRate === null) {
+      productForm.value.taxExclusiveTotalPrice = productForm.value.taxInclusiveTotalPrice;
+    } else {
+      productForm.value.taxExclusiveTotalPrice =
+        (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2);
+    }
   } else if (field === 'taxExclusiveTotalPrice') {
-    // 鍙嶇畻鍚◣鎬讳环
-    productForm.value.taxInclusiveTotalPrice =
-      (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2);
+    // 鍙嶇畻鍚◣鎬讳环锛堢◣鐜囧彲鑳戒负绌猴級
+    if (taxRate === null) {
+      productForm.value.taxInclusiveTotalPrice = productForm.value.taxExclusiveTotalPrice;
+    } else {
+      productForm.value.taxInclusiveTotalPrice =
+        (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2);
+    }
     // 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠�
     if (productForm.value.quantity) {
       productForm.value.taxInclusiveUnitPrice =

--
Gitblit v1.9.3