From f0bf8c399c354c22227f8f1a76ed806098db59c0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:51:02 +0800 Subject: [PATCH] 2024-05-21 --- src/tabviews/zshare/topSearch/index.jsx | 88 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 4e6d329..0e1c29d 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -42,7 +42,7 @@ sign = '' UNSAFE_componentWillMount () { - const { config, BID } = this.props + const { config } = this.props let _searchlist = [] let fieldMap = new Map() @@ -54,6 +54,7 @@ let record = {} let forbid = false // header涓笉璁剧疆楂樼骇鎼滅储 let _setting = {showAdv: false, show: false, style: null} + let BID = this.props.BID if (config.wrap) { _setting.show = config.wrap.show !== 'false' @@ -66,6 +67,15 @@ _setting.wrapperCol = {style: {width: (100 - _setting.labelwidth) + '%'}} _setting.borderRadius = config.wrap.borderRadius _setting.resetContrl = config.wrap.resetContrl || 'init' + + if (config.wrap.searchBtn === 'show') { + _setting.showBtn = true + } + + if (config.wrap.supModule) { + let BData = window.GLOB.CacheData.get(config.wrap.supModule) + BID = BData ? (BData.$BID || '') : '' + } } if (config.type === 'search') { @@ -178,20 +188,21 @@ // 鏁版嵁婧愭煡璇㈣鍙� if (item.resourceType === '1' && item.dataSource) { let _option = Utils.getSelectQueryOptions(item) + let _declare = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` let exec = true if (item.checkBid) { - item.sql = _option.sql + item.sql = _declare + _option.sql item.arr_field = _option.field exec = !!BID } if (exec) { - _option.sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`) + let _sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`) if (window.GLOB.debugger === true) { - console.info(_option.sql) + console.info(_declare + _sql) } // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 @@ -199,13 +210,20 @@ deForms.push({ ...item, arr_field: _option.field, - data_sql: Utils.formatOptions(_option.sql, window.GLOB.execType) + data_sql: Utils.formatOptions(_declare + _sql, window.GLOB.execType) }) } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 + _sql = _sql.replace(/%/ig, ' mpercent ') if (item.database === 'sso') { - mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`) + if (mainItems.length === 0) { + _sql = _declare + _sql + } + mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) } else { - localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`) + if (localItems.length === 0) { + _sql = _declare + _sql + } + localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) } } } @@ -278,19 +296,42 @@ searchlist: _list }, () => { if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { - this.improveSimpleSearch(deForms, false) + this.improveSimpleSearch(deForms, false, null, BID) } else if (mainItems.length > 0 || localItems.length > 0) { - this.improveSearch(mainItems, localItems) + this.improveSearch(mainItems, localItems, BID) } }) + } + + componentDidMount () { + const { config } = this.props + + if (config.type === 'search' && config.wrap.supModule) { + MKEmitter.addListener('resetSelectLine', this.resetParentParam) + } + } + + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) } UNSAFE_componentWillReceiveProps(nextProps) { const { config, BID } = this.props - if (config.checkBid && nextProps.BID !== BID) { + if (config.checkBid && config.type !== 'search' && nextProps.BID !== BID) { this.resetOptions(nextProps.BID) } + } + + resetParentParam = (MenuID, id) => { + const { config } = this.props + + if (config.wrap.supModule !== MenuID) return + + this.resetOptions(id) } resetOptions = (BID) => { @@ -346,7 +387,7 @@ }) if (deForms.length > 0) { - this.improveSimpleSearch(deForms, true, searchlist) + this.improveSimpleSearch(deForms, true, searchlist, BID) } else { this.setState({ searchlist: searchlist @@ -391,8 +432,7 @@ } // 鏌ヨ涓嬫媺鑿滃崟 - improveSearch = (mainItems, localItems) => { - const { BID } = this.props + improveSearch = (mainItems, localItems, BID) => { let deffers = [] // 鏈湴璇锋眰 @@ -495,7 +535,7 @@ } // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 - improveSimpleSearch = (deForms, trigger, searchlist) => { + improveSimpleSearch = (deForms, trigger, searchlist, BID) => { if (deForms.length === 0) return let deffers = deForms.map((item, index) => { @@ -506,8 +546,8 @@ arr_field: item.arr_field } - if (this.props.BID) { - param.BID = this.props.BID + if (BID) { + param.BID = BID } if (window.GLOB.execType === 'x') { @@ -569,11 +609,11 @@ } if (item.linkField) { - _item.ParentID = cell[item.linkField] + _item.ParentID = cell[item.linkField] + '' } if (item.type !== 'checkcard') { - _item.Value = cell[item.valueField] + _item.Value = cell[item.valueField] + '' _item.Text = cell[item.valueText] + '' if (map.has(_item.ParentID + _item.Value)) return @@ -588,7 +628,7 @@ map.set(_item.ParentID + _item.Value, 0) } else { - _item.$value = cell[item.cardValField] + _item.$value = cell[item.cardValField] + '' _item = {..._item, ...cell} if (item.urlField) { @@ -761,6 +801,16 @@ </Form.Item> </Col> ) + } else if (setting.showBtn) { + fields.push( + <Col className="mk-search-col search-button" key="actions"> + <Form.Item> + <Button type="primary" onClick={this.handleSubmit}> + 鎼滅储 + </Button> + </Form.Item> + </Col> + ) } return fields -- Gitblit v1.8.0