Commit 50fe79b2 authored by xiaoman's avatar xiaoman

bugfix: 类目展示错误的问题

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