king
2020-02-22 592ff0aa0f2d45d143872b672a1468e268d3157f
src/templates/ushare/modalform/index.jsx
@@ -10,7 +10,8 @@
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object, // 字典项
    dict: PropTypes.object,    // 字典项
    optionLibs: PropTypes.any, // 自定义下拉集
    formlist: PropTypes.any,
    card: PropTypes.object
  }
@@ -23,6 +24,7 @@
  }
  UNSAFE_componentWillMount () {
    const { optionLibs } = this.props
    let formlist = JSON.parse(JSON.stringify(this.props.formlist))
    let type = ''
@@ -50,7 +52,7 @@
    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin'] // 默认显示项
    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 选择类型、自定义资源
      _options = [..._options, 'resourceType', 'options']
      _options = [..._options, 'resourceType', 'options', 'quick']
    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 选择类型、数据源
      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
    } else if (type === 'number') {
@@ -87,7 +89,16 @@
          form.type = 'number'
          form.initVal = form.initVal || 0
          form.required = true
        } else if (form.key === 'quick') {
          form.options = [...optionLibs.values()].filter(cell => cell.uuid !== this.props.card.uuid)
          form.options = form.options.map(cell => {
            return {
              value: cell.uuid,
              text: cell.label + '(' + cell.parname + ')'
            }
          })
        }
        form.show = _options.includes(form.key)
        return form
      })
@@ -108,11 +119,12 @@
  }
  openTypeChange = (key, value) => {
    if (key === 'type') {
      let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin']
      if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 选择类型、自定义资源
        _options = [..._options, 'resourceType', 'options']
        _options = [..._options, 'resourceType', 'options', 'quick']
      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 选择类型、数据源
        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
      } else if (value === 'number') {
@@ -180,6 +192,18 @@
          })
        })
      })
    } else if (key === 'quick') {
      let option = this.props.optionLibs.get(value)
      this.setState({
        formlist: this.state.formlist.map(form => {
          if (form.key === 'options') {
            form.initVal = option.options
          }
          return form
        })
      })
    }
  }
@@ -211,7 +235,7 @@
    if (key === 'resourceType') {
      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required', 'hidden', 'readin']
      if (value === '0') {
        _options = [..._options, 'options']
        _options = [..._options, 'options', 'quick']
      } else if (value === '1') {
        _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
      }