From 28d65cf7ebfe0dd30ade6973e0634e1c8f663b63 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 十月 2020 16:12:20 +0800 Subject: [PATCH] 2020-10-28 --- src/tabviews/commontable/index.jsx | 123 ++++++++++++++--------------------------- 1 files changed, 42 insertions(+), 81 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 64a04a3..52c0e90 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -14,6 +14,7 @@ import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import { refreshTabView } from '@/store/action' +import MKEmitter from '@/utils/events.js' import MainSearch from '@/tabviews/zshare/topSearch' import NotFount from '@/components/404' @@ -59,7 +60,6 @@ setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� - resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -70,7 +70,6 @@ pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� - triggerBtn: null, // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳 tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 chartId: '', // 灞曞紑鍥捐〃ID statFields: [], // 鍚堣瀛楁 @@ -442,79 +441,58 @@ if (!preKey) return - let istrigger = false + let triggerId = '' - actions.forEach(item => { - if (!item.shortcut || typeof(item.shortcut) !== 'object' || item.shortcut.length === 0 || istrigger) return - - if (preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { + actions.some(item => { + if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { e.preventDefault() - istrigger = true - - this.setState({ - triggerBtn: { - uuid: new Date().getTime(), - parentId: this.props.MenuID, - button: item, - data: null - } - }) + triggerId = item.uuid + return true } + return false }) - if (istrigger) return + if (triggerId) { + MKEmitter.emit('triggerBtnId', triggerId) + return + } - Object.keys(userConfig).forEach(key => { - if (key === this.props.MenuID || !userConfig[key].action || istrigger) return + Object.keys(userConfig).some(key => { + if (key === this.props.MenuID || !userConfig[key].action) return false let _actions = userConfig[key].action - Object.keys(_actions).forEach(btnkey => { + Object.keys(_actions).some(btnkey => { let item = _actions[btnkey] - if (!item.shortcut || typeof(item.shortcut) !== 'object' || item.shortcut.length === 0 || istrigger) return - - if (preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { + if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { e.preventDefault() - istrigger = true + triggerId = btnkey let _groupId = '' let _ActiveTabId = '' config.tabgroups.forEach(group => { - if (group.sublist.length === 0) return - let _tab = group.sublist.filter(tab => tab.uuid === key)[0] - if (_tab) { - _groupId = group.uuid - _ActiveTabId = _tab.uuid - } + + if (!_tab) return + + _groupId = group.uuid + _ActiveTabId = _tab.uuid }) - if (this.state.tabActive[_groupId] === _ActiveTabId) { - this.setState({ - triggerBtn: { - uuid: new Date().getTime(), - parentId: key, - button: {...item, uuid: btnkey}, - data: null - } - }) - } else { - this.setState({ - tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId} - }, () => { - this.setState({ - triggerBtn: { - uuid: new Date().getTime(), - parentId: key, - button: {...item, uuid: btnkey}, - data: null - } - }) - }) - } + this.setState({ + tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId} + }, () => { + MKEmitter.emit('triggerBtnId', triggerId) + }) + + return true } + return false }) + + if (triggerId) return true + return false }) } } @@ -553,6 +531,7 @@ return item }), total: result.total, + selectedData: [], loading: false, pickup: false, BIDs: { @@ -639,9 +618,8 @@ this.getStatFieldsValue() }) } else { + MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 this.setState({ - resetTable: !this.state.resetTable, - selectedData: [], pageIndex: 1, search: searches }, () => { @@ -664,7 +642,6 @@ } this.setState({ - selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -677,9 +654,8 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { + MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 this.setState({ - resetTable: !this.state.resetTable, - selectedData: [], pageIndex: 1 }, () => { this.loadmaindata() @@ -757,20 +733,6 @@ */ changeSelectedData = (selectedData) => { this.setState({selectedData}) - } - - /** - * @description 琛ㄦ牸涓紝鎸夐挳瑙﹀彂浜嬩欢浼犻�� - */ - buttonTrigger = (btn, record) => { - this.setState({ - triggerBtn: { - uuid: new Date().getTime(), - parentId: this.props.MenuID, - button: btn, - data: record - } - }) } /** @@ -909,7 +871,7 @@ render() { const { menuType } = this.props - const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search, selectedData } = this.state + const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state return ( <div className="commontable" id={this.state.ContainerId}> @@ -944,12 +906,10 @@ setting={setting} actions={actions} dict={this.state.dict} - triggerBtn={triggerBtn} MenuID={this.props.MenuID} selectedData={selectedData} logcolumns={this.state.logcolumns} ContainerId={this.state.ContainerId} - operations={config.gridBtn.operations || []} refreshdata={this.refreshbyaction} getexceloutparam={this.getexceloutparam} /> @@ -971,6 +931,7 @@ } <MainTable tableId="mainTable" + BID={BID} pickup={pickup} config={config} setting={setting} @@ -981,11 +942,12 @@ total={this.state.total} MenuID={this.props.MenuID} loading={this.state.loading} - statFValue={this.state.statFValue} refreshdata={this.refreshbytable} - buttonTrigger={this.buttonTrigger} + logcolumns={this.state.logcolumns} + statFValue={this.state.statFValue} handleTableId={this.handleTableId} - resetTable={this.state.resetTable} + ContainerId={this.state.ContainerId} + refreshbyaction={this.refreshbyaction} chgSelectData={this.changeSelectedData} /> </div> @@ -993,7 +955,7 @@ ) } else if (item.chartType === 'card') { return ( - <Col span={item.width} key={item.uuid}> + <Col className="card-view" span={item.width} key={item.uuid}> <CardComponent BID={BID} plot={item} @@ -1043,7 +1005,6 @@ MenuID={_tab.linkTab} mainSearch={_tab.searchPass === 'true' ? search : null} userConfig={userConfig ? userConfig[_tab.uuid] : null} - triggerBtn={triggerBtn} SupMenuID={this.props.MenuID} refreshtabs={this.state.refreshtabs} ContainerId={this.state.ContainerId} -- Gitblit v1.8.0