提交 596bc67a 编写于 作者: NoSubject's avatar NoSubject

Merge branch 'feature/documenteditor_histroy' into 'wrdp'

正文编辑器版本保存功能优化

See merge request o2oa/o2oa!3140
......@@ -89,6 +89,17 @@
</table>
<div id="text{$.pid}allowHistoryScriptArea" style="display: text{($.allowHistory=='s')?'block':'none'}" class="MWFFormulaArea" name="allowHistoryScript" title="允许查看痕迹脚本 (S)"></div>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
<tr>
<td class="editTableTitle">保留历史版本:</td>
<td class="editTableValue">
<input class="editTableRadio" name="saveHistoricalFile" text{($.saveHistoricalFile!='n')?'checked':''} type="radio" value="y"/>保存
<input class="editTableRadio" name="saveHistoricalFile" text{($.saveHistoricalFile=='n')?'checked':''} type="radio" value="n"/>不保存
<br><div>如果选择保存历史版本,如果正文内容与上一版本有差异,系统会在流转时保存一个新版本</div>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
<tr>
<td class="editTableTitle">设置缩放:</td>
......
......@@ -165,9 +165,12 @@
"float": "right",
"background-color": "#f3f3f3",
"border-left": "1px solid #cccccc",
"border-top": "1px solid #cccccc",
"border-bottom": "1px solid #cccccc",
"position": "absolute",
"z-index": "20000",
"right": "0px"
"right": "0px",
"top": "37px"
},
"historyListTitleAreaNode":{
"height": "80px",
......@@ -202,6 +205,7 @@
"margin-bottom": "10px",
"overflow": "hidden",
"padding": "5px 10px",
"cursor": "pointer"
},
"historyListItemPatchNode": {
......@@ -211,6 +215,14 @@
"historyListItemDiffsNode": {
"overflow": "hidden"
},
"historyListItemActionNode": {
"height": "55px",
"width": "40px",
"float": "right",
"line-height": "55px",
"cursor": "pointer",
"color": "#0000FF"
},
"historyListItemDiffNode": {
"overflow": "hidden",
"padding": "5px 10px",
......
......@@ -980,9 +980,12 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
this.form.addEvent("beforeSave", function(){
this.resetData();
this.checkSaveNewEdition();
//if (!this.notSaveResetData) this.resetData();
}.bind(this));
// this.form.addEvent("beforeProcess", function(){
// this.checkSaveNewHistroy();
// }.bind(this));
if (this.json.toWord=="y"){
if (this.json.toWordTrigger=="open") this.docToWord();
if (this.json.toWordTrigger=="save") this.form.addEvent("beforeSave", this.docToWord.bind(this));
......@@ -1013,25 +1016,41 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
this.form.documenteditorList.push(this);
},
getFiletextText: function(data){
var div = new Element("div", {
"html": data
});
var text = div.get("text");
div.destroy();
return text;
},
checkSaveNewEdition: function(callback){
debugger;
if (!this.allowEdit || !this.data.filetext || this.data.filetext == this.json.defaultValue.filetext) return false;
if (this.form.businessData.work){
var originaData = this.form.businessData.originalData[this.json.id];
var editionData = {"category": this.json.id};
if (!originaData || !originaData.filetext || !this.originaHistoryData){
//保存原始版本
this.originaHistoryData = {"data": this.data.filetext};
editionData.data = JSON.stringify({"data": this.data.filetext});
this.originaHistoryData = {"data": this.data.filetext, "v": "6"};
editionData.data = JSON.stringify({"data": this.data.filetext, "v": "6"});
}else if (originaData.filetext!=this.data.filetext){
//保存历史版本
var data = this.data.filetext;
var earlyData = originaData.filetext;
var data = this.getFiletextText(this.data.filetext);
var earlyData = this.getFiletextText(originaData.filetext);
//var data = this.data.filetext;
//var earlyData = originaData.filetext;
var dmp = new diff_match_patch();
var diff_d = dmp.diff_main(earlyData, data);
dmp.diff_cleanupSemantic(diff_d);
var patch_list = dmp.patch_make(earlyData, data, diff_d);
editionData.data = JSON.stringify({"patchs": dmp.patch_toText(patch_list)});
var d = {
"patchs": dmp.patch_toText(patch_list),
"data": this.data.filetext,
"v": "6"
};
editionData.data = JSON.stringify(d);
}else{
return false;
}
......@@ -1041,27 +1060,20 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
}.bind(this));
}
},
// saveNewDataEdition: function(callback){
// if (this.form.businessData.work){
// var editionData = {"category": this.json.id};
// if (this.form.businessData.originalData[this.json.id] && this.form.businessData.originalData[this.json.id].filetext){
// var data = this.data.filetext;
// var earlyData = this.form.businessData.originalData[this.json.id].filetext;
// var dmp = new diff_match_patch();
// var diff_d = dmp.diff_main(earlyData, data);
// dmp.diff_cleanupSemantic(diff_d);
// var patch_list = dmp.patch_make(earlyData, data, diff_d);
// editionData.data = {"patchs": dmp.patch_toText(patch_list)};
//
// }else{
// editionData.data = {"data": this.data.filetext};
// }
// o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.create(this.form.businessData.work.id, editionData, function(json){
// this.form.businessData.originalData[this.json.id] = this.data.filetext;
// if (callback) callback();
// }.bind(this));
// }
// },
checkSaveNewHistroy: function(){
var p = o2.Actions.load("x_processplatform_assemble_surface").DocumentRevisionAction.getLast(this.form.businessData.work.job, this.json.id);
p.then(function(json){
if (!json.data || json.data.data!=this.data.filetext){
var data = {
"category": this.json.id,
"data":this.data.filetext
}
return o2.Actions.load("x_processplatform_assemble_surface").DocumentRevisionAction.create(this.form.businessData.work.id, data);
}
}.bind(this));
return p;
},
resizeToolbar: function(){
if (this.toolbarNode){
var p = this.toolNode.getPosition(this.scrollNode);
......
......@@ -1903,47 +1903,57 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
this.fireEvent("afterSave");
if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
this.workAction.processTask(function (json) {
//if (processor) processor.destroy();
//if (processNode) processNode.destroy();
if (callback) callback(json);
this.taskList = json.data;
this.fireEvent("afterProcess");
if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
// this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
this.addMessage(json.data, true);
if (this.app.taskObject) this.app.taskObject.destroy();
if (this.closeImmediatelyOnProcess) {
this.app.close();
} else if (typeOf(this.showCustomSubmitedDialog) === "function") {
this.showCustomSubmitedDialog(json.data);
} else if (layout.mobile) {
//移动端页面关闭
_self.finishOnMobile()
} else {
if (this.app.inBrowser) {
if (this.mask) this.mask.hide();
if (this.json.isPrompt !== false) {
this.showSubmitedDialog(json.data);
} else {
if (this.json.afterProcessAction == "redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code) {
var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
(new URI(url)).go();
// var promiseList = [];
// if (this.documenteditorList && this.documenteditorList.length) {
// var promiseList = [];
// this.documenteditorList.each(function (module) {
// promiseList.push(module.checkSaveNewHistroy());
// });
// }
// Promise.all(promiseList).then(function(){
this.workAction.processTask(function (json) {
//if (processor) processor.destroy();
//if (processNode) processNode.destroy();
if (callback) callback(json);
this.taskList = json.data;
this.fireEvent("afterProcess");
if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
// this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
this.addMessage(json.data, true);
if (this.app.taskObject) this.app.taskObject.destroy();
if (this.closeImmediatelyOnProcess) {
this.app.close();
} else if (typeOf(this.showCustomSubmitedDialog) === "function") {
this.showCustomSubmitedDialog(json.data);
} else if (layout.mobile) {
//移动端页面关闭
_self.finishOnMobile()
} else {
if (this.app.inBrowser) {
if (this.mask) this.mask.hide();
if (this.json.isPrompt !== false) {
this.showSubmitedDialog(json.data);
} else {
this.app.close();
if (this.json.afterProcessAction == "redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code) {
var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
(new URI(url)).go();
} else {
this.app.close();
}
}
}
//}
//}
} else {
this.app.close();
} else {
this.app.close();
}
}
}
//window.setTimeout(function(){this.app.close();}.bind(this), 2000);
}.bind(this), null, this.businessData.task.id, this.businessData.task);
//window.setTimeout(function(){this.app.close();}.bind(this), 2000);
}.bind(this), null, this.businessData.task.id, this.businessData.task);
// }.bind(this), function(){});
}.bind(this), null, true, data, true);
}.bind(this));
......
......@@ -249,7 +249,10 @@ MWF.xApplication.process.Xform.LP = {
"exit": "退出痕迹审查",
"diff_patch_count": "共有{history}个历史版本,{diff}处修订。",
"original": "原始版本",
"nodiff": "目前还没有历史修改信息"
"nodiff": "目前还没有历史修改信息",
"word": "",
"diff": "对比",
"diffTitle": "与上一版本对比"
},
"subjectEmpty": "标题不能为空",
"issuanceUnitEmpty": "发文单位不能为空",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册