From d77474983f533c13d4ccbbbf0a7e67826b9567ec Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 3 Jun 2021 22:22:03 +0800 Subject: [PATCH] no message --- resources/assets/js/pages/manage.vue | 47 +++++-------------- .../pages/manage/components/project-list.vue | 4 +- resources/assets/js/store/mutations.js | 27 +++++++++++ resources/assets/js/store/state.js | 1 + 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 4342f7246..69982c8a6 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -20,9 +20,9 @@ @@ -67,7 +67,7 @@
- +
@@ -245,29 +245,20 @@ export default { addRule: {}, columns: [], - - projectLoad: 0, - projectLists: [], - projectListTotal: 0, } }, mounted() { - this.$store.commit('getUserInfo', this.getProjectLists); + this.$store.commit('getUserInfo'); }, deactivated() { this.addShow = false; }, computed: { - ...mapState(['userId']), + ...mapState(['projectList']), }, watch: { '$route' (route) { this.curPath = route.path; - }, - userId(userid) { - if (userid > 0) { - this.getProjectLists() - } } }, methods: { @@ -342,12 +333,12 @@ export default { onAddProject() { this.$refs.addProject.validate((valid) => { if (valid) { - this.projectLoad++; + this.loadIng++; $A.apiAjax({ url: 'project/add', data: this.addData, complete: () => { - this.projectLoad--; + this.loadIng--; }, success: ({ret, data, msg}) => { if (ret === 1) { @@ -356,7 +347,10 @@ export default { this.$refs.addProject.resetFields(); this.$set(this.addData, 'template', 0); // - this.getProjectLists(true); + this.loadIng++; + this.$store.commit('getProjectList', () => { + this.loadIng--; + }); } else { $A.modalError(msg); } @@ -365,25 +359,6 @@ export default { } }); }, - - getProjectLists() { - this.projectLoad++; - $A.apiAjax({ - url: 'project/lists', - complete: () => { - this.projectLoad--; - }, - success: ({ret, data, msg}) => { - if (ret === 1) { - this.projectLists = data.data; - this.projectListTotal = data.total; - } else { - this.projectLists = []; - this.projectListTotal = 0; - } - } - }); - } } } diff --git a/resources/assets/js/pages/manage/components/project-list.vue b/resources/assets/js/pages/manage/components/project-list.vue index 4e3e21203..a5e4a0688 100644 --- a/resources/assets/js/pages/manage/components/project-list.vue +++ b/resources/assets/js/pages/manage/components/project-list.vue @@ -34,7 +34,7 @@ {{$L('项目设置')}} {{$L('移交项目')}} - {{$L('删除项目')}} + {{$L('删除项目')}} @@ -399,6 +399,7 @@ .project-switch { display: flex; justify-content: flex-end; + margin-top: 24px; .project-switch-button { display: flex; align-items: center; @@ -1016,6 +1017,7 @@ export default { this.$Modal.remove(); if (ret === 1) { $A.messageSuccess(msg); + this.$store.commit('getProjectList'); this.goForward({path: '/manage/dashboard'}, true); }else{ $A.modalError(msg, 301); diff --git a/resources/assets/js/store/mutations.js b/resources/assets/js/store/mutations.js index ed7086235..52918116a 100644 --- a/resources/assets/js/store/mutations.js +++ b/resources/assets/js/store/mutations.js @@ -96,6 +96,33 @@ export default { state.userId = userInfo.userid; state.userToken = userInfo.token; state.setStorage('userInfo', state.userInfo); + this.commit('getProjectList'); + }, + + /** + * 获取项目列表 + * @param state + * @param completeCallback + */ + getProjectList(state, completeCallback) { + if (state.userId === 0) { + state.projectList = []; + typeof completeCallback === "function" && completeCallback(); + return; + } + $A.apiAjax({ + url: 'project/lists', + complete: () => { + typeof completeCallback === "function" && completeCallback(); + }, + success: ({ret, data, msg}) => { + if (ret === 1) { + state.projectList = data.data; + } else { + $A.modalError(msg); + } + } + }); }, /** diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 3ef9b62e1..87e04d669 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -185,6 +185,7 @@ export default Object.assign(stateCommon, { cacheUserBasic: {}, projectLoad: 0, + projectList: [], projectDetail: { id: 0, project_column: [],