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/zshare/normalTable/index.jsx | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 02a78f8..5c49361 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -45,7 +45,6 @@ total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� - handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲 chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲 } @@ -237,6 +236,8 @@ componentDidMount () { MKEmitter.addListener('resetTable', this.resetTable) + MKEmitter.addListener('autoQueryData', this.autoQueryData) + MKEmitter.addListener('autoSelectData', this.autoSelectData) MKEmitter.addListener('mkTableCheckTopLine', this.mkTableCheckTopLine) } @@ -248,6 +249,8 @@ return } MKEmitter.removeListener('resetTable', this.resetTable) + MKEmitter.removeListener('autoQueryData', this.autoQueryData) + MKEmitter.removeListener('autoSelectData', this.autoSelectData) MKEmitter.removeListener('mkTableCheckTopLine', this.mkTableCheckTopLine) } @@ -257,6 +260,43 @@ if (this.props.data.length > 0) { this.changeRow(null, 0) } + } + + autoSelectData = (id, index) => { + if (id !== this.props.MenuID) return + + const { pageSize, pageIndex } = this.state + + let i = index - (pageIndex - 1) * pageSize - 1 + + if (this.props.data[i]) { + this.changeRow(null, i) + MKEmitter.emit('autoTransSelectData', this.props.MenuID, this.props.data[i]) + } else { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + } + } + + autoQueryData = (id, index) => { + if (id !== this.props.MenuID) return + + const { total } = this.props + const { pageSize } = this.state + + if (index !== 1 && (!total || index > total)) { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + return + } + + let pageIndex = Math.ceil(index / pageSize) + + this.setState({ + pageIndex: pageIndex, + selectedRowKeys: [], + activeIndex: null + }) + + this.props.refreshdata({pageIndex}) } // 瀛楁閫忚 @@ -1016,7 +1056,9 @@ } changedata = (index) => { - const { data, setting } = this.props + const { data, setting, tableId, ContainerId } = this.props + + if (!tableId || !ContainerId) return let _id = '' let _data = '' @@ -1026,13 +1068,13 @@ _data = data[index] || '' } - this.props.handleTableId(this.props.tableId, _id, _data) + MKEmitter.emit('changeTableLine', ContainerId, tableId, _id, _data) } resetTable = (id, repage) => { - const { MenuID, tableId } = this.props + const { tableId } = this.props - if (id !== (MenuID + tableId)) return + if (id !== tableId) return if (repage === 'false') { this.setState({ -- Gitblit v1.8.0