king
2020-01-09 f068c617b918fc7817c11724424cb1a9149ec3a2
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}>