diff --git a/src/pages/information/contentManage/contentList.vue b/src/pages/information/contentManage/contentList.vue index 605d0de..6739547 100644 --- a/src/pages/information/contentManage/contentList.vue +++ b/src/pages/information/contentManage/contentList.vue @@ -9,7 +9,7 @@ 新增文章
- + @@ -35,7 +24,6 @@ export default { data() { return { menuList: [], - activeName: this.$store.state.info.columnId, columnId: "", ids: [] }; @@ -53,7 +41,8 @@ export default { page: 1, size: 1000 }).then(res => { - this.menuList = res.columnTree; + this.menuList = res.columnTree + const storeId = this.$store.state.info.columnId if (this.menuList.length) { this.getId(this.menuList) if (this.menuList[0].children && this.menuList[0].children.length) { @@ -61,14 +50,15 @@ export default { } else { this.columnId = this.menuList[0].id; } - if (!this.$store.state.info.columnId) { - this.setColumnId(this.columnId) + if (!storeId) { + this.$store.commit('setColumnId', this.columnId) } else { - this.columnId = this.$store.state.info.columnId + this.columnId = storeId } } - console.log("🚀 ~ file: index.vue ~ line 58 ~ getMenuData ~ this.columnId", this.columnId) - + this.$nextTick(() => { + this.$refs.column.setCurrentKey(storeId) + }) }).catch(err => { }); }, @@ -79,9 +69,9 @@ export default { e.children.length && this.getId(e.children) }) }, - handleSelect(key, keyPath) { - this.columnId = key; - this.setColumnId(key) + handleSelect(key) { + this.columnId = key.id + this.setColumnId(key.id) } } }; @@ -93,17 +83,8 @@ export default { height: calc(100vh - 250px); border-right: solid 1px #e6e6e6; background-color: #F2F6FC; - .el-menu { - background-color: transparent; - - .el-submenu { - background-color: transparent; - } - - .el-menu-item.is-active { - color: #ffffff; - background-color: #9278FF; - } + /deep/.el-tree-node__content { + height: 50px; } } .right { diff --git a/src/pages/information/list/index.vue b/src/pages/information/list/index.vue index 5daf953..a7ba049 100644 --- a/src/pages/information/list/index.vue +++ b/src/pages/information/list/index.vue @@ -1,16 +1,12 @@ @@ -29,12 +25,54 @@ export default { tabsName: this.$store.state.info.tabsName }; }, + // 页面离开的时候如果内容管理的排序没有保存则提示 + beforeRouteLeave(to, from, next) { + const { content } = this.$refs.contentManage.$refs + const { list, originSort } = content + + // 更改了信息才需要提示 + if (JSON.stringify(list) !== JSON.stringify(originSort)) { + this.$confirm(`您已更改了文章排序,是否保存更改?`, '提示', { + type: 'warning' + }).then(() => { + content.sortSubmit() + next() + }).catch(() => { + next() + }) + } else { + next() + } + }, methods: { ...mapActions("info", [ "setTabsName" ]), - handleClick(tab, event) { - this.setTabsName(tab.name); + switchTab(id) { + this.tabsName = id + this.setTabsName(id) + }, + handleClick(id) { + if (this.tabsName == 2) { + const { content } = this.$refs.contentManage.$refs + const { list, originSort } = content + + // 更改了信息才需要提示 + if (JSON.stringify(list) !== JSON.stringify(originSort)) { + this.$confirm(`您已更改了文章排序,是否保存更改?`, '提示', { + type: 'warning' + }).then(() => { + content.sortSubmit() + this.switchTab(id) + }).catch(() => { + this.switchTab(id) + }) + } else { + this.switchTab(id) + } + } else { + this.switchTab(id) + } } }, mounted() { @@ -44,21 +82,22 @@ export default { \ No newline at end of file