From dc2fc10b5e5497ba00727040f9b3f4facf18b46b Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Mon, 10 Oct 2022 11:26:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E8=AE=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../information/contentManage/contentList.vue | 28 +++---
src/pages/information/contentManage/index.vue | 49 +++-------
src/pages/information/list/index.vue | 91 +++++++++++++------
3 files changed, 95 insertions(+), 73 deletions(-)
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 @@
新增文章
-
+
@@ -70,11 +70,12 @@ export default {
tabs: {
first: "栏目内容管理"
},
- listData: [],
+ list: [],
multipleSelection: [],
pageNo: +this.$route.query.page || 1,
pageSize: 10,
- totals: 0
+ totals: 0,
+ originSort: []
};
},
props: {
@@ -93,10 +94,11 @@ export default {
let data = {
columnId: this.columnId
};
- this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`, data).then(res => {
- this.listData = res.articleList;
- this.totals = res.total;
- if (!this.listData.length && this.totals) {
+ this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`, data).then(({ articleList, total }) => {
+ this.list = articleList;
+ this.totals = total;
+ if (JSON.stringify(this.originSort) !== '{}') this.originSort = JSON.parse(JSON.stringify(articleList))
+ if (!this.list.length && this.totals) {
this.pageNo--;
this.getData();
}
@@ -112,7 +114,7 @@ export default {
this.getData();
},
addArticle() {
- this.$router.push(`/information/addarticle?columnId=${this.columnId}&sort=${this.listData.length + 1}`);
+ this.$router.push(`/information/addarticle?columnId=${this.columnId}&sort=${this.list.length + 1}`);
},
editArticle(scope) {
this.$router.push(`/information/addarticle?columnId=${this.columnId}&id=${scope.row.id}&sort=${scope.$index + 1}`);
@@ -155,7 +157,7 @@ export default {
this.getData();
}).catch(res => {
});
- if(this.multipleSelection.length === this.listData.length && this.pageNo>1) {
+ if(this.multipleSelection.length === this.list.length && this.pageNo>1) {
this.handleCurrentChange(this.pageNo - 1)
}
})
@@ -174,12 +176,12 @@ export default {
});
},
sortSubmit() {
- if (this.listData.length) {
- if (this.listData.find(n => n.sort < 1)) return util.errorMsg("排序值最小为1");
- let data = { articleList: this.listData };
+ if (this.list.length) {
+ if (this.list.find(n => n.sort < 1)) return util.errorMsg("排序值最小为1");
+ let data = { articleList: this.list };
this.$post(this.api.articleSort, data).then(res => {
util.successMsg("保存成功");
- this.getContent(this.columnId);
+ this.getData();
})
.catch(err => {
});
diff --git a/src/pages/information/contentManage/index.vue b/src/pages/information/contentManage/index.vue
index 7a1f75b..3cc3f9e 100644
--- a/src/pages/information/contentManage/index.vue
+++ b/src/pages/information/contentManage/index.vue
@@ -2,21 +2,10 @@
@@ -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