king
2023-05-09 7b0dbecd1d6155d26ec67be0a47a16264c738c85
src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -104,12 +104,13 @@
  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'],
  switch: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'openText', 'closeText', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  check: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'checkTip', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
  range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth']
}
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object,     // 字典项
    formlist: PropTypes.any,    // 表单
    card: PropTypes.object,     // 搜索条件信息
    inputSubmit: PropTypes.any  // 回车提交事件
@@ -199,7 +200,7 @@
        if (this.record.resourceType === '0') {        // 自定义资源
          shows.push('options', 'fields')
        } else if (this.record.resourceType === '1') { // 数据源
          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database')
          shows.push('dataSource', 'cardValField', 'colorField', 'fields', 'orderBy', 'orderType', 'database')
        }
      } else {
        reRequired.fields = true
@@ -227,22 +228,24 @@
    }
    if (type === 'text') {
      reOptions.match = matchReg.text
      reOptions.match = matchReg.class1
    } else if (type === 'multiselect') {
      reOptions.match = matchReg.multiselect
      reOptions.match = matchReg.class3
    } else if (type === 'select' || type === 'link') {
      reOptions.match = matchReg.select
      reOptions.match = matchReg.class1
    } else if (type === 'switch' || type === 'check') {
      reOptions.match = matchReg.class2
    } else if (type === 'date') {
      reOptions.match = matchReg.date
      reOptions.match = matchReg.class4
    } else if (type === 'datemonth') {
      reOptions.match = matchReg.datemonth
      reOptions.match = matchReg.class5
    } else if (type === 'dateweek' || type === 'daterange' || type === 'range') {
      reOptions.match = matchReg.daterange
      reOptions.match = matchReg.class5
    } else if (type === 'checkcard') {
      if (this.record.multiple === 'false') {
        reOptions.match = matchReg.select
        reOptions.match = matchReg.class1
      } else if (this.record.multiple === 'true') {
        reOptions.match = matchReg.multiselect
        reOptions.match = matchReg.class3
      }
    }
@@ -267,7 +270,6 @@
  }
  optionChange = (key, value) => {
    let oriType = this.record.type
    this.record[key] = value
    let _fieldval = {}
@@ -292,9 +294,6 @@
      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) {
@@ -424,7 +423,11 @@
    let resource = this.props.form.getFieldValue('dataSource') || ''
    resource = `select '' as ${field},'全部' as ${text} union all \n${resource}`
    if (field === text) {
      resource = `select '' as ${field} union all \n${resource}`
    } else {
      resource = `select '' as ${field},'全部' as ${text} union all \n${resource}`
    }
    this.props.form.setFieldsValue({dataSource: resource})
  }
@@ -437,7 +440,6 @@
  getFields() {
    const { getFieldDecorator } = this.props.form
    const { dict } = this.props
    const { formlist } = this.state
    const fields = []
    
@@ -454,7 +456,7 @@
      if (item.type === 'text') {
        let type = this.record.type
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        if (item.key === 'field' || item.key === 'datefield') {
          rules.push({
@@ -487,7 +489,7 @@
        }
      } else if (item.type === 'number') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        initVal = item.initVal
@@ -498,7 +500,7 @@
        }
      } else if (item.type === 'select') { // 下拉搜索
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Select
@@ -516,7 +518,7 @@
        </Select>
      } else if (item.type === 'radio') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.optionChange(item.key, e.target.value)}}>
@@ -528,7 +530,7 @@
        </Radio.Group>
      } else if (item.type === 'codemirror') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        span = 24
        className = 'text-area'
@@ -550,7 +552,7 @@
          if (this.record.linkField) {
            type = 'link'
          }
          content = <DataTable dict={dict} type={type} display={this.record.display} linkSubFields={[]} transfield={{}} fields={this.record.fields || []} onChange={this.changeOptions}/>
          content = <DataTable type={type} display={this.record.display} linkSubFields={[]} transfield={{}} fields={this.record.fields || []} onChange={this.changeOptions}/>
        }
      } else if (item.type === 'fields') {
        span = 24
@@ -560,10 +562,10 @@
          { required: item.required, message: '请添加' + item.label + '!' }
        ]
        content = <FieldsTable dict={dict} onChange={this.changeField}/>
        content = <FieldsTable onChange={this.changeField}/>
      } else if (item.type === 'checkbox') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Checkbox.Group style={{width: '105%'}} options={item.options} onChange={(values) => this.optionChange(item.key, values)}/>
@@ -582,7 +584,7 @@
      } else if (item.type === 'color') {
        className = 'color-form-item'
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        
        content = <ColorSketch allowClear={true}/>
@@ -740,6 +742,8 @@
              })
              return
            }
          } else if (values.type === 'switch' || values.type === 'check') {
            values.initval = values.initval === values.openVal ? values.openVal : values.closeVal
          }
          ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {