no message
This commit is contained in:
parent
1f832ece2c
commit
4eee5cced6
@ -269,7 +269,7 @@ export default {
|
||||
this.addShow = false;
|
||||
this.$refs.addProject.resetFields();
|
||||
this.$set(this.addData, 'template', 0);
|
||||
this.$store.commit('storageProjectData', data);
|
||||
this.$store.commit('saveProjectData', data);
|
||||
this.toggleRoute('project/' + data.id)
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
|
@ -963,7 +963,7 @@ export default {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.settingShow = false;
|
||||
this.$store.commit("storageProjectData", data)
|
||||
this.$store.commit("saveProjectData", data)
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ export default {
|
||||
this.$Modal.remove();
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.$store.commit('forgetProjectData', this.projectDetail.id);
|
||||
this.$store.commit('removeProjectData', this.projectDetail.id);
|
||||
const project = this.projectList.find(({id}) => id);
|
||||
if (project) {
|
||||
this.goForward({path: '/manage/project/' + project.id}, true);
|
||||
@ -1071,7 +1071,7 @@ export default {
|
||||
this.$Modal.remove();
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.$store.commit('forgetProjectData', this.projectDetail.id);
|
||||
this.$store.commit('removeProjectData', this.projectDetail.id);
|
||||
const project = this.projectList.find(({id}) => id);
|
||||
if (project) {
|
||||
this.goForward({path: '/manage/project/' + project.id}, true);
|
||||
|
121
resources/assets/js/store/mutations.js
vendored
121
resources/assets/js/store/mutations.js
vendored
@ -87,15 +87,14 @@ export default {
|
||||
state.projectList = [];
|
||||
return;
|
||||
}
|
||||
if (state.method.isArray(state.cacheProjectList)) {
|
||||
if (state.cacheProjectList.length > 0) {
|
||||
state.projectList = state.cacheProjectList;
|
||||
}
|
||||
$A.apiAjax({
|
||||
url: 'project/lists',
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
state.projectList = data.data;
|
||||
state.method.setStorage("cacheProjectList", state.projectList);
|
||||
this.commit('saveProjectData', data.data);
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
@ -119,50 +118,12 @@ export default {
|
||||
},
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
this.commit('storageProjectData', data);
|
||||
this.commit('saveProjectData', data);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存项目信息
|
||||
* @param state
|
||||
* @param data
|
||||
*/
|
||||
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, Object.assign({}, state.projectList[index], data));
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取项目详情
|
||||
* @param state
|
||||
@ -172,16 +133,12 @@ export default {
|
||||
if (state.method.runNum(project_id) === 0) {
|
||||
return;
|
||||
}
|
||||
if (state.method.isJson(state.cacheProjectDetail[project_id])) {
|
||||
state.projectDetail = state.cacheProjectDetail[project_id];
|
||||
const project = state.cacheProjectList.find(({id}) => id == project_id);
|
||||
if (project) {
|
||||
state.projectDetail = Object.assign({project_column: [], project_user: []}, project);
|
||||
}
|
||||
state.projectDetail.id = project_id;
|
||||
//
|
||||
if (state.cacheProjectDetail[project_id + "::load"]) {
|
||||
return;
|
||||
}
|
||||
state.cacheProjectDetail[project_id + "::load"] = true;
|
||||
//
|
||||
state.projectLoad++;
|
||||
$A.apiAjax({
|
||||
url: 'project/detail',
|
||||
@ -190,13 +147,10 @@ export default {
|
||||
},
|
||||
complete: () => {
|
||||
state.projectLoad--;
|
||||
state.cacheProjectDetail[project_id + "::load"] = false;
|
||||
},
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
state.cacheProjectDetail[data.id] = data;
|
||||
state.method.setStorage("cacheProjectDetail", state.cacheProjectDetail);
|
||||
this.commit('storageProjectData', $A.cloneJSON(data));
|
||||
this.commit('saveProjectData', data);
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
@ -204,6 +158,47 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存项目信息
|
||||
* @param state
|
||||
* @param data
|
||||
*/
|
||||
saveProjectData(state, data) {
|
||||
if (state.method.isArray(data)) {
|
||||
if (state.projectDetail.id) {
|
||||
const project = data.find(({id}) => id == state.projectDetail.id);
|
||||
if (project) {
|
||||
state.projectDetail = Object.assign({}, state.projectDetail, project)
|
||||
}
|
||||
}
|
||||
state.projectList = data;
|
||||
} else if (state.method.isJson(data)) {
|
||||
if (data.id == state.projectDetail.id) {
|
||||
state.projectDetail = Object.assign({}, state.projectDetail, data)
|
||||
}
|
||||
let index = state.projectList.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.projectList.splice(index, 1, Object.assign({}, state.projectList[index], data));
|
||||
} else {
|
||||
state.projectList.unshift(data);
|
||||
}
|
||||
}
|
||||
state.method.setStorage("cacheProjectList", state.projectList);
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除项目信息
|
||||
* @param state
|
||||
* @param project_id
|
||||
*/
|
||||
removeProjectData(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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户基本信息
|
||||
* @param state
|
||||
@ -363,20 +358,20 @@ export default {
|
||||
}
|
||||
//
|
||||
state.dialogMsgList = [];
|
||||
if (state.method.isJson(state.cacheDialogMsg[dialog_id])) {
|
||||
let length = state.cacheDialogMsg[dialog_id].data.length;
|
||||
if (state.method.isJson(state.cacheDialogList[dialog_id])) {
|
||||
let length = state.cacheDialogList[dialog_id].data.length;
|
||||
if (length > 50) {
|
||||
state.cacheDialogMsg[dialog_id].data.splice(0, length - 50);
|
||||
state.cacheDialogList[dialog_id].data.splice(0, length - 50);
|
||||
}
|
||||
state.dialogDetail = state.cacheDialogMsg[dialog_id].dialog
|
||||
state.dialogMsgList = state.cacheDialogMsg[dialog_id].data
|
||||
state.dialogDetail = state.cacheDialogList[dialog_id].dialog
|
||||
state.dialogMsgList = state.cacheDialogList[dialog_id].data
|
||||
}
|
||||
state.dialogId = dialog_id;
|
||||
//
|
||||
if (state.cacheDialogMsg[dialog_id + "::load"]) {
|
||||
if (state.cacheDialogList[dialog_id + "::load"]) {
|
||||
return;
|
||||
}
|
||||
state.cacheDialogMsg[dialog_id + "::load"] = true;
|
||||
state.cacheDialogList[dialog_id + "::load"] = true;
|
||||
//
|
||||
state.dialogMsgLoad++;
|
||||
$A.apiAjax({
|
||||
@ -386,18 +381,18 @@ export default {
|
||||
},
|
||||
complete: () => {
|
||||
state.dialogMsgLoad--;
|
||||
state.cacheDialogMsg[dialog_id + "::load"] = false;
|
||||
state.cacheDialogList[dialog_id + "::load"] = false;
|
||||
},
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
const dialog = data.dialog;
|
||||
const reverse = data.data.reverse();
|
||||
// 更新缓存
|
||||
state.cacheDialogMsg[dialog_id] = {
|
||||
state.cacheDialogList[dialog_id] = {
|
||||
dialog,
|
||||
data: reverse,
|
||||
};
|
||||
state.method.setStorage("cacheDialogMsg", state.cacheDialogMsg);
|
||||
state.method.setStorage("cacheDialogList", state.cacheDialogList);
|
||||
// 更新当前会话消息
|
||||
if (state.dialogId == dialog_id) {
|
||||
state.dialogDetail = dialog;
|
||||
|
7
resources/assets/js/store/state.js
vendored
7
resources/assets/js/store/state.js
vendored
@ -23,7 +23,7 @@ const method = {
|
||||
return typeof value === "boolean" ? value : def;
|
||||
},
|
||||
|
||||
getStorageArray(key, def = {}) {
|
||||
getStorageArray(key, def = []) {
|
||||
let value = this.storage(key);
|
||||
return this.isArray(value) ? value : def;
|
||||
},
|
||||
@ -161,9 +161,8 @@ const state = { method };
|
||||
|
||||
// 数据缓存
|
||||
state.cacheUserBasic = state.method.getStorageJson("cacheUserBasic");
|
||||
state.cacheDialogMsg = state.method.getStorageJson("cacheDialogMsg");
|
||||
state.cacheDialogList = state.method.getStorageJson("cacheDialogList");
|
||||
state.cacheProjectList = state.method.getStorageArray("cacheProjectList");
|
||||
state.cacheProjectDetail = state.method.getStorageJson("cacheProjectDetail");
|
||||
|
||||
// 会员信息
|
||||
state.userInfo = state.method.getStorageJson('userInfo');
|
||||
@ -184,7 +183,7 @@ state.wsReadWaitList = [];
|
||||
// 项目信息
|
||||
state.projectLoad = 0;
|
||||
state.projectList = state.cacheProjectList;
|
||||
state.projectDetail = {id: 0, dialog_id: 0, project_column: [], project_user: []};
|
||||
state.projectDetail = {id: 0, project_column: [], project_user: []};
|
||||
|
||||
// 会话消息
|
||||
state.dialogId = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user