From e1cee96b38805bcccf48e7bcb9d296f2bc54c720 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 24 一月 2025 11:10:32 +0800 Subject: [PATCH] 2025-01-24 --- src/tabviews/custom/components/chart/antv-dashboard/index.jsx | 85 +++++++++++++++--------------------------- 1 files changed, 31 insertions(+), 54 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx index 3bcdc9c..c796a25 100644 --- a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx +++ b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx @@ -2,8 +2,8 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Chart, registerShape } from '@antv/g2' -import { Spin, notification, Modal } from 'antd' -import { DownloadOutlined } from '@ant-design/icons' +import { Spin } from 'antd' +// import { DownloadOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -91,7 +91,7 @@ this.data = window.GLOB.SyncData.get(_config.dataName) || [] if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS(), BID) } _config.setting.sync = 'false' @@ -100,6 +100,8 @@ window.GLOB.SyncData.delete(_config.dataName) } + } else if (_config.setting.supModule && !BID) { + _config.setting.onload = 'false' } if (_config.subtype !== 'ratioboard') { @@ -120,7 +122,6 @@ this.setState({ config: _config, BID: BID || '', - arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot }) } @@ -146,7 +147,7 @@ if (config.timer) { this.timer = new TimerTask() this.timer.init(config.uuid, config.timer, config.timerRepeats, () => { - this.loadData(true) + this.loadData('timer') }) } @@ -169,21 +170,21 @@ } initExec = () => { - const { config } = this.state + const { config, BID } = 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') { + Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { + if (!res.valid && config.setting.onload === 'true') { setTimeout(() => { - this.loadData() + this.loadData('init') }, config.setting.delay || 0) } - if (!res || this.loaded) return + if (!res.data || this.loaded) return - this.data = res + this.data = res.data if (config.subtype !== 'ratioboard') { if (Array.isArray(this.data)) { @@ -199,10 +200,10 @@ } } else { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, 0).then(res => { - if (!res || this.loaded) return + Api.getLCacheConfig(config.uuid, 0, BID).then(res => { + if (!res.data || this.loaded) return - this.data = res + this.data = res.data if (config.subtype !== 'ratioboard') { if (Array.isArray(this.data)) { @@ -217,7 +218,7 @@ if (config.setting.onload === 'true') { setTimeout(() => { - this.loadData() + this.loadData('init') }, config.setting.delay || 0) } else if (this.loaded) { this.handleData() @@ -233,14 +234,14 @@ } transferSyncData = (syncId) => { - const { config } = this.state + const { config, BID } = this.state if (config.$syncId !== syncId) return let _data = window.GLOB.SyncData.get(config.dataName) || [] if (config.$cache) { - Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID) } if (config.subtype !== 'ratioboard') { @@ -250,10 +251,8 @@ _data.value = _data[config.plot.valueField] || 0 } - if (!is(fromJS(this.data), fromJS(_data))) { - this.data = _data - this.handleData() - } + this.data = _data + this.handleData() this.loaded = true @@ -302,8 +301,8 @@ }, 100) } - async loadData (hastimer) { - const { config, arr_field, BID } = this.state + async loadData (type) { + const { config, BID } = this.state if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� let _data = null @@ -331,19 +330,19 @@ return } - if (!hastimer) { + if (type !== 'timer') { this.setState({ loading: true }) } let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, '', '', BID) + let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, '', '', BID) let result = await Api.genericInterface(param) if (result.status) { - if (config.$cache && config.setting.onload !== 'false') { - Api.writeCacheConfig(config.uuid, result.data || []) + if (config.$cache && type === 'init') { + Api.writeCacheConfig(config.uuid, result.data || [], BID) } this.loaded = true @@ -353,7 +352,7 @@ _data = result.data || [] } else { _data = result.data && result.data[0] ? result.data && result.data[0] : {} - _data.value = _data.value[config.plot.valueField] || 0 + _data.value = _data[config.plot.valueField] || 0 } if (!is(fromJS(this.data), fromJS(_data))) { @@ -371,37 +370,15 @@ this.timer && this.timer.stop() } } - if (result.message) { - if (result.ErrCode === 'Y') { - Modal.success({ - title: result.message - }) - } else if (result.ErrCode === 'S') { - notification.success({ - top: 92, - message: result.message, - duration: 2 - }) - } - } + + UtilsDM.querySuccess(result) } else { this.setState({ loading: false }) this.timer && this.timer.stop() - if (!result.message) return - if (result.ErrCode === 'N') { - Modal.error({ - title: result.message, - }) - } else if (result.ErrCode !== '-2') { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } + UtilsDM.queryFail(result) } } @@ -734,7 +711,7 @@ } <NormalHeader config={config} /> <div className="canvas-wrap"> - {config.plot.download === 'enable' && this.state.chart ? <DownloadOutlined onClick={this.downloadImage} className="system-color download"/> : null} + {/* {config.plot.download === 'enable' && this.state.chart ? <DownloadOutlined onClick={this.downloadImage} className="system-color download"/> : null} */} <div className="canvas" id={this.state.chartId}></div> </div> </div> -- Gitblit v1.8.0