From c39ea1f23d21b070188abcf5f4dd5bdd7b47c1f9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 三月 2020 10:32:13 +0800 Subject: [PATCH] 2020-03-10 --- src/tabviews/commontable/index.jsx | 190 ++++++++++++++++++++++++++++++++-------------- 1 files changed, 131 insertions(+), 59 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index cc1217c..f214488 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -13,6 +13,7 @@ import {refreshTabView, modifyTabview} from '@/store/action' import MainTable from './mainTable' +import VerifyCard from '@/tabviews/tableshare/verifycard' import MainAction from '@/tabviews/tableshare/actionList' import MainSearch from '@/tabviews/tableshare/topSearch' import SubTable from '@/tabviews/subtable' @@ -54,16 +55,16 @@ orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� BIDs: {}, // 涓婄骇琛╥d - setsingle: false, // 涓昏〃鍗曢�夊閫夊垏鎹� pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - isLinkMain: false, // 鏄惁瀛樺湪涓庝富琛ㄥ叧鑱旂殑瀛愯〃 popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� tabBtn: null, // 琛ㄥ崟鏍囩鎸夐挳 tabParam: null, // 琛ㄥ崟鏍囩鍙傛暟 - refreshtabs: null // 闇�瑕佸埛鏂扮殑鏍囩闆� + refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� + confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓� + settingVisible: false // 鑷畾涔夎缃ā鎬佹 } /** @@ -79,12 +80,20 @@ let result = await Api.getSystemCacheConfig(param) if (result.status) { let config = '' + let userConfig = '' try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) } catch (e) { console.warn('Parse Failure') config = '' + } + + try { // 閰嶇疆淇℃伅瑙f瀽 + userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + } catch (e) { + console.warn('Parse Failure') + userConfig = '' } // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� @@ -106,18 +115,34 @@ return } - let _arrField = [] // 瀛楁闆� - let _columns = [] // 鏄剧ず鍒� - let _logcolumns = [] // 鏃ュ織鏄剧ず鍒� - let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� - let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 - // 鏉冮檺杩囨护 config.action = config.action.filter(item => permAction[item.uuid]) // config.tabgroups.forEach(group => { // if (!config[group]) return // config[group] = config[group].filter(tab => permAction[tab.uuid]) // }) + + if (userConfig) { + config.setting = {...config.setting, ...userConfig.setting} + let _actions = {} + userConfig.action.forEach(item => { + _actions[item.uuid] = item + }) + + config.action = config.action.map(item => { + if (_actions[item.uuid]) { + item = {...item, ..._actions[item.uuid]} + } + + return item + }) + } + + let _arrField = [] // 瀛楁闆� + let _columns = [] // 鏄剧ず鍒� + let _logcolumns = [] // 鏃ュ織鏄剧ず鍒� + let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� + let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 let _actions = [] // 宸ュ叿鏍忔寜閽� let _operations = [] // 鎿嶄綔鍒楁寜閽紙瀛樺湪鏃讹級 @@ -180,17 +205,6 @@ } }) - let _isLinkMain = false // 妫�鏌ユ槸鍚︽湁涓庝富琛ㄥ叧鑱旂殑瀛愯〃 - config.tabgroups.forEach(groupId => { - if (!config[groupId] || config[groupId].length === 0) return - - config[groupId].forEach(tab => { - if (tab.supMenu === 'mainTable') { - _isLinkMain = true - } - }) - }) - this.setState({ loadingview: false, config: config, @@ -199,18 +213,17 @@ actions: _actions, columns: _columns, logcolumns: _logcolumns, - isLinkMain: _isLinkMain, arr_field: _arrField.join(','), search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { this.improveSearch() - if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇 this.setState({ loading: true }) this.loadmaindata() } + this.setShortcut() }) } else { this.setState({ @@ -221,6 +234,36 @@ top: 92, message: result.message, duration: 10 + }) + } + } + + setShortcut = () => { + const { actions } = this.state + if (!actions) return + + document.onkeydown = (event) => { + let e = event || window.event + let keyCode = e.keyCode || e.which || e.charCode + let preKey = '' + + if (e.ctrlKey) { + preKey = 'ctrl' + } else if (e.shiftKey) { + preKey = 'shift' + } else if (e.altKey) { + preKey = 'alt' + } + + let istrigger = false + actions.forEach(item => { + if (!item.shortcut || istrigger) return + + if (preKey === item.shortcut && keyCode === item.shortcutkey) { + e.preventDefault() + istrigger = true + this.refs.mainButton.actionTrigger(item) + } }) } } @@ -551,9 +594,7 @@ orderBy: '', search: '', BIDs: {}, - setsingle: false, - pickup: false, - isLinkMain: false + pickup: false }, () => { this.loadconfig() }) @@ -665,22 +706,6 @@ [type]: id, [type + 'data']: data } - }) - } - - /** - * @description 琛ㄦ牸鍗曢�夊閫夊垏鎹� - */ - checkChange = () => { - const { setsingle, BIDs } = this.state - - let _BIDs = JSON.parse(JSON.stringify(BIDs)) - _BIDs.mainTable = '' - - this.setState({ - setsingle: !setsingle, - pickup: false, - BIDs: _BIDs }) } @@ -831,19 +856,50 @@ }) } + controlCustomSetting = () => { + this.setState({ + settingVisible: true, + confirmLoading: false + }) + } + + settingSubmit = () => { + this.verifyRef.handleConfirm().then(res => { + let _LongParam = '' + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(res))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 10 + }) + return + } + + let param = { + func: 'sPC_TrdMenu_UserParam', + MenuID: this.props.MenuID, + LongParam: _LongParam + } + + this.setState({ + confirmLoading: true + }) + + Api.getSystemConfig(param).then(result => { + this.setState({ + settingVisible: false, + confirmLoading: false + }) + }) + }) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() - } - - componentDidMount () { - // document.onkeydown = (event) => { - // let e = event || window.event - - // if(e && e.keyCode === 27) { - // console.log(this.props.MenuID) - // } - // } } UNSAFE_componentWillReceiveProps(nextProps) { @@ -871,11 +927,11 @@ } render() { - const { view, setting, searchlist, actions, columns, loadingview, viewlost, setsingle, pickup, isLinkMain, config } = this.state + const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config } = this.state return ( <div> - {view === 'commontable' ? <div className={'commontable ' + (isLinkMain ? 'pick-control' : '')} id={this.state.ContainerId}> + {view === 'commontable' ? <div className="commontable pick-control" id={this.state.ContainerId}> {loadingview && <Spin size="large" />} {searchlist && searchlist.length > 0 ? <MainSearch @@ -904,18 +960,15 @@ } {columns && setting.onload !== 'false' ? <div className="main-table-box"> - {isLinkMain ? - <div className="pickchange"> - {setting.tableType === 'checkbox' ? <Switch title="鍗曢�夊垏鎹�" checkedChildren="鍗�" unCheckedChildren="澶�" defaultChecked={setsingle} onChange={this.checkChange} /> : null} - {this.state.BIDs.mainTable && (setting.tableType === 'radio' || setsingle) ? <Switch title="鏀惰捣" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null} - </div> : null + <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> + {this.state.data && this.state.data.length > 0 ? + <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } <MainTable ref="mainTable" pickup={pickup} setting={setting} columns={columns} - setsingle={setsingle} dict={this.state.dict} data={this.state.data} total={this.state.total} @@ -1010,6 +1063,25 @@ {this.getTreeNode(config.funcs)} </Tree> : null} </Modal> + {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} + <Modal + wrapClassName="common-table-custom-modal" + title={'鑷畾涔夎缃�'} + maskClosable={false} + width={850} + visible={this.state.settingVisible} + onOk={this.settingSubmit} + onCancel={() => { this.setState({ settingVisible: false }) }} + confirmLoading={this.state.confirmLoading} + destroyOnClose + > + {this.state.config ? + <VerifyCard + config={this.state.config} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> : null + } + </Modal> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> : null} {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null} -- Gitblit v1.8.0