fix:修复每次点击都刷新树形控件bug

This commit is contained in:
zyh
2022-05-27 16:54:02 +08:00
parent 394926e7ea
commit a668ea9bd0
2 changed files with 20 additions and 11 deletions

View File

@@ -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
}
})
},