调整结算模块
This commit is contained in:
@@ -116,8 +116,8 @@
|
||||
><el-input
|
||||
v-else
|
||||
v-model="row.taxRate"
|
||||
inputmode="decimal"
|
||||
maxlength="6"
|
||||
inputmode="numeric"
|
||||
maxlength="3"
|
||||
clearable
|
||||
placeholder="请输入"
|
||||
@input="value => taxRateInput(row, value)"
|
||||
@@ -678,23 +678,26 @@ export default {
|
||||
const feeItem = this.feeItemOptions(row).find(
|
||||
item => String(item.name || item.englishName || '') === String(value || '')
|
||||
);
|
||||
row.taxRate = this.hasTaxRate(feeItem?.taxRate) ? String(feeItem.taxRate) : '';
|
||||
row.taxRate = this.hasTaxRate(feeItem?.taxRate) ? this.normalizeTaxRate(feeItem.taxRate) : '';
|
||||
},
|
||||
fillRuleTaxRate(row) {
|
||||
if (this.hasTaxRate(row.taxRate) || !row.feeItem) return;
|
||||
const feeItem = this.feeItemOptions(row).find(
|
||||
item => String(item.name || item.englishName || '') === String(row.feeItem)
|
||||
);
|
||||
if (this.hasTaxRate(feeItem?.taxRate)) row.taxRate = String(feeItem.taxRate);
|
||||
if (this.hasTaxRate(feeItem?.taxRate)) row.taxRate = this.normalizeTaxRate(feeItem.taxRate);
|
||||
},
|
||||
hasTaxRate(value) {
|
||||
return value !== undefined && value !== null && String(value).trim() !== '';
|
||||
},
|
||||
normalizeTaxRate(value) {
|
||||
const rate = Number(String(value ?? '').trim());
|
||||
return Number.isFinite(rate) ? String(Math.trunc(Math.abs(rate))) : '';
|
||||
},
|
||||
taxRateInput(row, value) {
|
||||
const text = String(value ?? '').replace(/[^\d.]/g, '');
|
||||
const parts = text.split('.');
|
||||
row.taxRate =
|
||||
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 2)}` : parts[0];
|
||||
let text = String(value ?? '').replace(/\D/g, '');
|
||||
if (text.length > 1) text = text.replace(/^0+/, '') || '0';
|
||||
row.taxRate = text;
|
||||
},
|
||||
billingTypes(row) {
|
||||
return this.typeMap[row.billingElement] || [];
|
||||
@@ -845,8 +848,8 @@ export default {
|
||||
feeItemSet.add(feeItem);
|
||||
if (this.hasTaxRate(row.taxRate)) {
|
||||
const taxRate = Number(row.taxRate);
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(String(row.taxRate)) || taxRate < 0 || taxRate > 100) {
|
||||
this.$message.warning(`第${i + 1}行税率必须在0到100之间且最多保留2位小数`);
|
||||
if (!/^\d+$/.test(String(row.taxRate).trim()) || taxRate < 0 || taxRate > 100) {
|
||||
this.$message.warning(`第${i + 1}行税率必须是0到100之间的整数`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user