| | |
| | | productBarCode?: string; // 产品条码 |
| | | productPrice?: number; // 产品单价(参考价) |
| | | count: number; // 数量 |
| | | totalPrice?: number; // 明细未税金额 |
| | | taxPercent?: number; // 税率 |
| | | taxPrice?: number; // 税额(单价 × 数量 × 税率 ÷ 100) |
| | | qcCheckFlag?: boolean; // 是否质检 |
| | | demandTime?: string; // 需求日期 |
| | | remark?: string; // 备注 |
| | | } |
| | |
| | | fieldName: 'totalTaxPrice', |
| | | label: '税额', |
| | | component: 'InputNumber', |
| | | help: '计算规则:税额合计 = Σ(单价 × 数量 × 税率 ÷ 100)。单价按未税价计算,每条明细四舍五入保留2位。', |
| | | componentProps: { |
| | | placeholder: '根据明细税率自动计算', |
| | | min: 0, |
| | |
| | | formatter: 'formatAmount2', |
| | | }, |
| | | { |
| | | field: 'totalTaxPrice', |
| | | field: 'taxPrice', |
| | | title: '税额', |
| | | formatter: 'formatAmount2', |
| | | minWidth: 120, |
| | |
| | | function handleUpdateItems(items: ErpPurchaseRequestApi.PurchaseRequestItem[]) { |
| | | formData.value = modalApi.getData<ErpPurchaseRequestApi.PurchaseRequest>(); |
| | | formData.value.items = items; |
| | | const totalTaxPrice = items.reduce( |
| | | (sum, item) => sum + (item.taxPrice || 0), |
| | | 0, |
| | | ); |
| | | formApi.setValues({ |
| | | items, |
| | | totalTaxPrice, |
| | | }); |
| | | } |
| | | |
| | |
| | | formData.value = { |
| | | requestTime: '', |
| | | depositPrice: 0, |
| | | totalTaxPrice: 0, |
| | | items: [], |
| | | }; |
| | | await formApi.setFieldValue('depositPrice', 0); |
| | | await formApi.setValues({ depositPrice: 0, totalTaxPrice: 0 }); |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | |
| | | }, |
| | | 0, |
| | | ), |
| | | taxPrice: tableData.value.reduce( |
| | | (sum, item) => sum + (item.taxPrice || 0), |
| | | 0, |
| | | ), |
| | | }; |
| | | }); |
| | | |
| | |
| | | count: 1, |
| | | productPrice: undefined, |
| | | taxPercent: undefined, |
| | | taxPrice: 0, |
| | | demandTime: undefined, |
| | | remark: undefined, |
| | | totalPrice: 0, |
| | |
| | | |
| | | /** 处理行数据变更 */ |
| | | 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); |
| | | } |
| | | |
| | | /** 表单校验 */ |
| | |
| | | <div class="flex space-x-4"> |
| | | <span>数量:{{ erpCountInputFormatter(summaries.count) }}</span> |
| | | <span>预估金额:{{ erpPriceInputFormatter(summaries.totalPrice) }}</span> |
| | | <span>税额:{{ erpPriceInputFormatter(summaries.taxPrice) }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |