From a668ea9bd0b77badd729d183d0baf5168140df7f Mon Sep 17 00:00:00 2001 From: zyh Date: Fri, 27 May 2022 16:54:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E7=82=B9=E5=87=BB=E9=83=BD=E5=88=B7=E6=96=B0=E6=A0=91?= =?UTF-8?q?=E5=BD=A2=E6=8E=A7=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/common/popBox/selectPanel.vue | 19 +++++++++++++------ .../src/components/page/dashboard/panel.vue | 12 +++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/nezha-fronted/src/components/common/popBox/selectPanel.vue b/nezha-fronted/src/components/common/popBox/selectPanel.vue index 23e3a8528..e6498bc71 100644 --- a/nezha-fronted/src/components/common/popBox/selectPanel.vue +++ b/nezha-fronted/src/components/common/popBox/selectPanel.vue @@ -165,7 +165,7 @@ export default { }, methods: { // 获取收藏的列表 - async getStarred () { + async getStarred (type) { const params = { type: 'panel' } @@ -174,7 +174,12 @@ export default { this.tempArr = [] this.recursionStarred(this.panelData, response.data) this.starredData[0].children = this.formatStarred(this.tempArr) - this.$emit('refreshStarred', this.panelData) + if (type === 'tree') { + // 刷新树形控件 + this.$emit('refreshStarred', { data: this.panelData, type: 'tree' }) + } else { + this.$emit('refreshStarred', { data: this.panelData }) + } } }, // 比对收藏的列表和全部列表 改变状态 @@ -221,9 +226,10 @@ export default { type: 'panel', tid: data.id } - this.$post('/sys/user/starred', params).then(response => { + this.$post('/sys/user/starred', params).then(async response => { if (response.code === 200) { - this.getStarred() + await this.getStarred() + data.starred = true } }) }, @@ -231,9 +237,10 @@ export default { // 删除收藏 delStarred: bus.debounceFn(function (data) { - this.$delete('/sys/user/starred?type=panel&tid=' + data.id).then(response => { + this.$delete('/sys/user/starred?type=panel&tid=' + data.id).then(async response => { if (response.code === 200) { - this.getStarred() + await this.getStarred() + data.starred = false } }) }, diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 414e845c7..855825b96 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -308,15 +308,17 @@ export default { } }, methods: { - refreshStarred (value) { - // 重新赋值,否则树形菜单不更新 - this.panelData = JSON.parse(JSON.stringify(value)) + // 刷新树形菜单视图 + refreshStarred ({ data, type }) { + if (type === 'tree') { + this.panelData = JSON.parse(JSON.stringify(data)) + } this.$nextTick(() => { this.$refs.selectPanel.$refs.starredTree.filter(this.filterPanel) this.$refs.selectPanel.$refs.panelTree.filter(this.filterPanel) this.$refs.selectPanel.$refs.panelTree.setCurrentKey(this.showPanel) }) - // // 判断当前页面收藏状态 + // 判断当前页面收藏状态 const starredArr = this.$refs.selectPanel.tempArr this.showPanel.starred = starredArr.some(item => item.id === this.showPanel.id) }, @@ -673,7 +675,7 @@ export default { let isInitData = false this.panelData = JSON.parse(JSON.stringify(response.data.list)) this.$nextTick(() => { - this.$refs.selectPanel.getStarred() + this.$refs.selectPanel.getStarred('tree') }) if (response.data.list.length > 0) { if (this.$store.state.showPanel.id > 0 && this.$store.state.showPanel.name) {