From 388e286dc8a5b3b8c4717cc74bf128c807eba6b7 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期一, 20 四月 2026 14:07:58 +0800
Subject: [PATCH] fix: 阳光彩印-修复总价计算中的数值处理并调整税率验证逻辑

---
 src/views/procurementManagement/procurementLedger/index.vue |   27 ++++++++-----
 src/views/salesManagement/salesLedger/index.vue             |   42 +++++++++++----------
 src/views/salesManagement/salesQuotation/index.vue          |    9 +++-
 3 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 83616a3..8543b26 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -970,7 +970,7 @@
       taxInclusiveUnitPrice: [
         { required: true, message: "璇疯緭鍏�", trigger: "blur" },
       ],
-      taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+      // taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
       warnNum: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
       taxInclusiveTotalPrice: [
         { required: true, message: "璇疯緭鍏�", trigger: "blur" },
@@ -978,7 +978,7 @@
       taxExclusiveTotalPrice: [
         { required: true, message: "璇疯緭鍏�", trigger: "blur" },
       ],
-      invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+      // invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
       isChecked: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
     },
   });
@@ -1721,10 +1721,10 @@
     return `${year}-${month}-${day}`;
   }
   const mathNum = () => {
-    if (!productForm.value.taxRate) {
-      proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-      return;
-    }
+    // if (!productForm.value.taxRate) {
+    //   proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+    //   return;
+    // }
     if (!productForm.value.taxInclusiveUnitPrice) {
       return;
     }
@@ -1746,13 +1746,20 @@
           productForm.value.taxRate,
           3
         );
+    }else{
+      productForm.value.taxExclusiveTotalPrice =
+      proxy.calculateTaxIncludeTotalPrice(
+          productForm.value.taxInclusiveUnitPrice,
+          productForm.value.quantity,
+          3
+      );
     }
   };
   const reverseMathNum = field => {
-    if (!productForm.value.taxRate) {
-      proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-      return;
-    }
+    // if (!productForm.value.taxRate) {
+    //   proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+    //   return;
+    // }
     const taxRate = Number(productForm.value.taxRate);
     if (!taxRate) return;
 
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index d203f32..d3daec6 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -767,14 +767,14 @@
 		taxInclusiveUnitPrice: [
 			{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
 		],
-		taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+		// taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
 		taxInclusiveTotalPrice: [
 			{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
 		],
 		taxExclusiveTotalPrice: [
 			{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
 		],
-		invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+		// invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
 	},
 });
 const { productForm, productRules } = toRefs(productFormData);
@@ -1200,7 +1200,7 @@
 	productData.value = products.map((p) => {
 		const quantity = Number(p.quantity ?? 0) || 0;
 		const unitPrice = Number(p.unitPrice ?? 0) || 0;
-		const taxRate = "13"; // 榛樿 13%锛屼究浜庣洿鎺ユ彁浜わ紙濡傞渶鍙湪浜у搧涓嚜琛屼慨鏀癸級
+		const taxRate = "0"; // 榛樿 13%锛屼究浜庣洿鎺ユ彁浜わ紙濡傞渶鍙湪浜у搧涓嚜琛屼慨鏀癸級
 		const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(3);
 		const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(taxInclusiveTotalPrice, taxRate, 3);
 		return {
@@ -1936,10 +1936,10 @@
 
 // 鏍规嵁涓嶅惈绋庢�讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
 const calculateFromExclusiveTotalPrice = () => {
-	if (!productForm.value.taxRate) {
-		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-		return;
-	}
+	// if (!productForm.value.taxRate) {
+	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+	// 	return;
+	// }
 	if (isCalculating.value) return;
 	
 	const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
@@ -1965,10 +1965,10 @@
 
 // 鏍规嵁鏁伴噺鍙樺寲璁$畻鎬讳环
 const calculateFromQuantity = () => {
-	if (!productForm.value.taxRate) {
-		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-		return;
-	}
+	// if (!productForm.value.taxRate) {
+	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+	// 	return;
+	// }
 	if (isCalculating.value) return;
 	
 	const quantity = parseFloat(productForm.value.quantity);
@@ -1991,17 +1991,19 @@
 				productForm.value.taxRate,
 				3
 			);
-	}
+	}else{
+    productForm.value.taxExclusiveTotalPrice = (unitPrice * quantity).toFixed(3);
+  }
 	
 	isCalculating.value = false;
 };
 
 // 鏍规嵁鍚◣鍗曚环鍙樺寲璁$畻鎬讳环
 const calculateFromUnitPrice = () => {
-	if (!productForm.value.taxRate) {
-		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-		return;
-	}
+	// if (!productForm.value.taxRate) {
+	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+	// 	return;
+	// }
 	if (isCalculating.value) return;
 	
 	const quantity = parseFloat(productForm.value.quantity);
@@ -2031,10 +2033,10 @@
 
 // 鏍规嵁绋庣巼鍙樺寲璁$畻涓嶅惈绋庢�讳环
 const calculateFromTaxRate = () => {
-	if (!productForm.value.taxRate) {
-		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
-		return;
-	}
+	// if (!productForm.value.taxRate) {
+	// 	proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+	// 	return;
+	// }
 	if (isCalculating.value) return;
 	
 	const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
diff --git a/src/views/salesManagement/salesQuotation/index.vue b/src/views/salesManagement/salesQuotation/index.vue
index d77045b..bf13ec6 100644
--- a/src/views/salesManagement/salesQuotation/index.vue
+++ b/src/views/salesManagement/salesQuotation/index.vue
@@ -854,8 +854,13 @@
 }
 
 const calculateTotal = () => {
-  form.discountAmount = form.subtotal * (form.discountRate / 100)
-  form.totalAmount = form.subtotal + form.freight + form.otherFee - form.discountAmount
+  const rate = Number(form.discountRate)
+  const hasRate = Number.isFinite(rate) && rate > 0
+  const subtotal = Number(form.subtotal) || 0
+  const freight = Number(form.freight) || 0
+  const otherFee = Number(form.otherFee) || 0
+  form.discountAmount = hasRate ? subtotal * (rate / 100) : 0
+  form.totalAmount = subtotal + freight + otherFee - form.discountAmount
 }
 
 const handleCustomerChange = () => {

--
Gitblit v1.9.3