Commit 50fe79b2 authored by xiaoman's avatar xiaoman

bugfix: 类目展示错误的问题

parent d75ccac1
......@@ -149,6 +149,7 @@ export default {
components: { TreeTable },
data() {
return {
ids: [0],
uploadPath,
props: {
stripe: false,
......@@ -235,7 +236,7 @@ export default {
}
},
created() {
this.getAllCategories(0)
this.getAllCategories()
},
methods: {
// 成交记录
......@@ -245,25 +246,42 @@ export default {
onBack() {
this.activeLevel--
this.categoryList.length = this.categoryList.length - 1
if (this.activeLevel === 0) {
this.ids = [0]
} else {
this.ids.pop()
}
},
handleRadioClick(option) {
// console.log(option); // eslint-disable-line
},
handleChild(val) {
this.activeLevel = val.level
this.getAllCategories(val.id)
this.ids.push(val.id)
this.getAllCategories()
},
getAllCategories(id = 0) {
getAllCategories() {
const id = this.ids[this.ids.length - 1]
this.listLoading = true
const data = {
id: id || 0
}
getCategory(data).then(res => {
if (res && res.data && res.data.data && res.data.data.categoryList) {
this.categoryList.push({
list: res.data.data.categoryList,
path: res.data.data.categoryPath
})
if (['create', 'update', 'delete'].includes(this.dialogStatus)) {
this.categoryList.splice(this.activeLevel, 1, {
list: res.data.data.categoryList,
path: res.data.data.categoryPath
})
this.$forceUpdate()
} else {
this.categoryList.push({
list: res.data.data.categoryList,
path: res.data.data.categoryPath
})
}
}
this.listLoading = false
}).catch(() => {
......@@ -307,7 +325,8 @@ export default {
title: '成功',
message: '创建成功'
})
location.reload()
// location.reload()
this.getAllCategories()
})
.catch(response => {
this.$notify.error({
......@@ -342,7 +361,8 @@ export default {
title: '成功',
message: '更新成功'
})
location.reload()
// location.reload()
this.getAllCategories()
})
.catch(response => {
this.$notify.error({
......@@ -354,13 +374,15 @@ export default {
})
},
handleDelete(row) {
this.dialogStatus = 'delete'
deleteCategory(row)
.then(() => {
this.$notify.success({
title: '成功',
message: '删除成功'
})
location.reload()
// location.reload()
this.getAllCategories()
})
.catch(response => {
this.$notify.error({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment