{ title: ‘已完成金额‘, dataIndex: ‘finishAmount‘, scopedSlots: { customRender: ‘contractAmountModel‘ } } <span slot="contractAmountModel" slot-scope="text"> {{ text | contractAmountFilter() }} </span> contractAmountFilter(contractAmount) { if (contractAmount) { return (contractAmount + ‘‘).replace(/\B(?=(\d{3})+(?!\d))/g, ‘,‘) } return ‘‘ },
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" v-show="menuType===1" label="合同金额"> <a-input-number style="width:100%;" :formatter="value => `¥ ${value.replace(/\B(?=(\d{3})+(?!\d))/g, ‘,‘)}`" :parser="value => value.replace(/\¥\s?|(,*)/g, ‘‘)" placeholder="合同金额" v-decorator="[‘contractAmount‘, {rules: [{required: menuType===1, message: ‘请输入合同金额‘},{ validator:validatorMoneyRatio}]} ]" /> </a-form-item> validatorCollectionRatio(rule, value, callback) { const errors = [] if (value && value !== ‘‘ && (parseFloat(value) < 0 || parseFloat(value) > 100)) { errors.push(‘回款比例在1-100之间‘) callback(errors) } const regex = new RegExp(‘(^[1-9]([0-9]+)?(.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9].[0-9]([0-9])?$)‘) if (value && value !== ‘‘ && !regex.test(value)) { errors.push(‘回款比例为非负整数且最多保留两位小数‘) callback(errors) } callback() }, validatorMoneyRatio(rule, value, callback) { const errors = [] const regex = new RegExp(‘(^[1-9]([0-9]+)?(.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9].[0-9]([0-9])?$)‘) if (value && value !== ‘‘ && !regex.test(value)) { errors.push(‘金额为非负整数且最多保留两位小数‘) callback(errors) } else if (value && value !== ‘‘ && parseFloat(value) > 100000000000) { errors.push(‘金额过大,请调整后重新输入‘) callback(errors) } callback() }