From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 15 八月 2023 14:22:03 +0800 Subject: [PATCH] 2023-08-15 --- src/tabviews/custom/index.jsx | 77 ++++++++++++++++++++++++-------------- 1 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 83bf8a9..c859a83 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -4,8 +4,6 @@ import { notification, Spin, Row, Col, Modal } from 'antd' import Api from '@/api' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' @@ -59,7 +57,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� @@ -117,7 +114,7 @@ this.setState({ viewlost: true, loadingview: false, - lostmsg: this.state.dict['main.view.unenabled'] + lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��' }) return } @@ -171,11 +168,6 @@ let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - let regs = [ { reg: /@userName@/ig, value: `'${userName}'` }, { reg: /@fullName@/ig, value: `'${fullName}'` } @@ -204,11 +196,12 @@ } config.$cache = config.cacheLocal === 'true' + config.$time = config.localCacheTime || 0 let initInters = [] config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.MenuName, MenuID, MenuID) + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.$time, config.MenuName, MenuID, MenuID) let params = [] let BID = param.$BID || '' @@ -323,7 +316,6 @@ let _shortcut = `${preKey}+${keyCode}` if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') { - window.debugger = false window.GLOB.breakpoint = false sessionStorage.removeItem('breakpoint') @@ -342,10 +334,11 @@ } } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) => { return components.filter(item => { item.$pageId = pageId item.$cache = cache + item.$time = time item.$searchId = searchId item.$syncId = syncId @@ -439,19 +432,27 @@ item.subtabs = item.subtabs.map(tab => { tab.$pageId = pageId + tab.$cache = cache + tab.$time = time 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) - } - }) + if (tab.components.findIndex(cell => cell.type === 'search') > -1) { + _searchId = tab.uuid + } - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, _searchId, tab.uuid) + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, _searchId, tab.uuid) + + if (_searchId === tab.uuid) { + tab.components.forEach(cell => { + if (cell.type !== 'search') return + window.GLOB.SearchBox.set(_searchId, cell.$searches) + if (cell.$s_req) { + window.GLOB.SearchBox.set(_searchId + 'required', true) + } + }) + } + return tab }) @@ -464,7 +465,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName, searchId, syncId) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { @@ -497,9 +498,7 @@ } // 鎼滅储鏉′欢鍒濆鍖� - if (item.type === 'search' && item.search.length === 0) { - return false - } else if (item.search) { + if (item.search) { Utils.initSearchVal(item) item.$searches = Utils.initMainSearch(item.search) @@ -992,6 +991,10 @@ component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + if (component.setting.laypage) { + component.setting.custompage = /@pageSize@/i.test(component.setting.dataresource + component.setting.customScript) + } + if (component.setting.sync === 'true') { // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { @@ -1125,6 +1128,22 @@ this.setState({loading: true, loadingview: false}) + if (config.$cache && config.$time) { + Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { + if (!res.valid) { + this.getMainData(param, params, config.MenuID) + } else { + this.setState({ + loading: false + }) + } + }) + } else { + this.getMainData(param, params, config.MenuID) + } + } + + getMainData = (param, params, MenuID) => { Api.genericInterface(param).then(result => { this.setState({ loading: false @@ -1153,9 +1172,9 @@ window.GLOB.SyncData.set(item.name, _data) }) - MKEmitter.emit('transferSyncData', config.MenuID) + MKEmitter.emit('transferSyncData', MenuID) } else { - MKEmitter.emit('transferSyncData', config.MenuID) + MKEmitter.emit('transferSyncData', MenuID) if (!result.message) return if (result.ErrCode === 'N') { @@ -1501,13 +1520,13 @@ const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state return ( - <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''}`} id={this.state.ContainerId} style={config ? config.style : null}> + <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''} ${config && config.mask === 'false' ? 'mk-no-mask' : ''}`} id={this.state.ContainerId} style={config ? config.style : null}> {(loadingview || (loading && !config.$cache)) ? <Spin className="view-spin" size="large" /> : null} <Row id={config ? 'menu' + config.uuid : ''} style={config && config.minWidth ? {minWidth: config.minWidth} : null} className="component-wrap">{this.getComponents()}</Row> {config && config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null} {config && window.GLOB.breakpoint ? <DebugTable /> : null} {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null} - {!window.GLOB.mkHS && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null} + {!window.GLOB.mkHS && config ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0