king
2020-02-10 b70376bd370f83e0087e629b664243f3a4bf191c
src/templates/ushare/modalform/index.jsx
@@ -18,14 +18,35 @@
  state = {
    openType: null,
    resourceType: null,
    formlist: null
    formlist: null,
    linkSubFields: null
  }
  UNSAFE_componentWillMount () {
    let formlist = JSON.parse(JSON.stringify(this.props.formlist))
    let type = formlist.filter(cell => cell.key === 'type')[0].initVal
    let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
    let type = ''
    let resourceType = ''
    let linkSubFields = []
    formlist.forEach(cell => {
      if (cell.key === 'type') {
        type = cell.initVal
      } else if (cell.key === 'resourceType') {
        resourceType = cell.initVal
      } else if (cell.key === 'linkSubField') {
        let arr = []
        linkSubFields = cell.options.filter(option => {
          if (!['Value', 'Text'].includes(option.field) && cell.initVal.includes(option.field) && !arr.includes(option.field)) {
            arr.push(option.field)
            return true
          } else {
            return false
          }
        })
      }
    })
    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin'] // 默认显示项
    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 选择类型、自定义资源
@@ -51,10 +72,11 @@
    } else if (type === 'linkMain') {
      _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength']
    }
    this.setState({
      openType: type,
      resourceType: resourceType,
      linkSubFields: linkSubFields,
      formlist: formlist.map(form => {
        if (dateOptions.hasOwnProperty(type) && form.key === 'initval') {
          form.options = dateOptions[type]
@@ -137,6 +159,8 @@
            form.show = false
          } else if (form.key === 'resourceType') {
            form.initVal = this.state.resourceType
          } else if (form.key === 'linkSubField') {
            form.initVal = this.state.linkSubFields.map(_field => _field.field)
          }
          return form
        })
@@ -157,11 +181,18 @@
  multiselectChange = (key, value, options) => {
    if (key === 'linkSubField') {
      let arr = []
      let linkSubFields = options.filter(option => {
        if (!['Value', 'Text'].includes(option.field) && value.includes(option.field) && !arr.includes(option.field)) {
          arr.push(option.field)
          return true
        } else {
          return false
        }
      })
      this.setState({linkSubFields: linkSubFields})
    }
    console.log(key)
    console.log(value)
    console.log(options)
  }
  onChange = (e, key) => {
@@ -384,7 +415,7 @@
      } else if (item.type === 'options') {
        fields.push(
          <Col span={20} offset={4} key={index}>
            <EditTable data={item.initVal} type={this.state.openType} ref="editTable"/>
            <EditTable data={item.initVal} type={this.state.openType} linkSubFields={this.state.linkSubFields} ref="editTable"/>
          </Col>
        )
      }