king
2019-11-24 7d206112a4ca1930639907a7cb131d0c1e6525a6
src/tabviews/commontable/mainSearch/index.jsx
File was renamed from src/tabviews/commontable/modules/mainSearch/index.jsx
@@ -23,21 +23,22 @@
  }
  UNSAFE_componentWillMount () {
    let formats = {}
    let match = {}
    this.props.searchlist.forEach(item => {
      if (item.Type === 'date') {
        // formats[item.FieldName] = dateFormat
        formats[item.FieldName] = weekFormat
      } else if (item.ID === 'WHE1400200905') {
        formats[item.FieldName] = monthFormat
      }
      match[item.FieldName] = item.Op
    })
    this.setState({
      formats: formats,
      match: match
    })
    console.log(this.props.searchlist)
    // let formats = {}
    // let match = {}
    // this.props.searchlist.forEach(item => {
    //   if (item.Type === 'date') {
    //     // formats[item.FieldName] = dateFormat
    //     formats[item.FieldName] = weekFormat
    //   } else if (item.ID === 'WHE1400200905') {
    //     formats[item.FieldName] = monthFormat
    //   }
    //   match[item.FieldName] = item.Op
    // })
    // this.setState({
    //   formats: formats,
    //   match: match
    // })
  }
  // shouldComponentUpdate (nextProps, nextState) {
@@ -48,39 +49,39 @@
    const { getFieldDecorator } = this.props.form
    const fields = []
    this.props.searchlist.forEach((item, index) => {
      if (item.Type === 'text' || item.Type === 'string') { // 文本搜索
      if (item.type === 'text') { // 文本搜索
        fields.push(
          <Col span={6} key={index}>
            <Form.Item label={item.Label}>
              {getFieldDecorator(item.FieldName)(<Input placeholder="" autoComplete="off" />)}
            <Form.Item label={item.label}>
              {getFieldDecorator(item.field, {initialValue: item.initval })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
        )
      } else if (item.Type === 'select') { // 下拉搜索
      } else if (item.type === 'select') { // 下拉搜索
        fields.push(
          <Col span={6} key={index}>
            <Form.Item label={item.Label}>
              {getFieldDecorator(item.FieldName, {initialValue: item.DynOptions[0].id })(
            <Form.Item label={item.label}>
              {getFieldDecorator(item.field, {initialValue: item.initval })(
                <Select
                  showSearch
                  onChange={(val) => {this.selectChange(item.FieldName, val)}}
                  onChange={(val) => {this.selectChange(item.field, val)}}
                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                >
                  {item.DynOptions.map(option =>
                    <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option>
                  {item.options.map(option =>
                    <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option>
                  )}
                </Select>
              )}
            </Form.Item>
          </Col>
        )
      } else if (item.Type === 'date') { // 时间搜索
      } else if (item.type === 'date') { // 时间搜索
        if (item.ID === 'WHE14002009024') {
          fields.push(
            <Col span={6} key={index}>
              <Form.Item label={item.Label}>
                {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09-14', dateFormat) })(
                  <DatePicker format={dateFormat} onChange={(val) => {this.timeChange(item.FieldName, val)}} />
              <Form.Item label={item.label}>
                {getFieldDecorator(item.field, {initialValue: moment('2019-09-14', dateFormat) })(
                  <DatePicker format={dateFormat} onChange={(val) => {this.timeChange(item.field, val)}} />
                )}
              </Form.Item>
            </Col>
@@ -88,8 +89,8 @@
        } else if (item.ID === 'WHE1400200905') {
          fields.push(
            <Col span={6} key={index}>
              <Form.Item label={item.Label}>
                {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09', monthFormat) })(
              <Form.Item label={item.label}>
                {getFieldDecorator(item.field, {initialValue: moment('2019-09', monthFormat) })(
                  <MonthPicker format={monthFormat} onChange={(val) => {this.timeChange(item.FieldName, val)}} />
                )}
              </Form.Item>