king
2020-01-07 45466976d272c7b406b0e3d8b8fba92f3eb20524
src/templates/modalconfig/modalform/index.jsx
@@ -11,7 +11,8 @@
  static propTpyes = {
    dict: PropTypes.object, // 字典项
    formlist: PropTypes.any,
    card: PropTypes.object
    card: PropTypes.object,
    billCodes: PropTypes.array
  }
  state = {
@@ -22,7 +23,7 @@
  UNSAFE_componentWillMount () {
    let formlist = JSON.parse(JSON.stringify(this.props.formlist))
    console.log(formlist)
    let type = formlist.filter(cell => cell.key === 'type')[0].initVal
    let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required'] // 默认显示项
@@ -43,6 +44,10 @@
    if (type === 'link') { // 关联类型、增加关联字段
      _options = [..._options, 'linkField']
    }
    console.log(type)
    if (type === 'funcvar') {
      _options = ['label', 'field', 'linkfield']
    }
    
    this.setState({
@@ -96,6 +101,10 @@
      if (value === 'link') {
        _options = [..._options, 'linkField']
      }
      if (value === 'funcvar') {
        _options = ['label', 'field', 'linkfield']
      }
      
      this.setState({
        openType: value,
@@ -120,7 +129,7 @@
      }, () => {
        this.setState({
          formlist: this.state.formlist.map(form => {
            if (form.key === 'initval' && value !== 'fileupload') {
            if (form.key === 'initval' && value !== 'fileupload' && value !== 'funcvar') {
              form.hidden = false
            }
            return form
@@ -167,6 +176,16 @@
      if (item.hidden) return
      if (item.type === 'text') { // 文本搜索
        let rules = []
        if (item.key === 'field') {
          rules = [{
            pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig,
            message: '字段名只允许包含数字、字母、汉字以及_'
          }, {
            max: 50,
            message: '字段名最多50个字符!'
          }]
        }
        fields.push(
          <Col span={12} key={index}>
            <Form.Item label={item.label}>
@@ -176,7 +195,8 @@
                  {
                    required: !!item.required,
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                  },
                  ...rules
                ]
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)}
            </Form.Item>
@@ -305,7 +325,6 @@
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          let isvalid = true
          values.id = this.props.card.id
          values.uuid = this.props.card.uuid
          // 下拉菜单或关联菜单
          if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
@@ -324,6 +343,10 @@
            values.options = []
          }
          if (!values.type) {
            values.type = 'funcvar'
            values.readonly = 'true'
          }
          if (isvalid) {
            resolve(values)
          } else {