From fbe91f6f07f6296bbf6c30029c7f36014fe66e79 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 11 八月 2023 14:40:01 +0800 Subject: [PATCH] 2023-08-11 --- src/tabviews/basetable/index.jsx | 330 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 218 insertions(+), 112 deletions(-) diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx index c6b9ade..0540563 100644 --- a/src/tabviews/basetable/index.jsx +++ b/src/tabviews/basetable/index.jsx @@ -4,8 +4,6 @@ import { notification, Spin, Row, Col } 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 asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' @@ -16,7 +14,8 @@ const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table')) const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) -const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) +const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes')) +const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic')) const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) class BasePage extends Component { @@ -24,36 +23,35 @@ param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 Tab: PropTypes.string, // 寮圭獥鏍囩 MenuID: PropTypes.string, // 鑿滃崟Id - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuName: PropTypes.string // 鑿滃崟鍚嶇О + MenuName: PropTypes.string, // 鑿滃崟鍚嶇О + changeTemp: PropTypes.func } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 - mainSearch: null, // 涓绘悳绱� userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� - data: null, // 鍒楄〃鏁版嵁闆� loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� visible: false, // 鏍囩椤垫帶鍒� - shortcuts: null // 蹇嵎閿� + shortcuts: null, // 蹇嵎閿� + autoMatic: null } /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { MenuID } = this.props + const { MenuID, MenuName } = this.props let _param = { func: 'sPC_Get_LongParam', MenuID: MenuID } + let result = await Api.getCacheConfig(_param) if (result.status) { @@ -62,10 +60,46 @@ try { // 閰嶇疆淇℃伅瑙f瀽 config = window.decodeURIComponent(window.atob(result.LongParam)) + config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl) config = JSON.parse(config) + config.MenuID = MenuID + config.MenuName = MenuName || config.MenuName } catch (e) { console.warn('Parse Failure') config = '' + } + + // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� + if (!config) { + this.setState({ + viewlost: true, + loadingview: false + }) + return + } + + // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 + if (!config.enabled) { + this.setState({ + viewlost: true, + loadingview: false, + lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��' + }) + return + } + + // 妯℃澘閿欒 + if (config.Template !== 'BaseTable') { + if (config.Template === 'CustomPage' || config.Template === 'CommonTable') { + this.props.changeTemp(MenuID, config.Template) + } else { + this.setState({ + viewlost: true, + loadingview: false, + lostmsg: '鑿滃崟淇℃伅閿欒锛屽彲鑳藉師鍥狅細1銆佸綋鍓嶇敤鎴锋棤鏉冮檺锛�2銆佹墦寮�姝よ彍鍗曠殑鎸夐挳闇�瑕佹洿鏂般��' + }) + } + return } // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 @@ -83,25 +117,6 @@ } } - // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� - if (!config) { - this.setState({ - viewlost: true, - loadingview: false - }) - return - } - - // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 - if (!config.enabled) { - this.setState({ - viewlost: true, - loadingview: false, - lostmsg: this.state.dict['main.view.unenabled'] - }) - return - } - // 鏉冮檺杩囨护 let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID let skip = window.GLOB.mkHS @@ -111,11 +126,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}'` }, @@ -138,34 +148,58 @@ }) } - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID) + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName) + + let autoMatic = null + if (config.autoMatic && config.autoMatic.enable === 'true') { + config.components[0].action.forEach(item => { + if (item.uuid === config.autoMatic.action) { + autoMatic = config.autoMatic + autoMatic.OpenType = item.execMode || item.OpenType + config.components[0].wrap.selected = 'false' + config.components[0].MenuID = config.components[0].uuid + config.components[0].autoMatic = true + item.autoMatic = true + } + }) + } // 鑾峰彇涓绘悳绱㈡潯浠� - let mainSearch = [] config.components.forEach(component => { if (component.type === 'tabs') 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 + }) + + component.$searches = Utils.initMainSearch(component.search) + } + + if (component.$searches.length) { + component.$main = true + + window.GLOB.SearchBox.set(MenuID, component.$searches) + + if (component.$s_req) { + window.GLOB.SearchBox.set(MenuID + 'required', true) } - - return item - }) - - mainSearch = Utils.initMainSearch(component.search) + } }) let BID = param.$BID || '' - config.components = this.formatSetting(config.components, mainSearch, regs) + config.components = this.formatSetting(config.components, regs) this.setState({ BID: BID, shortcuts: shortcuts.length > 0 ? shortcuts : null, config, - mainSearch + autoMatic }, () => { setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� this.setState({ @@ -230,18 +264,16 @@ } } - filterComponent = (components, roleId, permAction, skip, urlparam, pageId) => { + filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName) => { return components.filter(item => { item.$pageId = pageId + item.$searchId = pageId - item.$menuname = (this.props.MenuName || '') + '-' + (item.name || '涓昏〃') + item.$menuname = (MenuName || '') + '-' + (item.name || '涓昏〃') if (item.type === 'tabs') { item.subtabs = item.subtabs.filter(tab => { - if ( - tab.blacklist && tab.blacklist.length > 0 && - tab.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 - ) { + if (!skip && !permAction[tab.components[0].uuid] && tab.permission === 'true') { return false } else if (tab.hide === 'true') { return false @@ -253,17 +285,22 @@ item.subtabs = item.subtabs.map(tab => { tab.components[0].name = tab.label - tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId) + if (tab.permission !== 'true') { // 鏉冮檺鏈紑鍚笉鍋氭潈闄愭帶鍒� + skip = true + } + tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName) return tab }) return true + } else { + item.name = (MenuName || '') } // 鎼滅储鏉′欢鍒濆鍖� - if (item.search && item.search.length > 0) { - item.search = Utils.initSearchVal(item.search) - } + Utils.initSearchVal(item) + + item.$searches = Utils.initMainSearch(item.search) if (item.setting.supModule) { let pid = item.setting.supModule.pop() @@ -281,6 +318,8 @@ return false } else if (col.Hide === 'true') { return false + } else if (col.type === 'action') { + col.type = 'custom' } if (col.type === 'number') { @@ -299,8 +338,58 @@ return false } } else if (col.type === 'custom') { - col.elements = col.elements.map(cell => { - if (['text', 'number', 'formula'].includes(cell.eleType)) { + col.elements = col.elements.filter(cell => { + if (cell.eleType === 'button') { + if (cell.hidden === 'true') return false + + cell.logLabel = item.$menuname + '-' + cell.label + cell.Ot = cell.Ot || 'requiredSgl' + cell.ContainerId = this.state.ContainerId + cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' + cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID + cell.$view = 'popview' + + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } + } + + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) + } + + if (cell.controlField) { + if (/,/ig.test(cell.controlVal)) { + cell.controlVals = cell.controlVal.split(',') + } else { + cell.controlVals = [(cell.controlVal || '')] + } + } + + return skip || permAction[cell.uuid] + } else if (['text', 'number', 'formula'].includes(cell.eleType)) { if (!cell.height) { cell.innerHeight = 'auto' } @@ -311,8 +400,12 @@ } } } - return cell + return true }) + + if (col.elements.length === 0) { + return false + } } if (col.linkmenu && col.linkmenu.length > 0) { @@ -330,58 +423,60 @@ item.statFields = Array.from(new Set(statFields)) // 鏉冮檺杩囨护 - let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 寮圭獥鏍囩鎸夐挳Id if (item.action && item.action.length > 0) { item.action = item.action.filter(cell => { - if (item.hidden === 'true') return false - - cell.logLabel = item.$menuname + '-' + cell.label - cell.ContainerId = this.state.ContainerId - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$MenuID = this.props.MenuID - cell.$tabId = tabId - cell.$view = 'BasePage' - cell.$toolbtn = true - - if (cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - } - - if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� - cell = this.getPrinter(cell, item.uuid) - } - - return skip || permAction[cell.uuid] - }) - } - - item.cols = item.cols.filter(col => { - if (col.type !== 'action') return true - col.elements = col.elements.filter(cell => { if (cell.hidden === 'true') return false - + cell.logLabel = item.$menuname + '-' + cell.label cell.Ot = cell.Ot || 'requiredSgl' cell.ContainerId = this.state.ContainerId cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid cell.$MenuID = this.props.MenuID - cell.$tabId = tabId - cell.$view = 'BasePage' + cell.$view = 'popview' + cell.$toolbtn = true - if (cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } + if (cell.controlField) { + if (/,/ig.test(cell.controlVal)) { + cell.controlVals = cell.controlVal.split(',') + } else { + cell.controlVals = [(cell.controlVal || '')] + } + } + return skip || permAction[cell.uuid] }) - return col.elements.length !== 0 - }) + } return true }) @@ -418,6 +513,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' @@ -446,10 +548,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, '\'\'') @@ -461,6 +561,10 @@ }) component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + + if (component.setting.laypage) { + component.setting.custompage = /@pageSize@/i.test(component.setting.dataresource + component.setting.customScript) + } component.setting.delay = delay delay += 20 @@ -530,10 +634,18 @@ } else { window.GLOB.CacheData.delete(item.uuid) } + if (item.type !== 'tabs' && item.$main) { + window.GLOB.SearchBox.delete(item.$searchId) + } }) } reloadview = () => { + window.GLOB.CacheData.delete(this.props.MenuID) + if (this.state.config) { + this.deleteCache(this.state.config.components) + } + this.setState({ BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� @@ -541,20 +653,13 @@ config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� shortcuts: null, - data: '' }, () => { this.loadconfig() }) } - resetSearch = (search) => { - this.setState({mainSearch: null}, () => { - this.setState({mainSearch: search}) - }) - } - getComponents = () => { - const { config, data, mainSearch } = this.state + const { config } = this.state if (!config || !config.components) return @@ -562,13 +667,13 @@ if (item.type === 'tabs') { return ( <Col span={item.width} key={item.uuid}> - <AntvTabs config={item} mainSearch={mainSearch} /> + <AntvTabs config={item}/> </Col> ) } else { return ( <Col span={item.width} key={item.uuid}> - <MkBaseTable config={item} data={data}/> + <MkBaseTable config={item}/> </Col> ) } @@ -576,15 +681,16 @@ } render() { - const { loadingview, viewlost, config, loading, shortcuts } = this.state + const { loadingview, viewlost, config, loading, shortcuts, autoMatic } = this.state return ( - <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}> + <div className={'custom-table-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}> {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null} <Row className="component-wrap">{this.getComponents()}</Row> {config && window.GLOB.breakpoint ? <DebugTable /> : null} - {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - {!window.GLOB.mkHS && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null} + {!window.GLOB.mkHS && config && autoMatic ? <AutoMatic autoMatic={autoMatic} tabId={config.MenuID} config={config.components[0]} /> : null} + {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null} + {!window.GLOB.mkHS && config ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0