李红攀:V2.0.001采购订单添加税率

This commit is contained in:
2026-04-25 10:57:12 +08:00
parent 6f1f32df62
commit 66f47cdde4
4 changed files with 186 additions and 7 deletions

View File

@@ -62,7 +62,9 @@
<!-- 金额信息 -->
<wd-cell-group title="金额信息" border>
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
<wd-cell title="合计产品金额" :value="formatPrice(detail.totalProductPrice)" />
<wd-cell title="合计税额" :value="formatPrice(detail.totalTaxPrice)" />
<wd-cell title="合计金额(含税)" :value="formatPrice(detail.totalPrice)" />
<wd-cell title="附加费" :value="formatPrice(detail.additionalFee)" />
</wd-cell-group>
@@ -104,7 +106,19 @@
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
</view>
<view class="mb-8rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">金额</text>
<text class="text-[#999]">产品金额</text>
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
</view>
<view v-if="item.taxPercent" class="mb-8rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">税率</text>
<text class="text-[#666]">{{ item.taxPercent }}%</text>
</view>
<view v-if="item.taxPrice" class="mb-8rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">税额</text>
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
</view>
<view class="mb-8rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">含税金额</text>
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
</view>
<view v-if="item.supplierName" class="mb-8rpx flex items-center justify-between text-26rpx">

View File

@@ -105,7 +105,25 @@
/>
</view>
<view class="mb-12rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">金额</text>
<text class="text-[#999]">产品金额</text>
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
</view>
<view class="mb-12rpx">
<wd-input
v-model="item.taxPercent"
label="税率(%)"
label-width="140rpx"
type="digit"
placeholder="请输入税率"
@change="calcItemTotal(item)"
/>
</view>
<view class="mb-12rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">税额</text>
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
</view>
<view class="mb-12rpx flex items-center justify-between text-26rpx">
<text class="text-[#999]">含税金额</text>
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
</view>
<view class="mb-12rpx">
@@ -137,7 +155,9 @@
<!-- 合计信息 -->
<wd-cell-group title="合计信息" border>
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
<wd-cell title="合计产品金额" :value="formatPrice(totalProductPrice)" />
<wd-cell title="合计税额" :value="formatPrice(totalTaxPrice)" />
<wd-cell title="合计金额(含税)" :value="formatPrice(totalPrice)" />
</wd-cell-group>
</wd-form>
</view>
@@ -284,7 +304,17 @@ const totalCount = computed(() => {
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
})
/** 合计金额 */
/** 合计产品金额 */
const totalProductPrice = computed(() => {
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalProductPrice) || 0), 0) || 0
})
/** 合计税额 */
const totalTaxPrice = computed(() => {
return formData.value.items?.reduce((sum, item) => sum + (Number(item.taxPrice) || 0), 0) || 0
})
/** 合计金额(含税) */
const totalPrice = computed(() => {
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
})
@@ -402,6 +432,9 @@ function addItem() {
productUnitName: undefined,
count: undefined,
productPrice: undefined,
totalProductPrice: 0,
taxPercent: undefined,
taxPrice: 0,
totalPrice: 0,
purpose: undefined,
remark: undefined,
@@ -413,11 +446,19 @@ function removeItem(index: number) {
formData.value.items?.splice(index, 1)
}
/** 计算产品项金额 */
/** 计算产品项金额(含税) */
function calcItemTotal(item: PurchaseRequisitionItem) {
const count = Number(item.count) || 0
const price = Number(item.productPrice) || 0
item.totalPrice = count * price
const taxPercent = Number(item.taxPercent) || 0
// 产品金额 = 单价 × 数量
const totalProductPrice = count * price
// 税额 = 产品金额 × 税率 / 100
const taxPrice = totalProductPrice * taxPercent / 100
// 含税金额 = 产品金额 + 税额
item.totalProductPrice = Math.round(totalProductPrice * 100) / 100
item.taxPrice = Math.round(taxPrice * 100) / 100
item.totalPrice = Math.round((totalProductPrice + taxPrice) * 100) / 100
}
/** 提交表单 */
@@ -446,6 +487,8 @@ async function handleSubmit() {
try {
// 设置合计
formData.value.totalCount = totalCount.value
formData.value.totalProductPrice = totalProductPrice.value
formData.value.totalTaxPrice = totalTaxPrice.value
formData.value.totalPrice = totalPrice.value
if (props.id) {