From 23cb54bbb041413ba327d046a4b396267ef2ecfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 13 一月 2021 19:31:56 +0800 Subject: [PATCH] 2021-01-13 --- src/tabviews/treepage/index.jsx | 221 +++++++++---------------------------------------------- 1 files changed, 36 insertions(+), 185 deletions(-) diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index 94a1210..76e31fa 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Tabs, Icon, Modal, Button, Tree, Row, Col, Card, Input, Empty } from 'antd' +import { notification, Spin, Tabs, Icon, Tree, Row, Col, Card, Input, Empty } from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' @@ -15,8 +15,8 @@ import NotFount from '@/components/404' import './index.scss' -const VerifyCard = asyncComponent(() => import('@/tabviews/zshare/verifycard')) const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable')) +const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) const { TabPane } = Tabs @@ -39,8 +39,6 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 - userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� - userParam: null, // 淇濆瓨鐢ㄦ埛缂栬緫涓殑閰嶇疆 setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 treedata: null, // 鍒楄〃鏁版嵁闆� treeNodes: null, // 鍒楄〃鏁版嵁闆� @@ -49,10 +47,9 @@ visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓� revertLoading: false, // 鎭㈠榛樿璁剧疆 - settingVisible: false,// 鑷畾涔夎缃ā鎬佹 - tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 expandedKeys: [], // 灞曞紑鐨勬爲鑺傜偣 selectedKeys: [], // 閫変腑鐨勬爲鑺傜偣 + shortcuts: null // 蹇嵎閿� } /** @@ -69,11 +66,12 @@ if (result.status) { let config = '' - let userConfig = null - let _curUserConfig = '' + let shortcuts = [] try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + config.MenuID = this.props.MenuID + config.MenuName = this.props.MenuName } catch (e) { console.warn('Parse Failure') config = '' @@ -81,11 +79,15 @@ if (result.LongParamUser) { try { // 閰嶇疆淇℃伅瑙f瀽 - userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) - _curUserConfig = userConfig[this.props.MenuID] + let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + if (userConfig) { + shortcuts = userConfig.action + userConfig.printers.forEach(item => { + window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) + }) + } } catch (e) { console.warn('Parse Failure') - userConfig = null } } @@ -118,12 +120,6 @@ ) }) - if (_curUserConfig) { - config.setting = {...config.setting, ..._curUserConfig.setting} - config.easyCode = _curUserConfig.easyCode || config.easyCode || '' - } - - let _tabActive = {} // 绛涢�夊睍寮�鐨則ab椤� let _tabgroups = [] config.tabgroups.forEach(group => { @@ -131,7 +127,6 @@ _group.sublist = _group.sublist.filter(tab => tab.level === 0) if (_group.sublist.length > 0) { - _tabActive[_group.uuid] = _group.sublist[0].uuid _tabgroups.push(_group) } }) @@ -182,10 +177,9 @@ BID: param && param.BID ? param.BID : '', loadingview: false, config: config, - tabActive: _tabActive, - userConfig: userConfig, setting: config.setting, - tabgroups: _tabgroups + tabgroups: _tabgroups, + shortcuts }, () => { this.loadmaindata() this.setShortcut() @@ -204,8 +198,12 @@ } setShortcut = () => { - const { 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 @@ -220,45 +218,21 @@ preKey = 'alt' } - if (!preKey) return + if (!preKey || !keyCode) return - let triggerId = '' + let _shortcut = `${preKey}+${keyCode}` - Object.keys(userConfig).some(key => { - if (key === this.props.MenuID || !userConfig[key].action) return false + shortcuts.some(item => { + if (item.$shortcut === _shortcut) { + MKEmitter.emit('triggerBtnId', item.uuid) - 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 - }) - - this.setState({ - tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId} - }, () => { - MKEmitter.emit('triggerBtnId', triggerId) - }) - - return true + let element = item.parentId ? document.getElementById(item.parentId) : '' // 鏍囩鍒囨崲 + if (element && element.click) { + element.click() } - return false - }) - if (triggerId) return true + return true + } return false }) } @@ -428,14 +402,12 @@ if (selected) { let _tabgroups = [] - let _tabActive = {} config.tabgroups.forEach(group => { let _group = fromJS(group).toJS() _group.sublist = _group.sublist.filter(tab => (!tab.level && tab.level !== 0) || tab.level === _data.level) if (_group.sublist.length > 0) { - _tabActive[_group.uuid] = _group.sublist[0].uuid _tabgroups.push(_group) } }) @@ -444,7 +416,6 @@ this.handleTableId('mainTable', _data.key, _data) this.setState({ tabgroups: _tabgroups, - tabActive: _tabActive, expandedKeys: _expandedKeys, selectedKeys: [_data.key] }) @@ -464,12 +435,12 @@ loadingview: true, viewlost: false, config: {}, - userConfig: null, setting: null, treedata: null, treeNodes: null, loading: false, BIDs: {}, + shortcuts: null, expandedKeys: [], selectedKeys: [] }, () => { @@ -489,99 +460,6 @@ [type]: id, [type + 'data']: data } - }) - } - - controlCustomSetting = () => { - this.setState({ - settingVisible: true, - confirmLoading: false, - revertLoading: false - }) - } - - changeMenuParam = (param) => { - this.setState({userParam: param}) - } - - settingRevert = () => { - let param = { - func: 's_TrdMenu_UserParam_del', - MenuID: this.props.MenuID - } - this.setState({ - revertLoading: true - }) - - Api.getSystemConfig(param).then(result => { - if (!result.status) { - this.setState({ - revertLoading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } - this.setState({ - settingVisible: false, - revertLoading: false - }, () => { - window.GLOB.CacheMap = new Map() - this.reloadview() - }) - }) - } - - settingSubmit = () => { - const { userParam } = this.state - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(userParam))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - return - } - - let easyCode = userParam[this.props.MenuID] ? userParam[this.props.MenuID].easyCode : '' - - let param = { - func: 'sPC_TrdMenu_UserParam', - MenuID: this.props.MenuID, - EasyCode: easyCode || '', - LongParam: _LongParam - } - - this.setState({ - confirmLoading: true - }) - - Api.getSystemConfig(param).then(result => { - if (!result.status) { - this.setState({ - confirmLoading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } - this.setState({ - settingVisible: false, - confirmLoading: false - }, () => { - window.GLOB.CacheMap = new Map() - this.reloadview() - }) }) } @@ -668,7 +546,7 @@ render() { const { menuType } = this.props - const { setting, loadingview, viewlost, config, userConfig, tabActive, tabgroups, treeNodes, treedata, expandedKeys, selectedKeys } = this.state + const { setting, loadingview, viewlost, config, tabgroups, treeNodes, treedata, expandedKeys, selectedKeys, shortcuts } = this.state return ( <div className="tree-page" id={this.state.ContainerId}> @@ -705,11 +583,11 @@ </Col> <Col span={24 - setting.width}> {tabgroups.map(group => ( - <Tabs activeKey={tabActive[group.uuid]} 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> @@ -719,7 +597,6 @@ Tab={_tab} MenuID={_tab.linkTab} mainSearch={null} - userConfig={userConfig ? userConfig[_tab.uuid] : null} SupMenuID={this.props.MenuID} ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} @@ -734,33 +611,7 @@ </Col> </Row> : null} {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} - <Modal - wrapClassName="common-table-custom-modal" - title={'鑷畾涔夎缃�'} - maskClosable={false} - width={950} - visible={this.state.settingVisible} - onCancel={() => { this.setState({ settingVisible: false }) }} - footer={[ - <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.state.dict['main.revert.default']}</Button>, - <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['main.cancel']}</Button>, - <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.state.dict['main.submit']}</Button> - ]} - destroyOnClose - > - {this.state.settingVisible ? - <VerifyCard - MenuID={this.props.MenuID} - MenuName={this.props.MenuName} - permAction={this.props.permAction} - config={this.state.config} - userConfig={this.state.userConfig} - columns={[]} - handleParam={this.changeMenuParam} - /> : null - } - </Modal> + {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0