From f068c617b918fc7817c11724424cb1a9149ec3a2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 09 一月 2020 16:51:10 +0800 Subject: [PATCH] 2020-01-09 --- src/templates/modalconfig/modalform/index.jsx | 74 +++++++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/templates/modalconfig/modalform/index.jsx b/src/templates/modalconfig/modalform/index.jsx index 49ab211..ff106e1 100644 --- a/src/templates/modalconfig/modalform/index.jsx +++ b/src/templates/modalconfig/modalform/index.jsx @@ -1,6 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber } from 'antd' +import { formRule } from '@/utils/option.js' import { dateOptions } from '@/utils/option.js' import EditTable from '../editable' import './index.scss' @@ -37,15 +38,11 @@ _options = ['label', 'field', 'type', 'readonly', 'required'] } - if (type === 'select' || type === 'link') { - _options.push('setAll') - } - - if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈� - _options = [..._options, 'linkField'] - } - - if (type === 'funcvar') { // 璁剧疆涓哄嚱鏁板彉閲忔椂锛屼笉闇�瑕佸叾浠栦俊鎭� + if (type === 'select') { + _options = [..._options, 'setAll', 'linkSubField'] + } else if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈� + _options = [..._options, 'setAll', 'linkField'] + } else if (type === 'funcvar') { // 璁剧疆涓哄嚱鏁板彉閲忔椂锛屼笉闇�瑕佸叾浠栦俊鎭� _options = ['label', 'field', 'type'] } @@ -93,15 +90,11 @@ _options = ['label', 'field', 'type', 'readonly', 'required'] } - if (value === 'select' || value === 'link') { - _options.push('setAll') - } - - if (value === 'link') { - _options = [..._options, 'linkField'] - } - - if (value === 'funcvar') { + if (value === 'select') { + _options = [..._options, 'setAll', 'linkSubField'] + } else if (value === 'link') { + _options = [..._options, 'setAll', 'linkField'] + } else if (value === 'funcvar') { _options = ['label', 'field', 'type'] } @@ -149,12 +142,10 @@ _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] } - if (openType === 'select' || openType === 'link') { - _options.push('setAll') - } - - if (openType === 'link') { - _options = [..._options, 'linkField'] + if (openType === 'select') { + _options = [..._options, 'setAll', 'linkSubField'] + } else if (openType === 'link') { + _options = [..._options, 'setAll', 'linkField'] } this.setState({ @@ -178,12 +169,19 @@ let rules = [] if (item.key === 'field') { rules = [{ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, - message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' + pattern: formRule.field.pattern, + message: formRule.field.message }, { - max: 50, - message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' + max: formRule.field.max, + message: formRule.field.maxMessage }] + } else { + rules = [ + { + max: formRule.input.max, + message: formRule.input.message + } + ] } fields.push( <Col span={12} key={index}> @@ -264,6 +262,26 @@ </Form.Item> </Col> ) + } else if (item.type === 'multiselect') { // 澶氶�� + fields.push( + <Col span={12} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.key, { + initialValue: item.initVal + })( + <Select + showSearch + mode="multiple" + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + > + {item.options.map(option => + <Select.Option id={option.uuid} key={option.uuid} value={option.field}>{option.label}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + ) } else if (item.type === 'radio') { fields.push( <Col span={12} key={index}> -- Gitblit v1.8.0