同一个页面只能一个人编辑

This commit is contained in:
暮光:城中城
2019-06-21 21:05:34 +08:00
parent 89b32304bd
commit fbd6ef5f83
9 changed files with 154 additions and 5 deletions

View File

@@ -9,6 +9,8 @@ var URL = {
pageDetail: '/zyplayer-doc-wiki/page/detail',
pageDelete: '/zyplayer-doc-wiki/page/delete',
pageNews: '/zyplayer-doc-wiki/page/news',
pageLock: '/zyplayer-doc-wiki/page/lock',
pageUnlock: '/zyplayer-doc-wiki/page/unlock',
spaceList: '/zyplayer-doc-wiki/space/list',
updateSpace: '/zyplayer-doc-wiki/space/update',
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',

View File

@@ -52,6 +52,27 @@ export default {
this.validateResult(res);
});
},
postNonCheck: function (url, param, callback) {
param = param || {};
param.accessToken = this.getAccessToken();
global.vue.axios({
method: "post",
url: url,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: Qs.stringify(param),
withCredentials: true,
}).then((res) => {
console.log("ok", res);
if (typeof callback == 'function') {
callback(res.data);
}
}).catch((res) => {
console.log("error", res);
if (typeof callback == 'function') {
callback(res.data);
}
});
},
/**
* 返回不为空的字符串为空返回def
*/

View File

@@ -23,6 +23,13 @@
import global from '../../common/config/global'
import WangEditor from 'wangeditor'
window.onunload = function () {
app.unlockPage();
};
window.onbeforeunload = function () {
app.unlockPage();
};
var app;
export default {
data() {
@@ -32,8 +39,12 @@
newPageTitle: "",
parentPath: {},
wikiPage: {},
isUnlock: false,
};
},
destroyed: function () {
this.unlockPage();
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
@@ -47,12 +58,22 @@
changeToRootPath() {
app.parentPath = {spaceId: this.parentPath.spaceId};
},
unlockPage() {
// 防止各种事件重复调这个接口,只需要调一次就好了
if (this.isUnlock) {
return;
}
this.isUnlock = true;
var param = {pageId: app.parentPath.pageId};
this.common.post(this.apilist1.pageUnlock, param, function (json) {});
},
createWikiCancel() {
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
confirmButtonText: '确定',
cancelButtonText: '继续编辑',
type: 'warning'
}).then(() => {
app.unlockPage();
app.$router.back();
});
},
@@ -114,6 +135,17 @@
} else {
this.cleanPage();
}
var param = {pageId: app.parentPath.pageId};
this.common.postNonCheck(this.apilist1.pageLock, param, function (json) {
if (json.errCode !== 200) {
app.$alert(json.errMsg || '未知错误', '错误', {
confirmButtonText: '确定',
callback: () => {
app.$router.back();
}
});
}
});
},
initEditor() {
this.editor = new WangEditor('#newPageContentDiv');

View File

@@ -183,7 +183,10 @@
},
methods: {
editWiki() {
this.$router.push({path: '/page/edit', query: this.parentPath});
var param = {pageId: app.parentPath.pageId};
this.common.post(this.apilist1.pageLock, param, function (json) {
app.$router.push({path: '/page/edit', query: app.parentPath});
});
},
getSearchUserList(query) {
if (query == '') {
@@ -320,6 +323,10 @@
this.recommentInfo = {};
},
submitPageComment() {
if (app.commentTextInput.length <= 0) {
toast.error("请输入评论内容");
return;
}
var param = {
pageId: app.wikiPage.id, content: app.commentTextInput,
parentId: app.recommentInfo.id
@@ -332,7 +339,7 @@
});
},
uploadFileError(err) {
toast.success("上传失败," + err);
toast.error("上传失败," + err);
},
uploadFileSuccess(response) {
this.common.validateResult({data: response}, function () {