1、调整业务模块
This commit is contained in:
@@ -247,13 +247,14 @@
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
@change="recalculateLine(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="含税金额" min-width="130">
|
||||
<el-table-column label="不含税单价" min-width="130">
|
||||
<template #default="{ row }">
|
||||
<el-input-number
|
||||
v-model="row.amountWithTax"
|
||||
v-model="row.unitPriceNoTax"
|
||||
:disabled="readonly"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
@@ -262,6 +263,9 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="不含税金额" min-width="130" align="right">
|
||||
<template #default="{ row }">{{ formatMoney(row.amountNoTax) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税率" min-width="110">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
@@ -281,6 +285,9 @@
|
||||
<el-table-column label="税额" min-width="120">
|
||||
<template #default="{ row }">{{ formatMoney(row.taxAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="合计" min-width="130" align="right">
|
||||
<template #default="{ row }">{{ formatMoney(row.totalAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="170">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" :disabled="readonly" maxlength="200" />
|
||||
@@ -374,6 +381,7 @@
|
||||
<span v-else-if="column.prop === 'transportType'">{{
|
||||
transportTypeLabel(row.transportType)
|
||||
}}</span>
|
||||
<span v-else-if="column.dateTime">{{ formatDateTime(row[column.prop]) }}</span>
|
||||
<span v-else>{{ displayValue(row[column.prop]) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -492,7 +500,9 @@ const emptyLine = () => ({
|
||||
unit: '吨',
|
||||
quantity: 0,
|
||||
unitPriceNoTax: 0,
|
||||
amountNoTax: 0,
|
||||
amountWithTax: 0,
|
||||
totalAmount: 0,
|
||||
taxRate: 0,
|
||||
taxAmount: 0,
|
||||
remark: '',
|
||||
@@ -598,7 +608,7 @@ export default {
|
||||
return this.form.sheets.reduce(
|
||||
(sheetTotal, sheet) =>
|
||||
sheetTotal +
|
||||
sheet.lines.reduce((lineTotal, line) => lineTotal + Number(line.amountWithTax || 0), 0),
|
||||
sheet.lines.reduce((lineTotal, line) => lineTotal + Number(line.totalAmount || 0), 0),
|
||||
0
|
||||
);
|
||||
},
|
||||
@@ -714,11 +724,11 @@ export default {
|
||||
const item = this.findInvoiceItem(line);
|
||||
if (item) {
|
||||
line.taxRate = Number(item.defaultTaxRate || 0);
|
||||
this.recalculateLine(line);
|
||||
} else if (clearInvalid) {
|
||||
line.goodsName = '';
|
||||
line.taxRate = 0;
|
||||
}
|
||||
this.recalculateLine(line);
|
||||
},
|
||||
handleGoodsCategoryChange(line) {
|
||||
const names = this.invoiceItemNames(line.goodsCategory);
|
||||
@@ -1067,9 +1077,14 @@ export default {
|
||||
sheet.lines.push(emptyLine());
|
||||
},
|
||||
recalculateLine(row) {
|
||||
const amount = Number(row.amountWithTax || 0);
|
||||
const quantity = Number(row.quantity || 0);
|
||||
const unitPrice = Number(row.unitPriceNoTax || 0);
|
||||
const amountNoTax = Number((quantity * unitPrice).toFixed(2));
|
||||
const rate = Number(row.taxRate || 0) / 100;
|
||||
row.taxAmount = rate ? Number((amount - amount / (1 + rate)).toFixed(2)) : 0;
|
||||
row.amountNoTax = amountNoTax;
|
||||
row.taxAmount = rate ? Number((amountNoTax * rate).toFixed(2)) : 0;
|
||||
row.totalAmount = Number((amountNoTax + row.taxAmount).toFixed(2));
|
||||
row.amountWithTax = row.totalAmount;
|
||||
},
|
||||
validateBusiness() {
|
||||
if (!this.selectedDetailIds.length) throw new Error('请至少选择一条开票明细');
|
||||
@@ -1082,7 +1097,7 @@ export default {
|
||||
for (const line of sheet.lines) {
|
||||
if (!line.goodsCategory || !line.goodsName) throw new Error('请完整填写商品和服务信息');
|
||||
if (
|
||||
[line.quantity, line.unitPriceNoTax, line.amountWithTax, line.taxRate].some(
|
||||
[line.quantity, line.unitPriceNoTax, line.amountNoTax, line.taxRate].some(
|
||||
Number.isNaN
|
||||
)
|
||||
) {
|
||||
@@ -1121,7 +1136,9 @@ export default {
|
||||
unit: line.unit,
|
||||
quantity: line.quantity,
|
||||
unitPriceNoTax: line.unitPriceNoTax,
|
||||
amountWithTax: line.amountWithTax,
|
||||
amountNoTax: line.amountNoTax,
|
||||
totalAmount: line.totalAmount,
|
||||
amountWithTax: line.totalAmount,
|
||||
taxRate: line.taxRate,
|
||||
taxAmount: line.taxAmount,
|
||||
remark: line.remark,
|
||||
@@ -1169,6 +1186,10 @@ export default {
|
||||
displayValue(value) {
|
||||
return value === null || value === undefined || value === '' ? '-' : value;
|
||||
},
|
||||
formatDateTime(value) {
|
||||
if (!value) return '-';
|
||||
return this.$dayjs(value).format('YYYY-MM-DD HH:mm:ss');
|
||||
},
|
||||
formatMoney(value) {
|
||||
return Number(value || 0).toFixed(2);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user