From 2c354c2d7ea51b0f78c858fef1edd93354405c6b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 12 十月 2026 18:20:16 +0800
Subject: [PATCH] fix(erp): 单据明细单价口径由「不含税单价」改为「含税单价」(前端)
---
src/views/erp/purchase/request/modules/item-form.vue | 48 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 13 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..0f4af30 100644
--- a/src/views/erp/purchase/request/modules/item-form.vue
+++ b/src/views/erp/purchase/request/modules/item-form.vue
@@ -30,19 +30,22 @@
const tableData = ref<ErpPurchaseRequestApi.PurchaseRequestItem[]>([]);
-/** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
+/** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁锛堣涓� totalPrice 涓轰笉鍚◣閲戦锛屽惈绋庡悎璁¢渶鍔犱笂绋庨锛� */
const summaries = computed(() => {
return {
count: tableData.value.reduce((sum, item) => sum + (item.count || 0), 0),
totalPrice: tableData.value.reduce(
- (sum, item) => {
- const price = erpPriceMultiply(item.productPrice || 0, item.count || 0) ?? 0;
- return sum + price;
- },
+ (sum, item) => sum + (item.totalPrice || 0),
0,
),
+ taxPrice: tableData.value.reduce((sum, item) => sum + (item.taxPrice || 0), 0),
};
});
+
+/** 鍚◣鍚堣 = 涓嶅惈绋庨噾棰� + 绋庨 */
+const totalTaxInclusivePrice = computed(
+ () => summaries.value.totalPrice + summaries.value.taxPrice,
+);
/** 琛ㄦ牸閰嶇疆 */
const [Grid, gridApi] = useVbenVxeGrid({
@@ -126,25 +129,39 @@
handleRowChange(row);
}
+/**
+ * 閲嶇畻琛岄噾棰濓紙鍗曚环涓�**鍚◣**鍗曚环锛�
+ * 鍚◣閲戦 = 鍚◣鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ */
+function recalcRow(row: ErpPurchaseRequestApi.PurchaseRequestItem) {
+ if (row.productPrice && row.count) {
+ const taxInclusivePrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
+ row.taxPrice =
+ erpPriceMultiply(taxInclusivePrice, (row.taxPercent || 0) / 100) ?? 0;
+ row.totalPrice = taxInclusivePrice - row.taxPrice;
+ }
+}
+
/** 澶勭悊琛屾暟鎹彉鏇� */
function handleRowChange(row: any) {
+ recalcRow(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]);
}
-/** 鍒濆鍖栬鏁版嵁 */
+/**
+ * 鍒濆鍖栬鏁版嵁
+ * 宸叉湁鍗曟嵁鐨勬槑缁嗚锛堝甫 id锛夋部鐢ㄥ悗绔繑鍥炵殑閲戦锛岄伩鍏嶅巻鍙插崟鎹鏂板彛寰勮鐩栵紱
+ * 鍙湁鏈繚瀛樼殑鏂板琛屾墠鎸夋柊鍙e緞閲嶇畻銆�
+ */
function initRow(row: ErpPurchaseRequestApi.PurchaseRequestItem) {
- if (row.productPrice && row.count) {
- row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
+ if (!row.id) {
+ recalcRow(row);
}
}
@@ -218,6 +235,9 @@
/>
<span v-else>{{ row.taxPercent ? `${row.taxPercent}%` : '-' }}</span>
</template>
+ <template #totalTaxInclusivePrice="{ row }">
+ <span>{{ erpPriceInputFormatter((row.totalPrice || 0) + (row.taxPrice || 0)) }}</span>
+ </template>
<template #demandTime="{ row }">
<DatePicker
v-if="!disabled"
@@ -264,7 +284,9 @@
<span class="font-medium text-foreground">鍚堣锛�</span>
<div class="flex space-x-4">
<span>鏁伴噺锛歿{ erpCountInputFormatter(summaries.count) }}</span>
- <span>棰勪及閲戦锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}</span>
+ <span>涓嶅惈绋庨噾棰濓細{{ erpPriceInputFormatter(summaries.totalPrice) }}</span>
+ <span>绋庨锛歿{ erpPriceInputFormatter(summaries.taxPrice) }}</span>
+ <span>鍚◣鍚堣锛歿{ erpPriceInputFormatter(totalTaxInclusivePrice) }}</span>
</div>
</div>
</div>
--
Gitblit v1.9.3