king
2019-12-31 46f59e30133c25f1f01074b1c92445f9e85b8c98
src/templates/tableshare/searchform/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd'
import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip } from 'antd'
import { dateOptions, matchReg } from '@/utils/option.js'
import EditTable from '../editable'
import './index.scss'
@@ -32,10 +32,14 @@
    let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
    let _options = ['label', 'field', 'initval', 'type', 'match']                // 默认显示项
    if ((type === 'select' || type === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
      _options = [..._options, 'resourceType', 'setAll', 'options', 'display']
    } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
      _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
      _options = [..._options, 'resourceType', 'options', 'display']
    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
    }
    if (type === 'select' || type === 'link') {
      _options.push('setAll')
    }
    if (type === 'link') { // 关联类型、增加关联上级的字段名
@@ -55,7 +59,7 @@
        if (form.key === 'match') {
          if (type === 'text') {
            form.options = matchReg.text
          } else if (type === 'select' || type === 'link') {
          } else if (type === 'multiselect' || type === 'select' || type === 'link') {
            form.options = matchReg.select
          } else if (type === 'date') {
            form.options = matchReg.date
@@ -71,6 +75,19 @@
    })
  }
  componentDidMount () {
    const { card } = this.props
    if (card.focus) {
      try {
        let _form = document.getElementById('label')
        _form.select()
      } catch {
        console.warn('表单focus失败!')
      }
    }
  }
  /**
   * @description 搜索条件类型切换
   */
@@ -80,10 +97,14 @@
    if (key === 'type') {
      let _options = ['label', 'field', 'initval', 'type', 'match']
      if ((value === 'select' || value === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
        _options = [..._options, 'resourceType', 'setAll', 'options', 'display']
      } else if ((value === 'select' || value === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
        _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
      if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '0') {        // 下拉选择类型、选项为自定义资源
        _options = [..._options, 'resourceType', 'options', 'display']
      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取
        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
      }
      if (value === 'select' || value === 'link') {
        _options.push('setAll')
      }
      
      if (value === 'link') {
@@ -107,7 +128,7 @@
          } else if (form.key === 'match') {                     // 搜索条件类型切换时,匹配规则类型对应切换
            if (value === 'text') {
              form.options = matchReg.text
            } else if (value === 'select' || value === 'link') {
            } else if (value === 'multiselect' || value === 'select' || value === 'link') {
              form.options = matchReg.select
            } else if (value === 'date') {
              form.options = matchReg.date
@@ -147,12 +168,16 @@
    let value = e.target.value
    if (key === 'resourceType') {
      let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'setAll', 'display']
      let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display']
      if (value === '0') {
        _options = [..._options, 'options']
      } else if (value === '1') {
        _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
      }
      if (openType === 'select' || openType === 'link') {
        _options.push('setAll')
      }
      
      if (openType === 'link') {
@@ -176,16 +201,23 @@
      if (item.hidden) return
      if (item.type === 'text') { // 文本搜索
        let rules = item.rules || []
        fields.push(
          <Col span={12} key={index}>
            <Form.Item label={item.label}>
            <Form.Item label={item.tooltip ?
              <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}>
                <Icon type="question-circle" />
                {item.label}
              </Tooltip> : item.label
            }>
              {getFieldDecorator(item.key, {
                initialValue: item.initVal || '',
                rules: [
                  {
                    required: !!item.required,
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                  },
                  ...rules
                ]
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)}
            </Form.Item>