From c51f5e007a3e03c9d6731ab7f28f0080de009990 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 17 十一月 2021 18:38:32 +0800 Subject: [PATCH] 2021-11-17 --- src/tabviews/custom/components/table/normal-table/index.jsx | 87 +++++++++++++++++++++++++++++++------------ 1 files changed, 62 insertions(+), 25 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index cd57cff..2f53d2c 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -56,11 +56,16 @@ * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦 */ UNSAFE_componentWillMount () { - const { data, initdata, BID } = this.props + const { data, initdata, BID, BData } = this.props let _config = fromJS(this.props.config).toJS() let _cols = new Map() let _data = null let _sync = _config.setting.sync === 'true' + let setting = {..._config.setting, ..._config.wrap, style: {}} + + if (setting.selected !== 'always' && setting.selected !== 'init') { + setting.selected = 'false' + } if (_config.setting.sync === 'true' && data) { _data = data[_config.dataName] || [] @@ -75,9 +80,19 @@ item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' item.$$BID = BID || '' + item.$$BData = BData || '' item.$Index = index + 1 + '' return item }) + + if (setting.selected !== 'false' && _data && _data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', _config.uuid) + }, 200) + if (setting.selected === 'init') { + setting.selected = 'false' + } + } } _config.columns.forEach(item => { @@ -97,7 +112,6 @@ } }) - let setting = {..._config.setting, ..._config.wrap, style: {}} if (setting.color) { setting.style.color = setting.color } @@ -110,7 +124,9 @@ } this.setState({ + pageSize: setting.pageSize || 10, BID: BID || '', + BData: BData || '', title: _config.wrap.title, sync: _sync, data: _data, @@ -178,7 +194,20 @@ let result = await Api.genericInterface(param) if (result.status) { - MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + if (setting.selected !== 'false' && result.data && result.data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid) + }, 200) + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } + } else { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } + } + reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 let start = 1 @@ -199,9 +228,6 @@ total: result.total, loading: false }) - if (setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, [], false) - } } else { this.setState({ loading: false @@ -263,7 +289,7 @@ } return item }) - } catch { + } catch (e) { console.warn('鏁版嵁鏌ヨ閿欒') } } @@ -460,7 +486,7 @@ const { setting } = this.state if (!setting.supModule || setting.supModule !== MenuID) return - if (id !== this.state.BID) { + if (id !== this.state.BID || id !== '') { this.setState({ pageIndex: 1, BID: id, @@ -478,12 +504,16 @@ * @param {*} position // 鍒锋柊浣嶇疆 * @param {*} btn // 鎵ц鐨勬寜閽� */ - refreshByButtonResult = (menuId, position, btn) => { + refreshByButtonResult = (menuId, position, btn, id, lines) => { const { config, BID } = this.state if (config.uuid !== menuId) return - this.reloadtable(btn) // 鏁版嵁鍒锋柊 + if (position === 'line' && lines && lines.length === 1) { + this.loadmainLinedata(lines[0].$$uuid) + } else { + this.reloadtable(btn) // 鏁版嵁鍒锋柊 + } if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) { MKEmitter.emit('reloadData', btn.syncComponentId) // 鍚岀骇鏍囩鍒锋柊 @@ -498,20 +528,30 @@ } UNSAFE_componentWillReceiveProps(nextProps) { - const { sync, config, BID } = this.state + const { sync, config, setting, BID, BData } = this.state if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { let _data = [] if (nextProps.data && nextProps.data[config.dataName]) { _data = nextProps.data[config.dataName] || [] + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + return item + }) + + if (setting.selected !== 'false' && _data && _data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid) + }, 200) + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } + } } - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$$BID = BID || '' - item.$Index = index + 1 + '' - return item - }) this.setState({sync: false, data: _data}) } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { @@ -546,7 +586,7 @@ } render() { - const { BID, setting, searchlist, actions, config, columns, selectedData } = this.state + const { BID, setting, searchlist, actions, config, columns, selectedData, BData } = this.state return ( <div className="custom-normal-table" style={config.style}> @@ -559,7 +599,7 @@ BID={BID} setting={setting} actions={actions} - BData={this.state.BData} + BData={BData} columns={config.columns} selectedData={selectedData} /> @@ -588,7 +628,7 @@ BID={BID} setting={setting} actions={actions} - BData={this.state.BData} + BData={BData} columns={config.columns} selectedData={selectedData} /> @@ -615,10 +655,7 @@ const mapStateToProps = (state) => { return { - menuType: state.editLevel, - tabviews: state.tabviews, - permAction: state.permAction, - permMenus: state.permMenus + menuType: state.editLevel } } -- Gitblit v1.8.0