Commit b4cc384b authored by rockyl's avatar rockyl

完善多人协作

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