diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php
index ab1d1bd7..b3a6e40d 100755
--- a/app/Http/Controllers/Api/ProjectController.php
+++ b/app/Http/Controllers/Api/ProjectController.php
@@ -188,7 +188,7 @@ class ProjectController extends AbstractController
$column['project_id'] = $project->id;
ProjectColumn::createInstance($column)->save();
}
- return Base::retSuccess('添加成功');
+ return Base::retSuccess('添加成功', $project->find($project->id));
});
}
@@ -236,7 +236,7 @@ class ProjectController extends AbstractController
$project->desc = $desc;
$project->save();
//
- return Base::retSuccess('修改成功');
+ return Base::retSuccess('修改成功', $project);
}
/**
diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue
index 714c982c..59d31862 100644
--- a/resources/assets/js/pages/manage.vue
+++ b/resources/assets/js/pages/manage.vue
@@ -269,11 +269,8 @@ export default {
this.addShow = false;
this.$refs.addProject.resetFields();
this.$set(this.addData, 'template', 0);
- //
- this.loadIng++;
- this.$store.commit('getProjectList', () => {
- this.loadIng--;
- });
+ this.$store.commit('storageProjectData', data);
+ this.toggleRoute('project/' + data.id)
} else {
$A.modalError(msg);
}
diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue
index 1a206078..f6cc09d8 100644
--- a/resources/assets/js/pages/manage/components/ProjectList.vue
+++ b/resources/assets/js/pages/manage/components/ProjectList.vue
@@ -46,14 +46,14 @@
+
{
if (ret === 1) {
$A.messageSuccess(msg);
- this.$set(this.projectDetail, 'name', this.settingData.name);
- this.$set(this.projectDetail, 'desc', this.settingData.desc);
this.settingShow = false;
+ this.$store.commit("storageProjectData", data)
} else {
$A.modalError(msg);
}
@@ -1036,8 +1036,13 @@ export default {
this.$Modal.remove();
if (ret === 1) {
$A.messageSuccess(msg);
- this.$store.commit('getProjectList');
- this.goForward({path: '/manage/dashboard'}, true);
+ this.$store.commit('forgetProjectData', this.projectDetail.id);
+ const project = this.projectList.find(({id}) => id);
+ if (project) {
+ this.goForward({path: '/manage/project/' + project.id}, true);
+ } else {
+ this.goForward({path: '/manage/dashboard'}, true);
+ }
}else{
$A.modalError(msg, 301);
}
@@ -1066,8 +1071,13 @@ export default {
this.$Modal.remove();
if (ret === 1) {
$A.messageSuccess(msg);
- this.$store.commit('getProjectList');
- this.goForward({path: '/manage/dashboard'}, true);
+ this.$store.commit('forgetProjectData', this.projectDetail.id);
+ const project = this.projectList.find(({id}) => id);
+ if (project) {
+ this.goForward({path: '/manage/project/' + project.id}, true);
+ } else {
+ 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 4db7f4c5..0645197a 100644
--- a/resources/assets/js/store/mutations.js
+++ b/resources/assets/js/store/mutations.js
@@ -81,12 +81,10 @@ export default {
/**
* 获取项目列表
* @param state
- * @param afterCallback
*/
- getProjectList(state, afterCallback) {
+ getProjectList(state) {
if (state.userId === 0) {
state.projectList = [];
- typeof afterCallback === "function" && afterCallback();
return;
}
if (state.method.isArray(state.cacheProjectList)) {
@@ -94,9 +92,6 @@ export default {
}
$A.apiAjax({
url: 'project/lists',
- after: () => {
- typeof afterCallback === "function" && afterCallback();
- },
success: ({ret, data, msg}) => {
if (ret === 1) {
state.projectList = data.data;
@@ -124,7 +119,7 @@ export default {
},
success: ({ret, data, msg}) => {
if (ret === 1) {
- this.commit('storageProjectOne', data);
+ this.commit('storageProjectData', data);
}
}
});
@@ -133,17 +128,38 @@ export default {
/**
* 保存项目信息
* @param state
- * @param project
+ * @param data
*/
- storageProjectOne(state, project) {
- if (typeof project.project_column !== "undefined") delete project.project_column;
- if (typeof project.project_user !== "undefined") delete project.project_user;
- let index = state.projectList.findIndex(({id}) => id === project.id);
+ storageProjectData(state, data) {
+ if (data.id == state.projectDetail.id) {
+ state.projectDetail = Object.assign({}, state.projectDetail, data)
+ }
+ //
+ if (typeof data.project_column !== "undefined") delete data.project_column;
+ if (typeof data.project_user !== "undefined") delete data.project_user;
+ let index = state.projectList.findIndex(({id}) => id == data.id);
if (index > -1) {
- state.projectList.splice(index, 1, project);
- state.method.setStorage("cacheProjectList", state.projectList);
+ state.projectList.splice(index, 1, Object.assign({}, state.projectList[index], data));
} else {
- state.projectList.push(project);
+ state.projectList.unshift(data);
+ }
+ state.method.setStorage("cacheProjectList", state.projectList);
+ },
+
+ /**
+ * 删除项目信息
+ * @param state
+ * @param project_id
+ */
+ forgetProjectData(state, project_id) {
+ let index = state.projectList.findIndex(({id}) => id == project_id);
+ if (index > -1) {
+ state.projectList.splice(index, 1);
+ state.method.setStorage("cacheProjectList", state.projectList);
+ }
+ if (typeof state.cacheProjectDetail[project_id] !== "undefined") {
+ delete state.cacheProjectDetail[project_id];
+ state.method.setStorage("cacheProjectDetail", state.cacheProjectDetail);
}
},
@@ -179,11 +195,8 @@ export default {
success: ({ret, data, msg}) => {
if (ret === 1) {
state.cacheProjectDetail[data.id] = data;
- if (state.projectDetail.id === data.id) {
- state.projectDetail = data;
- }
state.method.setStorage("cacheProjectDetail", state.cacheProjectDetail);
- this.commit('storageProjectOne', $A.cloneJSON(data));
+ this.commit('storageProjectData', $A.cloneJSON(data));
} else {
$A.modalError(msg);
}
@@ -282,7 +295,7 @@ export default {
getDialogUpdate(state, data) {
let splice = false;
state.dialogList.some(({id, unread}, index) => {
- if (id === data.id) {
+ if (id == data.id) {
unread !== data.unread && this.commit('getDialogMsgUnread');
state.dialogList.splice(index, 1, data);
return splice = true;
@@ -345,7 +358,7 @@ export default {
if (state.method.runNum(dialog_id) === 0) {
return;
}
- if (state.dialogId === dialog_id) {
+ if (state.dialogId == dialog_id) {
return;
}
//
@@ -386,10 +399,10 @@ export default {
};
state.method.setStorage("cacheDialogMsg", state.cacheDialogMsg);
// 更新当前会话消息
- if (state.dialogId === dialog_id) {
+ if (state.dialogId == dialog_id) {
state.dialogDetail = dialog;
reverse.forEach((item) => {
- let index = state.dialogMsgList.findIndex(({id}) => id === item.id);
+ let index = state.dialogMsgList.findIndex(({id}) => id == item.id);
if (index === -1) {
state.dialogMsgList.push(item);
} else {
@@ -414,7 +427,7 @@ export default {
url: 'dialog/msg/unread',
success: ({ret, data, msg}) => {
if (ret === 1) {
- if (unread === state.dialogMsgUnread) {
+ if (unread == state.dialogMsgUnread) {
state.dialogMsgUnread = data.unread;
} else {
setTimeout(() => {
@@ -535,8 +548,8 @@ export default {
(function (msg) {
const {data} = msg;
const {dialog_id} = data;
- if (dialog_id === state.dialogId) {
- let index = state.dialogMsgList.findIndex(({id}) => id === data.id);
+ if (dialog_id == state.dialogId) {
+ let index = state.dialogMsgList.findIndex(({id}) => id == data.id);
if (index === -1) {
state.dialogMsgList.push(data);
} else {
diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js
index 1c76561f..d9f32856 100644
--- a/resources/assets/js/store/state.js
+++ b/resources/assets/js/store/state.js
@@ -151,7 +151,7 @@ const state = { method };
// 变量缓存
[
'projectChatShow', // 项目聊天显示
- 'projectListPanel', // 项目面板显示类型
+ 'projectTablePanel', // 项目面板显示类型
'taskMyShow', // 项目面板显示我的任务
'taskUndoneShow', // 项目面板显示未完成任务
'taskCompletedShow' // 项目面板显示已完成任务