From 432b788acf901b0720184b8ee8bc81a2e6fa47e0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 28 九月 2021 18:22:02 +0800 Subject: [PATCH] 2021-09-28 --- src/tabviews/custom/components/table/normal-table/index.jsx | 88 ++++++++++++++++++++++++++++++-------------- 1 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 2c57e82..9adf4bf 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') { + 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 } @@ -111,6 +125,7 @@ this.setState({ BID: BID || '', + BData: BData || '', title: _config.wrap.title, sync: _sync, data: _data, @@ -138,7 +153,7 @@ */ async loadmaindata (reset, repage) { const { mainSearch } = this.props - const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state + const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -148,6 +163,9 @@ }) MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } return } @@ -175,7 +193,17 @@ let result = await Api.genericInterface(param) if (result.status) { - MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + if (setting.selected !== 'false') { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid) + }, 200) + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } + } else { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + } + reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 let start = 1 @@ -188,6 +216,7 @@ item.key = index item.$$uuid = item[setting.primaryKey] || '' item.$$BID = BID || '' + item.$$BData = BData || '' item.$Index = start + index + '' return item }), @@ -195,6 +224,9 @@ total: result.total, loading: false }) + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } } else { this.setState({ loading: false @@ -212,7 +244,7 @@ */ async loadmainLinedata (id) { const { mainSearch } = this.props - const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state + const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state let searches = fromJS(search).toJS() if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -239,6 +271,7 @@ let _data = result.data[0] || {} _data.$$uuid = _data[setting.primaryKey] || '' _data.$$BID = BID || '' + _data.$$BData = BData || '' try { data = data.map(item => { if (item.$$uuid === _data.$$uuid) { @@ -255,7 +288,7 @@ } return item }) - } catch { + } catch (e) { console.warn('鏁版嵁鏌ヨ閿欒') } } @@ -489,29 +522,31 @@ } } - getSyncData = (syncModule, btnId) => { - const { config, selectedData } = this.state - - if (config.uuid !== syncModule) return - - MKEmitter.emit('triggerBtnId', btnId, (selectedData || [])) - } - 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') { + 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))) { @@ -527,7 +562,6 @@ componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) - MKEmitter.addListener('getSyncData', this.getSyncData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) @@ -541,14 +575,13 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) - MKEmitter.removeListener('getSyncData', this.getSyncData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } 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}> @@ -561,7 +594,7 @@ BID={BID} setting={setting} actions={actions} - BData={this.state.BData} + BData={BData} columns={config.columns} selectedData={selectedData} /> @@ -590,7 +623,7 @@ BID={BID} setting={setting} actions={actions} - BData={this.state.BData} + BData={BData} columns={config.columns} selectedData={selectedData} /> @@ -618,7 +651,6 @@ const mapStateToProps = (state) => { return { menuType: state.editLevel, - tabviews: state.tabviews, permAction: state.permAction, permMenus: state.permMenus } -- Gitblit v1.8.0