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/card/balcony/index.jsx | 88 ++++++++++++++++++++++++++++++-------------- 1 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index e65688f..ff3bec1 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -49,6 +49,8 @@ let _data = { $$empty: true } if (_config.wrap.datatype === 'dynamic') { + _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true' + if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { _data = window.GLOB.SyncData.get(_config.dataName) || [] @@ -64,12 +66,11 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { - _data = window.GLOB.CacheData.get(_config.wrap.publicId) - _data = fromJS(_data).toJS() - this.loaded = true - } else if (_config.wrap.datatype === 'static') { - this.loaded = true + } else if (_config.wrap.datatype === 'public') { + if (window.GLOB.CacheData.has(_config.wrap.publicId)) { + _data = window.GLOB.CacheData.get(_config.wrap.publicId) + _data = fromJS(_data).toJS() + } } _data.$$BID = BID || '' @@ -118,13 +119,7 @@ data: _data, BID: BID || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -146,20 +141,13 @@ MKEmitter.addListener('mkPublicData', this.mkPublicData) } - if (config.timer && config.wrap.datatype === 'dynamic') { - this.timer = new TimerTask() - this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) - } + if (config.wrap.datatype === 'dynamic') { + if (config.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) + } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - let _data = res[0] || {$$empty: true} - _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.setState({data: _data}) - }) + this.initExec() } } @@ -181,6 +169,52 @@ MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) this.timer && this.timer.stop() + } + + initExec = () => { + const { config } = this.state + + if (config.$cache) { + if (config.$time) { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res && config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + + if (!res || this.loaded) return + + let _data = res[0] || {$$empty: true} + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + }) + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + let _data = res[0] || {$$empty: true} + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } } transferSyncData = (syncId) => { @@ -220,8 +254,6 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' - - this.loaded = true this.setState({data: _data}) } -- Gitblit v1.8.0