From 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 25 七月 2023 16:36:23 +0800 Subject: [PATCH] 2023-07-25 --- src/tabviews/custom/components/table/normal-table/index.jsx | 314 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 183 insertions(+), 131 deletions(-) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 59e8a1f..262deee 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -81,52 +81,56 @@ setting.orisel = true } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - _data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) - } - - _config.setting.sync = 'false' - - _data = _data.map((item, index) => { - item.key = index - item.$$uuid = item[_config.setting.primaryKey] || '' - item.$$key = '' + item.key + item.$$uuid - item.$$BID = BID || '' - item.$$BData = BData || '' - item.$Index = index + 1 + '' - - if (_config.absFields) { - _config.absFields.forEach(f => { - if (!isNaN(item[f])) { - item[f] = Math.abs(item[f]) - } - }) + if (window.GLOB.SyncData.has(_config.dataName)) { + _data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) } - - if (setting.controlField) { - if (setting.controlVal.includes(item[setting.controlField] + '')) { - item.$disabled = true + + _config.setting.sync = 'false' + + _data = _data.map((item, index) => { + item.key = index + item.$$uuid = item[_config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + 1 + '' + + if (_config.absFields) { + _config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + }) + + if (setting.selected !== 'false' && _data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', _config.uuid, '', setting.selected) + }, 200) + if (setting.selected === 'init') { + setting.selected = 'false' } } - - return item - }) - - if (setting.selected !== 'false' && _data.length > 0) { - setTimeout(() => { - MKEmitter.emit('mkCheckTopLine', _config.uuid, '', setting.selected) - }, 200) - if (setting.selected === 'init') { - setting.selected = 'false' - } + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } if (_config.wrap.collapse === 'true') { @@ -147,16 +151,145 @@ columns: _config.cols, arr_field: _config.columns.map(col => col.field).join(','), search: _config.$searches - }, () => { - if (config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadmaindata() - this.getStatFieldsValue() - }, _config.setting.delay || 0) - } else if (_config.setting.onload === 'true') { - this.getStatFieldsValue() - } }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + const { config } = this.state + + MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('refreshLineData', this.refreshLineData) + MKEmitter.addListener('resetSelectLine', this.resetParentParam) + MKEmitter.addListener('queryModuleParam', this.queryModuleParam) + MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.setting.useMSearch) { + MKEmitter.addListener('searchRefresh', this.searchRefresh) + } + + if (config.setting.sync === 'true') { + MKEmitter.addListener('transferSyncData', this.transferSyncData) + } + + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata(true, 'true', '', 'timer') + this.getStatFieldsValue() + }) + }) + } + + this.initExec() + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('searchRefresh', this.searchRefresh) + MKEmitter.removeListener('refreshLineData', this.refreshLineData) + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) + MKEmitter.removeListener('transferSyncData', this.transferSyncData) + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + this.timer && this.timer.stop() + } + + initExec = () => { + const { config, setting } = this.state + + if (config.$cache) { + if (config.$time && !setting.laypage) { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res && config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + }, config.setting.delay || 0) + } + + if (!res || this.loaded) return + + this.setState({data: res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$Index = index + 1 + '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + })}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$Index = index + 1 + '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField] + '')) { + item.$disabled = true + } + } + + return item + })}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + this.getStatFieldsValue() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + this.getStatFieldsValue() + }, config.setting.delay || 0) + } } transferSyncData = (syncId) => { @@ -702,87 +835,6 @@ this.setState({pageIndex: 1}, () => { this.reloadtable() }) - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - componentDidMount () { - const { config, setting } = this.state - - MKEmitter.addListener('reloadData', this.reloadData) - MKEmitter.addListener('refreshLineData', this.refreshLineData) - MKEmitter.addListener('resetSelectLine', this.resetParentParam) - MKEmitter.addListener('queryModuleParam', this.queryModuleParam) - MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) - - if (config.setting.useMSearch) { - MKEmitter.addListener('searchRefresh', this.searchRefresh) - } - - if (config.setting.sync === 'true') { - MKEmitter.addListener('transferSyncData', this.transferSyncData) - } - - if (config.timer) { - this.timer = new TimerTask() - this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { - this.setState({ - pageIndex: 1 - }, () => { - this.loadmaindata(true, 'true', '', 'timer') - this.getStatFieldsValue() - }) - }) - } - - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.setState({data: res.map((item, index) => { - item.key = index - item.$$uuid = item[config.setting.primaryKey] || '' - item.$$key = '' + item.key + item.$$uuid - item.$Index = index + 1 + '' - - if (config.absFields) { - config.absFields.forEach(f => { - if (!isNaN(item[f])) { - item[f] = Math.abs(item[f]) - } - }) - } - - if (setting.controlField) { - if (setting.controlVal.includes(item[setting.controlField] + '')) { - item.$disabled = true - } - } - - return item - })}) - }) - } - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('reloadData', this.reloadData) - MKEmitter.removeListener('searchRefresh', this.searchRefresh) - MKEmitter.removeListener('refreshLineData', this.refreshLineData) - MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - MKEmitter.removeListener('transferSyncData', this.transferSyncData) - MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) - MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) - - this.timer && this.timer.stop() } render() { -- Gitblit v1.8.0