From 4b6a4e2f04f492d770573cf48ca52d4e748a086a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 18 十月 2021 18:30:50 +0800 Subject: [PATCH] 2021-10-18 --- src/tabviews/commontable/index.jsx | 65 +++++++++++++++++++------------- 1 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 5e6d483..d37f4be 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -392,7 +392,9 @@ _actions.forEach(item => { if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { autoMatic = config.autoMatic + autoMatic.OpenType = item.execMode || item.OpenType config.setting.selected = 'false' + item.autoMatic = true } }) } @@ -474,15 +476,12 @@ } loadData = () => { + const { MenuID } = this.props const { setting, search, BIDs, loadCustomApi, hasReqFields } = this.state this.setState({ selectedData: [], - BIDs: { - ...BIDs, - mainTable: '', - mainTabledata: '' - } + BIDs: { ...BIDs, [MenuID]: '', [MenuID + 'data']: '' } }) if (hasReqFields) { @@ -690,7 +689,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state + const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state this.setState({ loading: true @@ -740,10 +739,21 @@ loading: false, pickup: false }) + + if (autoMatic) { + if (result.data && result.data.length > 0) { + MKEmitter.emit('autoGetData', this.props.MenuID) + } else { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + } + } } else { this.setState({ loading: false }) + if (autoMatic) { + MKEmitter.emit('autoMaticError', this.props.MenuID) + } notification.error({ top: 92, message: result.message, @@ -881,7 +891,7 @@ this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches @@ -895,6 +905,15 @@ * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 */ refreshbytable = (pagination, filters, sorter) => { + if (!sorter) { + this.setState({ + pageIndex: pagination.pageIndex + }, () => { + this.loadData() + }) + return + } + if (sorter.order) { let _chg = { ascend: 'asc', @@ -917,14 +936,14 @@ */ reloadtable = (btn) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 鍒楄〃閲嶇疆 this.loadData() } } @@ -963,21 +982,6 @@ */ changeSelectedData = (selectedData) => { this.setState({selectedData}) - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) } /** @@ -1035,6 +1039,14 @@ this.setShortcut() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� * @param {*} menuId // 鑿滃崟Id @@ -1061,6 +1073,7 @@ componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('changeTableLine', this.changeTableLine) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) @@ -1076,6 +1089,7 @@ document.onkeydown = () => {} MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) @@ -1135,7 +1149,6 @@ statFValue={this.state.statFValue} ContainerId={this.state.ContainerId} refreshdata={this.refreshbytable} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> @@ -1154,7 +1167,6 @@ data={this.state.data} loading={this.state.loading} ContainerId={this.state.ContainerId} - handleTableId={this.handleTableId} /> </Col> ) @@ -1191,7 +1203,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> </TabPane> ) -- Gitblit v1.8.0