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/carousel/prop-card/index.jsx | 79 +++++++++++++++++++++++++++++---------- 1 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index e732b7a..ba2b928 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -49,6 +49,8 @@ } 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,8 +66,6 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else if (_config.wrap.datatype === 'static') { - this.loaded = true } _data.$$uuid = _data[_config.setting.primaryKey] || '' @@ -91,15 +91,7 @@ BID: BID || '', BData: BData || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } else if (_config.wrap.display === 'modal' && _config.wrap.datatype === 'static') { - this.openModal() - } + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -126,16 +118,7 @@ }) } - 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() } shouldComponentUpdate (nextProps, nextState) { @@ -156,6 +139,60 @@ this.timer && this.timer.stop() } + initExec = () => { + const { config } = this.state + + if (config.wrap.datatype === 'dynamic') { + 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 (this.loaded) { + this.openModal() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.openModal() + } + } else if (config.wrap.display === 'modal' && config.wrap.datatype === 'static') { + this.openModal() + } + } + transferSyncData = (syncId) => { const { config } = this.state -- Gitblit v1.8.0