o2oa api: x-游戏厅捕鱼达人

source

mwf.xapplication.cms = mwf.xapplication.cms || {};
mwf.xapplication.cms.xform = mwf.xapplication.cms.xform || {};
mwf.require("mwf.widget.common", null, false);
// mwf.require("mwf.xaction.org.express.restactions", null, false);
mwf.xdesktop.requireapp("selector", "package", null, false);
mwf.xdesktop.requireapp("process.xform", "form", null, false);
mwf.require("mwf.widget.o2identity", null, false);
mwf.xdesktop.requireapp("cms.xform", "package", null, false);
/** @class cmsform 内容管理表单。
 * @o2cn 内容管理表单
 * @o2category formcomponents
 * @o2range {cms}
 * @alias cmsform
 * @example
 * //可以在脚本中获取表单
 * //方法1:
 * var form = this.form.getapp().appform; //获取表单
 * //方法2
 * var form = this.target; //在表单本身的事件脚本中获取
 * @hideconstructor
 */
mwf.xapplication.cms.xform.form = mwf.cmsform = new class(
    /** @lends cmsform# */
    {
        implements: [options, events],
        extends: mwf.appform,
        options: {
            "style": "default",
            "readonly": false,
            "csspath": "",
            "autosave": false,
            "saveonclose": null,
            "showattachment": true,
            "moduleevents": [
                /**
                 * 表单加载前触发。表单html已经就位。
                 * @event cmsform#queryload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "queryload",
                /**
                 * 表单加载前触发。数据(businessdata)已经就绪。
                 * @event cmsform#beforeload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforeload",
                /**
                 * 表单的所有组件加载前触发,此时表单的样式和js head已经加载。
                 * @event cmsform#beforemodulesload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforemodulesload",
                /**
                 * 表单加载后触发。
                 * @event cmsform#postload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "postload",
                /**
                 * 表单的所有组件加载后触发。
                 * @event cmsform#aftermodulesload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "aftermodulesload",
                /**
                 * 表单加载后触发。
                 * @event cmsform#afterload
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "afterload",
                /**
                 * 保存前触发。
                 * @event cmsform#beforesave
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforesave",
                /**
                 * 数据已经整理完成,但还未保存到后台时触发。this.event指向整理完成的数据
                 * @event cmsform#postsave
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "postsave",
                /**
                 * 数据保存到后台后触发。
                 * @event cmsform#aftersave
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "aftersave",
                /**
                 * 关闭前触发。
                 * @event cmsform#beforeclose
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforeclose",
                /**
                 * 发布前触发。
                 * @event cmsform#beforepublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforepublish",
                /**
                 * 数据已经整理完成,但还未调用服务发布触发。this.event指向整理完成的数据
                 * @event cmsform#postpublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "postpublish",
                /**
                 * 执行后台服务发布后触发。
                 * @event cmsform#afterpublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "afterpublish",
                /**
                 * 定时发布前触发。
                 * @event cmsform#beforewaitpublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforewaitpublish",
                /**
                 * 数据已经整理完成,但还未调用定时发布服务前触发。this.event指向整理完成的数据
                 * @event cmsform#postwaitpublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "postwaitpublish",
                /**
                 * 执行后台定时发布服务后触发。
                 * @event cmsform#afterpublish
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "afterwaitpublish",
                /**
                 * 删除前触发。
                 * @event cmsform#beforedelete
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "beforedelete",
                /**
                 * 删除后触发。
                 * @event cmsform#afterdelete
                 * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
                 */
                "afterdelete",
                "resize"
            ]
        },
        /**
         * @summary 获取表单的所有数据.
         * @method getdata
         * @memberof cmsform
         * @example
         * var data = this.form.getapp().appform.getdata();
         * @return {object}
         */
        initialize: function (node, data, options) {
            this.setoptions(options);
            /**
             * @summary 表单容器
             * @see https://mootools.net/core/docs/1.6.0/element/element
             * @member {element}
             * @example
             *  //可以在脚本中获取表单容器
             * var formcontainer = this.form.getapp().appform.container;
             */
            this.container = $(node);
            this.container.setstyle("-webkit-user-select", "text");
            this.data = data;
            /**
             * @summary 表单的配置信息,比如表单名称等等.
             * @member {object}
             * @example
             *  //可以在脚本中获取表单配置信息
             * var json = this.form.getapp().appform.json; //表单配置信息
             * var name = json.name; //表单名称
             */
            this.json = data.json;
            this.html = data.html;
            this.path = "../x_component_cms_xform/$form/";
            this.csspath = this.options.csspath || "../x_component_cms_xform/$form/"   this.options.style   "/css.wcss";
            this._loadcss();
            /**
             * @summary 表单中的所有组件数组.
             * @member {array}
             * @example
             * //下面的样例对表单组件进行循环,并且判断是输入类型的组件
             * var modules = this.form.getapp().appform.modules; //获取所有表单组件
             * for( var i=0; i
             * 需要注意的是,在子表单中嵌入不绑定数据的组件(比如div,common,button等等),系统允许重名。
* 在打开表单的时候,系统会根据重名情况,自动在组件的标识后跟上 "_1", "_2"。 * @summary 表单中的所有组件对象. * @member {object} * @example * var moduleall = this.form.getapp().appform.all; //获取组件对象 * var subjectfield = moduleall["subject"] //获取名称为subject的组件 */ this.all = {}; this.forms = {}; //if (!this.personactions) this.personactions = new mwf.xaction.org.express.restactions(); }, load: function (callback) { if (this.app) { if (this.app.formnode) this.app.formnode.setstyles(this.json.styles); if (this.app.addevent) this.app.addevent("resize", function () { this.fireevent("resize"); }.bind(this)) } //if (!this.businessdata.control.allowsave) this.setoptions({"readonly": true}); this.macro = new mwf.cmsmacro.cmsformcontext(this); this.loadlanguage(function(flag) { this.isparselanguage = flag; if (flag && this.formdatatext) { var data = o2.bindjson(this.formdatatext, {"lp": mwf.xapplication.cms.xform.lp.form}); this.data = json.parse(data); this.json = this.data.json; this.html = this.data.html; } var cssclass = ""; if (this.json.css && this.json.css.code) cssclass = this.loadcss(); this.container.set("html", this.html); this.node = this.container.getfirst(); if (cssclass) this.node.addclass(cssclass); this._loadevents(); this.loadrelatedscript(); if (this.fireevent("queryload")) { // mwf.xdesktop.requireapp("cms.xform", "lp." mwf.language, null, false); // this.container.setstyles(this.css.container); this._loadbusinessdata(); this.fireevent("beforeload"); if (this.app) if (this.app.fireevent) this.app.fireevent("beforeload"); this.loadcontent(callback); } }.bind(this)); }, loadlanguage: function(callback){ mwf.xdesktop.requireapp("cms.xform", "lp." mwf.language, null, false); //formdatatext if (this.json.languagetype!=="script" && this.json.languagetype!=="default"){ if (callback) callback(); return true; } var language = mwf.xapplication.cms.xform.lp.form; var languagejson = null; if (this.json.languagetype=="script"){ if (this.json.languagescript && this.json.languagescript.code){ languagejson = this.macro.exec(this.json.languagescript.code, this); } }else if (this.json.languagetype=="default") { var name = "lp-" o2.language; var application = this.businessdata.document.appid; var p1 = new promise(function(resolve, reject){ this.documentaction.getdictroot(name, application, function(d){ resolve( d.data ); }, function(){ reject(""); return true; }); }.bind(this)); var p2 = new promise(function(resolve, reject){ this.documentaction.getscriptbynamev2(name, application, function(d){ if (d.data.text) { resolve( this.macro.exec(d.data.text, this) ); } }.bind(this), function(){ reject(""); return true; }); }.bind(this)); languagejson = promise.any([p1, p2]); } if (languagejson){ if (languagejson.then && o2.typeof(languagejson.then)=="function"){ languagejson.then(function(json) { if (!json.data){ var o = object.clone(json); json.data = o; } mwf.xapplication.cms.xform.lp.form = object.merge(mwf.xapplication.cms.xform.lp.form, json); if (callback) callback(true); }, function(){ if (callback) callback(true); }); }else{ mwf.xapplication.cms.xform.lp.form = object.merge(mwf.xapplication.cms.xform.lp.form, languagejson); if (callback) callback(true); } }else{ if (callback) callback(true); } }, loadrelatedscript: function () { if (this.json.includescripts && this.json.includescripts.length) { var includescripttext = ""; var includedids = []; this.json.includescripts.each(function (s) { if (this.app.relatedscriptmap && this.app.relatedscriptmap[s.id]) { includescripttext = "\n" this.app.relatedscriptmap[s.id].text; includedids.push(s.id); } }.bind(this)); if (includescripttext) this.macro.exec(includescripttext, this); } }, loadcontent: function (callback) { this.subformcount = 0; this.subformloadedcount = 0; this.subformloaded = [this.json.id]; this._loadhtml(); this._loadform(); this.fireevent("beforemodulesload"); if (this.app && this.app.fireevent) this.app.fireevent("beforemodulesload"); this._loadmodules(this.node); if (!this.options.readonly) { if (this.options.autosave) this.autosave(); this.app.addevent("queryclose", function () { if (this.options.saveonclose && this.businessdata.document.docstatus == "draft") this.savedocument(null, true, true); //if (this.autosavetimerid) window.clearinterval(this.autosavetimerid); object.each(this.forms, function (module, id) { if (module.json && module.json.type == "htmleditor" && module.editor) { //if(ckeditor.currentimagedialog)ckeditor.currentimagedialog.destroy(); //ckeditor.currentimagedialog = null; ckeditor.remove(module.editor); delete module.editor } }); }.bind(this)); } // 移动端表单 展现底部工具栏 debugger; if (this.json.mode === "mobile") { var node = document.body.getelement(".o2_form_mobile_actions"); if (node) { node.empty(); this._loadmobileactions(node, callback); } else { if (callback) callback(); } }else { if (callback) callback(); } //this.fireevent("aftermodulesload"); this.fireevent("postload"); //this.fireevent("afterload"); if (this.app && this.app.fireevent) { //this.app.fireevent("aftermodulesload"); this.app.fireevent("postload"); //this.app.fireevent("afterload"); } this.checksubformloaded(true); }, checksubformloaded: function (isallsubformloaded) { if (isallsubformloaded) { this.isallsubformloaded = true; } if (!this.isallsubformloaded) return; if ((!this.subformcount || this.subformcount === this.subformloadedcount)){ //this.container.setstyle("opacity", 1); var moduleaglist = []; this.modules.each( function(module){ if( module.modulevalueag )moduleaglist.push( module.modulevalueag ); if( module.moduleselectag && module.modulevalueag !== module.moduleselectag )moduleaglist.push(module.moduleselectag); }); promise.all( moduleaglist ).then(function () { this.fireevent("aftermodulesload"); if (this.app && this.app.fireevent) this.app.fireevent("aftermodulesload"); this.fireevent("afterload"); if (this.app && this.app.fireevent) this.app.fireevent("afterload"); this.isloaded = true; }.bind(this)); } }, autosave: function () { //this.autosavetimerid = window.setinterval(function(){ // this.savedocument(); //}.bind(this), 300000); }, // 默认的移动端底部工具栏 _loadmobiledefaulttools: function (callback) { if (this.json.defaulttools) { if (callback) callback(); } else { this.json.defaulttools = o2.json.get("../x_component_process_formdesigner/module/actionbar/toolbars.json", function (json) { this.json.defaulttools = json; if (callback) callback(); }.bind(this)); } }, // 移动端生成底部工具栏 _loadmobileactions: function (node, callback) { var tools = []; this._loadmobiledefaulttools(function () { if (this.json.defaulttools) { var jsonstr = json.stringify(this.json.defaulttools); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.cms.xform.lp.form}); this.json.defaulttools = json.parse(jsonstr); this.json.defaulttools.each(function (tool) { var flag = this._checkdefaultmobileactionitem(tool, this.options.readonly); if (flag) tools.push(tool); }.bind(this)); } if (this.json.tools) { var jsonstr = json.stringify(this.json.tools); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.cms.xform.lp.form}); this.json.tools = json.parse(jsonstr); this.json.tools.each(function (tool) { var flag = this._checkcustommobileactionitem(tool, this.options.readonly); if (flag) tools.push(tool); }.bind(this)); } this.mobiletools = tools; //app上用原来的按钮样式 if (window.o2android) { if (tools.length) if (node) this._createmobileactions(node, tools); } else if (window.webkit && window.webkit.messagehandlers && window.webkit.messagehandlers.o2mlog) { if (tools.length) if (node) this._createmobileactions(node, tools); } else { //钉钉 企业微信用新的样式 if (tools.length) if (node) this._createmobileactionsdingdingstyle(node, tools); } if (callback) callback(); }.bind(this)); }, // 检查默认按钮是否显示 _checkdefaultmobileactionitem: function (tool, readonly, nocondition) { var flag = true; if (tool.control) { flag = this.businessdata.control[tool.control] } if (!nocondition) if (tool.condition) { var hideflag = this.macro.exec(tool.condition, this); flag = flag && (!hideflag); } // if (readonly) if (!tool.read) flag = false; if (readonly){ if (!tool.read) flag = false; }else{ if (!tool.edit) flag = false; } // 移动端禁用 关闭和打印 if (tool.id === "action_close" || tool.id === "action_print" || tool.id === "action_popular") { flag = false; } return flag; }, // 检查自定义按钮是否显示 _checkcustommobileactionitem: function (tool, readonly) { var flag = true; if (readonly) { flag = tool.readshow; } else { flag = tool.editshow; } if (flag) { flag = true; if (tool.control) { flag = this.businessdata.control[tool.control] } if (tool.condition) { var hideflag = this.macro.exec(tool.condition, this); flag = !hideflag; } } return flag; }, // 创建默认样式的底部工具栏 _createmobileactions: function (node, tools) { node.show(); var count = tools.length; if (count <= 2) { this.css.html5actionbutton.width = "100%"; if (count == 2) this.css.html5actionbutton.width = "49%"; tools.each(function (tool) { var action = new element("div", { "styles": this.css.html5actionbutton, "text": tool.text }).inject(node); action.store("tool", tool); action.addevent("click", function (e) { var t = e.target.retrieve("tool"); e.setdisable = function () { } if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this)); this._setmobilebottonstyle(action); }.bind(this)); if (count == 2) new element("div", { "styles": this.css.html5actionbuttonsplit }).inject(node.getlast(), "before"); } else { this.css.html5actionbutton.width = "38%" for (var i = 0; i < 2; i ) { tool = tools[i]; var action = new element("div", { "styles": this.css.html5actionbutton, "text": tool.text }).inject(node); action.store("tool", tool); action.addevent("click", function (e) { var t = e.target.retrieve("tool"); e.setdisable = function () { } if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this)); this._setmobilebottonstyle(action); } new element("div", { "styles": this.css.html5actionbuttonsplit }).inject(node.getlast(), "before"); new element("div", { "styles": this.css.html5actionbuttonsplit }).inject(node); this.css.html5actionbutton.width = "23%" var action = new element("div", { "styles": this.css.html5actionbutton, "text": "…" }).inject(node); action.addevent("click", function (e) { this._loadmoremobileactions(tools, 2, node); }.bind(this)); this._setmobilebottonstyle(action); } }, // 更多按钮 _loadmoremobileactions: function (tools, n, node) { document.body.mask({ "id": "cms_toolbar_mask_id", "style": { "background-color": "#cccccc", "opacity": 0.6 }, "hideonclick": true, "onhide": function () { if (this.actionmorearea){ this.actionmorearea.setstyle("display", "none"); } }.bind(this) }); if (this.actionmorearea) { this.actionmorearea.setstyle("display", "block"); } else { var size = document.body.getsize(); this.actionmorearea = new element("div", { "styles": this.css.html5actionotherarea }).inject(document.body); var pl = this.actionmorearea.getstyle("padding-left").toint(); var pr = this.actionmorearea.getstyle("padding-right").toint(); var w = size.x - pl - pr; this.actionmorearea.setstyle("width", "" w "px"); for (var i = n; i < tools.length; i ) { tool = tools[i]; var action = new element("div", { "styles": this.css.html5actionotherbutton, "text": tool.text }).inject(this.actionmorearea); action.store("tool", tool); action.addevent("click", function (e) { //隐藏更多菜单 var mask = document.id("cms_toolbar_mask_id"); mask.destroy(); this.actionmorearea.setstyle("display", "none"); var t = e.target.retrieve("tool"); e.setdisable = function () { } if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this)); this._setmobilebottonstyle(action); } } // actionarea.position({ // relativeto: node, // position: 'topcenter', // edge: 'bottomcenter' // }); }, _setmobilebottonstyle: function (action) { var _self = this; action.addevents({ "mouseover": function (e) { this.setstyles(_self.css.html5actionbutton_over) }, "mouseout": function (e) { this.setstyles(_self.css.html5actionbutton_up) }, "mousedown": function (e) { this.setstyles(_self.css.html5actionbutton_over) }, "mouseup": function (e) { this.setstyles(_self.css.html5actionbutton_up) }, "touchstart": function (e) { this.setstyles(_self.css.html5actionbutton_over) }, "touchcancel": function (e) { this.setstyles(_self.css.html5actionbutton_up) }, "touchend": function (e) { this.setstyles(_self.css.html5actionbutton_up) }, "touchmove": function (e) { this.setstyles(_self.css.html5actionbutton_over) } }); }, // 钉钉企业微信样式的按钮 _createmobileactionsdingdingstyle: function (node, tools) { node.show(); var count = tools.length; if (count <= 2) { //左边 间隔 var dingdingsplitleft = new element("div", { "styles": this.css.html5actionbuttondingdingsplit, "text": " " }).inject(node); var splitsize = dingdingsplitleft.getsize(); var size = document.body.getsize(); var buttonwidth = (size.x - splitsize.x * (count 1) - (count * 2)) / count; tools.each(function (tool) { var actionstyle = this.css.html5actionbuttondingdingnormal; if (tool.id === "action_edit" || tool.id === "action_savedata" || tool.id === "action_savedraftdocument" || tool.id === "action_publishdocument" || tool.id === "action_publishdocumentdelayed") { actionstyle = this.css.html5actionbuttondingdingprimary; } else if (tool.id === "action_delete") { actionstyle = this.css.html5actionbuttondingdingdanger; } actionstyle.width = buttonwidth "px"; var action = new element("div", { "styles": actionstyle, "text": tool.text }).inject(node); action.store("tool", tool); action.addevent("click", function (e) { var clickfun = function () { var t = e.target.retrieve("tool"); e.setdisable = function () { }; if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this); if (tool.text === "继续流转" || tool.id === "action_processwork") { //输入法激活的时候,需要一段时间等待输入法关闭 window.settimeout(clickfun, 100) } else { clickfun(); } }.bind(this)); new element("div", { "styles": this.css.html5actionbuttondingdingsplit, "text": " " }).inject(node); }.bind(this)); } else { //左边 间隔 var dingdingsplitleft = new element("div", { "styles": this.css.html5actionbuttondingdingsplit, "text": " " }).inject(node); var splitsize = dingdingsplitleft.getsize(); var size = document.body.getsize(); var buttonwidth = (size.x - splitsize.x * 4 - 6) / 5; for (var i = 0; i < 3; i ) { tool = tools[i]; var actionstyle = this.css.html5actionbuttondingdingnormal; if (tool.id === "action_edit" || tool.id === "action_savedata" || tool.id === "action_savedraftdocument" || tool.id === "action_publishdocument" || tool.id === "action_publishdocumentdelayed") { actionstyle = this.css.html5actionbuttondingdingprimary; } else if (tool.id === "action_delete") { actionstyle = this.css.html5actionbuttondingdingdanger; } if (i == 2) { this.css.html5actionbuttondingdingmore.width = buttonwidth "px"; var action = new element("div", { "styles": this.css.html5actionbuttondingdingmore, "text": "…" }).inject(node); action.addevent("click", function (e) { this._loadmoremobileactionsdingdingstyle(tools, 2, node); }.bind(this)); } else { actionstyle.width = (buttonwidth * 2) "px"; var action = new element("div", { "styles": actionstyle, "text": tool.text }).inject(node); action.store("tool", tool); action.addevent("click", function (e) { var t = e.target.retrieve("tool"); e.setdisable = function () { } if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this)); } new element("div", { "styles": this.css.html5actionbuttondingdingsplit, "text": " " }).inject(node); } } }, // _loadmoremobileactionsdingdingstyle: function (tools, n, node) { document.body.mask({ "id": "cms_toolbar_mask_id", "style": { "background-color": "#cccccc", "opacity": 0.6 }, "hideonclick": true, "onhide": function () { if (this.actionmorearea){ this.actionmorearea.setstyle("display", "none"); } }.bind(this) }); if (this.actionmorearea) { this.actionmorearea.setstyle("display", "block"); } else { var size = document.body.getsize(); this.actionmorearea = new element("div", { "styles": this.css.html5actionotherarea }).inject(document.body); var pl = this.actionmorearea.getstyle("padding-left").toint(); var pr = this.actionmorearea.getstyle("padding-right").toint(); var w = size.x - pl - pr; this.actionmorearea.setstyle("width", "" w "px"); for (var i = n; i < tools.length; i ) { tool = tools[i]; var actionstyle = this.css.html5actionbuttondingdingnormal; if (tool.id === "action_edit" || tool.id === "action_savedata" || tool.id === "action_savedraftdocument" || tool.id === "action_publishdocument" || tool.id === "action_publishdocumentdelayed") { actionstyle = this.css.html5actionbuttondingdingprimary; } else if (tool.id === "action_delete") { actionstyle = this.css.html5actionbuttondingdingdanger; } actionstyle.width = "100%"; var action = new element("div", { "styles": actionstyle, "text": tool.text }).inject(this.actionmorearea); action.store("tool", tool); action.addevent("click", function (e) { //隐藏更多菜单 var mask = document.id("cms_toolbar_mask_id"); mask.destroy(); this.actionmorearea.setstyle("display", "none"); var t = e.target.retrieve("tool"); e.setdisable = function () { } if (t.actionscript) { this._runcustomaction(t.actionscript); } else { if (this[t.action]) this[t.action](e); } }.bind(this)); } } }, _loadbusinessdata: function () { if (!this.businessdata) { this.businessdata = { "data": {} }; } }, _loadevents: function () { object.each(this.json.events, function (e, key) { if (e.code) { if (this.options.moduleevents.indexof(key) != -1) { this.addevent(key, function (event) { return this.macro.fire(e.code, this, event); }.bind(this)); } else { if (key == "load") { this.addevent("postload", function () { return this.macro.fire(e.code, this); }.bind(this)); } else if (key == "submit") { this.addevent("beforepublish", function () { return this.macro.fire(e.code, this); }.bind(this)); } else { this.node.addevent(key, function (event) { return this.macro.fire(e.code, this, event); }.bind(this)); } } } }.bind(this)); }, _loadmodules: function (dom, beforeloadmodule, replace, callback) { var modulenodes = this._getmodulenodes(dom); var modules = [], jsons = []; modulenodes.each(function (node) { var json = this._getdomjson(node); jsons.push( json ); if (!this.options.showattachment && json && json.type == "attachment") { return; } //移动端去掉操作栏 if (layout.mobile && json && json.type === "actionbar") { return; } var module = this._loadmodule(json, node, beforeloadmodule, replace); this.modules.push(module); modules.push( module ); }.bind(this)); if( callback )callback( modulenodes, jsons, modules ) }, _loadmodule: function (json, node, beforeload, replace) { if (!json) return null; //流程组件返回 if( ( json.type === "log" && json.logtype ) || ["monitor","readlog"].contains(json.type) ){ node.empty(); return; }else if( this.options.useprocessform && json.type === "actionbar" ){ //使用流程表单,组件是操作条 json.type = "processactionbar" } if (!mwf["cms" json.type]) { var moduletype = json.type; if(moduletype === "attachmentdg")moduletype = "attachment"; mwf.xdesktop.requireapp("cms.xform", moduletype, null, false); } var module = new mwf["cms" json.type](node, json, this); if (beforeload) beforeload.apply(module); if (replace || !this.all[json.id]) this.all[json.id] = module; if (module.field) { if (replace || !this.forms[json.id]) this.forms[json.id] = module; } module.readonly = this.options.readonly; module.load(); return module; }, //getdata: function(){ // var data= object.clone(this.businessdata.data); // object.each(this.forms, function(module, id){ // debugger; // if (module.json.section=="yes"){ // data[id] = this.getsectiondata(module, data[id]); // }else{ // data[id] = module.getdata(); // } // }.bind(this)); // // this.businessdata.data = data; // this.macro.environment.setdata(this.businessdata.data); // return data; //}, trim: function (array) { var arr = []; array.each(function (v) { if (v) arr.push(v); }); return arr; }, transportpermissiondata: function (array, t) { var result = []; array.each(function (data) { var dn = typeof(data) === "string" ? data : data.distinguishedname; if (dn) { var flag = dn.substr(dn.length - 1, 1); var type; switch (flag.tolowercase()) { case "i": type = "人员"; //"身份"; break; case "p": type = "人员"; break; case "u": type = "组织"; break; case "g": type = "群组"; break; case "r": type = "角色"; break; default: type = ""; //result.push( data ); } if (type) { var name; if( typeof(data) === "object" && data.name ){ name = data.name; }else if( mwf.name && mwf.name.cn ){ name = mwf.name.cn( dn ); }else{ name = dn.split("@")[0]; } result.push({ permission: t === "author" ? "作者" : "阅读", permissionobjecttype: type, permissionobjectname: name, permissionobjectcode: dn }) } } }); return result; }, getspecialdata: function () { var data = this.businessdata.data; var readers = []; var authors = []; var pictures = []; var cloudpictures = []; var summary = ""; object.each(this.forms, function (module, id) { if (module.json.type == "readerfield" || module.json.type == "reader") { if (module.json.section == "yes") { readers = readers.concat(this.getsectiondata(module, data[id])); } else { readers = readers.concat(module.getdata()); } } if (module.json.type == "authorfield" || module.json.type == "author") { if (module.json.section == "yes") { authors = authors.concat(this.getsectiondata(module, data[id])); } else { authors = authors.concat(module.getdata()); } } if (module.json.type == "imageclipper") { var d = module.getdata(); if (d) pictures.push(d); } if (module.json.type == "htmleditor") { var text = module.gettext(); summary = text.substr(0, 80); cloudpictures = cloudpictures.concat(module.getimageids()); } if (module.json.type == "tinymceeditor") { var text = module.gettext(); summary = text.substr(0, 80); cloudpictures = cloudpictures.concat(module.getimageids()); } }); if (data.processownerlist && typeof(data.processownerlist) == "array") { //如果是流程中发布的 var owner = { personvalue: [] }; data.processownerlist.each(function (p) { owner.personvalue.push({ name: p, type: "person" }); }); readers = readers.concat(owner); } return { readers: this.transportpermissiondata(readers, "reader"), authors: this.transportpermissiondata(authors, "author"), pictures: pictures, summary: summary, cloudpictures: cloudpictures }; }, getdocumentdata: function (formdata) { var data = object.clone(this.businessdata.document); if (formdata.subject) { data.title = formdata.subject; data.subject = formdata.subject; this.businessdata.document.title = formdata.subject; this.businessdata.document.subject = formdata.subject; } if (formdata.objectsecurityclearance) { data.objectsecurityclearance = formdata.objectsecurityclearance; this.businessdata.document.objectsecurityclearance = formdata.objectsecurityclearance; } data.isnewdocument = false; return data; }, saveformdata: function (callback, sync) { var data = this.getdata(); var specialdata = this.getspecialdata(); var documentdata = this.getdocumentdata(data); if( documentdata.docstatus === "waitpublish" ){ documentdata.documentnotify = this.getnoticeoptions(); } documentdata.readerlist = specialdata.readers; documentdata.authorlist = specialdata.authors; documentdata.picturelist = specialdata.pictures; documentdata.summary = specialdata.summary; documentdata.cloudpictures = specialdata.cloudpictures; documentdata.docdata = data; delete documentdata.attachmentlist; if (this.officelist) { this.officelist.each(function (module) { module.save(); }); } this.documentaction.savedocument(documentdata, function () { this.businessdata.data.isnew = false; if (callback && typeof callback === "function") callback(); }.bind(this), null, !sync); }, savedocument: function (callback, sync, silent) { this.fireevent("beforesave"); if (this.businessdata.document.docstatus == "published") { if (!this.formvalidation("publish")) { this.app.content.unmask(); //if (callback) callback(); return false; } } if (!this.formsavevalidation()) { this.app.content.unmask(); if (callback && typeof callback === "function") callback(); return false; } var data = this.getdata(); var specialdata = this.getspecialdata(); var documentdata = this.getdocumentdata(data); if( documentdata.docstatus === "waitpublish" ){ documentdata.documentnotify = this.getnoticeoptions(); } documentdata.readerlist = specialdata.readers; documentdata.authorlist = specialdata.authors; documentdata.picturelist = specialdata.pictures; documentdata.summary = specialdata.summary; documentdata.cloudpictures = specialdata.cloudpictures; documentdata.docdata = data; delete documentdata.attachmentlist; this.fireevent("postsave", [documentdata]); if (this.officelist) { this.officelist.each(function (module) { module.save(); }); } this.documentaction.savedocument(documentdata, function () { //this.documentaction.savedata(function(json){ if(!silent)this.app.notice(mwf.xapplication.cms.xform.lp.datasaved, "success"); this.businessdata.data.isnew = false; this.fireevent("aftersave", [this, documentdata]); if (this.app) if (this.app.fireevent) this.app.fireevent("aftersave",[this, documentdata]); if (callback && typeof callback === "function") callback(); if( !this.json.notreloadwhensave ){ this._reloadreadform(); } //}.bind(this), null, this.businessdata.document.id, data, !sync ); }.bind(this), null, !sync); }, // 重新加载阅读表单 _reloadreadform: function() { if (this.app.inbrowser) { this.fireevent("reloadreadform"); this.modules.each(function (module) { mwf.release(module); }); //mwf.release(this); this.app.node.destroy(); this.app.options.readonly = true; this.app.loadapplication(); } }, closedocument: function () { this.fireevent("beforeclose"); if (this.app) if (this.app.fireevent) this.app.fireevent("beforeclose"); if (this.app) { this.app.close(); } }, printdocument: function (form) { var form = form; if (!form) { form = this.json.id; if (this.json.printform && this.json.printform !== "none") form = this.json.printform; } window.open(o2.filter); }, formvalidation: function (status) { if (this.options.readonly) return true; var flag = true; //flag = this.validation(); object.each(this.forms, function (field, key) { if (field.validationmode)field.validationmode(); if (field.validation && !field.validation(status)) { flag = false; } }.bind(this)); return flag; }, formsavevalidation: function () { if (!this.json.validationsave) return true; if (!this.json.validationsave.code) return true; var flag = this.macro.exec(this.json.validationsave.code, this); if (!flag) flag = mwf.xapplication.cms.xform.lp.notvalidation; if (typeof(flag) === "string") { if (flag !== "true") { this.app.notice(flag, "error"); return false; } } else if (flag.tostring() != "true") { return false; } return true; }, formpublishvalidation: function () { if (!this.json.validationpublish) return true; if (!this.json.validationpublish.code) return true; var flag = this.macro.exec(this.json.validationpublish.code, this); if (!flag) flag = mwf.xapplication.cms.xform.lp.notvalidation; if (typeof(flag) === "string") { if (flag !== "true") { this.app.notice(flag, "error"); return false; } } else if (flag.tostring() != "true") { return false; } return true; }, publishdocumentdelayed: function( callback ){ this.fireevent("beforewaitpublish"); // this.app.content.mask({ // "destroyonhide": true, // "style": this.app.css.masknode // }); if (!this.formvalidation("publish")) { // this.app.content.unmask(); //if (callback) callback(); return false; } if (!this.formpublishvalidation()) { // this.app.content.unmask(); if (callback) callback(); return false; } mwf.xdesktop.requireapp("cms.document", "delaypublishform", null, false); debugger; var form = new mwf.xapplication.cms.document.delaypublishform(this, {}, { publishtime : this.businessdata.document.publishtime || "", onpostok : function( publishtime ){ this._publishdocumentdelayed( publishtime ); }.bind(this) },{ app : this.app, lp : this.app.lp, css : this.app.css, actions : this.app.action }); form.create(); }, _publishdocumentdelayed: function( publishtime ){ var data = this.getdata(); var specialdata = this.getspecialdata(); //this.documentaction.savedata(function(json){ var documentdata = this.getdocumentdata(data); documentdata.publishtime = publishtime; documentdata.docstatus = "waitpublish"; documentdata.documentnotify = this.getnoticeoptions(); documentdata.readerlist = specialdata.readers; documentdata.authorlist = specialdata.authors; documentdata.picturelist = specialdata.pictures; documentdata.summary = specialdata.summary; documentdata.cloudpictures = specialdata.cloudpictures; documentdata.docdata = data; delete documentdata.attachmentlist; //this.documentaction.savedocument(documentdata, function(){ this.fireevent("postwaitpublish", [documentdata]); if (this.app) if (this.app.fireevent) this.app.fireevent("postwaitpublish",[documentdata]); if (this.officelist) { this.officelist.each(function (module) { module.save(); }); } this.documentaction.publishdocumentcomplex(documentdata, function (json) { this.businessdata.data.isnew = false; this.fireevent("afterwaitpublish", [this, json.data]); if (this.app) if (this.app.fireevent) this.app.fireevent("afterwaitpublish",[this, json.data]); // if (callback) callback(); // 传进来不是function if (layout.mobile) { // this.app.content.unmask(); this.closewindowonmobile(); } else { if (this.businessdata.document.title) { this.app.notice(mwf.xapplication.cms.xform.lp.documentdelayedpublished ": “" this.businessdata.document.title "”", "success"); } else { this.app.notice(mwf.xapplication.cms.xform.lp.documentdelayedpublished, "success"); } this.options.saveonclose = false; debugger; if( layout.inbrowser ){ try{ if( window.opener && window.opener.o2refreshcmsview ){ window.opener.o2refreshcmsview(); } }catch (e) {} window.settimeout(function () { this.app.close(); }.bind(this), 1500) }else{ this.app.close(); } } }.bind(this)); }, publishdocument: function (callback, slience) { this.fireevent("beforepublish"); this.app.content.mask({ "destroyonhide": true, "style": this.app.css.masknode }); if (!this.formvalidation("publish")) { this.app.content.unmask(); if (o2.typeof(callback) === "function") callback(); return false; } if (!this.formpublishvalidation()) { this.app.content.unmask(); if (o2.typeof(callback) === "function") callback(); return false; } var data = this.getdata(); var specialdata = this.getspecialdata(); //this.documentaction.savedata(function(json){ var documentdata = this.getdocumentdata(data); documentdata.readerlist = specialdata.readers; documentdata.authorlist = specialdata.authors; documentdata.picturelist = specialdata.pictures; documentdata.summary = specialdata.summary; documentdata.cloudpictures = specialdata.cloudpictures; documentdata.docdata = data; delete documentdata.attachmentlist; //this.documentaction.savedocument(documentdata, function(){ this.fireevent("postpublish", [documentdata]); if (this.app) if (this.app.fireevent) this.app.fireevent("postpublish",[documentdata]); if (this.officelist) { this.officelist.each(function (module) { module.save(); }); } this.documentaction.publishdocumentcomplex(documentdata, function (json) { this.sendnotice(function () { this.businessdata.data.isnew = false; this.fireevent("afterpublish", [this, json.data]); if (this.app) if (this.app.fireevent) this.app.fireevent("afterpublish",[this, json.data]); if (o2.typeof(callback) === "function") callback(json); // 传进来不是function if (layout.mobile) { this.app.content.unmask(); this.closewindowonmobile(); } else { if( slience !== true ){ if (this.businessdata.document.title) { this.app.notice(mwf.xapplication.cms.xform.lp.documentpublished ": “" this.businessdata.document.title "”", "success"); } else { this.app.notice(mwf.xapplication.cms.xform.lp.documentpublished, "success"); } } this.options.saveonclose = false; debugger; if( layout.inbrowser ){ try{ if( window.opener && window.opener.o2refreshcmsview ){ window.opener.o2refreshcmsview(); } }catch (e) {} window.settimeout(function () { this.app.close(); }.bind(this), 1500) }else{ this.app.close(); } } }.bind(this)); }.bind(this)); //}.bind(this)) //}.bind(this), null, this.businessdata.document.id, data); }, getnoticeoptions: function(){ var rangelist = []; var sendoptions; if( this.json.noticetype === "custom" ){ //reader switch ( o2.typeof( this.json.noticespecificlist ) ) { case "array": rangelist = this.json.noticespecificlist; break; case "string": case "object": rangelist.push( this.json.noticespecificlist ); break; } (this.json.noticeformfieldlist || []).each(function (name) { var range = this.all[name.id] ? this.all[name.id].getdata() : null; if( range )rangelist = rangelist.concat( range ); }.bind(this)); if( this.json.noticescript && this.json.noticescript.code ){ range = this.macro.exec(this.json.noticescript.code, this); switch ( o2.typeof( range ) ) { case "array": rangelist = rangelist.concat( range ); break; case "string": case "object": rangelist.push( range ); break; } } rangelist = rangelist.clean().map(function ( range ) { return o2.typeof(range) === "string" ? range : range.distinguishedname }).unique(); sendoptions = { documentid: this.businessdata.document.id, notifypersonlist: rangelist, notifycreateperson: this.json.notifycreateperson !== "no" }; }else{ var readers = []; object.each(this.forms, function (module, id) { if (module.json.type === "readerfield" || module.json.type === "reader") { readers = readers.concat(module.getdata()); } }); rangelist = readers.clean().map(function ( range ) { return o2.typeof(range) === "string" ? range : range.distinguishedname }).unique(); if( rangelist.length === 0 ){ if( this.json.blanktoallnotify !== "no" ){ //通知所有人 sendoptions = { documentid: this.businessdata.document.id, notifybydocumentreadperson: true, notifycreateperson: this.json.notifycreateperson !== "no" }; } }else{ sendoptions = { documentid: this.businessdata.document.id, notifypersonlist: rangelist, notifybydocumentreadperson: true, notifycreateperson: this.json.notifycreateperson !== "no" }; } } if( !sendoptions && this.json.notifycreateperson !== "no" ){ sendoptions = { documentid: this.businessdata.document.id, notifybydocumentreadperson: false, notifycreateperson: true }; } return sendoptions; }, sendnotice: function( callback ){ var sendoptions = this.getnoticeoptions(); if( sendoptions && o2.actions.load("x_cms_assemble_control").documentaction.publishnotify ) { o2.actions.load("x_cms_assemble_control").documentaction.publishnotify(this.businessdata.document.id, sendoptions, function () { if (callback) callback( sendoptions ); }, function () { if (callback) callback( sendoptions ); }) }else{ if(callback)callback( sendoptions ); } }, deletedocumentformobile: function () { if (layout.mobile) { this.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); this.fireevent("beforedelete"); if (this.app && this.app.fireevent) this.app.fireevent("beforedelete"); this.documentaction.removedocument(this.businessdata.document.id, function (json) { this.fireevent("afterdelete"); if (this.app && this.app.fireevent) this.app.fireevent("afterdelete"); this.app.notice(mwf.xapplication.cms.xform.lp.documentdelete ": “" this.businessdata.document.title "”", "success"); this.options.autosave = false; this.options.saveonclose = false; this.fireevent("postdelete"); this.closewindowonmobile(); }.bind(this)); } }, /** * @summary 弹出删除文档确认框. * @method deletedocument * @memberof cmsform * @example * this.form.getapp().appform.deletedocument(); */ deletedocument: function () { var _self = this; var p = mwf.getcenterposition(this.app.content, 380, 150); var event = { "event": { "x": p.x, "y": p.y - 200, "clientx": p.x, "clienty": p.y - 200 } }; debugger; this.app.confirm("infor", event, mwf.xapplication.cms.xform.lp.deletedocumenttitle, mwf.xapplication.cms.xform.lp.deletedocumenttext, 380, 120, function () { if (layout.mobile) { _self.deletedocumentformobile(); } else { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); _self.fireevent("beforedelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforedelete"); _self.documentaction.removedocument(_self.businessdata.document.id, function (json) { debugger; _self.fireevent("afterdelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterdelete"); _self.app.notice(mwf.xapplication.cms.xform.lp.documentdelete ": “" _self.businessdata.document.title "”", "success"); _self.options.autosave = false; _self.options.saveonclose = false; _self.fireevent("postdelete"); _self.app.close(); this.close(); }.bind(this)); } //this.close(); }, function () { this.close(); }); }, /** * @summary 编辑文档. * @method editdocument * @memberof cmsform * @example * this.form.getapp().appform.editdocument(); */ editdocument: function () { this.fireevent("editdocument"); if (this.app.inbrowser) { this.modules.each(function (module) { mwf.release(module); }); //mwf.release(this); this.app.node.destroy(); this.app.options.readonly = false; this.app.loadapplication(); } else { var options = { "documentid": this.businessdata.document.id, "readonly": false }; //this.explorer.app.options.application.allowcontrol}; debugger; if (this.app.options.postpublish)options.postpublish = this.app.options.postpublish; if (this.app.options.afterpublish)options.afterpublish = this.app.options.afterpublish; if (this.app.options.aftersave)options.aftersave = this.app.options.aftersave; if (this.app.options.beforeclose)options.beforeclose = this.app.options.beforeclose; if (this.app.options.postdelete)options.postdelete = this.app.options.postdelete; if (this.app.options.formeditid) options.formeditid = this.app.options.formeditid; this.app.desktop.openapplication(null, "cms.document", options); this.app.close(); } }, //2019-11-29 移动端 开启编辑模式 /** * @summary 移动端开启编辑模式. * @method editdocumentformobile * @memberof cmsform * @example * this.form.getapp().appform.editdocumentformobile(); */ editdocumentformobile: function () { if (layout.mobile) { this.app.options.readonly = false; this.app.loaddocument(this.app.options); } }, /** * @summary 弹出设置热点的界面. * @method setpopulardocument * @memberof cmsform * @example * this.form.getapp().appform.setpopulardocument(); */ setpopulardocument: function () { this.app.setpopulardocument(); }, // printwork: function (app, form) { // var application = app || this.businessdata.work.application; // var form = form; // if (!form) { // form = this.json.id; // if (this.json.printform) form = this.json.printform; // } // window.open(o2.filter); // }, openwindow: function (form, app) { var form = form; if (!form) { form = this.json.id; } if (this.businessdata.document) { //var application = app; //window.open("../x_desktop/printwork.html?workcompletedid=" this.businessdata.workcompleted.id "&app=" application "&form=" form); } }, /** * @summary 将新上传的附件在指定的附件组件中展现. * @method uploadedattachment * @memberof cmsform * @param {string} site - 附件组件的标识 * @param {string} id - 新上传的附件id * @example * this.form.getapp().appform.uploadedattachment(site, id); */ uploadedattachment: function (site, id) { this.documentaction.getattachment(id, this.businessdata.document.id, function (json) { var flag = this.businessdata.attachmentlist.some(function (attdata) { return json.data.id === attdata.id; }.bind(this)); if( !flag ){ this.businessdata.attachmentlist.push(json.data); } var att = this.all[site]; if (att) { if (json.data) att.attachmentcontroller.addattachment(json.data); att.attachmentcontroller.checkactions(); att.fireevent("upload", [json.data]); } }.bind(this)); }, replacedattachment: function (site, id) { this.documentaction.getattachment(id, this.businessdata.document.id, function (json) { var att = this.all[site]; if (att) { var attachmentcontroller = att.attachmentcontroller; var attachment = null; for (var i = 0; i < attachmentcontroller.attachments.length; i ) { if (attachmentcontroller.attachments[i].data.id === id) { attachment = attachmentcontroller.attachments[i]; break; } } attachment.data = json.data; attachment.reload(); attachmentcontroller.checkactions(); } }.bind(this)) }, uploadedattachmentdatagrid: function (site, id, moduleid) { this.documentaction.getattachment(id, this.businessdata.document.id, function (json) { var flag = this.businessdata.attachmentlist.some(function (attdata) { return json.data.id === attdata.id; }.bind(this)); if( !flag ){ this.businessdata.attachmentlist.push(json.data); } var att = this.all[moduleid]; if (att) { if (json.data) att.attachmentcontroller.addattachment(json.data); att.setattachmentbusinessdata(); att.attachmentcontroller.checkactions(); att.fireevent("upload", [json.data]); att.fireevent("change", [json.data]); } }.bind(this)); }, replacedattachmentdatagrid: function (site, id, moduleid) { this.documentaction.getattachment(id, this.businessdata.document.id, function (json) { var att = this.all[moduleid]; if (att) { var attachmentcontroller = att.attachmentcontroller; var attachment = null; for (var i = 0; i < attachmentcontroller.attachments.length; i ) { if (attachmentcontroller.attachments[i].data.id === id) { attachment = attachmentcontroller.attachments[i]; break; } } attachment.data = json.data; att.setattachmentbusinessdata(); attachment.reload(); attachmentcontroller.checkactions(); att.fireevent("change", [json.data]); } }.bind(this)) }, /** * @summary 弹出文档置顶对话框,操作后使当前文档在列式服务中排在前面. * @method settop * @memberof cmsform * @example * this.form.getapp().appform.settop(); */ settop: function () { var _self = this; var p = mwf.getcenterposition(this.app.content, 380, 150); var event = { "event": { "x": p.x, "y": p.y - 200, "clientx": p.x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.cms.xform.lp.settoptitle, mwf.xapplication.cms.xform.lp.settoptext, 380, 120, function () { o2.actions.load("x_cms_assemble_control").documentaction.persist_top(_self.businessdata.document.id, function () { _self.app.notice(mwf.xapplication.cms.xform.lp.settopsuccess, "success"); _self.app.reload(); this.close(); }.bind(this)) //this.close(); }, function () { this.close(); }); }, /** * @summary 弹出文档取消置顶对话框. * @method canceltop * @memberof cmsform * @example * this.form.getapp().appform.canceltop(); */ canceltop: function () { var _self = this; var p = mwf.getcenterposition(this.app.content, 380, 150); var event = { "event": { "x": p.x, "y": p.y - 200, "clientx": p.x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.cms.xform.lp.canceltoptitle, mwf.xapplication.cms.xform.lp.canceltoptext, 380, 120, function () { o2.actions.load("x_cms_assemble_control").documentaction.persist_untop(_self.businessdata.document.id, function () { _self.app.notice(mwf.xapplication.cms.xform.lp.canceltopsuccess, "success"); _self.app.reload(); this.close(); }.bind(this)) //this.close(); }, function () { this.close(); }); }, /** * @summary 一键下载表单和附件. * @method downloadall * @memberof cmsform * @example * this.form.getapp().appform.downloadall(); */ downloadall: function () { o2.actions.load("x_cms_assemble_control").fileinfoaction.uploadworkinfo(this.businessdata.document.id, "pdf", { "workhtml": encodeuricomponent(this.app.content.get("html")), "pagewidth": 1000 }, function (json) { var htmlformid = json.data.id; htmlformid = htmlformid.replace("#", "#"); var url = "/x_cms_assemble_control/jaxrs/fileinfo/batch/download/doc/" this.businessdata.document.id "/site/(0)"; url = o2.filter url); var downloadurl = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; //var xtoken = cookie.read(o2.tokenname); downloadurl = "&" o2.tokenname "=" xtoken; } window.open(downloadurl); }.bind(this)); }, /** * 移动端处理关闭 */ closewindowonmobile: function () { if (window.o2android && window.o2android.postmessage) { var body = { type: "closedocumentwindow", data: {} }; window.o2android.postmessage(json.stringify(body)); } else if (window.o2android && window.o2android.closedocumentwindow) { window.o2android.closedocumentwindow(""); } else if (window.webkit && window.webkit.messagehandlers && window.webkit.messagehandlers.closedocumentwindow) { window.webkit.messagehandlers.closedocumentwindow.postmessage(""); } else if (window.wx && window.__wxjs_environment === 'miniprogram') { //微信小程序 关闭页面 wx.miniprogram.navigateback({ delta: 1 }); } else if (window.uni && window.uni.navigateback) { // uniapp 关闭页面 window.uni.navigateback(); } 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(); } else { var uri = new uri(window.location.href); var redirectlink = uri.getdata("redirectlink"); if (redirectlink) { history.replacestate(null, "work", redirectlink); redirectlink.touri().go(); } else { this.app.close(); } // var len = window.history.length; // if (len > 1) { // history.back(); // } else { // // window.location = o2.filter; // history.replacestate(null, "work", o2.filter); // o2.filter.touri().go(); // } } }, // //列式流程log // listworklog: function ( callback ) { // if( !this.businessdata.data.$work || !this.businessdata.data.$work.job ){ // callback([]); // return // } // // if( this.workloglist ){ // callback(this.workloglist); // return; // } // // //只获取一次。把callback存起来,等异步调用完成后一次性执行callback // if( !this.worklogcallbacklist )this.worklogcallbacklist = []; // promise.resolve( o2.actions.load("x_processplatform_assemble_surface").worklogaction.listwithjob( this.businessdata.data.$work.job )).then(function(json){ // this.workloglist = json.data; // debugger; // while( this.worklogcallbacklist.length ){ // this.worklogcallbacklist.shift()( this.workloglist ); // } // }.bind(this)); // this.worklogcallbacklist.push( callback ); // }, // //列式流程record // listworkrecord: function ( callback ) { // if( !this.businessdata.data.$work || !this.businessdata.data.$work.job ){ // callback([]); // return // } // // if( this.workrecordlist ){ // callback(this.workrecordlist); // return; // } // // //只获取一次。把callback存起来,等异步调用完成后一次性执行callback // if( !this.workrecordcallbacklist )this.workrecordcallbacklist = []; // promise.resolve( o2.actions.load("x_processplatform_assemble_surface").recordaction.listwithjob( this.businessdata.data.$work.job )).then(function(json){ // this.workrecordlist = json.data; // while( this.workrecordcallbacklist.length ){ // this.workrecordcallbacklist.shift()( this.workrecordlist ); // } // }.bind(this)); // this.workrecordcallbacklist.push( callback ); // } });
网站地图