| | |
| | | }) |
| | | } |
| | | |
| | | handleInputNumber = (rule, value, callback, item) => { |
| | | if (item.required === 'true' && (!value && value !== 0)) { |
| | | callback() |
| | | } else if ((item.min || item.min === 0) && (value || value === 0) && value < item.min) { |
| | | callback(item.label + '最小值为' + item.min + '!') |
| | | } else if ((item.max || item.max === 0) && (value || value === 0) && value > item.max) { |
| | | callback(item.label + '最大值为' + item.max + '!') |
| | | } |
| | | } |
| | | // handleInputNumber = (rule, value, callback, item) => { |
| | | // if (item.required === 'true' && (!value && value !== 0)) { |
| | | // callback(this.props.dict['form.required.input'] + item.label + '!') |
| | | // } else if ((item.min || item.min === 0) && (value || value === 0) && value < item.min) { |
| | | // callback(item.label + '最小值为' + item.min + '!') |
| | | // } else if ((item.max || item.max === 0) && (value || value === 0) && value > item.max) { |
| | | // callback(item.label + '最大值为' + item.max + '!') |
| | | // } |
| | | // } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | |
| | | let max = (item.max || item.max === 0) ? item.max : Infinity |
| | | let _initval = item.initval |
| | | let precision = (item.decimal || item.decimal === 0) ? item.decimal : null |
| | | let rules = [] |
| | | if ((item.min || item.min === 0) || (item.max || item.max === 0)) { |
| | | rules.push({ |
| | | validator: (rule, value, callback) => {this.handleInputNumber(rule, value, callback, item)} |
| | | }) |
| | | } |
| | | |
| | | |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | { |
| | | required: item.required === 'true', |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | }, |
| | | ...rules |
| | | } |
| | | ] |
| | | })( |
| | | precision === null ? |
| | |
| | | if (item.linkSubField && item.linkSubField.length > 0) { // 存在关联字段,数据存储 |
| | | hasSubField = true |
| | | } |
| | | |
| | | |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |