From 64d0a616694f34378422e253759a768d67a74d1b Mon Sep 17 00:00:00 2001 From: yaojn Date: Tue, 8 Apr 2025 12:15:38 +0800 Subject: [PATCH] =?UTF-8?q?-=20[=E4=BF=AE=E5=A4=8D]=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=BF=9B=E8=A1=8C=E7=BB=84=E4=BB=B6=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=20=20=20=20-=20[=E5=85=B3=E8=81=94]#[1394819?= =?UTF-8?q?564273664]=E4=BB=AA=E8=A1=A8=E6=9D=BF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=EF=BC=8C=E5=9C=A8=E7=BC=96=E8=BE=91=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=8B=96=E6=8B=BD=E6=93=8D=E4=BD=9C=20http:/?= =?UTF-8?q?/192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/93?= =?UTF-8?q?9050947543057/1394819564273664?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pages/dashboard/dashboard-edit.vue | 70 +++++++++++++------ .../pages/dashboard/dashboard-manage.vue | 2 +- 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/views/pages/dashboard/dashboard-edit.vue b/src/views/pages/dashboard/dashboard-edit.vue index 434c9b7c7..b6cbe5944 100644 --- a/src/views/pages/dashboard/dashboard-edit.vue +++ b/src/views/pages/dashboard/dashboard-edit.vue @@ -295,13 +295,16 @@ export default { addHistory(isActive, isFallback) { //给恢复队列增加历史数据 const dashboardData = this.$utils.deepClone(this.dashboard); - dashboardData.widgetList.forEach(widget => { - for (let key in widget) { - if (key.startsWith('_')) { - this.$delete(widget, key); + if (dashboardData && dashboardData.widgetList && dashboardData.widgetList.length > 0) { + dashboardData.widgetList.forEach(widget => { + for (let key in widget) { + if (key.startsWith('_')) { + this.$delete(widget, key); + } } - } - }); + }); + } + //如果已经是恢复途中,则把isInUse后面的数据先清除再Push const inUseIndex = this.recoverQueue.findIndex(d => d.isInUse); if (inUseIndex > -1) { @@ -404,14 +407,16 @@ export default { const newWidget = this.$utils.deepClone(widget); let maxI = 0; let maxY = 0; - this.dashboard.widgetList.forEach(element => { - if (maxI < element.i) { - maxI = element.i; - } - if (maxY < element.y) { - maxY = element.y; - } - }); + if (this.dashboard && this.dashboard.widgetList && this.dashboard.widgetList.length > 0) { + this.dashboard.widgetList.forEach(element => { + if (maxI < element.i) { + maxI = element.i; + } + if (maxY < element.y) { + maxY = element.y; + } + }); + } newWidget.name = newWidget.name + '_copy'; newWidget.i = maxI + 1; newWidget.x = 0; @@ -419,20 +424,30 @@ export default { newWidget._selected = false; newWidget.uuid = this.$utils.setUuid(); //前端使用uuid作为唯一标识 this.addHistory(true); + if (this.$utils.isEmpty(this.dashboard)) { + this.dashboard = { + name: '', + isActive: 1, + widgetList: [] + }; + } else if (!this.dashboard.hasOwnProperty('widgetList')) { + this.$set(this.dashboard, 'widgetList', []); + } this.dashboard.widgetList.push(newWidget); }, addWidget(widget) { let maxI = 0; let maxY = 0; - this.dashboard.widgetList.forEach(element => { - if (maxI < element.i) { - maxI = element.i; - } - if (maxY < element.y) { - maxY = element.y; - } - }); - + if (this.dashboard && this.dashboard.widgetList && this.dashboard.widgetList.length > 0) { + this.dashboard.widgetList.forEach(element => { + if (maxI < element.i) { + maxI = element.i; + } + if (maxY < element.y) { + maxY = element.y; + } + }); + } const newWidget = { type: widget.type, w: widget.width, @@ -452,6 +467,15 @@ export default { } newWidget.uuid = this.$utils.setUuid(); //前端使用uuid作为唯一标识 this.addHistory(true); + if (this.$utils.isEmpty(this.dashboard)) { + this.dashboard = { + name: '', + isActive: 1, + widgetList: [] + }; + } else if (!this.dashboard.hasOwnProperty('widgetList')) { + this.$set(this.dashboard, 'widgetList', []); + } this.dashboard.widgetList.push(newWidget); }, fullscreen() { diff --git a/src/views/pages/dashboard/dashboard-manage.vue b/src/views/pages/dashboard/dashboard-manage.vue index a585162a5..bcc07877d 100644 --- a/src/views/pages/dashboard/dashboard-manage.vue +++ b/src/views/pages/dashboard/dashboard-manage.vue @@ -54,7 +54,7 @@