| | |
| | | } |
| | | } |
| | | |
| | | handleConfirmPassword = (rule, value, callback, item) => { |
| | | let val = parseFloat(value) |
| | | |
| | | if (!isNaN(val)) { |
| | | if (typeof(item.min) === 'number' && val < item.min) { |
| | | callback(item.label + '最小值为 ' + item.min) |
| | | } else if (typeof(item.max) === 'number' && val > item.max) { |
| | | callback(item.label + '最大值为 ' + item.max) |
| | | } |
| | | } |
| | | |
| | | callback() |
| | | } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { cols } = this.state |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'number') { // 数字 |
| | | let min = (item.min || item.min === 0) ? item.min : -Infinity |
| | | let max = (item.max || item.max === 0) ? item.max : Infinity |
| | | let _initval = item.initval |
| | | let precision = (item.decimal || item.decimal === 0) ? item.decimal : null |
| | | |
| | |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | }, |
| | | { |
| | | validator: (rule, value, callback) => this.handleConfirmPassword(rule, value, callback, item) |
| | | } |
| | | ] |
| | | })( |
| | | precision === null ? |
| | | <InputNumber min={min} max={max} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : |
| | | <InputNumber min={min} max={max} precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> |
| | | <InputNumber disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : |
| | | <InputNumber precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |