From 4a55db3ee9932c641a0895deddb4ee3b0b47ad20 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期一, 26 十月 2026 10:52:28 +0800
Subject: [PATCH] fix(erp): 新增采购申请实时计算税额

---
 src/views/erp/purchase/request/modules/item-form.vue |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/views/erp/purchase/request/modules/item-form.vue b/src/views/erp/purchase/request/modules/item-form.vue
index 7cd972a..436cdaa 100644
--- a/src/views/erp/purchase/request/modules/item-form.vue
+++ b/src/views/erp/purchase/request/modules/item-form.vue
@@ -41,6 +41,10 @@
       },
       0,
     ),
+    taxPrice: tableData.value.reduce(
+      (sum, item) => sum + (item.taxPrice || 0),
+      0,
+    ),
   };
 });
 
@@ -93,6 +97,7 @@
     count: 1,
     productPrice: undefined,
     taxPercent: undefined,
+    taxPrice: 0,
     demandTime: undefined,
     remark: undefined,
     totalPrice: 0,
@@ -128,24 +133,31 @@
 
 /** 澶勭悊琛屾暟鎹彉鏇� */
 function handleRowChange(row: any) {
+  calculateRowAmount(row);
   const index = tableData.value.findIndex((item) => item.seq === row.seq);
   if (index === -1) {
     tableData.value.push(row);
   } else {
     tableData.value[index] = row;
   }
-  // 璁$畻棰勪及閲戦
-  if (row.productPrice && row.count) {
-    row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
-  }
   emit('update:items', [...tableData.value]);
+}
+
+/** 鎸夋湭绋庝环璁$畻锛氱◣棰� = 鍗曚环 脳 鏁伴噺 脳 绋庣巼 梅 100 */
+function calculateRowAmount(row: ErpPurchaseRequestApi.PurchaseRequestItem) {
+  row.totalPrice = erpPriceMultiply(
+    row.productPrice || 0,
+    row.count || 0,
+  ) ?? 0;
+  row.taxPrice = erpPriceMultiply(
+    row.totalPrice,
+    (row.taxPercent || 0) / 100,
+  ) ?? 0;
 }
 
 /** 鍒濆鍖栬鏁版嵁 */
 function initRow(row: ErpPurchaseRequestApi.PurchaseRequestItem) {
-  if (row.productPrice && row.count) {
-    row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
-  }
+  calculateRowAmount(row);
 }
 
 /** 琛ㄥ崟鏍¢獙 */
@@ -265,6 +277,7 @@
           <div class="flex space-x-4">
             <span>鏁伴噺锛歿{ erpCountInputFormatter(summaries.count) }}</span>
             <span>棰勪及閲戦锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}</span>
+            <span>绋庨锛歿{ erpPriceInputFormatter(summaries.taxPrice) }}</span>
           </div>
         </div>
       </div>

--
Gitblit v1.9.3