From e5fc2d92b1036aabf9ffc2c9706ed401bd9735c8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 09 九月 2021 18:14:29 +0800 Subject: [PATCH] 2021-09-09 --- src/tabviews/custom/components/table/normal-table/index.jsx | 76 ++++++++++++++++++++++++++----------- 1 files changed, 53 insertions(+), 23 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..bfe5644 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -61,6 +61,11 @@ 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] || [] @@ -78,6 +83,15 @@ 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 +111,6 @@ } }) - let setting = {..._config.setting, ..._config.wrap, style: {}} if (setting.color) { setting.style.color = setting.color } @@ -138,7 +151,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 +161,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 +191,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 +214,7 @@ item.key = index item.$$uuid = item[setting.primaryKey] || '' item.$$BID = BID || '' + item.$$BData = BData || '' item.$Index = start + index + '' return item }), @@ -195,6 +222,9 @@ total: result.total, loading: false }) + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } } else { this.setState({ loading: false @@ -212,7 +242,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 +269,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 +286,7 @@ } return item }) - } catch { + } catch (e) { console.warn('鏁版嵁鏌ヨ閿欒') } } @@ -489,29 +520,30 @@ } } - 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 } = 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.$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 +559,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,7 +572,6 @@ 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) -- Gitblit v1.8.0