From 75347779d54c3c8a0893166dbb9c03bc06ea1eee Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 21 十二月 2019 16:58:31 +0800 Subject: [PATCH] 2019-12-21 --- src/tabviews/commontable/mainSearch/index.jsx | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/tabviews/commontable/mainSearch/index.jsx b/src/tabviews/commontable/mainSearch/index.jsx index 78ff563..e65725f 100644 --- a/src/tabviews/commontable/mainSearch/index.jsx +++ b/src/tabviews/commontable/mainSearch/index.jsx @@ -14,26 +14,39 @@ 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}> @@ -186,7 +199,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -197,7 +210,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -208,7 +221,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -219,14 +232,14 @@ } 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] }) -- Gitblit v1.8.0