king
2020-02-22 592ff0aa0f2d45d143872b672a1468e268d3157f
src/templates/tableshare/searchform/index.jsx
@@ -9,9 +9,10 @@
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object,  // 字典项
    formlist: PropTypes.any, // 表单
    card: PropTypes.object   // 搜索条件信息
    dict: PropTypes.object,    // 字典项
    formlist: PropTypes.any,   // 表单
    optionLibs: PropTypes.any, // 自定义下拉集
    card: PropTypes.object     // 搜索条件信息
  }
  state = {
@@ -26,14 +27,14 @@
   * 2、下拉选择,根据数据源类型显示相关配置
   */
  UNSAFE_componentWillMount () {
    const { formlist } = this.props
    const { formlist, optionLibs } = this.props
    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', 'match']                // 默认显示项
    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
      _options = [..._options, 'resourceType', 'options', 'display']
      _options = [..._options, 'resourceType', 'options', 'display', 'quick']
    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display', 'database']
    }
@@ -68,6 +69,14 @@
          } else if (type === 'dateweek' || type === 'daterange') {
            form.options = matchReg.daterange
          }
        } 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.hidden = !_options.includes(form.key)
        return form
@@ -98,7 +107,7 @@
      let _options = ['label', 'field', 'initval', 'type', 'match']
      if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
        _options = [..._options, 'resourceType', 'options', 'display']
        _options = [..._options, 'resourceType', 'options', 'display', 'quick']
      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display', 'database']
      }
@@ -157,6 +166,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
        })
      })
    }
  }
@@ -171,7 +192,7 @@
      let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display']
      if (value === '0') {
        _options = [..._options, 'options']
        _options = [..._options, 'options', 'quick']
      } else if (value === '1') {
        _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
      }