king
2020-05-12 d21470fe80e265cda2c355f636c3258eb0f56636
src/templates/sharecomponent/columncomponent/columnform/index.jsx
@@ -8,9 +8,9 @@
import './index.scss'
const columnTypeOptions = {
  text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist', 'linkmenu'],
  number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist', 'linkmenu'],
  textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist'],
  text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'color', 'fieldlength', 'blacklist', 'linkmenu'],
  number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'color', 'blacklist', 'linkmenu'],
  textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'color', 'fieldlength', 'blacklist'],
  picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale', 'maxHeight']
}
@@ -29,25 +29,24 @@
  }
  UNSAFE_componentWillMount () {
    let _type = this.props.formlist.filter(form => form.key === 'type')[0].initVal
    const { card } = this.props
    let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || ''
    let _options = JSON.parse(JSON.stringify(columnTypeOptions[_type]))
    let _options = JSON.parse(JSON.stringify(columnTypeOptions[card.type]))
    this.setState({
      menulist: _menulist.options || [],
      formlist: this.props.formlist.map(item => {
        item.hidden = !_options.includes(item.key)
        if (item.key === 'matchVal' && (_type === 'text' || _type === 'textarea')) {
          item.type = 'text'
        } else if (item.key === 'matchVal' && _type === 'number') {
          item.type = 'number'
        }
        return item
      })
    })
  }
  /**
   * @description 初次添加的显示列元素,聚焦提示文字
   */
  componentDidMount () {
    const { card } = this.props
@@ -64,38 +63,25 @@
  typeChange = (key, value) => {
    if (key === 'type') {
      let _options = JSON.parse(JSON.stringify(columnTypeOptions[value]))
      let fieldlength = 50
      if (value !== 'text') {
        fieldlength = 512
      }
      this.setState({
        formlist: this.props.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          if (item.key === 'matchVal' && (value === 'text' || value === 'textarea')) {
            item.type = 'text'
          } else if (item.key === 'matchVal' && value === 'number') {
            item.type = 'number'
            item.initVal = ''
            item.hidden = true
          } else if (item.key === 'fieldlength') {
            if (value === 'text') {
              item.initVal = 50
            } else {
              item.initVal = 512
            }
            item.hidden = true
          }
          return item
        })
      }, () => {
        this.setState({
          formlist: this.props.formlist.map(item => {
            if (item.key === 'matchVal' && value === 'number') {
              item.hidden = false
            } else if (item.key === 'fieldlength' && value !== 'number') {
              item.hidden = false
            }
            return item
          })
        })
        if (this.props.form.getFieldValue('fieldlength') !== undefined) {
          this.props.form.setFieldsValue({fieldlength: fieldlength})
        }
      })
    } else if (key === 'format' && value === 'percent') {
      this.props.form.setFieldsValue({postfix: '%'})
    }
  }
@@ -115,7 +101,7 @@
      if (item.type === 'text') { // 文本搜索
        let rules = []
        if (item.key === 'field') {
        if (item.key === 'field' || item.key === 'contrastField') {
          rules = [{
            pattern: formRule.field.pattern,
            message: formRule.field.message
@@ -167,7 +153,8 @@
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                ]
              })(<InputNumber min={item.min} max={item.max} precision={item.decimal} />)}
              })(item.unlimit ? <InputNumber /> :
                  <InputNumber min={item.min} max={item.max} precision={item.decimal} />)}
            </Form.Item>
          </Col>
        )
@@ -327,6 +314,7 @@
        if (!err) {
          values.id = this.props.card.id
          values.uuid = this.props.card.uuid
          values.marks = this.props.card.marks || ''
          
          if ((values.type === 'text' || values.type === 'number') && values.linkmenu && values.linkmenu.length > 0) {
            let linkThdMenu = ''