From c27d57333ed38c92f595219d2190ea63cef4d182 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 一月 2021 18:29:16 +0800 Subject: [PATCH] 2021-01-12 --- src/tabviews/commontable/index.jsx | 139 +++++++++++++++------------------------------- 1 files changed, 46 insertions(+), 93 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 9a7f5fd..72654e5 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -44,7 +44,7 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 - userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� + shortcuts: null, // 蹇嵎閿� searchlist: null, // 鎼滅储鏉′欢 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� @@ -60,7 +60,6 @@ search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� BIDs: {}, // 涓婄骇琛╥d pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 chartId: '', // 灞曞紑鍥捐〃ID statFields: [], // 鍚堣瀛楁 statFValue: [], // 鍚堣鍊� @@ -81,7 +80,7 @@ if (result.status) { let config = '' - let userConfig = null + let shortcuts = [] let _curUserConfig = '' try { // 閰嶇疆淇℃伅瑙f瀽 @@ -94,13 +93,32 @@ // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 if (result.LongParamUser && this.props.menuType !== 'HS') { try { // 閰嶇疆淇℃伅瑙f瀽 - userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + userConfig = [] + + // if (window.GLOB.UserCacheMap.has(_param)) { + // return Promise.resolve(window.GLOB.UserCacheMap.get(_param)) + // } else { + // param = this.encryptParam(param) + // return new Promise(resolve => { + // axios({ + // url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, + // data: param + // }).then(res => { + // if (res.status) { + // window.GLOB.UserCacheMap.set(_param, res) + // } + // resolve(res) + // }) + // }) + // } _curUserConfig = userConfig[this.props.MenuID] } catch (e) { console.warn('Parse Failure') - userConfig = null } } + console.log(config) + console.log(shortcuts) // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� if (!config) { @@ -218,8 +236,6 @@ } if (_curUserConfig) { - config.easyCode = _curUserConfig.easyCode || config.easyCode || '' - config.action = config.action.map(item => { if (_curUserConfig.action[item.uuid]) { delete _curUserConfig.action[item.uuid].label @@ -240,12 +256,6 @@ return item }) } - - let _tabActive = {} // 绛涢�夊睍寮�鐨則ab椤� - - config.tabgroups.forEach(group => { - _tabActive[group.uuid] = group.sublist[0].uuid - }) let _arrField = [] // 瀛楁闆� let _columns = [] // 鏄剧ず鍒� @@ -336,29 +346,13 @@ return _item }) - if (_curUserConfig) { - _columns = _columns.map(item => { - if (_curUserConfig.columns[item.uuid]) { - delete _curUserConfig.columns[item.uuid].label - item = {...item, ..._curUserConfig.columns[item.uuid]} - } - - return item - }) - - _columns.sort((pre, next) => { - return pre.sort - next.sort - }) - } - this.setState({ loadingview: false, absFields, chartId, config, statFields, - userConfig, - tabActive: _tabActive, + shortcuts, setting: config.setting, searchlist: config.search, actions: _actions, @@ -387,8 +381,12 @@ } setShortcut = () => { - const { actions, userConfig, config } = this.state - if (!userConfig) return + const { shortcuts } = this.state + + if (!shortcuts || shortcuts.length === 0) { + document.onkeydown = () => {} + return + } document.onkeydown = (event) => { let e = event || window.event @@ -403,56 +401,21 @@ preKey = 'alt' } - if (!preKey) return + if (!preKey || !keyCode) return - let triggerId = '' + let _shortcut = preKey + keyCode - actions.some(item => { - if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { - e.preventDefault() - triggerId = item.uuid + shortcuts.some(item => { + if (item.shortcut === _shortcut) { + MKEmitter.emit('triggerBtnId', item.uuid) + + let element = item.parentId ? document.getElementById(item.parentId) : '' // 鏍囩鍒囨崲 + if (element && element.click) { + element.click() + } + return true } - return false - }) - - if (triggerId) { - MKEmitter.emit('triggerBtnId', triggerId) - return - } - - Object.keys(userConfig).some(key => { - if (key === this.props.MenuID || !userConfig[key].action) return false - - let _actions = userConfig[key].action - - Object.keys(_actions).some(btnkey => { - let item = _actions[btnkey] - - if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { - e.preventDefault() - triggerId = btnkey - - let _groupId = '' - let _ActiveTabId = '' - config.tabgroups.forEach(group => { - let _tab = group.sublist.filter(tab => tab.uuid === key)[0] - - if (!_tab) return - - _groupId = group.uuid - _ActiveTabId = _tab.uuid - }) - - if (_ActiveTabId && this.state.tabActive[_groupId] === _ActiveTabId) { - MKEmitter.emit('triggerBtnId', triggerId) - return true - } - } - return false - }) - - if (triggerId) return true return false }) } @@ -884,8 +847,8 @@ } render() { - const { menuType, MenuName } = this.props - const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state + const { menuType } = this.props + const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData } = this.state return ( <div className="commontable" id={this.state.ContainerId}> @@ -920,16 +883,6 @@ /> </div> <div className="main-table-box"> - {this.props.menuType !== 'HS' ? <SettingComponent - config={config} - columns={columns} - MenuName={MenuName} - dict={this.state.dict} - MenuID={this.props.MenuID} - permAction={this.props.permAction} - userConfig={this.state.userConfig} - reloadview={this.reloadview} - /> : null} {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } @@ -986,11 +939,11 @@ })} </Row> : null } {setting && config.tabgroups.map(group => ( - <Tabs key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}> + <Tabs key={group.uuid}> {group.sublist.map(_tab => { return ( <TabPane tab={ - <span> + <span id={_tab.uuid}> {_tab.icon ? <Icon type={_tab.icon} /> : null} {_tab.label} </span> @@ -999,7 +952,6 @@ Tab={_tab} MenuID={_tab.linkTab} mainSearch={_tab.searchPass === 'true' ? search : null} - userConfig={userConfig ? userConfig[_tab.uuid] : null} SupMenuID={this.props.MenuID} ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} @@ -1012,6 +964,7 @@ </Tabs>)) } {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} + {menuType !== 'HS' ? <SettingComponent config={config} dict={this.state.dict} MenuID={this.props.MenuID} permAction={this.props.permAction}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0