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/subtable/index.jsx | 110 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index f716868..e17dc76 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -34,7 +34,6 @@ SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id mainSearch: PropTypes.any, // 涓昏〃鎼滅储鏉′欢 ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID - handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d } state = { @@ -62,23 +61,18 @@ statFValue: [], // 鍚堣鍊� absFields: [], // 缁濆鍊煎瓧娈� loadCustomApi: true, // 鍔犺浇澶栭儴璧勬簮 - hasReqFields: false + hasReqFields: false, + BID: '', + BData: '' } /** * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 */ UNSAFE_componentWillReceiveProps(nextProps) { - const { config, setting } = this.state + const { setting } = this.state - if (config && setting && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { - this.loadData() - }) - } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({}, () => { this.loadData() }) @@ -89,7 +83,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, permMenus, Tab, BID } = this.props + const { permAction, permMenus, Tab, BID, BData } = this.props let param = { func: 'sPC_Get_LongParam', @@ -327,6 +321,8 @@ } this.setState({ + BID: BID || '', + BData: BData || '', loadingview: false, chartId, config, @@ -360,8 +356,8 @@ } loadData = () => { - const { mainSearch, BID } = this.props - const { setting, search, loadCustomApi, hasReqFields } = this.state + const { mainSearch } = this.props + const { setting, BID, search, loadCustomApi, hasReqFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -385,7 +381,7 @@ statFValue: [], total: 0 }) - this.handleTableId() + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') return } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { notification.warning({ @@ -399,7 +395,7 @@ this.setState({ selectedData: [] }) - this.handleTableId() + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') if (setting.interType === 'custom' && loadCustomApi) { if (setting.execTime === 'once') { @@ -416,8 +412,7 @@ } loadOutResource = (searches) => { - const { BID } = this.props - const { setting } = this.state + const { setting, BID } = this.state let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) @@ -511,7 +506,7 @@ } customCallbackRequest = (result) => { - const { setting } = this.state + const { setting, BID } = this.state let errSql = '' if (result.$ErrCode === 'E') { errSql = ` @@ -535,8 +530,8 @@ param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) - if (this.props.BID) { - param.BID = this.props.BID + if (BID) { + param.BID = BID } if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 @@ -587,8 +582,8 @@ * @description 瀛愯〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { mainSearch, BID } = this.props - const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + const { mainSearch } = this.props + const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -660,8 +655,8 @@ * @description 鑾峰彇鍗曡鏁版嵁 */ async loadmainLinedata (id) { - const { mainSearch, BID } = this.props - const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + const { mainSearch } = this.props + const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -736,8 +731,7 @@ * @description 鑾峰彇鍚堣瀛楁鍊� */ getStatFieldsValue = (searches) => { - const { BID } = this.props - const { setting, orderBy, statFields } = this.state + const { setting, BID, orderBy, statFields } = this.state if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return @@ -782,7 +776,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches, @@ -817,14 +811,14 @@ */ reloadtable = (btn) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 this.loadData() } } @@ -856,13 +850,6 @@ */ changeSelectedData = (selectedData) => { this.setState({selectedData}) - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { - this.props.handleTableId(type, id, data) } /** @@ -907,15 +894,14 @@ if (MenuID !== menuId) return - const { Tab, SupMenuID, BID } = this.props + const { Tab, SupMenuID } = this.props + const { BID } = this.state if (position === 'grid' || position === 'view') { this.reloadtable(btn) } else if (position === 'maingrid' || position === 'mainline') { this.reloadtable(btn) - if (Tab.supMenu === 'mainTable') { - MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 涓昏〃閲嶇疆 - } else if (Tab.supMenu) { + if (Tab.supMenu) { MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 涓昏〃閲嶇疆 } else if (!Tab.supMenu && Tab.level === 0) { MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 鏍戝舰缁撴瀯锛�0绾ф爣绛� @@ -928,17 +914,35 @@ } } + changeTableLine = (ContainerId, tableId, id, data) => { + const { Tab } = this.props + + if (!Tab.supMenu || 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 + }, () => { + this.loadData() + }) + } + } + UNSAFE_componentWillMount() { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } - shouldComponentUpdate (nextProps, nextState) { // handleTableId 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleTableId: ''}), fromJS({...nextProps, handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) } componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('changeTableLine', this.changeTableLine) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) } @@ -951,18 +955,19 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state + const { config, BID, BData, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state return ( <div className="subtable" id={'subtable' + this.props.MenuID}> {loadingview && <Spin />} {searchlist && searchlist.length ? - <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null + <SubSearch BID={BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } {config ? <Row className="chart-view" gutter={16}> {/* 瑙嗗浘缁� */} @@ -979,12 +984,12 @@ {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} <div className="sub-action"> <SubAction + BID={BID} + BData={BData} setting={setting} actions={actions} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} MenuID={this.props.MenuID} selectedData={selectedData} ContainerId={this.props.ContainerId} @@ -995,6 +1000,7 @@ <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null } <SubTable + BData={BData} tableId={this.props.Tab.uuid} pickup={pickup} setting={setting} @@ -1002,14 +1008,12 @@ pageSize={pageSize} dict={this.state.dict} data={this.state.data} - BData={this.props.BData} total={this.state.total} MenuID={this.props.MenuID} loading={this.state.loading} statFValue={this.state.statFValue} ContainerId={this.props.ContainerId} refreshdata={this.refreshbytable} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> @@ -1019,17 +1023,17 @@ return ( <Col className="card-view" span={item.width} key={item.uuid}> <CardComponent + BID={BID} plot={item} + BData={BData} config={config} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} data={this.state.data} MenuID={this.props.MenuID} loading={this.state.loading} tableId={this.props.Tab.uuid} - handleTableId={this.handleTableId} + ContainerId={this.props.ContainerId} /> </Col> ) @@ -1037,9 +1041,9 @@ return ( <Col span={item.width} key={item.uuid}> <ChartComponent + BID={BID} plot={item} config={config} - BID={this.props.BID} Tab={this.props.Tab} data={this.state.data} loading={this.state.loading} -- Gitblit v1.8.0