From f36141f3075edf9d41928d64f759ad6bd1b1ac60 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 七月 2020 17:43:34 +0800 Subject: [PATCH] 2020-07-14 --- src/templates/sharecomponent/searchcomponent/index.jsx | 63 ++++++++++++++++++++++++++----- 1 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx index c0cdff2..d8855cd 100644 --- a/src/templates/sharecomponent/searchcomponent/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/index.jsx @@ -16,7 +16,6 @@ const { confirm } = Modal -// **鎮茶鑰呭線寰�姝g‘锛屼箰瑙傝�呭線寰�鎴愬姛 class SearchComponent extends Component { static propTpyes = { menu: PropTypes.object, // 褰撳墠鑿滃崟淇℃伅 @@ -28,7 +27,7 @@ } state = { - dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, + dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, searchlist: null, // 鎼滅储鏉′欢闆� sqlVerifing: false, // sql楠岃瘉涓� visible: false, // 妯℃�佹鎺у埗 @@ -54,7 +53,7 @@ this.setState({searchlist: [...searchlist, nextProps.pasteContent]}) this.handleSearch(nextProps.pasteContent) } else if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) { - this.setState({searchlist: nextProps.config.search}) + this.setState({searchlist: fromJS(nextProps.config.search).toJS()}) } } @@ -68,8 +67,9 @@ this.setState({searchlist: list}) this.handleSearch(card) } else { - this.setState({searchlist: list}) - this.props.updatesearch({...config, search: list}) + this.setState({searchlist: list}, ()=> { + this.props.updatesearch({...config, search: list}) + }) } } @@ -77,10 +77,22 @@ * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� */ handleSearch = (card) => { + const { searchlist } = this.state + let linkableFields = [] + + searchlist.forEach(item => { + if (item.uuid !== card.uuid && (item.type === 'select' || item.type === 'link')) { + linkableFields.push({ + value: item.field, + text: item.label + }) + } + }) + this.setState({ visible: true, card: card, - formlist: getSearchForm(card, this.props.sysRoles) + formlist: getSearchForm(card, this.props.sysRoles, linkableFields) }) } @@ -127,7 +139,27 @@ _searchlist = _searchlist.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴� if (item.uuid !== res.uuid && res.field && item.field) { - if (item.field === res.field) { + let itemFields = [] + if (item.type === 'text') { + itemFields = item.field.split(',') + } else if (item.type === 'group') { + itemFields = [item.field, item.datefield] + } else { + itemFields = [item.field] + } + + let resFields = [] + if (res.type === 'text') { + resFields = res.field.split(',') + } else if (res.type === 'group') { + resFields = [res.field, res.datefield] + } else { + resFields = [res.field] + } + + let setFields = Array.from(new Set([...itemFields, ...resFields])) + + if (setFields.length < itemFields.length + resFields.length && (res.type !== 'date' || item.type !== 'date')) { fieldrepet = true } else if (item.label === res.label) { labelrepet = true @@ -176,6 +208,9 @@ func: 's_debug_sql', LText: res.dataSource } + + param.LText = param.LText.replace(/@\$|\$@/ig, '') + param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) @@ -190,8 +225,9 @@ sqlVerifing: false, searchlist: _searchlist, visible: false + }, ()=> { + this.props.updatesearch({...config, search: _searchlist}, optionLibs) }) - this.props.updatesearch({...config, search: _searchlist}, optionLibs) } else { this.setState({sqlVerifing: false}) @@ -204,8 +240,9 @@ this.setState({ searchlist: _searchlist, visible: false + }, ()=> { + this.props.updatesearch({...config, search: _searchlist}, optionLibs) }) - this.props.updatesearch({...config, search: _searchlist}, optionLibs) } }) } @@ -221,7 +258,7 @@ confirm({ content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋, okText: dict['model.confirm'], - cancelText: this.state.dict['header.cancel'], + cancelText: this.state.dict['model.cancel'], onOk() { let _searchlist = fromJS(_this.state.searchlist).toJS() @@ -246,6 +283,10 @@ } } + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + render() { const { dict, searchlist, visible, sqlVerifing, card } = this.state @@ -265,7 +306,7 @@ <Modal title={dict['model.searchCriteria'] + '-' + (card && card.copyType === 'search' ? dict['model.copy'] : dict['model.edit'])} visible={visible} - width={750} + width={850} maskClosable={false} onOk={this.handleSubmit} confirmLoading={sqlVerifing} -- Gitblit v1.8.0