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 +++++++++ src/templates/modalconfig/modalform/index.jsx | 30 +++++++++----- src/templates/modalviewconfig/index.jsx | 8 ++-- src/templates/modalconfig/index.jsx | 17 ++++++++ src/templates/modalconfig/source.jsx | 9 ++++ src/templates/modalconfig/dragelement/index.jsx | 3 + src/tabviews/tableshare/mutilform/index.scss | 5 ++ src/templates/comtableconfig/index.jsx | 8 ++-- src/templates/subtableconfig/index.jsx | 8 ++-- 9 files changed, 83 insertions(+), 24 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 ? diff --git a/src/tabviews/tableshare/mutilform/index.scss b/src/tabviews/tableshare/mutilform/index.scss index 8ca26e5..2a79447 100644 --- a/src/tabviews/tableshare/mutilform/index.scss +++ b/src/tabviews/tableshare/mutilform/index.scss @@ -14,6 +14,11 @@ .ant-input-number { width: 100%; } + .ant-form-explain { + overflow:hidden; + text-overflow:ellipsis; + white-space:nowrap; + } p { color: #1890ff; border-bottom: 1px solid #d9d9d9; diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index cf9bfdc..0e46a74 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -367,8 +367,8 @@ tooltipClass: 'middle', required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' @@ -814,8 +814,8 @@ initVal: card.field, required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' diff --git a/src/templates/modalconfig/dragelement/index.jsx b/src/templates/modalconfig/dragelement/index.jsx index 4b0c581..fc28b03 100644 --- a/src/templates/modalconfig/dragelement/index.jsx +++ b/src/templates/modalconfig/dragelement/index.jsx @@ -76,6 +76,9 @@ newcard.valueText = '' newcard.orderBy = '' newcard.orderType = 'asc' + newcard.decimal = 0 + newcard.min = '' + newcard.max = '' newcard.readonly = 'false' newcard.required = 'true' newcard.focus = true diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 79654ca..f32d956 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -475,6 +475,20 @@ required: false }, { + type: 'number', + key: 'min', + label: '鏈�灏忓��', + initVal: card.min || '', + required: false + }, + { + type: 'number', + key: 'max', + label: '鏈�澶у��', + initVal: card.max || '', + required: false + }, + { type: 'radio', key: 'readonly', label: this.state.dict['header.form.readonly'], @@ -813,6 +827,9 @@ valueText: '', orderBy: '', orderType: 'asc', + decimal: 0, + min: '', + max: '', readonly: 'false', required: 'true' } diff --git a/src/templates/modalconfig/modalform/index.jsx b/src/templates/modalconfig/modalform/index.jsx index 8c2d523..49ab211 100644 --- a/src/templates/modalconfig/modalform/index.jsx +++ b/src/templates/modalconfig/modalform/index.jsx @@ -32,7 +32,7 @@ } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮 _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] } else if (type === 'number') { - _options = [..._options, 'decimal'] + _options = [..._options, 'decimal', 'min', 'max'] } else if (type === 'fileupload') { _options = ['label', 'field', 'type', 'readonly', 'required'] } @@ -88,7 +88,7 @@ } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮 _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] } else if (value === 'number') { - _options = [..._options, 'decimal'] + _options = [..._options, 'decimal', 'min', 'max'] } else if (value === 'fileupload') { _options = ['label', 'field', 'type', 'readonly', 'required'] } @@ -178,8 +178,8 @@ let rules = [] if (item.key === 'field') { rules = [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' @@ -223,7 +223,7 @@ <Col span={12} key={index}> <Form.Item label={item.label}> {getFieldDecorator(item.key, { - initialValue: item.initVal || 0, + initialValue: item.initVal, rules: [ { required: !!item.required, @@ -337,21 +337,29 @@ } if (emptys.length > 0) { isvalid = false + notification.warning({ + top: 92, + message: this.props.dict['header.form.selectItem.error'], + duration: 10 + }) } } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') { values.options = [] } else if (values.type === 'funcvar') { // 鍑芥暟鍙橀噺涓哄彧璇诲厓绱� values.readonly = 'true' + } else if (values.type === 'number' && (values.min || values.min === 0) && (values.max || values.max === 0)) { // 鏁板�煎瀷楠岃瘉鏈�灏忔渶澶у�� + if (values.min > values.max) { + isvalid = false + notification.warning({ + top: 92, + message: '鏈�灏忓�间笉鍙ぇ浜庢渶澶у�硷紒', + duration: 10 + }) + } } if (isvalid) { resolve(values) - } else { - notification.warning({ - top: 92, - message: this.props.dict['header.form.selectItem.error'], - duration: 10 - }) } } else { reject(err) diff --git a/src/templates/modalconfig/source.jsx b/src/templates/modalconfig/source.jsx index cc4a213..a3335c8 100644 --- a/src/templates/modalconfig/source.jsx +++ b/src/templates/modalconfig/source.jsx @@ -36,6 +36,9 @@ valueText: '', orderBy: '', orderType: 'asc', + decimal: 0, + min: '', + max: '', readonly: 'false', required: 'false' }, { @@ -54,6 +57,9 @@ valueText: '', orderBy: '', orderType: 'asc', + decimal: 0, + min: '', + max: '', readonly: 'false', required: 'false' }, { @@ -72,6 +78,9 @@ valueText: '', orderBy: '', orderType: 'asc', + decimal: 0, + min: '', + max: '', readonly: 'false', required: 'false' } diff --git a/src/templates/modalviewconfig/index.jsx b/src/templates/modalviewconfig/index.jsx index cf9bfdc..0e46a74 100644 --- a/src/templates/modalviewconfig/index.jsx +++ b/src/templates/modalviewconfig/index.jsx @@ -367,8 +367,8 @@ tooltipClass: 'middle', required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' @@ -814,8 +814,8 @@ initVal: card.field, required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index bc0d1be..bace997 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -319,8 +319,8 @@ tooltipClass: 'middle', required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' @@ -739,8 +739,8 @@ initVal: card.field, required: true, rules: [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' }, { max: 50, message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' -- Gitblit v1.8.0