Commit b4cc384b authored by rockyl's avatar rockyl

完善多人协作

parent 925e5d79
...@@ -93,8 +93,12 @@ export const projectStore = { ...@@ -93,8 +93,12 @@ export const projectStore = {
makeProjectDirty() { makeProjectDirty() {
}, },
updateProjectUpdateTime(state, updateTime) { updateProjectUpdateTime(state, {time, dirty = true}) {
state.update_time = updateTime; state.update_time = time;
if(dirty){
this.commit('makeProjectDirty');
}
}, },
updateProject(state, project) { updateProject(state, project) {
const {id, name, creator, data, operators, operator, update_time} = project; const {id, name, creator, data, operators, operator, update_time} = project;
...@@ -730,17 +734,22 @@ export const projectStore = { ...@@ -730,17 +734,22 @@ export const projectStore = {
commit('updateProject', project); commit('updateProject', project);
}, },
async saveToRemote({state, dispatch, getters, commit}, {remark, data}) { async saveToRemote({state, dispatch, getters, commit}, {remark, data}) {
if (data) { //如果已经合并了冲突
commit('updateProjectUpdateTime', {time: state.base_time});
}
let project = Object.assign({}, getters.project); let project = Object.assign({}, getters.project);
if (data) { if (data) {
project.data = data; project.data = data;
project.force = true;
} }
let resp = await projectApi.saveOne(project, remark); let resp = await projectApi.saveOne(project, remark);
if (resp.result) { if (resp.result) {
commit('updateProjectUpdateTime', resp.project.update_time); commit('updateProjectUpdateTime', {time: resp.project.update_time, dirty: false});
dispatch('deleteLocalVersion', state.id); dispatch('deleteLocalVersion', state.id);
} }
resp.localData = project.data; resp.localData = data || project.data;
if (!resp.result) {
state.base_time = resp.updateTime;
}
return resp; return resp;
}, },
async updateProject({commit}, projectID) { async updateProject({commit}, projectID) {
......
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
type: 'success' type: 'success'
}); });
} else { } else {
cancel = true;
await this.$confirm(i18n.t('There are conflicts in the project'), i18n.t('Alert'), { await this.$confirm(i18n.t('There are conflicts in the project'), i18n.t('Alert'), {
confirmButtonText: i18n.t('Confirm'), confirmButtonText: i18n.t('Confirm'),
cancelButtonText: i18n.t('Cancel'), cancelButtonText: i18n.t('Cancel'),
...@@ -227,6 +228,7 @@ ...@@ -227,6 +228,7 @@
}).then(() => { }).then(() => {
this.$refs.projectConflictResolveDialog.show(resp.remoteData, resp.localData); this.$refs.projectConflictResolveDialog.show(resp.remoteData, resp.localData);
}).catch((e) => { }).catch((e) => {
this.$loading({}).close();
}); });
} }
} }
...@@ -235,8 +237,10 @@ ...@@ -235,8 +237,10 @@
}, },
async onConflictResolved(data) { async onConflictResolved(data) {
const {projectID, project} = this.$route.params; const {projectID, project} = this.$route.params;
await this.saveProject(true, data); let cancel = await this.saveProject(true, data);
this.loadRemoteVersion(projectID, project, undefined, data); if(!cancel){
this.loadRemoteVersion(projectID, project, undefined, data);
}
}, },
checkAuth() { checkAuth() {
let checkStatus = this.operators.includes(this.currentOperator); let checkStatus = this.operators.includes(this.currentOperator);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment