From 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 25 七月 2023 16:36:23 +0800 Subject: [PATCH] 2023-07-25 --- src/tabviews/custom/popview/index.jsx | 315 ++++++++++++++++++++++++++++----------------------- 1 files changed, 173 insertions(+), 142 deletions(-) diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index 67bdd49..9b2324c 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -8,6 +8,7 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' +import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import NotFount from '@/components/404' import './index.scss' @@ -40,6 +41,7 @@ const TimeLine = asyncComponent(() => import('../components/timeline/normal-timeline')) const Voucher = asyncComponent(() => import('../components/module/voucher')) const Iframe = asyncComponent(() => import('../components/iframe')) +const Calendar = asyncComponent(() => import('../components/calendar')) const AntvG6 = asyncComponent(() => import('../components/chart/antv-G6')) const AntvX6 = asyncComponent(() => import('../components/chart/antv-X6')) @@ -55,8 +57,6 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 - mainSearch: null, // 涓绘悳绱� - data: null, // 鍒楄〃鏁版嵁闆� loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� } @@ -131,38 +131,35 @@ }) } - config.$cache = config.cacheLocal === 'true' - - config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache) + config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, Tab.uuid, Tab.uuid) // 鑾峰彇涓绘悳绱㈡潯浠� - let mainSearch = [] config.components.forEach(component => { if (component.type !== 'search') return - component.search = component.search.map(item => { - item.oriInitval = item.initval - if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { - item.initval = param.$searchval - } + if (param.$searchkey) { + component.search = component.search.map(item => { + if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { + item.initval = param.$searchval + } - return item - }) + return item + }) - mainSearch = Utils.initMainSearch(component.search) + component.$searches = Utils.initMainSearch(component.search) + } + + window.GLOB.SearchBox.set(Tab.uuid, component.$searches) + + if (component.$s_req) { + window.GLOB.SearchBox.set(Tab.uuid + 'required', true) + } }) let params = [] let BID = param.$BID || '' - let inherit = {} - if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 - inherit.cacheUseful = config.cacheUseful - inherit.timeUnit = config.timeUnit - inherit.cacheTime = config.cacheTime - } - - config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) + config.components = this.formatSetting(config.components, params, regs, balMap) if ([...balMap.keys()].length > 0) { config.components = this.filterBalcony(config.components, balMap) @@ -170,8 +167,7 @@ this.setState({ BID: BID, - config, - mainSearch + config }, () => { if (params.length > 0) { this.loadmaindata(params) @@ -179,10 +175,11 @@ }) } - filterComponent = (components, roleId, balMap, urlparam, Tab, cache) => { + filterComponent = (components, roleId, balMap, urlparam, Tab, searchId, syncId) => { return components.filter(item => { item.$pageId = Tab.uuid - item.$cache = cache + item.$searchId = searchId + item.$syncId = syncId if (item.style && item.style.boxShadow) { delete item.style.hShadow @@ -201,6 +198,13 @@ return false } + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + item.setting.supModule = pid || '' + } else { + item.setting.supModule = '' + } + item.subtabs = item.subtabs.filter(tab => { if ( tab.blacklist && tab.blacklist.length > 0 && @@ -210,35 +214,37 @@ } else if (tab.hide === 'true') { return false } + + if (item.setting.supModule) { + if (tab.controlVal === '@pass@') { + tab.$pass = true + } else if (/,/ig.test(tab.controlVal)) { + tab.controlVals = tab.controlVal.split(',') + } else { + tab.controlVals = [(tab.controlVal || '')] + } + } + return true }) if (item.setting.supModule) { - let pid = item.setting.supModule.pop() - item.setting.supModule = pid || '' + item.setting.controlField = item.setting.controlField.toLowerCase() - if (item.setting.supModule) { - item.setting.controlField = item.setting.controlField.toLowerCase() - - if (item.setting.supModule === 'preview') { - item.setting.supModule = '' - let val = '' - Object.keys(urlparam).forEach(key => { - if (key.toLowerCase() === item.setting.controlField) { - val = urlparam[key] - } - }) - - item.subtabs = item.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - - return true - }) - } + if (item.setting.supModule === 'preview') { + item.setting.supModule = '' + let val = '' + Object.keys(urlparam).forEach(key => { + if (key.toLowerCase() === item.setting.controlField) { + val = urlparam[key] + } + }) + + item.subtabs = item.subtabs.filter(tab => { + if (tab.$pass) return true + + return !tab.controlVals.includes(val) + }) } } @@ -266,7 +272,18 @@ item.subtabs = item.subtabs.map(tab => { tab.$pageId = Tab.uuid - tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache) + let _searchId = searchId + + tab.components.forEach(cell => { + if (cell.type !== 'search') return + _searchId = cell.uuid + window.GLOB.SearchBox.set(cell.uuid, cell.$searches) + if (cell.$s_req) { + window.GLOB.SearchBox.set(cell.uuid + 'required', true) + } + }) + + tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, _searchId, tab.uuid) return tab }) @@ -279,7 +296,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache) + item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, searchId, syncId) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { @@ -299,8 +316,12 @@ } // 鎼滅储鏉′欢鍒濆鍖� - if (item.search && item.search.length > 0) { - item.search = Utils.initSearchVal(item.search) + if (item.type === 'search' && item.search.length === 0) { + return false + } else if (item.search) { + Utils.initSearchVal(item) + + item.$searches = Utils.initMainSearch(item.search) } if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 @@ -487,6 +508,7 @@ group.subButton.OpenType = 'formSubmit' group.subButton.execError = 'never' group.subButton.logLabel = item.$menuname + '-' + group.subButton.label + group.subButton.$tabId = Tab.uuid if (!group.subButton.Ot) { group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl' @@ -671,28 +693,28 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, inherit, regs, balMap) => { + formatSetting = (components, params, regs, balMap) => { let delay = 20 return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap) - tab = {...tab, ...inherit} + tab.components = this.formatSetting(tab.components, null, regs, balMap) return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) - component = {...component, ...inherit} + component.components = this.formatSetting(component.components, params, regs, balMap) return component } else if (component.wrap && component.wrap.datatype === 'public') { component.setting.useMSearch = false + component.setting.sync = 'false' return component } else if (component.wrap && component.wrap.datatype === 'static') { component.format = '' component.setting = component.setting || {} component.setting.useMSearch = false + component.setting.sync = 'false' return component } else if (!component.setting || !component.format) { @@ -700,6 +722,13 @@ } component.setting.useMSearch = component.setting.useMSearch === 'true' + if (component.setting.useMSearch) { + if (!window.GLOB.SearchBox.has(component.$searchId)) { + component.setting.useMSearch = false + } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) { + component.$s_req = true + } + } if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 component.setting.sync = 'false' @@ -728,10 +757,8 @@ } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - _customScript = _customScript.replace(/@\$/ig, '*/') + component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') } else { component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') @@ -744,35 +771,39 @@ component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + if (component.setting.sync === 'true') { + // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ + if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { + + } else { + component.setting.sync = 'false' + } + } + // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О if (component.setting.sync === 'true') { component.dataName = 'mk' + component.uuid.slice(-18) - } - // floor 缁勪欢鐨勫眰绾� - // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if (params && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { - let searchlist = [] - if (component.search && component.search.length > 0) { - searchlist = Utils.initMainSearch(component.search) - } - if (component.setting.useMSearch) { - let keys = searchlist.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { + if (params) { + let searchlist = component.$searches || [] + + if (component.setting.useMSearch) { + let mainSearch = window.GLOB.SearchBox.get(component.$searchId) + let keys = component.$s_keys || [] + mainSearch.forEach(item => { + if (keys.includes(item.key.toLowerCase())) return + searchlist.push(item) - } - }) + }) + } + + if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) { + component.setting.sync = 'false' + component.setting.onload = 'false' + } else { + params.push(getStructDefaultParam(component, searchlist, params.length === 0)) + } } - - if (searchlist.filter(item => item.required && item.value === '').length > 0) { - component.setting.sync = 'false' - component.setting.onload = 'false' - } else { - params.push(getStructDefaultParam(component, searchlist, params.length === 0)) - } - } else if (params) { - component.setting.sync = 'false' } component.setting.delay = delay @@ -791,12 +822,17 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { + const { Tab } = this.props const { config } = this.state let param = getStructuredParams(params, config, this.state.BID || '') this.setState({loading: true}) Api.genericInterface(param).then(result => { + this.setState({ + loading: false + }) + if (result.status) { if (result.message) { if (result.ErrCode === 'Y') { @@ -812,30 +848,17 @@ } } - delete result.status - delete result.message - delete result.ErrMesg - delete result.ErrCode - - if (config.$cache) { - params.forEach((item) => { - let _data = result[item.name] || '' - if (_data && !Array.isArray(_data)) { - _data = [_data] - } - Api.writeCacheConfig(item.uuid, _data) - }) - } - - this.setState({ - data: result, - loading: false + params.forEach((item) => { + let _data = result[item.name] || '' + if (_data && !Array.isArray(_data)) { + _data = [_data] + } + window.GLOB.SyncData.set(item.name, _data) }) + + MKEmitter.emit('transferSyncData', Tab.uuid) } else { - this.setState({ - data: '', - loading: false - }) + MKEmitter.emit('transferSyncData', Tab.uuid) if (!result.message) return if (result.ErrCode === 'N') { @@ -884,20 +907,20 @@ }) } else if (item.type === 'group') { this.deleteCache(item.components) + } else if (item.type === 'search') { + window.GLOB.SearchBox.delete(item.$searchId) } else { window.GLOB.CacheData.delete(item.uuid) + } + + if (item.dataName) { + window.GLOB.SyncData.delete(item.dataName) } }) } - resetSearch = (search) => { - this.setState({mainSearch: null}, () => { - this.setState({mainSearch: search}) - }) - } - getComponents = () => { - const { config, BID, data, mainSearch } = this.state + const { config, BID } = this.state if (!config) return @@ -906,24 +929,26 @@ if (item.style && item.style.clear === 'left') { style = {clear: 'left'} + } else if (item.style && item.style.clear === 'right') { + style = {float: 'right'} } if (item.type === 'card' && item.subtype === 'datacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <DataCard config={item} data={data} mainSearch={mainSearch}/> + <DataCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'propcard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <PropCard config={item} data={data} mainSearch={mainSearch}/> + <PropCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'dualdatacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <DoubleDataCard config={item} mainSearch={mainSearch}/> + <DoubleDataCard config={item}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'basetable') { @@ -935,127 +960,133 @@ } else if (item.type === 'bar' || item.type === 'line') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> + <AntvBarAndLine config={item}/> </Col> ) } else if (item.type === 'pie') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvPie config={item} data={data} mainSearch={mainSearch}/> + <AntvPie config={item}/> </Col> ) } else if (item.type === 'scatter') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvScatter config={item} data={data} mainSearch={mainSearch}/> + <AntvScatter config={item}/> </Col> ) } else if (item.type === 'dashboard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> + <AntvDashboard config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'simpleform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <SimpleForm config={item} data={data} mainSearch={mainSearch}/> + <SimpleForm config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'stepform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <StepForm config={item} data={data} mainSearch={mainSearch}/> + <StepForm config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'tabform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TabForm config={item} data={data} mainSearch={mainSearch}/> + <TabForm config={item}/> </Col> ) } else if (item.type === 'search') { return ( <Col span={item.width} style={style} key={item.uuid}> - <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> + <MainSearch config={item} BID={BID} /> </Col> ) } else if (item.type === 'tabs') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvTabs config={item} mainSearch={mainSearch} /> + <AntvTabs config={item}/> </Col> ) } else if (item.type === 'balcony') { return ( <Col span={item.width} style={style} key={item.uuid}> - <Balcony config={item} data={data}/> + <Balcony config={item}/> </Col> ) } else if (item.type === 'timeline') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TimeLine config={item} data={data} mainSearch={mainSearch}/> + <TimeLine config={item}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'datacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> + <CarouselDataCard config={item}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'propcard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> + <CarouselPropCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'tablecard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TableCard config={item} data={data} mainSearch={mainSearch}/> + <TableCard config={item}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'normaltable') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalTable config={item} data={data} mainSearch={mainSearch}/> + <NormalTable config={item}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'editable') { return ( <Col span={item.width} style={style} key={item.uuid}> - <EditTable config={item} mainSearch={mainSearch}/> + <EditTable config={item}/> </Col> ) } else if (item.type === 'group' && item.subtype === 'normalgroup') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalGroup config={item} mainSearch={mainSearch}/> + <NormalGroup config={item}/> </Col> ) } else if (item.type === 'editor') { return ( <Col span={item.width} style={style} key={item.uuid}> - <BraftEditor config={item} data={data} mainSearch={mainSearch}/> + <BraftEditor config={item}/> </Col> ) } else if (item.type === 'tree') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalTree config={item} data={data} mainSearch={mainSearch}/> + <NormalTree config={item}/> + </Col> + ) + } else if (item.type === 'calendar') { + return ( + <Col span={item.width} style={style} key={item.uuid}> + <Calendar config={item}/> </Col> ) } else if (item.type === 'code') { return ( <Col span={item.width} style={style} key={item.uuid}> - <SandBox config={item} data={data} mainSearch={mainSearch}/> + <SandBox config={item}/> </Col> ) } else if (item.type === 'chart') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CustomChart config={item} data={data} mainSearch={mainSearch}/> + <CustomChart config={item}/> </Col> ) } else if (item.type === 'module' && item.subtype === 'voucher') { @@ -1067,13 +1098,13 @@ } else if (item.type === 'iframe') { return ( <Col span={item.width} style={style} key={item.uuid}> - <Iframe config={item} data={data} mainSearch={mainSearch}/> + <Iframe config={item}/> </Col> ) } else if (item.type === 'antvG6') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvG6 config={item} data={data} mainSearch={mainSearch}/> + <AntvG6 config={item}/> </Col> ) } else if (item.type === 'antvX6') { @@ -1093,7 +1124,7 @@ return ( <div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}> - {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null} + {loading ? <Spin className="view-spin" size="large" /> : null} <Row className="component-wrap">{this.getComponents()}</Row> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> -- Gitblit v1.8.0