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/verupmanage/subtabtable/index.jsx | 77 ++++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/tabviews/verupmanage/subtabtable/index.jsx b/src/tabviews/verupmanage/subtabtable/index.jsx index f33788b..d33454c 100644 --- a/src/tabviews/verupmanage/subtabtable/index.jsx +++ b/src/tabviews/verupmanage/subtabtable/index.jsx @@ -29,7 +29,6 @@ MenuID: PropTypes.string, // 鑿滃崟Id SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID - handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃 refreshtabs:PropTypes.any } @@ -54,22 +53,15 @@ popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 + BID: '', + BData: '' } /** * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 */ UNSAFE_componentWillReceiveProps(nextProps) { - if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { - this.setState({ - pageIndex: 1, - selectedData: [] - }, () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.loadmaindata(nextProps.BID, 'refresh') - }) - } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { - + if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { this.reloadtable() } } @@ -78,7 +70,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { Tab, BID } = this.props + const { Tab, BID, BData } = this.props let config = tabConfig[this.props.MenuID] @@ -127,6 +119,8 @@ } this.setState({ + BID: BID || '', + BData: BData || '', config: config, setting: config.setting, searchlist: config.search, @@ -152,14 +146,12 @@ /** * @description 瀛愯〃鏁版嵁鍔犺浇 */ - async loadmaindata (bid, type) { - const { setting } = this.state + async loadmaindata (type) { + const { setting, BID } = this.state let param = '' - let _BID = this.props.BID if (type === 'refresh') { - _BID = bid - if (!bid) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 + if (!BID) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 this.setState({ data: [], total: 0, @@ -171,12 +163,10 @@ } if (setting.interType === 'system') { - param = this.getDefaultParam(_BID) + param = this.getDefaultParam(BID) } else { - param = this.getCustomParam(_BID) + param = this.getCustomParam(BID) } - - this.handleTableId() let result = await Api.genericInterface(param) if (result.status) { @@ -184,7 +174,7 @@ data: result.data.map((item, index) => { item.key = index item.$$uuid = item[setting.primaryKey] || '' - item.$$BID = _BID || '' + item.$$BID = BID || '' return item }), total: result.total, @@ -304,7 +294,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -342,7 +332,7 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -404,13 +394,6 @@ } /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { - this.props.handleTableId(type, id, data) - } - - /** * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 */ pickupChange = () => { @@ -421,13 +404,35 @@ }) } + changeTableLine = (ContainerId, tableId, id, data) => { + const { Tab } = this.props + + if (tableId !== Tab.supMenu) return + + this.setState({BData: data, BID: id}) + + if (id !== this.state.BID) { + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1, + selectedData: [] + }, () => { + this.loadmaindata('refresh') + }) + } + } + UNSAFE_componentWillMount() { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } + componentDidMount () { + MKEmitter.addListener('changeTableLine', this.changeTableLine) + } + shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) } /** @@ -437,10 +442,11 @@ this.setState = () => { return } + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } render() { - const { setting, searchlist, actions, columns, pickup, selectedData } = this.state + const { BID, BData, setting, searchlist, actions, columns, pickup, selectedData } = this.state return ( <div className="verup-subtable" id={'subtable' + this.props.MenuID}> @@ -451,12 +457,12 @@ <div className="sub-action"> <SubAction type="sub" + BID={BID} + BData={BData} setting={setting} actions={actions} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} dict={this.state.dict} selectedData={selectedData} MenuID={this.props.SupMenuID} @@ -482,7 +488,6 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={() => {}} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> : null -- Gitblit v1.8.0