From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 八月 2023 16:22:15 +0800 Subject: [PATCH] 2023-08-17 --- src/tabviews/zshare/topSearch/index.jsx | 61 +++++++++++++++++------------- 1 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index a92e5cb..11d86ec 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -7,10 +7,10 @@ import md5 from 'md5' import Api from '@/api' -import options from '@/store/options.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' import MKInput from './mkInput' import './index.scss' @@ -18,6 +18,7 @@ const MKCheckCard = asyncComponent(() => import('./mkCheckCard')) const MKCheck = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheck')) const MKSwitch = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkSwitch')) +const MKRadio = asyncComponent(() => import('./mkRadio')) const MKSelect = asyncComponent(() => import('./mkSelect')) const DateGroup = asyncComponent(() => import('./dategroup')) const MKDatePicker = asyncComponent(() => import('./mkDatePicker')) @@ -25,8 +26,7 @@ class MainSearch extends Component { static propTpyes = { BID: PropTypes.any, // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤� - config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�) - refreshdata: PropTypes.func // 鍒锋柊鏁版嵁 + config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 } state = { @@ -51,8 +51,6 @@ let advanceValues = [] let linkFields = {} let record = {} - let hasReqFields = false - let forbid = false // header涓笉璁剧疆楂樼骇鎼滅储 let _setting = {showAdv: false, show: false, style: null} @@ -114,10 +112,6 @@ item.field = item.field + '@tail@' } - if (item.required) { - hasReqFields = true - } - if (item.advanced && !forbid) { _setting.showAdv = true } else { @@ -133,7 +127,9 @@ val = val + ':00' } } - advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + if (['text', 'date', 'datemonth', 'dateweek', 'daterange'].includes(item.type)) { + advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + } } if (item.type === 'group') { @@ -143,7 +139,7 @@ record[item.field] = item.initval } - if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type)) { + if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(item.type)) { item.options = item.options || [] item.options = item.options.filter(op => !op.Hide) if (item.setAll === 'true' && ['select', 'link'].includes(item.type)) { @@ -157,17 +153,14 @@ // 鏁版嵁婧愭煡璇㈣鍙� if (item.resourceType === '1' && item.dataSource) { - if (item.multiple === 'dropdown') { - item.parentField = 'pid' - } let _option = Utils.getSelectQueryOptions(item) - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { + if (window.GLOB.debugger === true) { console.info(_option.sql) } // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (!window.GLOB.mkHS && options.sysType === 'local' && !window.GLOB.systemType) { + if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) { deForms.push({ ...item, arr_field: _option.field, @@ -221,11 +214,11 @@ this.setState({ setting: _setting, - hasReqFields, + hasReqFields: config.$s_req, advanceValues, searchlist: _list }, () => { - if (!window.GLOB.mkHS && options.sysType === 'local' && window.GLOB.systemType !== 'production') { + if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { this.improveSimpleSearch(deForms) } else if (mainItems.length > 0 || localItems.length > 0) { this.improveSearch(mainItems, localItems) @@ -234,10 +227,11 @@ } resetCheckcard = (item) => { + let pid = item.resourceType === '0' ? 'pid' : item.parentField let _options = [] let _others = [] item.oriOptions.forEach(op => { - if (op.pid === item.mark) { + if (op[pid] === item.mark) { _options.push(op) } else { _others.push(op) @@ -248,7 +242,7 @@ op.children = [] _others = _others.filter(cell => { - if (cell.pid === op.$value) { + if (cell[pid] === op.$value) { op.children.push(cell) return false } @@ -327,8 +321,8 @@ if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉 mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) - if (options.cloudServiceApi) { - mainparam.rduri = options.cloudServiceApi + if (window.GLOB.cloudServiceApi) { + mainparam.rduri = window.GLOB.cloudServiceApi mainparam.userid = sessionStorage.getItem('CloudUserID') || '' mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } @@ -423,7 +417,7 @@ resetSearch = (result) => { let _searchlist = fromJS(this.state.searchlist).toJS().map(item => { - if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(item.type) && result[item.field] && result[item.field].length > 0) { let options = [] let map = new Map() let all = false @@ -557,6 +551,8 @@ content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} /> } else if (item.type === 'checkcard') { content = <MKCheckCard config={item} onChange={(val) => this.cardChange(val, item)} /> + } else if (item.type === 'radio') { + content = <MKRadio config={item} onChange={(val) => this.recordChange(val, false, item)} /> } else if (item.type === 'check') { content = <MKCheck config={item} onChange={(val) => this.recordChange(val, false, item)} /> } else if (item.type === 'switch') { @@ -636,7 +632,9 @@ val = val + ':00' } } - advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + if (['text', 'date', 'datemonth', 'dateweek', 'daterange'].includes(item.type)) { + advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + } } }) this.setState({advanceValues}) @@ -691,7 +689,12 @@ this.sign = '' }, 2000) - this.props.refreshdata(searches) + if (this.props.refreshdata) { + this.props.refreshdata(searches) + } else { + window.GLOB.SearchBox.set(this.props.config.$searchId, searches) + MKEmitter.emit('searchRefresh', this.props.config.$searchId) + } }) }) } @@ -726,7 +729,9 @@ val = val + ':00' } } - advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + if (['text', 'date', 'datemonth', 'dateweek', 'daterange'].includes(item.type)) { + advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + } } return item @@ -841,7 +846,9 @@ val = val + ':00' } } - advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + if (['text', 'date', 'datemonth', 'dateweek', 'daterange'].includes(item.type)) { + advanceValues.push({field: item.field, type: item.type, label: item.label, value: val}) + } } }) -- Gitblit v1.8.0