From 19b9752a1d935546dfa2b0a9cc61ab18d7daaa16 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Thu, 29 Jun 2023 11:46:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=B8=B2=E6=9F=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/RemoteComponents/index.vue | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/data-room-ui/packages/RemoteComponents/index.vue b/data-room-ui/packages/RemoteComponents/index.vue index 3ed56ea5..59ee2bb9 100644 --- a/data-room-ui/packages/RemoteComponents/index.vue +++ b/data-room-ui/packages/RemoteComponents/index.vue @@ -84,11 +84,22 @@ export default { }) } }, - chartInit () { - // key和code相等,说明是一进来刷新,调用/chart/data/list + async chartInit () { + let config = this.config + // key和code相等,说明是一进来刷新,调用list接口 if (this.config.code === this.config.key || this.isPreview) { - // 再根据数据更新组件 - this.updateChart() + // 改变样式 + config = this.changeStyle(config) ? this.changeStyle(config) : config + // 改变数据 + config = await this.changeDataByCode(config) + } else { + // 否则说明是更新,这里的更新只指更新数据(改变样式时是直接调取changeStyle方法),因为更新数据会改变key,调用chart接口 + // TODO 直接改变prop控制台会报错,待优化 + try { + this.config = await this.changeData(config) + } catch (e) { + console.error(e) + } } }, linkEvent (formData) { @@ -121,22 +132,6 @@ export default { setting } }, - /** - * @description: 只更新数据 - */ - updateData () { - this.updateChart() - }, - /** - * 更新组件 - */ - updateChart () { - if (this.isPreview) { - this.changeDataByCode() - } else { - this.changeData(this.config) - } - }, /** * 组件的配置 * @returns {Promise}