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/commontable/index.jsx | 101 +++++++++++++++++++++++++------------------------- 1 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 72654e5..2139f68 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -81,10 +81,11 @@ if (result.status) { let config = '' let shortcuts = [] - let _curUserConfig = '' try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + config.MenuID = this.props.MenuID + config.MenuName = MenuName } catch (e) { console.warn('Parse Failure') config = '' @@ -94,31 +95,37 @@ if (result.LongParamUser && this.props.menuType !== 'HS') { try { // 閰嶇疆淇℃伅瑙f瀽 let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) - userConfig = [] + if (userConfig && !userConfig.version) { + Object.keys(userConfig).forEach(key => { + let component = userConfig[key] - // 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] + if (!component.action) return + + Object.keys(component.action).forEach(uuid => { + let item = {uuid: uuid, parentId: key, shortcut: component.action[uuid].shortcut} + let printer = component.action[uuid].printer + + if (item.shortcut) { + item.$shortcut = item.shortcut.join('+') + shortcuts.push(item) + } + if (printer) { + item.printer = printer.defaultPrinter || '' + item.printerList = printer.printerList || '' + window.GLOB.UserCacheMap.set(key + uuid, item) + } + }) + }) + } else if (userConfig) { + shortcuts = userConfig.action + userConfig.printers.forEach(item => { + window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) + }) + } } catch (e) { console.warn('Parse Failure') } } - console.log(config) - console.log(shortcuts) // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� if (!config) { @@ -235,28 +242,6 @@ } } - if (_curUserConfig) { - config.action = config.action.map(item => { - if (_curUserConfig.action[item.uuid]) { - delete _curUserConfig.action[item.uuid].label - item = {...item, ..._curUserConfig.action[item.uuid]} - } - - if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify && item.printer) { - item.verify.defaultPrinter = item.printer.defaultPrinter || '' - if (item.verify.printerTypeList && item.printer.printerList) { - item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { - cell.printer = item.printer.printerList[cell.Value] || '' - - return cell - }) - } - } - - return item - }) - } - let _arrField = [] // 瀛楁闆� let _columns = [] // 鏄剧ず鍒� let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� @@ -270,6 +255,22 @@ config.action.forEach(item => { item.logLabel = MenuName + '-' + item.label // 鐢ㄤ簬sPC_TableData_InUpDe璁板綍鎿嶄綔鎸夐挳 item.$menuId = this.props.MenuID + + if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 鎵撳嵃鏈鸿缃� + let _item = window.GLOB.UserCacheMap.get(this.props.MenuID + item.uuid) + + if (_item) { + item.printer = _item.printer || '' + item.verify.defaultPrinter = _item.printer || '' + if (item.verify.printerTypeList && _item.printerList) { + item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { + cell.printer = _item.printerList[cell.Value] || '' + + return cell + }) + } + } + } if (item.position === 'toolbar') { _actions.push(item) @@ -403,13 +404,13 @@ if (!preKey || !keyCode) return - let _shortcut = preKey + keyCode + let _shortcut = `${preKey}+${keyCode}` shortcuts.some(item => { - if (item.shortcut === _shortcut) { + if (item.$shortcut === _shortcut) { MKEmitter.emit('triggerBtnId', item.uuid) - let element = item.parentId ? document.getElementById(item.parentId) : '' // 鏍囩鍒囨崲 + let element = item.parentId && item.parentId !== this.props.MenuID ? document.getElementById(item.parentId) : '' // 鏍囩鍒囨崲 if (element && element.click) { element.click() } @@ -686,7 +687,7 @@ */ reloadview = () => { this.setState({ loadingview: true, viewlost: false, config: {}, setting: null, - data: null, total: 0, loading: false, pageIndex: 1, + data: null, total: 0, loading: false, pageIndex: 1, shortcuts: null, pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false }, () => { this.loadconfig() @@ -848,11 +849,11 @@ render() { const { menuType } = this.props - const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData } = this.state + const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts } = this.state return ( <div className="commontable" id={this.state.ContainerId}> - {loadingview && <Spin size="large" />} + {loadingview ? <Spin size="large" /> : null} {searchlist && searchlist.length ? <MainSearch BID={BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } @@ -964,7 +965,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} + {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