调整结算模块
This commit is contained in:
+15
-11
@@ -54,8 +54,8 @@
|
||||
<template #taxRate-form>
|
||||
<el-input
|
||||
v-model="form.taxRate"
|
||||
inputmode="decimal"
|
||||
maxlength="6"
|
||||
inputmode="numeric"
|
||||
maxlength="3"
|
||||
clearable
|
||||
placeholder="请输入税率"
|
||||
@input="handleTaxRateInput"
|
||||
@@ -183,8 +183,8 @@ export default {
|
||||
validator: (rule, value, callback) => {
|
||||
const text = String(value ?? '').trim();
|
||||
const rate = Number(text);
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(text) || rate < 0 || rate > 100) {
|
||||
callback(new Error('税率必须是0到100之间且最多保留2位小数的数字'));
|
||||
if (!/^\d+$/.test(text) || rate < 0 || rate > 100) {
|
||||
callback(new Error('税率必须是0到100之间的整数'));
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
@@ -364,7 +364,10 @@ export default {
|
||||
return option ? `${option.dictValue}/${option.dictKey}` : feeCategory;
|
||||
},
|
||||
formatTaxRate(value) {
|
||||
return value === undefined || value === null || value === '' ? '' : `${value}%`;
|
||||
const text = String(value ?? '').trim();
|
||||
if (text === '') return '';
|
||||
const rate = Number(text);
|
||||
return Number.isFinite(rate) ? `${Math.trunc(Math.abs(rate))}%` : `${text}%`;
|
||||
},
|
||||
getFeeItemCodeSuffix(code, feeCategory) {
|
||||
const value = String(code || '').trim();
|
||||
@@ -397,6 +400,11 @@ export default {
|
||||
const values = { ...row };
|
||||
values.feeCategory = String(values.feeCategory || '').trim();
|
||||
values.englishName = this.getFeeItemCodeSuffix(values.englishName, values.feeCategory);
|
||||
const taxRateText = String(values.taxRate ?? '').trim();
|
||||
const taxRate = Number(taxRateText);
|
||||
if (taxRateText !== '' && Number.isFinite(taxRate)) {
|
||||
values.taxRate = String(Math.trunc(Math.abs(taxRate)));
|
||||
}
|
||||
return values;
|
||||
},
|
||||
validateUnique(row) {
|
||||
@@ -497,12 +505,8 @@ export default {
|
||||
done();
|
||||
},
|
||||
handleTaxRateInput(value) {
|
||||
let normalized = String(value || '').replace(/[^\d.]/g, '');
|
||||
normalized = normalized.replace(/(\..*)\./g, '$1');
|
||||
if (normalized.startsWith('.')) normalized = `0${normalized}`;
|
||||
const [integerPart, decimalPart] = normalized.split('.');
|
||||
normalized =
|
||||
decimalPart === undefined ? integerPart : `${integerPart}.${decimalPart.slice(0, 2)}`;
|
||||
let normalized = String(value ?? '').replace(/\D/g, '');
|
||||
if (normalized.length > 1) normalized = normalized.replace(/^0+/, '') || '0';
|
||||
this.form.taxRate = normalized;
|
||||
},
|
||||
searchReset() {
|
||||
|
||||
Reference in New Issue
Block a user