| | |
| | | |
| | | state = { |
| | | match: null, // 搜索条件匹配规则 |
| | | style: null |
| | | style: null, |
| | | searchlist: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let match = {} |
| | | let style = {} |
| | | let _list = [] |
| | | let fieldMap = new Map() |
| | | |
| | | this.props.searchlist.forEach(item => { |
| | | if (fieldMap.has(item.field)) { |
| | | item.field = item.field + '@tail@' |
| | | } |
| | | fieldMap.set(item.field, true) |
| | | |
| | | match[item.field] = item.match |
| | | style[item.field] = item.type |
| | | |
| | | _list.push(item) |
| | | }) |
| | | |
| | | this.setState({ |
| | | match: match, |
| | | style: style |
| | | style: style, |
| | | searchlist: _list |
| | | }) |
| | | } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.props.searchlist.forEach((item, index) => { |
| | | this.state.searchlist.forEach((item, index) => { |
| | | if (item.type === 'text') { // 文本搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | | } else { |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: values[key].replace(/(^\s*|\s*$)/ig, ''), |
| | | match: this.state.match[key] |
| | | }) |