|
@@ -27,10 +27,11 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
this.lp = MWF.xApplication.cms.Document.LP;
|
|
this.lp = MWF.xApplication.cms.Document.LP;
|
|
|
if (this.status){
|
|
if (this.status){
|
|
|
this.options.documentId = this.status.documentId;
|
|
this.options.documentId = this.status.documentId;
|
|
|
- this.options.readonly = (this.status.readonly=="true" || this.status.readonly==true) ? true : false;
|
|
|
|
|
- this.options.autoSave = (this.status.autoSave=="true" || this.status.autoSave==true) ? true : false;
|
|
|
|
|
- this.options.saveOnClose = (this.status.saveOnClose=="true" || this.status.saveOnClose==true) ? true : false;
|
|
|
|
|
|
|
+ this.options.readonly = (this.status.readonly==="true" || this.status.readonly===true) ? true : false;
|
|
|
|
|
+ this.options.autoSave = (this.status.autoSave==="true" || this.status.autoSave===true) ? true : false;
|
|
|
|
|
+ this.options.saveOnClose = (this.status.saveOnClose==="true" || this.status.saveOnClose===true) ? true : false;
|
|
|
this.options.formId = this.status.formId;
|
|
this.options.formId = this.status.formId;
|
|
|
|
|
+ this.options.formEditId = this.status.formEditId;
|
|
|
this.options.printFormId = this.status.printFormId;
|
|
this.options.printFormId = this.status.printFormId;
|
|
|
}
|
|
}
|
|
|
if( this.options.readonly === "false" )this.options.readonly = false;
|
|
if( this.options.readonly === "false" )this.options.readonly = false;
|
|
@@ -51,11 +52,13 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
if (!this.options.isRefresh){
|
|
if (!this.options.isRefresh){
|
|
|
this.maxSize(function(){
|
|
this.maxSize(function(){
|
|
|
this.mask.loadNode(this.content);
|
|
this.mask.loadNode(this.content);
|
|
|
- this.loadDocument();
|
|
|
|
|
|
|
+ // this.loadDocument();
|
|
|
|
|
+ this.loadDocumentV2();
|
|
|
}.bind(this));
|
|
}.bind(this));
|
|
|
}else{
|
|
}else{
|
|
|
this.mask.loadNode(this.content);
|
|
this.mask.loadNode(this.content);
|
|
|
- this.loadDocument();
|
|
|
|
|
|
|
+ // this.loadDocument();
|
|
|
|
|
+ this.loadDocumentV2();
|
|
|
}
|
|
}
|
|
|
if (callback) callback();
|
|
if (callback) callback();
|
|
|
//}.bind(this));
|
|
//}.bind(this));
|
|
@@ -92,175 +95,210 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- reload: function(data){
|
|
|
|
|
|
|
+ reload: function(){
|
|
|
|
|
+ this.formNode.empty();
|
|
|
if (this.form){
|
|
if (this.form){
|
|
|
- this.formNode.empty();
|
|
|
|
|
MWF.release(this.form);
|
|
MWF.release(this.form);
|
|
|
this.form = null;
|
|
this.form = null;
|
|
|
}
|
|
}
|
|
|
- this.parseData(data);
|
|
|
|
|
- this.openDocument();
|
|
|
|
|
|
|
+ // this.parseDocumentV2(data);
|
|
|
|
|
+ // this.openDocument();
|
|
|
|
|
+ this.loadDocumentV2();
|
|
|
},
|
|
},
|
|
|
- getDocument : function( callback ){
|
|
|
|
|
- var id = this.options.documentId;
|
|
|
|
|
- //if( this.options.anonymousAccess ){
|
|
|
|
|
- // this.action.getDocumentByAnonymous(id, function(json){
|
|
|
|
|
- // callback(json)
|
|
|
|
|
- // }.bind(this), function( error ){
|
|
|
|
|
- // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- // this.close();
|
|
|
|
|
- // }.bind(this));
|
|
|
|
|
- //}else if( this.options.readonly ){
|
|
|
|
|
- // this.action.viewDocument(id, function(json){
|
|
|
|
|
- // callback(json)
|
|
|
|
|
- // }.bind(this), function( error ){
|
|
|
|
|
- // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- // this.close();
|
|
|
|
|
- // }.bind(this));
|
|
|
|
|
- //}else{
|
|
|
|
|
- // this.action.getDocument(id, function(json){
|
|
|
|
|
- // callback(json)
|
|
|
|
|
- // }.bind(this), function( error ){
|
|
|
|
|
- // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- // this.close();
|
|
|
|
|
- // }.bind(this));
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
- var documentMethod = "getDocument";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ loadDocumentV2 : function( callback ){
|
|
|
|
|
+ debugger;
|
|
|
|
|
+
|
|
|
|
|
+ this.loadFormFlag = false;
|
|
|
|
|
+ this.loadDocumentFlag = false;
|
|
|
|
|
+ this.loadModuleFlag = false;
|
|
|
|
|
+
|
|
|
|
|
+ this.json_document = null;
|
|
|
|
|
+ this.json_form = null;
|
|
|
|
|
+
|
|
|
|
|
+ var readonly = this.options.readonly !== false;
|
|
|
|
|
+
|
|
|
|
|
+ var formId = "";
|
|
|
|
|
+ if( this.options.printFormId ){ //有确定的id
|
|
|
|
|
+ formId = this.options.printFormId;
|
|
|
|
|
+ }else if( readonly && this.options.formId ){ //只读,并且有只读表单id
|
|
|
|
|
+ formId = this.options.formId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if( formId ){
|
|
|
|
|
+ this.getFormV2(formId);
|
|
|
|
|
+ this.getDocumentV2();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if( readonly ){ //只读情况,不需要判断是否有阅读权限
|
|
|
|
|
+ this.lookupFormV2( true );
|
|
|
|
|
+ }
|
|
|
|
|
+ this.getDocumentV2();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var cl = "$all";
|
|
|
|
|
+ MWF.xDesktop.requireApp("cms.Xform", cl, function(){
|
|
|
|
|
+ this.loadModuleFlag = true;
|
|
|
|
|
+ this.checkLoad();
|
|
|
|
|
+ }.bind(this));
|
|
|
|
|
+ },
|
|
|
|
|
+ checkLoad : function ( toLoadForm ) {
|
|
|
|
|
+ if( toLoadForm ){
|
|
|
|
|
+ if( this.json_document ){
|
|
|
|
|
+ this.getFormV2( this.formId );
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.needLoadForm = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if( this.needLoadForm && !this.loadFormFlag && this.json_document ){
|
|
|
|
|
+ this.needLoadForm = false;
|
|
|
|
|
+ this.getFormV2( this.formId );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if( this.loadFormFlag && this.loadDocumentFlag && this.loadModuleFlag ){
|
|
|
|
|
+ this.parseFormV2( this.json_form.data );
|
|
|
|
|
+ if (layout.session && layout.session.user){
|
|
|
|
|
+ this.openDocument();
|
|
|
|
|
+ if (this.mask) this.mask.hide();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (layout.sessionPromise){
|
|
|
|
|
+ layout.sessionPromise.then(function(){
|
|
|
|
|
+ this.openDocument();
|
|
|
|
|
+ if (this.mask) this.mask.hide();
|
|
|
|
|
+ }.bind(this), function(){});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ getDocumentV2 : function(){
|
|
|
|
|
+ var id = this.options.documentId || this.options.id;
|
|
|
|
|
+ var readonly = this.options.readonly !== false;
|
|
|
|
|
+
|
|
|
|
|
+ var documentMethod;
|
|
|
if( this.options.anonymousAccess ){
|
|
if( this.options.anonymousAccess ){
|
|
|
documentMethod = "getDocumentByAnonymous"
|
|
documentMethod = "getDocumentByAnonymous"
|
|
|
- }else if( this.options.readonly && !this.options.printFormId){
|
|
|
|
|
|
|
+ }else if( readonly && !this.options.printFormId){
|
|
|
documentMethod = "viewDocument";
|
|
documentMethod = "viewDocument";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ documentMethod = "getDocument";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var attachmentMethod = "listAttachment";
|
|
|
|
|
- if( this.options.anonymousAccess ){
|
|
|
|
|
- attachmentMethod = "listAttachmentByAnonymous"
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var attachmentMethod = this.options.anonymousAccess ? "listAttachmentByAnonymous" : "listAttachment";
|
|
|
|
|
|
|
|
o2.Actions.invokeAsync([
|
|
o2.Actions.invokeAsync([
|
|
|
{"action": this.action, "name": documentMethod},
|
|
{"action": this.action, "name": documentMethod},
|
|
|
- {"action": this.action, "name": attachmentMethod }
|
|
|
|
|
- ], {"success": function(json_document, json_att){
|
|
|
|
|
- if (json_document ){
|
|
|
|
|
- if( json_att && typeOf( json_att.data ) === "array" ){
|
|
|
|
|
- json_document.data.attachmentList = json_att.data ;
|
|
|
|
|
|
|
+ {"action": this.action, "name": attachmentMethod },
|
|
|
|
|
+ ], {"success": function(jsonDocument, jsonAtt){
|
|
|
|
|
+ if (jsonDocument ){
|
|
|
|
|
+ if( jsonAtt && typeOf( jsonAtt.data ) === "array" ){
|
|
|
|
|
+ jsonDocument.data.attachmentList = jsonAtt.data ;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ jsonDocument.data.attachmentList = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ this.json_document = jsonDocument;
|
|
|
|
|
+ this.loadDocumentFlag = true;
|
|
|
|
|
+
|
|
|
|
|
+ this.parseDocumentV2(this.json_document.data);
|
|
|
|
|
+
|
|
|
|
|
+ var toLoadForm = this.options.readonly !== true; //编辑状态要先获取document再判断有没有权限编辑
|
|
|
|
|
+ this.checkLoad( toLoadForm )
|
|
|
}else{
|
|
}else{
|
|
|
- json_document.data.attachmentList = [];
|
|
|
|
|
|
|
+ this.errorLoadingV2();
|
|
|
}
|
|
}
|
|
|
- callback(json_document)
|
|
|
|
|
- }else{
|
|
|
|
|
- this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- this.close();
|
|
|
|
|
- }
|
|
|
|
|
- }.bind(this), "failure": function(){
|
|
|
|
|
- this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- this.close();
|
|
|
|
|
- }.bind(this)}, id);
|
|
|
|
|
|
|
+ }.bind(this), "failure": function(error){
|
|
|
|
|
+ this.errorLoadingV2( error );
|
|
|
|
|
+ }.bind(this)}, id, id);
|
|
|
},
|
|
},
|
|
|
- loadDocument: function(){
|
|
|
|
|
- this.getDocument( function(json){
|
|
|
|
|
- json.data = json.data || [];
|
|
|
|
|
- this.parseData(json.data);
|
|
|
|
|
- this.loadForm( this.formId );
|
|
|
|
|
- }.bind(this) );
|
|
|
|
|
- },
|
|
|
|
|
- errorDocument: function(){
|
|
|
|
|
- if (this.mask) this.mask.hide();
|
|
|
|
|
- this.node.set("text", "openError");
|
|
|
|
|
- },
|
|
|
|
|
- loadForm : function( formId, flag ){
|
|
|
|
|
- var success = function(json){
|
|
|
|
|
- if (json.form){
|
|
|
|
|
- this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
|
|
|
|
|
- this.relatedFormMap = json.relatedFormMap;
|
|
|
|
|
- this.relatedScriptMap = json.relatedScriptMap;
|
|
|
|
|
- if( json.form.data )delete json.form.data;
|
|
|
|
|
- this.formInfor = json.form;
|
|
|
|
|
- }else{
|
|
|
|
|
- if( layout.mobile ){
|
|
|
|
|
- this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
|
|
|
|
|
- if( !this.form ){
|
|
|
|
|
- this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ getFormV2 : function( formId, cacheTag, ignoreFromCategory ){
|
|
|
|
|
+ var formMethod;
|
|
|
|
|
+ if( this.options.anonymousAccess ){
|
|
|
|
|
+ formMethod = layout.mobile ? "getFormMobileAnonymousV2" : "getFormAnonymousV2";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ formMethod = layout.mobile ? "getFormMobileV2" : "getFormV2";
|
|
|
|
|
+ }
|
|
|
|
|
+ this.action[formMethod](
|
|
|
|
|
+ formId,
|
|
|
|
|
+
|
|
|
|
|
+ cacheTag || "",
|
|
|
|
|
+
|
|
|
|
|
+ function( jsonForm ){
|
|
|
|
|
+ this.json_form = jsonForm;
|
|
|
|
|
+ this.loadFormFlag = true;
|
|
|
|
|
+ this.checkLoad();
|
|
|
|
|
+ }.bind(this),
|
|
|
|
|
+
|
|
|
|
|
+ function(error){
|
|
|
|
|
+ //没有表单,重新获取分类表单
|
|
|
|
|
+ if( !ignoreFromCategory && this.document && this.document.categoryId ){
|
|
|
|
|
+ this.action.getCategory( this.document.categoryId, function(json){
|
|
|
|
|
+ var d = json.data;
|
|
|
|
|
+ if( this.readonly == true && d.readFormId && d.readFormId != "" ){
|
|
|
|
|
+ this.formId = d.readFormId;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.formId = d.formId || d.readFormId;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.getFormV2( this.formId, null,true );
|
|
|
|
|
+ }.bind(this));
|
|
|
}else{
|
|
}else{
|
|
|
- this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
|
|
|
|
+ this.errorLoadingV2( error , "form" );
|
|
|
}
|
|
}
|
|
|
- if( json.data.data )delete json.data.data;
|
|
|
|
|
- if( json.data.mobileData )delete json.data.mobileData;
|
|
|
|
|
- this.formInfor = json.form;
|
|
|
|
|
|
|
+ }.bind(this)
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ lookupFormV2 : function ( isReadonly ) {
|
|
|
|
|
+ var id = this.options.documentId || this.options.id;
|
|
|
|
|
+
|
|
|
|
|
+ var lookupMethod;
|
|
|
|
|
+ if( this.options.anonymousAccess ){
|
|
|
|
|
+ lookupMethod = layout.mobile ? "lookupFormWithDocMobileAnonymousV2" : "lookupFormWithDocAnonymousV2";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ lookupMethod = layout.mobile ? "lookupFormWithDocMobileV2" : "lookupFormWithDocV2";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.action[lookupMethod](id, function(json){
|
|
|
|
|
+ var formId;
|
|
|
|
|
+ if( isReadonly ){
|
|
|
|
|
+ formId = json.data.readFormId || json.data.formId;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ formId = json.data.formId || json.data.readFormId;
|
|
|
}
|
|
}
|
|
|
- //this.listAttachment();
|
|
|
|
|
- this.openDocument();
|
|
|
|
|
- if (this.mask) this.mask.hide();
|
|
|
|
|
- }.bind(this);
|
|
|
|
|
- var failure = function(error){
|
|
|
|
|
- //没有表单,重新获取分类表单
|
|
|
|
|
- if( !flag ){
|
|
|
|
|
- this.action.getCategory( this.document.categoryId, function(json){
|
|
|
|
|
- var d = json.data;
|
|
|
|
|
- this.formId = d.formId || d.readFormId;
|
|
|
|
|
- if( this.readonly == true && d.readFormId && d.readFormId != "" ){
|
|
|
|
|
- this.formId = d.readFormId;
|
|
|
|
|
- }
|
|
|
|
|
- this.loadForm( this.formId, true );
|
|
|
|
|
- }.bind(this));
|
|
|
|
|
|
|
+ if (json.data.form){
|
|
|
|
|
+ this.json_form = json;
|
|
|
|
|
+ this.loadFormFlag = true;
|
|
|
|
|
+ this.checkLoad();
|
|
|
}else{
|
|
}else{
|
|
|
- this.notice( this.lp.formGettedError + ":" + error.responseText , "error");
|
|
|
|
|
- this.close();
|
|
|
|
|
|
|
+ var cacheTag = json.data.cacheTag || "";
|
|
|
|
|
+ this.getFormV2( formId, cacheTag )
|
|
|
}
|
|
}
|
|
|
- }.bind(this);
|
|
|
|
|
- if( this.options.printFormId){
|
|
|
|
|
- this.action.getForm(this.options.printFormId, function( json ){
|
|
|
|
|
- success(json);
|
|
|
|
|
- }.bind(this), function(error){
|
|
|
|
|
- failure(error)
|
|
|
|
|
- }.bind(this));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }.bind(this), function(){
|
|
|
|
|
+ this.checkLoad( true );
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ parseFormV2: function( json ){
|
|
|
|
|
+ if (json.form){
|
|
|
|
|
+ this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
|
|
|
|
|
+ this.relatedFormMap = json.relatedFormMap;
|
|
|
|
|
+ this.relatedScriptMap = json.relatedScriptMap;
|
|
|
|
|
+ if( json.form.data )delete json.form.data;
|
|
|
|
|
+ this.formInfor = json.form;
|
|
|
}else{
|
|
}else{
|
|
|
- if( this.options.anonymousAccess ){
|
|
|
|
|
- this.action.getFormByAnonymous(formId, function( json ){
|
|
|
|
|
- success(json);
|
|
|
|
|
- }.bind(this), function(error){
|
|
|
|
|
- failure(error)
|
|
|
|
|
- }.bind(this));
|
|
|
|
|
|
|
+ if( layout.mobile ){
|
|
|
|
|
+ this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
|
|
|
|
|
+ if( !this.form ){
|
|
|
|
|
+ this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
- this.action.getForm(formId, function( json ){
|
|
|
|
|
- success(json);
|
|
|
|
|
- }.bind(this), function(error){
|
|
|
|
|
- failure(error)
|
|
|
|
|
- }.bind(this));
|
|
|
|
|
|
|
+ this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
}
|
|
}
|
|
|
|
|
+ if( json.data.data )delete json.data.data;
|
|
|
|
|
+ if( json.data.mobileData )delete json.data.mobileData;
|
|
|
|
|
+ this.formInfor = json.form;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- //listAttachment: function(){
|
|
|
|
|
- // if( this.document.attachmentList && this.document.attachmentList.length > 0 ){
|
|
|
|
|
- // this.action.listAttachment(this.options.documentId, function( json ){
|
|
|
|
|
- // if (this.mask) this.mask.hide();
|
|
|
|
|
- // this.attachmentList = json.data;
|
|
|
|
|
- // this.attachmentList.each(function(att){
|
|
|
|
|
- // att.lastUpdateTime = att.updateTime;
|
|
|
|
|
- // att.person = att.creatorUid;
|
|
|
|
|
- // })
|
|
|
|
|
- // this.openDocument();
|
|
|
|
|
- // }.bind(this), function(error){
|
|
|
|
|
- // this.notice( this.lp.attachmentGettedError + ":" + error.responseText, "error");
|
|
|
|
|
- // this.close();
|
|
|
|
|
- // }.bind(this));
|
|
|
|
|
- // }else{
|
|
|
|
|
- // if (this.mask) this.mask.hide();
|
|
|
|
|
- // this.attachmentList = [];
|
|
|
|
|
- // this.openDocument();
|
|
|
|
|
- // }
|
|
|
|
|
- //},
|
|
|
|
|
- isEmptyObject: function( obj ) {
|
|
|
|
|
- var name;
|
|
|
|
|
- for ( name in obj ) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- return true;
|
|
|
|
|
- },
|
|
|
|
|
- parseData: function(data){
|
|
|
|
|
-
|
|
|
|
|
|
|
+ parseDocumentV2 : function( data ){
|
|
|
var title = "";
|
|
var title = "";
|
|
|
title = data.document.title;
|
|
title = data.document.title;
|
|
|
|
|
|
|
@@ -276,92 +314,287 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
att.person = att.creatorUid;
|
|
att.person = att.creatorUid;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- if( this.isEmptyObject(this.data) ){
|
|
|
|
|
- this.data.isNew = true;
|
|
|
|
|
- }else{
|
|
|
|
|
- this.data.isNew = false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.data.isNew = this.isEmptyObject(this.data) ? true : false;
|
|
|
|
|
|
|
|
this.document = data.document;
|
|
this.document = data.document;
|
|
|
|
|
|
|
|
var isAdmin = false;
|
|
var isAdmin = false;
|
|
|
|
|
|
|
|
- if( MWF.AC.isCMSManager() ){
|
|
|
|
|
|
|
+ if( MWF.AC.isCMSManager() || data.isAppAdmin || data.isCategoryAdmin || data.isManager){
|
|
|
this.options.isControl = true;
|
|
this.options.isControl = true;
|
|
|
- isAdmin = true;
|
|
|
|
|
|
|
+ this.isAdmin = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( data.isAppAdmin ){
|
|
|
|
|
- this.options.isControl = true;
|
|
|
|
|
- isAdmin = true;
|
|
|
|
|
- }
|
|
|
|
|
- if( data.isCategoryAdmin ){
|
|
|
|
|
- this.options.isControl = true;
|
|
|
|
|
- isAdmin = true;
|
|
|
|
|
- }
|
|
|
|
|
- if( data.isManager ){
|
|
|
|
|
- this.options.isControl = true;
|
|
|
|
|
- isAdmin = true;
|
|
|
|
|
- }
|
|
|
|
|
- this.isAdmin = isAdmin;
|
|
|
|
|
- ////系统管理员
|
|
|
|
|
- //if( MWF.AC.isAdministrator() ){
|
|
|
|
|
- // this.options.isControl = true;
|
|
|
|
|
- // isAdmin = true;
|
|
|
|
|
- //}
|
|
|
|
|
- ////栏目管理员
|
|
|
|
|
- //if(this.controllers && this.controllers.contains(this.desktop.session.user.name) ){
|
|
|
|
|
- // this.options.isControl = true;
|
|
|
|
|
- // isAdmin = true;
|
|
|
|
|
- //}
|
|
|
|
|
//文档创建人
|
|
//文档创建人
|
|
|
if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
|
|
if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
|
|
|
this.options.isControl = true;
|
|
this.options.isControl = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( data.isEditor ){ //作者权限
|
|
|
|
|
|
|
+ //作者权限
|
|
|
|
|
+ if( data.isEditor ){
|
|
|
this.options.isControl = true;
|
|
this.options.isControl = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if( this.options.readonly ){ //强制只读
|
|
if( this.options.readonly ){ //强制只读
|
|
|
this.readonly = true;
|
|
this.readonly = true;
|
|
|
}else{
|
|
}else{
|
|
|
- this.readonly = true;
|
|
|
|
|
- if(this.options.isControl && this.document.docStatus != "archived"){
|
|
|
|
|
|
|
+ if(this.options.isControl && this.document.docStatus != "archived"){ //有编辑权限并且不是归档状态
|
|
|
this.readonly = false;
|
|
this.readonly = false;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.readonly = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.formId = this.document.form || this.document.readFormId;
|
|
|
|
|
- if( this.readonly == true && this.document.readFormId && this.document.readFormId != "" ){
|
|
|
|
|
- this.formId = this.document.readFormId;
|
|
|
|
|
- if(this.options.formId){
|
|
|
|
|
- this.formId = this.options.formId
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
- if(this.options.formEditId){
|
|
|
|
|
- this.formId = this.options.formEditId
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var formId;
|
|
|
|
|
+ if( this.readonly === true ){
|
|
|
|
|
+ formId = this.options.printFormId || this.options.formId || this.document.readFormId || this.options.formEditId || this.document.form;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ formId = this.options.printFormId || this.options.formEditId || this.document.form || this.options.formId || this.document.readFormId;
|
|
|
}
|
|
}
|
|
|
|
|
+ this.formId = formId;
|
|
|
|
|
|
|
|
if(this.readonly || this.document.docStatus == "published"){
|
|
if(this.readonly || this.document.docStatus == "published"){
|
|
|
this.options.autoSave = false;
|
|
this.options.autoSave = false;
|
|
|
this.options.saveOnClose = false;
|
|
this.options.saveOnClose = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //this.attachmentList = data.attachmentList;
|
|
|
|
|
-
|
|
|
|
|
- //this.inheritedAttachmentList = data.inheritedAttachmentList;
|
|
|
|
|
var isControl = this.options.isControl;
|
|
var isControl = this.options.isControl;
|
|
|
this.control = data.control || {
|
|
this.control = data.control || {
|
|
|
- "allowRead": true,
|
|
|
|
|
- "allowPublishDocument": isControl && this.document.docStatus == "draft",
|
|
|
|
|
- "allowSave": isControl && this.document.docStatus == "published",
|
|
|
|
|
- "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
|
|
|
|
|
- "allowEditDocument": isControl && !this.document.wf_workId,
|
|
|
|
|
- "allowDeleteDocument": isControl && !this.document.wf_workId
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ "allowRead": true,
|
|
|
|
|
+ "allowPublishDocument": isControl && this.document.docStatus == "draft",
|
|
|
|
|
+ "allowSave": isControl && this.document.docStatus == "published",
|
|
|
|
|
+ "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
|
|
|
|
|
+ "allowEditDocument": isControl && !this.document.wf_workId,
|
|
|
|
|
+ "allowDeleteDocument": isControl && !this.document.wf_workId
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ errorLoadingV2 : function( error, type ){
|
|
|
|
|
+ var text;
|
|
|
|
|
+ if( type === "form" ){
|
|
|
|
|
+ text = this.lp.formGettedError;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ text = this.lp.documentGettedError;
|
|
|
|
|
+ }
|
|
|
|
|
+ if( error )text = text + ":" + error.responseText;
|
|
|
|
|
+ this.notice( text , "error");
|
|
|
|
|
+ layout.sessionPromise.then(function(){
|
|
|
|
|
+ if (this.mask) this.mask.hide();
|
|
|
|
|
+ this.close();
|
|
|
|
|
+ }.bind(this), function(){});
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ isEmptyObject: function( obj ) {
|
|
|
|
|
+ var name;
|
|
|
|
|
+ for ( name in obj ) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // getDocument : function( callback ){
|
|
|
|
|
+ // var id = this.options.documentId;
|
|
|
|
|
+ //
|
|
|
|
|
+ // var documentMethod = "getDocument";
|
|
|
|
|
+ // if( this.options.anonymousAccess ){
|
|
|
|
|
+ // documentMethod = "getDocumentByAnonymous"
|
|
|
|
|
+ // }else if( this.options.readonly && !this.options.printFormId){
|
|
|
|
|
+ // documentMethod = "viewDocument";
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // var attachmentMethod = "listAttachment";
|
|
|
|
|
+ // if( this.options.anonymousAccess ){
|
|
|
|
|
+ // attachmentMethod = "listAttachmentByAnonymous"
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // o2.Actions.invokeAsync([
|
|
|
|
|
+ // {"action": this.action, "name": documentMethod},
|
|
|
|
|
+ // {"action": this.action, "name": attachmentMethod }
|
|
|
|
|
+ // ], {"success": function(json_document, json_att){
|
|
|
|
|
+ // if (json_document ){
|
|
|
|
|
+ // if( json_att && typeOf( json_att.data ) === "array" ){
|
|
|
|
|
+ // json_document.data.attachmentList = json_att.data ;
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // json_document.data.attachmentList = [];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // callback(json_document)
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
+ // this.close();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }.bind(this), "failure": function(){
|
|
|
|
|
+ // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
|
|
|
|
|
+ // this.close();
|
|
|
|
|
+ // }.bind(this)}, id);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // loadDocument: function(){
|
|
|
|
|
+ // this.getDocument( function(json){
|
|
|
|
|
+ // json.data = json.data || [];
|
|
|
|
|
+ // this.parseData(json.data);
|
|
|
|
|
+ // this.loadForm( this.formId );
|
|
|
|
|
+ // }.bind(this) );
|
|
|
|
|
+ // },
|
|
|
|
|
+ // errorDocument: function(){
|
|
|
|
|
+ // if (this.mask) this.mask.hide();
|
|
|
|
|
+ // this.node.set("text", "openError");
|
|
|
|
|
+ // },
|
|
|
|
|
+ // loadForm : function( formId, flag ){
|
|
|
|
|
+ // var success = function(json){
|
|
|
|
|
+ // if (json.form){
|
|
|
|
|
+ // this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
|
|
|
|
|
+ // this.relatedFormMap = json.relatedFormMap;
|
|
|
|
|
+ // this.relatedScriptMap = json.relatedScriptMap;
|
|
|
|
|
+ // if( json.form.data )delete json.form.data;
|
|
|
|
|
+ // this.formInfor = json.form;
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // if( layout.mobile ){
|
|
|
|
|
+ // this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
|
|
|
|
|
+ // if( !this.form ){
|
|
|
|
|
+ // this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if( json.data.data )delete json.data.data;
|
|
|
|
|
+ // if( json.data.mobileData )delete json.data.mobileData;
|
|
|
|
|
+ // this.formInfor = json.form;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // //this.listAttachment();
|
|
|
|
|
+ // this.openDocument();
|
|
|
|
|
+ // if (this.mask) this.mask.hide();
|
|
|
|
|
+ // }.bind(this);
|
|
|
|
|
+ // var failure = function(error){
|
|
|
|
|
+ // //没有表单,重新获取分类表单
|
|
|
|
|
+ // if( !flag ){
|
|
|
|
|
+ // this.action.getCategory( this.document.categoryId, function(json){
|
|
|
|
|
+ // var d = json.data;
|
|
|
|
|
+ // this.formId = d.formId || d.readFormId;
|
|
|
|
|
+ // if( this.readonly == true && d.readFormId && d.readFormId != "" ){
|
|
|
|
|
+ // this.formId = d.readFormId;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.loadForm( this.formId, true );
|
|
|
|
|
+ // }.bind(this));
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.notice( this.lp.formGettedError + ":" + error.responseText , "error");
|
|
|
|
|
+ // this.close();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }.bind(this);
|
|
|
|
|
+ // if( this.options.printFormId){
|
|
|
|
|
+ // this.action.getForm(this.options.printFormId, function( json ){
|
|
|
|
|
+ // success(json);
|
|
|
|
|
+ // }.bind(this), function(error){
|
|
|
|
|
+ // failure(error)
|
|
|
|
|
+ // }.bind(this));
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // if( this.options.anonymousAccess ){
|
|
|
|
|
+ // this.action.getFormByAnonymous(formId, function( json ){
|
|
|
|
|
+ // success(json);
|
|
|
|
|
+ // }.bind(this), function(error){
|
|
|
|
|
+ // failure(error)
|
|
|
|
|
+ // }.bind(this));
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.action.getForm(formId, function( json ){
|
|
|
|
|
+ // success(json);
|
|
|
|
|
+ // }.bind(this), function(error){
|
|
|
|
|
+ // failure(error)
|
|
|
|
|
+ // }.bind(this));
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+ // parseData: function(data){
|
|
|
|
|
+ //
|
|
|
|
|
+ // var title = "";
|
|
|
|
|
+ // title = data.document.title;
|
|
|
|
|
+ //
|
|
|
|
|
+ // this.setTitle(title);
|
|
|
|
|
+ //
|
|
|
|
|
+ // data.document.subject = data.document.title;
|
|
|
|
|
+ //
|
|
|
|
|
+ // this.data = data.data;
|
|
|
|
|
+ //
|
|
|
|
|
+ // this.attachmentList = data.attachmentList || [];
|
|
|
|
|
+ // this.attachmentList.each(function(att){
|
|
|
|
|
+ // att.lastUpdateTime = att.updateTime;
|
|
|
|
|
+ // att.person = att.creatorUid;
|
|
|
|
|
+ // });
|
|
|
|
|
+ //
|
|
|
|
|
+ // if( this.isEmptyObject(this.data) ){
|
|
|
|
|
+ // this.data.isNew = true;
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.data.isNew = false;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // this.document = data.document;
|
|
|
|
|
+ //
|
|
|
|
|
+ // var isAdmin = false;
|
|
|
|
|
+ //
|
|
|
|
|
+ // if( MWF.AC.isCMSManager() ){
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // isAdmin = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if( data.isAppAdmin ){
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // isAdmin = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if( data.isCategoryAdmin ){
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // isAdmin = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if( data.isManager ){
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // isAdmin = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.isAdmin = isAdmin;
|
|
|
|
|
+ //
|
|
|
|
|
+ // //文档创建人
|
|
|
|
|
+ // if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if( data.isEditor ){ //作者权限
|
|
|
|
|
+ // this.options.isControl = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if( this.options.readonly ){ //强制只读
|
|
|
|
|
+ // this.readonly = true;
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // this.readonly = true;
|
|
|
|
|
+ // if(this.options.isControl && this.document.docStatus != "archived"){
|
|
|
|
|
+ // this.readonly = false;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // this.formId = this.document.form || this.document.readFormId;
|
|
|
|
|
+ // if( this.readonly == true && this.document.readFormId && this.document.readFormId != "" ){
|
|
|
|
|
+ // this.formId = this.document.readFormId;
|
|
|
|
|
+ // if(this.options.formId){
|
|
|
|
|
+ // this.formId = this.options.formId
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }else {
|
|
|
|
|
+ // if(this.options.formEditId){
|
|
|
|
|
+ // this.formId = this.options.formEditId
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(this.readonly || this.document.docStatus == "published"){
|
|
|
|
|
+ // this.options.autoSave = false;
|
|
|
|
|
+ // this.options.saveOnClose = false;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // //this.attachmentList = data.attachmentList;
|
|
|
|
|
+ //
|
|
|
|
|
+ // //this.inheritedAttachmentList = data.inheritedAttachmentList;
|
|
|
|
|
+ // var isControl = this.options.isControl;
|
|
|
|
|
+ // this.control = data.control || {
|
|
|
|
|
+ // "allowRead": true,
|
|
|
|
|
+ // "allowPublishDocument": isControl && this.document.docStatus == "draft",
|
|
|
|
|
+ // "allowSave": isControl && this.document.docStatus == "published",
|
|
|
|
|
+ // "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
|
|
|
|
|
+ // "allowEditDocument": isControl && !this.document.wf_workId,
|
|
|
|
|
+ // "allowDeleteDocument": isControl && !this.document.wf_workId
|
|
|
|
|
+ // };
|
|
|
|
|
+ // },
|
|
|
|
|
+
|
|
|
setPopularDocument: function(){
|
|
setPopularDocument: function(){
|
|
|
MWF.xDesktop.requireApp("cms.Document", "HotLinkForm", null, false);
|
|
MWF.xDesktop.requireApp("cms.Document", "HotLinkForm", null, false);
|
|
|
var form = new MWF.xApplication.cms.Document.HotLinkForm(this, this.document, {
|
|
var form = new MWF.xApplication.cms.Document.HotLinkForm(this, this.document, {
|
|
@@ -378,7 +611,7 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
openDocument: function(){
|
|
openDocument: function(){
|
|
|
if (this.form){
|
|
if (this.form){
|
|
|
// MWF.xDesktop.requireApp("cms.Xform", "Form", function(){
|
|
// MWF.xDesktop.requireApp("cms.Xform", "Form", function(){
|
|
|
- MWF.xDesktop.requireApp("cms.Xform", "$all", function(){
|
|
|
|
|
|
|
+ MWF.xDesktop.requireApp("cms.Xform", "$all", function(){
|
|
|
this.appForm = new MWF.CMSForm(this.formNode, this.form, {
|
|
this.appForm = new MWF.CMSForm(this.formNode, this.form, {
|
|
|
"readonly": this.readonly,
|
|
"readonly": this.readonly,
|
|
|
"autoSave" : this.options.autoSave,
|
|
"autoSave" : this.options.autoSave,
|
|
@@ -416,6 +649,7 @@ MWF.xApplication.cms.Document.Main = new Class({
|
|
|
"saveOnClose" : this.options.saveOnClose
|
|
"saveOnClose" : this.options.saveOnClose
|
|
|
};
|
|
};
|
|
|
if( this.options.formId )status.formId = this.options.formId;
|
|
if( this.options.formId )status.formId = this.options.formId;
|
|
|
|
|
+ if( this.options.formEditId )status.formEditId = this.options.formEditId;
|
|
|
if( this.options.printFormId )status.printFormId = this.options.printFormId;
|
|
if( this.options.printFormId )status.printFormId = this.options.printFormId;
|
|
|
if(this.options.appId && this.options.appId!="")status.appId = this.options.appId;
|
|
if(this.options.appId && this.options.appId!="")status.appId = this.options.appId;
|
|
|
return status;
|
|
return status;
|