king
2022-04-26 5046d0d13dc6a8563b8e54e31913bc44cfa1072f
src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -94,17 +94,17 @@
]
const searchTypeOptions = {
  text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'inputType', 'advanced', 'query'],
  select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query'],
  multiselect: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query'],
  date: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  checkcard: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'resourceType', 'display', 'width', 'multiple', 'borderColor', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  dateweek: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  datemonth: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  daterange: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query'],
  group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'labelShow', 'query'],
  range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query']
  text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'inputType', 'advanced', 'query', 'labelwidth'],
  select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query', 'labelwidth'],
  multiselect: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query', 'labelwidth'],
  date: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'precision', 'labelwidth'],
  checkcard: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'resourceType', 'display', 'width', 'multiple', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  dateweek: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  datemonth: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  daterange: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'precision', 'labelwidth'],
  group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'labelShow', 'query', 'labelwidth'],
  range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth']
}
class MainSearch extends Component {
@@ -197,9 +197,9 @@
        }
      } else {
        if (this.record.resourceType === '0') {        // 自定义资源
          shows.push('options', 'fields', 'backgroundColor')
          shows.push('options', 'fields', 'backgroundColor', 'borderColor')
        } else if (this.record.resourceType === '1') { // 数据源
          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'backgroundColor')
          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'backgroundColor', 'borderColor')
        }
      }
      shows.push('linkField')
@@ -257,6 +257,7 @@
  }
  optionChange = (key, value) => {
    let oriType = this.record.type
    this.record[key] = value
    let _fieldval = {}
@@ -281,6 +282,9 @@
      if (value === 'checkcard') {
        this.record.multiple = 'false'
        _fieldval.multiple = 'false'
        _fieldval.ratio = 24
      } else if (oriType === 'checkcard') {
        _fieldval.ratio = 6
      }
      if (this.record.options.length > 0) {
@@ -385,6 +389,36 @@
    }
  }
  handleEmpty = () => {
    let field = this.props.form.getFieldValue('valueField')
    if (!field) {
      notification.warning({
        top: 92,
        message: '请填写值·字段。',
        duration: 5
      })
      return
    }
    let text = this.props.form.getFieldValue('valueText')
    if (!text) {
      notification.warning({
        top: 92,
        message: '请填写文本·字段。',
        duration: 5
      })
      return
    }
    let resource = this.props.form.getFieldValue('dataSource') || ''
    resource = `select '' as ${field},'全部' as ${text} union all \n${resource}`
    this.props.form.setFieldsValue({dataSource: resource})
  }
  getFields() {
    const { getFieldDecorator } = this.props.form
    const { dict } = this.props
@@ -398,9 +432,10 @@
      let rules = []
      let className = ''
      let content = null
      let extra = null
      let initVal = item.initVal || ''
      if (item.type === 'text') { // 文本搜索
      if (item.type === 'text') {
        let type = this.record.type
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
@@ -428,7 +463,7 @@
        initVal = item.initVal
        if (item.max) {
          content = <InputNumber min={item.min} max={item.max} precision={0} onPressEnter={this.handleSubmit}/>
          content = <InputNumber min={item.min} max={item.max} precision={item.precision || 0} onPressEnter={this.handleSubmit}/>
        } else {
          content = <InputNumber onPressEnter={this.handleSubmit}/>
        }
@@ -440,7 +475,7 @@
        content = <Select
          showSearch
          allowClear={item.allowClear === true}
          filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0}
          filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
          onChange={(value) => {this.optionChange(item.key, value)}}
          getPopupContainer={() => document.getElementById('commontable-search-form-box')}
        >
@@ -462,12 +497,16 @@
            )
          })}
        </Radio.Group>
      } else if (item.type === 'textarea') {
      } else if (item.type === 'codemirror') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
        ]
        span = 24
        className = 'text-area'
        if (this.record.type === 'select' || this.record.type === 'link') {
          extra = <span className="add-resource-empty" onClick={this.handleEmpty}>全部</span>
        }
        content = <CodeMirror />
      } else if (item.type === 'options') {
@@ -477,7 +516,7 @@
        let type = this.record.type
        
        if (type !== 'checkcard') {
          content = <EditTable type={type} transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/>
          content = <EditTable type={type} module="search" transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/>
        } else {
          if (this.record.linkField) {
            type = 'link'
@@ -514,7 +553,7 @@
      fields.push(
        <Col span={span} key={index}>
          <Form.Item className={className} label={item.tooltip ?
          <Form.Item className={className} extra={extra} label={item.tooltip ?
            <Tooltip placement="topLeft" title={item.tooltip}>
              <QuestionCircleOutlined className="mk-form-tip" />
              {item.label}