From e7aa72fb3038debcaefba16a98b20f2de495f2fb Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 08 一月 2020 19:17:17 +0800 Subject: [PATCH] 2020-01-08 --- src/tabviews/tableshare/mutilform/index.jsx | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx index 10272db..a4750de 100644 --- a/src/tabviews/tableshare/mutilform/index.jsx +++ b/src/tabviews/tableshare/mutilform/index.jsx @@ -184,6 +184,16 @@ }) } + 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 + '!') + } + } + getFields() { const { getFieldDecorator } = this.props.form @@ -226,6 +236,12 @@ 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}> @@ -236,7 +252,8 @@ { required: item.required === 'true', message: this.props.dict['form.required.input'] + item.label + '!' - } + }, + ...rules ] })( precision === null ? -- Gitblit v1.8.0