From 07c005cf28acf74e3afde82122e4c53e1000d70c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 12 六月 2023 12:06:18 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/tabviews/custom/components/carousel/data-card/index.jsx | 73 +++++++++++++++++++++++++----------- 1 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx index 8829c61..590bc98 100644 --- a/src/tabviews/custom/components/carousel/data-card/index.jsx +++ b/src/tabviews/custom/components/carousel/data-card/index.jsx @@ -32,11 +32,12 @@ visible: false } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() let _card = _config.subcards[0] - let _cols = new Map() let _data = null let _sync = _config.setting.sync === 'true' @@ -62,6 +63,7 @@ } if (_data) { + this.loaded = true _data = _data.map((item, index) => { item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' @@ -72,21 +74,9 @@ }) } - _config.columns.forEach(item => { - if (item.type !== 'number') return - _cols.set(item.field, item) - }) - if (_card.setting.click) { _card.style.cursor = 'pointer' } - - _card.elements = _card.elements.map(item => { - if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { - item.decimal = _cols.get(item.field).decimal || 0 - } - return item - }) if (!_config.wrap.height) { // 鍏煎 _config.wrap.height = _config.style.height || '300px' @@ -129,6 +119,21 @@ this.loadData('timer') }) } + + if (config.$cache && !this.loaded) { + Api.getLCacheConfig(config.uuid).then(res => { + if (!res || this.loaded) return + + let _data = res.map((item, index) => { + item.key = index + item.$$uuid = item[config.setting.primaryKey] || '' + item.$Index = index + 1 + '' + return item + }) + + this.setState({data: _data}) + }) + } } shouldComponentUpdate (nextProps, nextState) { @@ -153,6 +158,8 @@ return item }) + this.loaded = true + this.setState({sync: false, data: _data}, () => { this.openModal() }) @@ -174,7 +181,7 @@ this.timer && this.timer.stop() } - openModal = () => { + openModal = (ErrCode) => { const { config, data } = this.state if (config.wrap.display !== 'modal' || !data || data.length === 0) return @@ -188,6 +195,10 @@ localStorage.setItem(code, data[0].$$uuid + data.length) Api.getAppVersion(true) + + if (ErrCode === '-1') { + return + } } setTimeout(() => { @@ -256,6 +267,8 @@ data: [], loading: false }) + + this.loaded = true return } @@ -276,19 +289,33 @@ let result = await Api.genericInterface(param) if (result.status) { + this.loaded = true + if (config.$cache && config.setting.onload !== 'false') { + Api.writeCacheConfig(config.uuid, result.data || '') + } + + let data = result.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 + }) + this.setState({ - data: result.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 - }), + data: data, loading: false }, () => { - this.openModal() + this.openModal(result.ErrCode) }) + + if (config.timer && config.clearField && result.data && result.data[0]) { + let vals = (config.clearValue || '').split(',') + if (vals.includes(result.data[0][config.clearField])) { + this.timer && this.timer.stop() + } + } } else { this.setState({ loading: false -- Gitblit v1.8.0