Commit 32c1235b by Sweet Zhang

小数点后面不加千分位符号,入账检核时,新增入账检核记录时,入账金额支持负数

parent 8bd1b7ec
...@@ -24,10 +24,19 @@ ...@@ -24,10 +24,19 @@
:disabled="item.disabled" :disabled="item.disabled"
@input="val => handleNumberInput(val, item)" @input="val => handleNumberInput(val, item)"
@change="val => handleModelChange(val, item)" @change="val => handleModelChange(val, item)"
:formatter=" :formatter="value => {
value => (item.inputType ? `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : value) if (!item.inputType || !value) return value;
" const str = String(value);
:parser="value => value.replace(/\$\s?|(,*)/g, '')" // 如果包含小数点
if (str.indexOf('.') > -1) {
const [int, dec] = str.split('.');
// 只格式化整数部分,保留小数部分原样
return int.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + '.' + dec;
}
// 如果没有小数点,直接格式化
return str.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}"
:parser="value => value.replace(/\$\s?|(,*)/g, '')"
/> />
<!-- Select (支持 dictType / api / options) --> <!-- Select (支持 dictType / api / options) -->
......
...@@ -534,11 +534,11 @@ const addCheckRecordConfig = ref([ ...@@ -534,11 +534,11 @@ const addCheckRecordConfig = ref([
type: 'input', type: 'input',
prop: 'amount', prop: 'amount',
label: '入账金额', label: '入账金额',
inputType: 'decimal', inputType: 'decimalNumber',
decimalDigits: 4, decimalDigits: 4,
rules: [ rules: [
{ required: true, message: '请输入金额', trigger: 'blur' }, { required: true, message: '请输入金额', trigger: 'blur' },
{ pattern: /^\d+(\.\d{1,4})?$/, message: '最多四位小数', trigger: 'blur' } { pattern: /^-?\d+(\.\d+)?$/, message: '请输入有效的数字', trigger: 'blur' }
] ]
}, { }, {
type: 'select', type: 'select',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment