mwf.xdesktop.requireapp("process.xform", "$module", null, false);
/** @class office office控件。
* @o2cn ntko office控件
* @example
* //可以在脚本中获取该组件
* //方法1:
* var attachment = this.form.get("name"); //获取组件
* //方法2
* var attachment = this.target; //在组件事件脚本中获取
* @extends mwf.xapplication.process.xform.$module
* @o2category formcomponents
* @o2range {process|cms}
* @hideconstructor
*/
mwf.xapplication.process.xform.office = mwf.appoffice = new class(
/** @lends mwf.xapplication.process.xform.office# */
{
extends: mwf.app$module,
isactive: false,
options:{
"productcaption": "o2",
"productkey": "edcc626cb85c9a1d3e0d7bdddc2637753c596725",
"makercaption": "浙江兰德纵横网络技术股份有限公司",
"makerkey": "e138dabb4ac26c2d8e09fae59ab3bde87afb9d7b",
"version": "5.0.4.0",
"clsid": "a64e3073-2016-4baf-a89d-ffe1faa10ec0",
"codebase": "../o2_lib/officecontrol/5040/officecontrol.cab",
"clsid64": "a64e3073-2016-4baf-a89d-ffe1faa10ee1",
"codebase64": "../o2_lib/officecontrol/5040/ofctnewclsid.cab",
"pdftype": "pdf.ntkodocument",
"pdfversion": "4.0.0.3",
"pdfcodebase": "../o2_lib/officecontrol/5040/ntkooledocall.cab",
"pdfcodebase64": "../o2_lib/officecontrol/5040/ntkooledocall64.cab",
"files": ["doc","docx","dotx","dot","xls","xlsx","xlsm","xlt","xltx","pptx","ppt","pot","potx","potm","pdf"],
/**
* @event mwf.xapplication.process.xform.office#queryload
* @ignore
*/
/**
* @event mwf.xapplication.process.xform.office#postload
* @ignore
*/
/**
* 点击套红按钮触发。
* @event mwf.xapplication.process.xform.office#redfile
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* 点击盖章按钮触发。
* @event mwf.xapplication.process.xform.office#seal
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* ntko控件执行afteropenfromurl事件(beginopenfromurl方法执行完毕之后被触发)时执行。
* 本事件可以通过this.event获取当前打开的文档对象。比如,对于一个word文档,第二个参数是一个word.document对象。
* @event mwf.xapplication.process.xform.office#afteropen
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* ntko控件执行ondocumentopened事件(office文档打开完毕)时触发。
* 本事件可以通过this.event获取以下内容
*
{
url : url, //office文档路径或者url
doc : doc //office文档的自动化接口,比如,对于一个word文档,第二个参数是一个word.document对象。
}
* @event mwf.xapplication.process.xform.office#afteropenoffice
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* 在新建office文档后触发。
* @event mwf.xapplication.process.xform.office#aftercreate
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* 在保存office文档前触发。
* @event mwf.xapplication.process.xform.office#beforesave
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* 在保存office文档后触发。
* @event mwf.xapplication.process.xform.office#aftersave
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* 在关闭office文档时执行。
* @event mwf.xapplication.process.xform.office#aftercloseoffice
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
"moduleevents": ["redfile",
"afteropen",
"afteropenoffice",
"aftercreate",
"seal",
"beforesave",
"aftersave",
"aftercloseoffice",
"load"
]
},
initialize: function(node, json, form, options){
this.node = $(node);
this.node.store("module", this);
this.json = json;
this.form = form;
this.field = true;
this.openedattachment = null;
this.fieldmoduleloaded = false;
},
_loaduserinterface: function(){
this.node.empty();
this.node.setstyles({
"min-height": "100px"
});
// this.isactive = true;
//if (browser.name==="ie" || browser.name==="chrome" || browser.name==="firefox"){
if (browser.name==="ie"){
this.isactive = true;
this.file = null;
if (!this.form.officelist) this.form.officelist=[];
this.form.officelist.push(this);
}
},
_afterloaded: function(){
if (!this.json.isnotloadnow){
this.loadoffice();
}
//this.fireevent("load");
},
loadoffice: function(file){
if (!this.officeloaded){
if (!this.isactive){
this.loadofficenotactive();
}else{
mwf.getjson("../o2_lib/officecontrol/config.json", function(json){
this.officeconfig = json;
}.bind(this), false);
this.loadofficecontorl(file);
}
this.officeloaded = true;
}else{
if (this.officeocx) this.officeocx.beginopenfrom;
}
this.fieldmoduleloaded = true;
},
getprogid: function(){
switch (this.json.officetype){
case "word":
return "word.document";
case "excel":
return "excel.sheet";
case "ppt":
return "powerpoint.show";
}
return "word.document"
},
defaultparam: function(readonly){
var o = {
"productcaption": this.json.productcaption || this.options.productcaption,
"productkey": this.json.productkey || this.options.productkey,
"makercaption": this.officeconfig.makercaption || this.json.makercaption || this.options.makercaption,
"makerkey": this.officeconfig.makerkey || this.options.makerkey || this.options.makerkey,
"titlebar": "0",
"menubar": "0",
"toolbars": (readonly) ? "0" : "1",
"statusbar": "0",
"isuseutf8url": "1",
"isuseutf8data": "1",
"borderstyle": (readonly) ? "0" : "0",
"isnocopy": "0",
"isresettoolbarsonopen": "1",
"filenew": "0",
"fileopen": "1",
"fileclose": "0",
"filesave": "0",
"fileproperties": "0"
};
return o;
},
loadofficecontorl: function(file){
if (this.node.getsize().y<800) this.node.setstyle("height", "800px");
if (!layout.desktop.offices) layout.desktop.offices = {};
layout.desktop.offices[this.getofficeobjectid()] = this;
if (this.readonly){
this.loadofficeread(file);
}else if (this.json.isreadonly || this.form.json.isreadonly){
this.readonly = true;
this.loadofficeread(file);
}else{
if (this.json.readscript && this.json.readscript.code){
var flag = this.form.macro.exec(this.json.readscript.code, this);
if (flag){
this.readonly = true;
this.loadofficeread(file);
}else{
this.loadofficeedit(file);
}
}else{
this.loadofficeedit(file);
}
}
},
loadofficespacer: function(){
var size = this.node.getsize();
this.officenode = new element("div#officenode", {
"styles": this.form.css.officeareanode
}).inject(this.node);
var y = size.y-40;
this.officenode.setstyle("height", "" y "px");
this.form.app.addevent("uncurrent", function(){
var display = this.officenode.getstyle("display");
this.officenode.store("officedisplay", display);
this.officenode.setstyle("display", "none");
}.bind(this));
this.form.app.addevent("current", function(){
var display = this.officenode.retrieve("officedisplay");
if (display) this.officenode.setstyle("display", display);
if (this.officeocx) this.officeocx.activate(true);
}.bind(this));
this.form.app.addevent("queryclose", function(){
this.fireevent("queryclose");
var id = this.getofficeobjectid();
layout.desktop.offices[id] = null;
delete layout.desktop.offices[id];
}.bind(this));
},
hide: function(){
if (this.officenode.getstyle("display")!="none"){
var display = this.officenode.getstyle("display");
this.officenode.store("officedisplay", display);
this.officenode.setstyle("display", "none");
}
},
show: function(){
if ((layout.desktop.currentapp && layout.desktop.currentapp.appid===this.form.app.appid) || this.form.app.inbrowser){
var display = this.officenode.retrieve("officedisplay");
if (display) this.officenode.setstyle("display", display);
if (this.officeocx) this.officeocx.activate(true);
}
},
iscover: function(node){
},
getformid: function(){
var id = (!this.form.businessdata.workcompleted) ? this.form.businessdata.work.id : this.form.businessdata.workcompleted.id;
return "form" this.json.id id;
},
getfilename: function(){
var ename = "docx";
switch (this.json.officetype){
case "word":
ename = "docx";
break;
case "excel":
ename = "xlsx";
break;
case "ppt":
ename = "pptx";
}
var id = (!this.form.businessdata.workcompleted) ? this.form.businessdata.work.id : this.form.businessdata.workcompleted.id;
return "file" this.json.id id "." ename;
},
getofficeobjectid: function(){
var id = (!this.form.businessdata.workcompleted) ? this.form.businessdata.work.id : this.form.businessdata.workcompleted.id;
return "ntkoocx" this.json.id id;
},
getfileinputname: function(){
var id = (!this.form.businessdata.workcompleted) ? this.form.businessdata.work.id : this.form.businessdata.workcompleted.id;
return "fileinput" this.json.id id;
},
gettempleteurl: function(){
//return "../x_desktop/temp/杭州城管委文件.doc";
if (this.json.template){
var root = "";
var flag = this.json.template.substr(0,1);
if (flag==="/"){
root = this.json.template.substr(1, this.json.template.indexof("/", 1)-1);
}else{
root = this.json.template.substr(0, this.json.template.indexof("/"));
}
if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexof(root.tolowercase())!==-1){
var host = mwf.actions.gethost(root);
return (flag==="/") ? host this.json.template : host "/" this.json.template
}
}
return this.json.template;
},
getfile: function(site){
var file = null;
atts = this.form.businessdata.attachmentlist;
for (var i=0; i
source
",
"container": this.form.app.content,
"isclose": true,
"buttonlist": [
{
"text": mwf.xapplication.process.xform.lp.close,
"action": function(){this.close();}
}
],
"onpostshow": function(){
this.showhistorycontent(dlg, button)
}.bind(this)
});
dlg.show();
}.bind(this));
}
},
showhistorycontent: function(dlg, button){
dlg.content.setstyle("overflow", "auto");
atts = this.form.businessdata.attachmentlist;
var site = this.json.id "history";
for (var i=0; i -1) {
objecthtml = "