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

source

//mwf.require(["mwf.widget.common", "mwf.widget.identity", "mwf.widget.o2identity"], null, false);
mwf.require(["mwf.widget.common", "mwf.widget.o2identity"], null, false);
mwf.xapplication.process = mwf.xapplication.process || {};
mwf.xapplication.process.xform = mwf.xapplication.process.xform || {};
mwf.xdesktop.requireapp("process.xform", "lp."   mwf.language, null, false);
//mwf.xdesktop.requireapp("process.xform", "package", null, false);
/** @class form 流程表单。
 * @o2cn 流程表单
 * @o2category formcomponents
 * @o2range {process}
 * @example
 * //可以在脚本中获取表单
 * //方法1:
 * var form = this.form.getapp().appform; //获取表单
 * //方法2
 * var form = this.target; //在表单本身的事件脚本中获取
 * @hideconstructor
 */
mwf.xapplication.process.xform.form = mwf.appform = new class(
    /** @lends mwf.xapplication.process.xform.form# */
{
    implements: [options, events],
    extends: mwf.widget.common,
    options: {
        "style": "default",
        "readonly": false,
        "csspath": "",
        "macro": "formcontext",
        "parameters": null,
        "moduleevents": [
            /**
             * 表单加载前触发。数据(businessdata)、预加载脚本和表单html已经就位。
             * @event mwf.xapplication.process.xform.form#queryload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "queryload",
            /**
             * 表单加载前触发。如果是流程表单,已提示抢办锁定。
             * @event mwf.xapplication.process.xform.form#beforeload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeload",
            /**
             * 表单的所有组件加载前触发,此时表单的样式和js head已经加载。
             * @event mwf.xapplication.process.xform.form#beforemodulesload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforemodulesload",
            /**
             * 表单加载后触发。主表单的组件加载完成,但不保证子表单、子页面、部件加载完成。
             * @event mwf.xapplication.process.xform.form#postload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "postload",
            /**
             * 表单的所有组件加载后触发。表单包含有子表单、子页面、部件时,此事件会在这些组件加载后触发。
             * 如果包含异步加载的组件,如异步加载的下拉框选项等,会在这些组件加载完成后执行。
             * @event mwf.xapplication.process.xform.form#aftermodulesload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "aftermodulesload",
            /**
             * 表单加载后触发。表单包含有子表单、子页面、部件时,此事件会在这些组件加载后触发。
             * @event mwf.xapplication.process.xform.form#afterload
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterload",
            /**
             * 保存前触发。如果是流程表单,流转前也会触发本事件。
             * @event mwf.xapplication.process.xform.form#beforesave
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforesave",
            /**
             * 保存后触发。如果是流程表单,流转后也会触发本事件。
             * @event mwf.xapplication.process.xform.form#aftersave
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "aftersave",
            /**
             * 关闭前触发。
             * @event mwf.xapplication.process.xform.form#beforeclose
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeclose",
            /**
             * 弹出提交界面前触发。
             * @event mwf.xapplication.process.xform.form#beforeprocesswork
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeprocesswork",
            /**
             * 流转前触发。
             * @event mwf.xapplication.process.xform.form#beforeprocess
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeprocess",
            /**
             * 流转后触发。
             * @event mwf.xapplication.process.xform.form#afterprocess
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterprocess",
            /**
             * 加载弹出的提交界面以后执行,this.event指向弹出界面对象。
             * @event mwf.xapplication.process.xform.form#afterloadprocessor
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterloadprocessor",
            /**
             * 重置处理人前触发。
             * @event mwf.xapplication.process.xform.form#beforereset
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforereset",
            /**
             * 重置处理人后触发。
             * @event mwf.xapplication.process.xform.form#afterreset
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterreset",
            /**
             * 撤回前触发。
             * @event mwf.xapplication.process.xform.form#beforeretract
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeretract",
            /**
             * 撤回后触发。
             * @event mwf.xapplication.process.xform.form#afterretract
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterretract",
            /**
             * 调度前触发。
             * @event mwf.xapplication.process.xform.form#beforereroute
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforereroute",
            /**
             * 调度后触发。
             * @event mwf.xapplication.process.xform.form#afterreroute
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterreroute",
            /**
             * 删除工作前触发。
             * @event mwf.xapplication.process.xform.form#beforedelete
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforedelete",
            /**
             * 删除工作后触发。
             * @event mwf.xapplication.process.xform.form#afterdelete
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterdelete",
            "resize",
            /**
             * 已阅前触发。
             * @event mwf.xapplication.process.xform.form#beforereaded
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforereaded",
            /**
             * 已阅后触发。
             * @event mwf.xapplication.process.xform.form#afterreaded
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afterreaded",
            /**
             * 加签前触发。
             * @event mwf.xapplication.process.xform.form#beforeaddtask
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "beforeaddtask",
            /**
             * 加签后触发。
             * @event mwf.xapplication.process.xform.form#afteraddtask
             * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
             */
            "afteraddtask"
        ]
    },
    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");
        if (browser.firefox) this.container.setstyle("opacity", 0);
        this.data = data;
        //var jsondata = json.parse(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_process_xform/$form/";
        this.csspath = this.options.csspath || "../x_component_process_xform/$form/"   this.options.style   "/css.wcss";
        this._loadcss();
        this.sectionlistobj = {};
        /**
         * @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.allforname = {}; this.forms = {}; //if (!this.personactions) this.personactions = new mwf.xaction.org.express.restactions(); }, parsecss: function (css) { var rex = /(url\(.*\))/g; var match; while ((match = rex.exec(css)) !== null) { var pic = match[0]; var len = pic.length; var s = pic.substring(pic.length - 2, pic.length - 1); var n0 = (s === "'" || s === "\"") ? 5 : 4; var n1 = (s === "'" || s === "\"") ? 2 : 1; pic = pic.substring(n0, pic.length - n1); if ((pic.indexof("x_processplatform_assemble_surface") != -1 || pic.indexof("x_portal_assemble_surface") != -1)) { var host1 = mwf.actions.gethost("x_processplatform_assemble_surface"); var host2 = mwf.actions.gethost("x_portal_assemble_surface"); if (pic.indexof("/x_processplatform_assemble_surface") !== -1) { pic = pic.replace("/x_processplatform_assemble_surface", host1 "/x_processplatform_assemble_surface"); } else if (pic.indexof("x_processplatform_assemble_surface") !== -1) { pic = pic.replace("x_processplatform_assemble_surface", host1 "/x_processplatform_assemble_surface"); } if (pic.indexof("/x_portal_assemble_surface") !== -1) { pic = pic.replace("/x_portal_assemble_surface", host2 "/x_portal_assemble_surface"); } else if (pic.indexof("x_portal_assemble_surface") !== -1) { pic = pic.replace("x_portal_assemble_surface", host2 "/x_portal_assemble_surface"); } pic = o2.filter; } pic = ""; var len2 = pic.length; css = css.substring(0, match.index) pic css.substring(rex.lastindex, css.length); rex.lastindex = rex.lastindex (len2 - len); } return css; }, loadcss: function () { var csstext = (this.json.css) ? this.json.css.code : ""; //var head = (document.head || document.getelementsbytagname("head")[0] || document.documentelement); var stylenode = $("style" this.json.id); //if (stylenode) stylenode.destroy(); if (!stylenode && csstext) { //删除注释 csstext = csstext.replace(/\/\*[\s\s]*?\*\/\n|([^:]|^)\/\/.*\n$/g, '').replace(/\\n/, ''); csstext = this.parsecss(csstext); var rex = new regexp("(. )(?=\\{)", "g"); var match; var id = this.json.id.replace(/\-/g, ""); var prefix = ".css" id " "; while ((match = rex.exec(csstext)) !== null) { var rulesstr = match[0]; var startwith = rulesstr.substring(0, 1); if (startwith === "@" || startwith === ":" || rulesstr.indexof("%") !== -1) { }else if (rulesstr.trim()==='from' || rulesstr.trim()==='to'){ } else { if (rulesstr.indexof(",") != -1) { //var rules = rulesstr.split(/\s*,\s*/g); var rules = rulesstr.split(/,/g); rules = rules.map(function (r) { return prefix r; }); var rule = rules.join(","); csstext = csstext.substring(0, match.index) rule csstext.substring(rex.lastindex, csstext.length); rex.lastindex = rex.lastindex (prefix.length * rules.length); } else { var rule = prefix match[0]; csstext = csstext.substring(0, match.index) rule csstext.substring(rex.lastindex, csstext.length); rex.lastindex = rex.lastindex prefix.length; } } } stylenode = document.createelement("style"); stylenode.setattribute("type", "text/css"); stylenode.id = "style" this.json.id; stylenode.inject(document.head, "before"); if (stylenode.stylesheet) { var setfunc = function () { stylenode.stylesheet.csstext = csstext; }; if (stylenode.stylesheet.disabled) { settimeout(setfunc, 10); } else { setfunc(); } } else { var csstextnode = document.createtextnode(csstext); stylenode.appendchild(csstextnode); } return "css" id; } return ""; }, keylock: function (async) { var lockdata = null; var key = this.businessdata.work.id "-" this.businessdata.work.activitytoken; o2.actions.load("x_processplatform_assemble_surface").keylockaction.lock({ "key": key }, function (json) { flagdata = json.data; if (async && flagdata.success) this.keylocktimeoutid = window.settimeout(function () { this.keylock(true) }.bind(this), 90000); if (async && !flagdata.success) this.app.reload(); }.bind(this), null, !!async); return flagdata; }, checklock: function () { if (this.businessdata.control.allowprocessing && this.businessdata.activity && this.businessdata.activity.manualmode == "grab") { this.app.addevent("queryclose", function () { if (this.keylocktimeoutid) window.cleartimeout(this.keylocktimeoutid); }.bind(this)); var lockdata = this.keylock(); if (lockdata.success) { this.keylock(true); } else { this.businessdata.control.allowflow = false; this.businessdata.control.allowprocessing = false; this.businessdata.control.allowsave = false; this.businessdata.control.allowreset = false; this.businessdata.control.allowreroute = false; this.businessdata.control.allowdelete = false; this.businessdata.control.allowaddsplit = false; this.businessdata.control.allowretract = false; this.businessdata.control.allowrollback = false; this.lockdataperson = lockdata.person; // var text = mwf.xapplication.process.xform.lp.keylockinfor; // text = text.replace("{name}", o2.name.cn(lockdata.person)); // var title = mwf.xapplication.process.xform.lp.keylocktitle; // this.app.alert("info", "center", title, text, 400, 160); // o2.dl.open({ // "title": title, // "text": text, // "width": 400 // }) } } }, load: function (callback) { this.loadmacro(function () { debugger this.loadlanguage(function(flag){ this.isparselanguage = flag; if (flag && this.formdatatext){ var data = o2.bindjson(this.formdatatext, {"lp": mwf.xapplication.process.xform.lp.form}); this.data = json.parse(data); this.json = this.data.json; this.html = this.data.html; } this.checklock(); this.loadextendstyle(function () { 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)); this.app.addevent("queryclose", function () { this.beforeclosework(); }.bind(this)); } } if (!this.businessdata.control.allowsave) this.setoptions({ "readonly": true }); var cssclass = ""; if (this.json.css && this.json.css.code) cssclass = this.loadcss(); //this.container.setstyle("opacity", 0); this.container.set("html", this.html); this.node = this.container.getfirst(); if (cssclass) this.node.addclass(cssclass); this._loadevents(); this.loadrelatedscript(); //this.loadresource( function () { // this.loaddictionarylist(function () { this.fireevent("queryload"); if (this.event_resolve) { this.event_resolve(function () { this.loadform(callback) }.bind(this)); } else { this.loadform(callback); } }.bind(this)); // }.bind(this)); //}.bind(this)); }.bind(this)); }.bind(this)); }, loadlanguage: function(callback){ if (this.json.languagetype!=="script" && this.json.languagetype!=="default" && this.json.languagetype!=="lib" && this.json.languagetype!=="dict"){ if (callback) callback(); return true; } var language = mwf.xapplication.process.xform.lp.form; var languagejson = null; var name = "lp-" o2.language; var app; if (this.options.macro==="pagecontext") { app = (this.app.portal && this.app.portal.id) ? this.app.portal.id : this.json.application; }else{ app = (this.businessdata.work || this.businessdata.workcompleted).application; } 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 p1, p2; if (this.options.macro==="pagecontext"){ var portal = (this.app.portal && this.app.portal.id) ? this.app.portal.id : this.json.application; p1 = this.workaction.getdictroot(name, portal, function(d){ return d.data; }, function(){ return true; }); p2 = new promise(function(resolve, reject){ this.workaction.getscriptbynamev2(portal, name, function(d){ if (d.data.text) { resolve(this.macro.exec(d.data.text, this)); } }.bind(this), function(){reject("");}); }.bind(this)); languagejson = promise.any([p1, p2]); }else{ var application = (this.businessdata.work || this.businessdata.workcompleted).application; p1 = this.workaction.getdictroot(name, application, function(d){ return d.data; }, function(){ return true; }); p2 = new promise(function(resolve, reject){ this.workaction.getscriptbynamev2(name, application, function(d){ if (d.data.text) { resolve(this.macro.exec(d.data.text, this)); } }.bind(this), function(){reject("");}); }.bind(this)); languagejson = promise.any([p1, p2]); } }else if (this.json.languagetype=="lib") { var par1 = (this.options.macro==="pagecontext") ? app : name; var par2 = (this.options.macro==="pagecontext") ? name : app; languagejson = new promise(function(resolve, reject){ this.workaction.getscriptbynamev2(par1, par2, function(d){ if (d.data.text) { resolve(this.macro.exec(d.data.text, this)); } }.bind(this), function(){reject("");}); }.bind(this)); }else if (this.json.languagetype=="dict") { languagejson = this.workaction.getdictroot(name, app, function(d){ return d.data; }, function(){ return true; }); } 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.process.xform.lp.form = object.merge(mwf.xapplication.process.xform.lp.form, json); if (callback) callback(true); }, function(){ if (callback) callback(true); }) }else{ mwf.xapplication.process.xform.lp.form = object.merge(mwf.xapplication.process.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); } }, loadform: function (callback) { if (this.lockdataperson) { var text = mwf.xapplication.process.xform.lp.keylockinfor; text = text.replace("{name}", o2.name.cn(this.lockdataperson)); var title = mwf.xapplication.process.xform.lp.keylocktitle; this.app.alert("info", "center", title, text, 400, 160); } if (this.app) if (this.app.fireevent) this.app.fireevent("queryload"); this._loadbusinessdata(); this.fireevent("beforeload"); if (this.app) if (this.app.fireevent) this.app.fireevent("beforeload"); this.loadcontent(callback); }, loadextendstyle: function (callback) { if (!this.json.styleconfig || !this.json.styleconfig.extendfile) { if (callback) callback(); return; } if (this.json["$version"] == "5.2") { if (callback) callback(); return; } var stylesurl = "../x_component_process_formdesigner/module/form/skin/" this.json.styleconfig.extendfile; mwf.getjson(stylesurl, { "onsuccess": function (responsejson) { if (responsejson && responsejson.form) { this.json = object.merge(this.json, responsejson.form); } if (callback) callback(); }.bind(this), "onrequestfailure": function () { if (callback) callback(); }.bind(this), "onerror": function () { if (callback) callback(); }.bind(this) } ); }, loadmacro: function (callback) { //if (!mwf.macro[this.options.macro || "formcontext"]){ mwf.require("mwf.xscript.macro", function () { this.macro = new mwf.macro[this.options.macro || "formcontext"](this); if (callback) callback(); }.bind(this)); // }else{ // this.macro = new mwf.macro[this.options.macro || "formcontext"](this); // if (callback) callback(); // } }, loadcontent: function (callback) { this.subformcount = 0; this.subformloadedcount = 0; this.subformloaded = [this.json.id]; this.subpagecount = 0; this.subpageloadedcount = 0; this.subpageloaded = []; this.widgetcount = 0; this.widgetloadedcount = 0; this.widgetloaded = []; this._loadhtml(); this._loadform(); this.fireevent("beforemodulesload"); if (this.app && this.app.fireevent) this.app.fireevent("beforemodulesload"); this._loadmodules(this.node); if (browser.firefox) this.container.setstyle("opacity", 1); 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(); //console.log("没有找到移动端底部操作栏!") } } else { if (callback) callback(); } this.fireevent("postload"); if (this.app && this.app.fireevent) this.app.fireevent("postload"); this.checksubformloaded(true); }, checksubformloaded: function (isallsubformloaded) { if (isallsubformloaded) { this.isallsubformloaded = true; } if (!this.isallsubformloaded) return; //console.log( "checksubformloaded this.subformcount=" this.subformcount " this.subformloadedcount=" this.subformloadedcount ); if ((!this.subformcount || this.subformcount === this.subformloadedcount) && (!this.subpagecount || this.subpagecount === this.subpageloadedcount) && (!this.widgetcount || this.widgetcount === this.widgetloadedcount) ) { //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)); } }, _loadmobiledefaulttools: function (callback) { if (this.json.multitools) { if (callback) callback(); }else if (this.json.defaulttools) { if (callback) callback(); } else { this.json.defaulttools = o2.json.get("../x_component_process_formdesigner/module/form/toolbars.json", function (json) { this.json.defaulttools = json; if (callback) callback(); }.bind(this)); } }, _loadmobileactions: function (node, callback) { var tools = []; this._loadmobiledefaulttools(function () { var jsonstr; if( this.json.multitools ){ jsonstr = json.stringify(this.json.multitools); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.process.xform.lp.form}); this.multitoolsjson = json.parse(jsonstr); var json = array.clone(this.multitoolsjson); json.each(function (tool) { var flag; if( tool.system ){ flag = this._checkdefaultmobileactionitem(tool, this.options.readonly); }else{ flag = this._checkcustommobileactionitem(tool, this.options.readonly) } if (flag) tools.push(tool); }.bind(this)); }else{ if (this.json.defaulttools) { jsonstr = json.stringify(this.json.defaulttools); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.process.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) { jsonstr = json.stringify(this.json.tools); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.process.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; if (tools.length <= 0) { node.hide(); } else { //app上用原来的按钮样式 if (window.o2android) { if (node) this._createmobileactions(node, tools); } else if (window.webkit && window.webkit.messagehandlers && window.webkit.messagehandlers.o2mlog) { if (node) this._createmobileactions(node, tools); } else { //钉钉 企业微信用新的样式 if (node) this._createmobileactionsdingdingstyle(node, tools); } } if (callback) callback(); }.bind(this)); }, // 修改成钉钉 button _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; var classbg = ""; debugger; if (tool.action === "processwork" || tool.action === "flowwork" || tool.action === "retractwork" || tool.id === "action_processwork" || tool.id === "action_retract" || tool.id === "action_flowwork") { actionstyle = this.css.html5actionbuttondingdingprimary; classbg = "maincolor_bg maincolor_border"; } else if (tool.action === "deletework" || tool.id === "action_delete") { actionstyle = this.css.html5actionbuttondingdingdanger; } actionstyle.width = buttonwidth "px"; var action = new element("div", { "styles": actionstyle, "class": classbg, "text": tool.text }).inject(node); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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.action === "processwork" || tool.id === "action_processwork" || tool.action === "flowwork" || tool.id === "action_flowwork") { //输入法激活的时候,需要一段时间等待输入法关闭 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; var classbg = ""; if (tool.action === "processwork" || tool.action === "flowwork" || tool.action === "retractwork") { actionstyle = this.css.html5actionbuttondingdingprimary; classbg = "maincolor_bg maincolor_border"; } else if (tool.action === "deletework") { 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, "class": classbg, "text": tool.text }).inject(node); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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({ "style": { "background-color": "#cccccc", "opacity": 0.6 }, "hideonclick": true, "onhide": function () { 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.action === "processwork" || tool.action === "flowwork" || tool.action === "retractwork") { actionstyle = this.css.html5actionbuttondingdingprimary; } else if (tool.action === "deletework") { actionstyle = this.css.html5actionbuttondingdingdanger; } actionstyle.width = "100%"; var action = new element("div", { "styles": actionstyle, "text": tool.text }).inject(this.actionmorearea); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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); } // 关闭 if (this.actionmorearea) { this.actionmorearea.setstyle("display", "none"); document.body.unmask(); } }.bind(this)); } } }, _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, "class": "maincolor_color", "text": tool.text }).inject(node); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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, "class": "maincolor_color", "text": tool.text }).inject(node); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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, "class": "maincolor_color", "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({ "style": { "background-color": "#cccccc", "opacity": 0.6 }, "hideonclick": true, "onhide": function () { 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, "class": "maincolor_color", "text": tool.text }).inject(this.actionmorearea); if (tool.id && tool.id !== "") { action.set("id", tool.id); } if( o2.typeof(tool.properties) === "object" && object.keys(tool.properties).length )action.set(tool.properties); 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); } // 关闭 if (this.actionmorearea) { this.actionmorearea.setstyle("display", "none"); document.body.unmask(); } }.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) } }); }, _runcustomaction: function (actionscript) { //var script = bt.node.retrieve("script"); this.macro.exec(actionscript, this); }, _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.form.businessdata.control[tool.control] } if (tool.condition) { var hideflag = this.macro.exec(tool.condition, this); flag = !hideflag; } } return flag; }, _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 (tool.id == "action_processwork" || tool.id == "action_flowwork") { if (this.businessdata.work.starttime) { // 正常模式 if (!this.businessdata.task || !this.businessdata.work || !this.businessdata.work.starttime) { flag = false; } } else { // 草稿模式 if (!this.businessdata.work) { flag = false; } } } if (tool.id == "action_rollback") tool.read = true; if (readonly) if (!tool.read) flag = false; return flag; }, _loadbusinessdata: function () { if (!this.businessdata) { this.businessdata = {}; // this.businessdata = { // "data": { // "select": "222", // "radio": "bbb", // "checkbox": ["check1", "check3"], // "orderdata": [ // { // "ordername": {"namefield": "电脑"}, // "ordercount": {"countfield": "3"}, // "pricecount": {"pricefield": "9000"} // }, // { // "ordername": {"namefield": "路由器"}, // "ordercount": {"countfield": "2"}, // "pricecount": {"pricefield": "1000"} // }, // { // "ordername": {"namefield": "网线"}, // "ordercount": {"countfield": "10"}, // "pricecount": {"pricefield": "200"} // } // ] // // } // }; } }, _loadhtml: function () { // this.container.set("html", this.html); // this.node = this.container.getfirst(); //this.node.setstyle("overflow", "hidden"); this.node.addevent("selectstart", function (e) { var select = "text"; if (e.target.getstyle("-webkit-user-select")) { select = e.target.getstyle("-webkit-user-select").tostring().tolowercase(); } if (select !== "text" && select !== "auto") e.preventdefault(); }); }, _loadform: function () { this._loadstyles(); this._loadcsslinks(); this._loadscriptsrc(); this._loadjsheader(); //this._loadevents(); }, _loadstyles: function () { if (this.json.styles) object.each(this.json.styles, function (value, key) { if ((value.indexof("x_processplatform_assemble_surface") != -1 || value.indexof("x_portal_assemble_surface") != -1)) { var host1 = mwf.actions.gethost("x_processplatform_assemble_surface"); var host2 = mwf.actions.gethost("x_portal_assemble_surface"); if (value.indexof("/x_processplatform_assemble_surface") !== -1) { value = value.replace("/x_processplatform_assemble_surface", host1 "/x_processplatform_assemble_surface"); } else if (value.indexof("x_processplatform_assemble_surface") !== -1) { value = value.replace("x_processplatform_assemble_surface", host1 "/x_processplatform_assemble_surface"); } if (value.indexof("/x_portal_assemble_surface") !== -1) { value = value.replace("/x_portal_assemble_surface", host2 "/x_portal_assemble_surface"); } else if (value.indexof("x_portal_assemble_surface") !== -1) { value = value.replace("x_portal_assemble_surface", host2 "/x_portal_assemble_surface"); } } value = o2.filter; this.node.setstyle(key, value); }.bind(this)); //this.node.setstyles(this.json.styles); }, _loadcsslinks: function () { var urls = this.json.csslinks; urls.each(function (url) { new element("link", { "rel": "stylesheet", "type": "text/css", "href": url }).inject($(document.head)); }); }, _loadscriptsrc: function () { var urls = this.json.scriptsrc; urls.each(function (url) { new element("script", { "src": url }).inject($(document.head)); }); }, _loadjsheader: function () { var code = (this.json.jsheader) ? this.json.jsheader.code : ""; if (code) browser.exec(code); }, _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("beforeprocess", 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)); }, addmoduleevent: function (key, fun) { if (this.options.moduleevents.indexof(key) !== -1) { this.addevent(key, function (event) { return (fun) ? fun(this, event) : null; }.bind(this)); } else { if (key === "load") { this.addevent("postload", function (event) { return (fun) ? fun(this, event) : null; }.bind(this)); } else if (key === "submit") { this.addevent("beforeprocess", function (event) { return (fun) ? fun(this, event) : null; }.bind(this)); } else { this.node.addevent(key, function (event) { return (fun) ? fun(this, event) : null; }.bind(this)); } } }, _getdomjson: function (dom) { var mwftype = dom.get("mwftype") || dom.get("mwftype"); switch (mwftype) { case "form": return this.json; case "": return null; default: var id = dom.get("id"); if (!id) id = dom.get("mwfid"); if (id) { return this.json.modulelist[id]; } else { return null; } } }, _getmodulenodes: function (dom, dollarflag ) { var modulenodes = []; var subdom = dom.getfirst(); while (subdom) { var mwftype = subdom.get("mwftype") || subdom.get("mwftype"); if (mwftype) { var type = mwftype; if (type.indexof("$") === -1 || dollarflag===true) { modulenodes.push(subdom); } // && mwftype !== "tab$content" if (mwftype !== "datagrid" && mwftype !== "datatable" && mwftype !== "subsource" && mwftype !== "tab$content" && mwftype !== "datatemplate") { modulenodes = modulenodes.concat(this._getmodulenodes(subdom, dollarflag)); } } else { modulenodes = modulenodes.concat(this._getmodulenodes(subdom, dollarflag)); } subdom = subdom.getnext(); } return modulenodes; }, _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 ); 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; //console.log( json.id ); if (json.type === "subform" || json.modulename === "subform") this.subformcount ; //if( json.type === "subform" || json.modulename === "subform" ){ // console.log( "add subformcount , this.subformcount = " this.subformcount ); //} if (json.type === "subpage" || json.modulename === "subpage") this.subpagecount ; if (json.type === "widget" || json.modulename === "widget") this.widgetcount ; if (!mwf["app" json.type]) { var moduletype = json.type; if(moduletype === "attachmentdg")moduletype = "attachment"; mwf.xdesktop.requireapp("process.xform", moduletype, null, false); } var module = new mwf["app" json.type](node, json, this); if (beforeload) beforeload.apply(module); if (replace || !this.all[json.id]) this.all[json.id] = module; if (json.name) { if (this.allforname[json.name]) { var item = this.allforname[json.name]; typeof(item) === "array" ? item.push(module) : this.allforname[json.name] = [item, module]; } else { this.allforname[json.name] = module; } } if (module.field) { if (replace || !this.forms[json.id]) this.forms[json.id] = module; } module.readonly = this.options.readonly; module.load(); return module; }, saveopinion: function (module) { var op = module._getbusinesssectiondatabyperson(); mwf.ud.getdatajson("useropinion", function (json) { if (!json) json = []; var idx = json.indexof(op); if (idx == -1) { if (json.length >= 50) json.shift(); } else { json.splice(idx, 1); } json.push(op); mwf.ud.putdata("useropinion", json); }.bind(this), false); }, loadpathdata: function (path) { var data = null; this.workaction.getjobdatabypath(this.businessdata.work.job, path, function (json) { data = json.data || null; }, null, false); return data; }, /** * @summary 获取表单的所有数据. * @example * var data = this.form.getapp().appform.getdata(); * @return {object} */ getdata: function (issubmit) { //var data = object.clone(this.businessdata.data); var data = this.businessdata.data; object.each(this.forms, function (module, id) { //对id类似于 xx..0..xx 的字段 不处理 if( id.indexof("..") > 0 )return; if (module.json.type === "opinion") { if (issubmit) { this.saveopinion(module); var key = layout.desktop.session.user.id; if (typeof(data[id]) === "object" && typeof(data[id][key]) === "string") { data[id][key] = ""; } else if (typeof(data[id]) === "string") { data[id] = ""; } // delete data[id]; } else { var v = module.getdata(); // var d = this.loadpathdata(id); // if (d) data[id] = d; data[id] = this.getsectiondatabyperson(v, data[id]); } } else { if (module.json.section === "yes") { // var d = this.loadpathdata(id); // if (d) data[id] = d; var v = this.getsectiondata(module, data[id]); //if (o2.typeof(v)==="string") v = o2.txt(v); data[id] = v } else { if (module.fieldmoduleloaded!==false && module.readonly!==true){ var v = module.getdata(); //if (o2.typeof(v)==="string") v = o2.txt(v); data[id] = v; } } } }.bind(this)); this.fireevent("getdata", [data]); this.businessdata.data = data; this.macro.environment.setdata(this.businessdata.data); return data; }, getsectiondata: function (module, obj) { var v = module.getdata(); switch (module.json.sectionby) { case "person": return this.getsectiondatabyperson(v, obj); case "unit": return this.getsectiondatabyunit(v, obj); case "activity": return this.getsectiondatabypactivity(v, obj); case "splitvalue": return this.getsectiondatabysplitvalue(v, obj); case "script": return this.getsectiondatabyscript(module.json.sectionbyscript.code, v, obj); default: return v; } }, getsectiondatabyperson: function (v, obj) { var key = layout.desktop.session.user.id; if (!obj || (typeof(obj) !== "object")) obj = {}; obj[key] = v; return obj; }, getsectiondatabyunit: function (v, obj) { var key = (this.businessdata.task) ? this.businessdata.task.unit : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; if (key) obj[key] = v; return obj; }, getsectiondatabypactivity: function (v, obj) { var key = (this.businessdata.work) ? this.businessdata.work.activity : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; if (key) obj[key] = v; return obj; }, getsectiondatabysplitvalue: function (v, obj) { var key = (this.businessdata.work) ? this.businessdata.work.splitvalue : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; if (key) obj[key] = v; return obj; }, getsectiondatabyscript: function (code, v, obj) { var key = this.macro.exec(code, this); if (!obj || (typeof(obj) !== "object")) obj = {}; if (key) obj[key] = v; return obj; }, setsection: function (json, data) { var obj = data[json.name]; switch (json.sectionby) { case "person": return this.setsectionbyperson(obj, json.name); case "unit": return this.setsectionbyunit(obj, json.name); case "activity": return this.setsectionbypactivity(obj, json.name); case "splitvalue": return this.setsectionbysplitvalue(obj, json.name); case "script": return this.setsectionbyscript(json.sectionbyscript.code, obj, json.name); default: return v; } }, setsectionbyperson: function (obj, name) { var key = layout.desktop.session.user.id; if (!obj || (typeof(obj) !== "object")) obj = {}; //obj[key] = v; this.sectionlistobj[name] = key; return obj; }, setsectionbyunit: function (obj, name) { var key = (this.businessdata.task) ? this.businessdata.task.unit : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; this.sectionlistobj[name] = key || ""; //if (key) obj[key] = v; return obj; }, setsectionbypactivity: function (obj, name) { var key = (this.businessdata.work) ? this.businessdata.work.activity : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; this.sectionlistobj[name] = key || ""; //if (key) obj[key] = v; return obj; }, setsectionbysplitvalue: function (obj, name) { var key = (this.businessdata.work) ? this.businessdata.work.splitvalue : ""; if (!obj || (typeof(obj) !== "object")) obj = {}; this.sectionlistobj[name] = key || ""; //if (key) obj[key] = v; return obj; }, setsectionbyscript: function (code, obj, name) { var key = this.macro.exec(code, this); if (!obj || (typeof(obj) !== "object")) obj = {}; this.sectionlistobj[name] = key || ""; //if (key) obj[key] = v; return obj; }, savework: function (callback, silent) { if( this.disallowsaving )return; if (this.businessdata.control["allowsave"]) { if (!this.formsavevalidation()) { if (callback) callback(); return false; } this.fireevent("beforesave"); this.fireevent("beforesavework"); if (this.app && this.app.fireevent) this.app.fireevent("beforesave"); this.saveformdata(function (json) { if (this.app && !silent) this.app.notice(mwf.xapplication.process.xform.lp.datasaved, "success"); if (callback && typeof(callback) === "function") callback(json); this.fireevent("aftersave"); this.fireevent("aftersavework"); if (this.app && this.app.fireevent) this.app.fireevent("aftersave"); }.bind(this)); } else { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); //if (failure) failure(null, "permission denied", ""); } }, getsectionlist: function () { return object.keys(this.sectionlistobj).map(function (p) { var o = { "path": p }; if (this.sectionlistobj[p]) o.key = this.sectionlistobj[p]; return o; }.bind(this)); }, setmodifeddatabypathlist: function (data, pathlist) { var d = this.modifeddata; for (var i = 0; i < pathlist.length; i ) { if (i === pathlist.length - 1) { d[pathlist[i]] = data; } else { if (typeof(d[pathlist[i]]) === "object" || typeof(d[pathlist[i]]) === "array") { d = d[pathlist[i]] } else if (typeof(pathlist[i]) === "number") { d = d[pathlist[i]] = []; } else { d = d[pathlist[i]] = {}; } } } }, getorigianlpathdata: function (pathlist) { var d = this.businessdata.originaldata; for (var i = 0; i < pathlist.length; i ) { if (i === pathlist.length - 1) { d = d[pathlist[i]]; } else { if (typeof(d[pathlist[i]]) === "object" || typeof(d[pathlist[i]]) === "array") { d = d[pathlist[i]]; } else { return null; } } } return d; }, setmodifeddata: function (data, pathlist) { pathlist = pathlist || []; if (typeof(data) === "object") { for (var key in data) { //if (key.substring(0,2)!=="__"){ var plist = array.clone(pathlist); plist.push(key); this.setmodifeddata(data[key], plist); //} } } else if (typeof(data) === "array") { var od = this.getorigianlpathdata(pathlist); // if (typeof(od) !== "array" || od.length !== data.length || json.stringify(od) !== json.stringify(data)) { if (typeof(od) !== "array" || od.length !== data.length || !this.compareobjects( od, data ) ) { this.setmodifeddatabypathlist(data, pathlist); } //}else{ // for( var i=0; i 15 )return false; //最大层数,避免相互嵌套 var type1 = typeof( o ), type2 = typeof( p ); if( type1 !== type2 )return false; if( type1 === "object" ){ for( var k in o ){ if( o[k] === null || o[k] === undefined )delete o[k] } for( var k in p ){ if( p[k] === null || p[k] === undefined )delete p[k] } } switch (type1) { case "object": case "array": var i, keyso = object.keys(o), keysp = object.keys(p); if (keyso.length !== keysp.length){ return false; } keyso.sort(); keysp.sort(); for ( i=0; i 8) { count = ids.length; ids = ids.slice(0, 8); } ids = o2.name.cns(ids); var lp = mwf.xapplication.process.xform.lp; var t = "" lp.nextactivity "" stack.name "" lp.nextuser "" ids.join(",") " " ((count) ? "," lp.next_etc.replace("{count}", count) : "") ""; activityusers.push(t); }.bind(this)); content = activityusers.join("
"); } else { content = mwf.xapplication.process.xform.lp.taskcompleted; } } else { if (data.properties.nextmanuallist && data.properties.nextmanuallist.length) { var activityusers = []; data.properties.nextmanuallist.each(function (a) { var ids = []; a.taskidentitylist.each(function (i) { var cn = o2.name.cn(i); if( !ids.contains( cn ) ){ ids.push(cn) } }); var t = "" mwf.xapplication.process.xform.lp.nextactivity "" o2.txt(a.activityname) "" mwf.xapplication.process.xform.lp.nextuser "" ids.join(",") ""; activityusers.push(t); }); content = activityusers.join("
"); if (data.manualtaskidentitymatrix && data.manualtaskidentitymatrix.matrix){ var manualtaskidentitymatrix = data.manualtaskidentitymatrix.matrix; manualtaskidentitymatrix = (manualtaskidentitymatrix.flat) ? manualtaskidentitymatrix.flat() : manualtaskidentitymatrix.reduce(function(acc, val){ return acc.concat(val); }, []); manualtaskidentitymatrix = manualtaskidentitymatrix.filter(function(id){ return !data.properties.nextmanualtaskidentitylist.contains(id); }); var len = manualtaskidentitymatrix.length if (len){ var idtext = (len>8) ? o2.name.cns(manualtaskidentitymatrix.slice(0.8)).join(", ") " ..." : o2.name.cns(manualtaskidentitymatrix).join(", "); content = "
" mwf.xapplication.process.xform.lp.nexttaskmatrix "" idtext ""; } } } else { if (data.arrivedactivityname) { content = mwf.xapplication.process.xform.lp.arrivedactivity o2.txt(data.arrivedactivityname); } else { content = mwf.xapplication.process.xform.lp.taskcompleted; } } } } var title = this.businessdata.data.title || this.businessdata.data.subject || this.businessdata.work.title if (maxlength && title.length > maxlength) { title = title.substr(0, maxlength) "..." } return "
" (titlelp || mwf.xapplication.process.xform.lp.taskprocessedmessage) "“" o2.txt(title) "”
" content; }, addmessage: function (data, notshowbrowserdkg) { if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.taskprocessed, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.taskprocessedmessage) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser && !notshowbrowserdkg) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.taskprocessedmessage)); } } }, formsavevalidation: function(){ var flag = true; object.each(this.forms, function (field, key) { if( !field.json.id || field.json.id.indexof("..") > 0 )return; field.validationmode(); if (!field.savevalidation()) flag = false; }.bind(this)); return flag; }, formvalidation: function (routename, opinion, medias) { if (this.options.readonly) return true; this.macro.environment.form.currentroutename = routename; this.macro.environment.form.opinion = opinion; this.macro.environment.form.medias = medias; var flag = true; //flag = this.validation(); object.each(this.forms, function (field, key) { field.validationmode(); if (!field.validation(routename, opinion, medias)) flag = false; }.bind(this)); return flag; }, validation: function (routename, opinion, processor, medias) { this.macro.environment.form.currentroutename = routename; this.macro.environment.form.opinion = opinion; this.macro.environment.form.medias = medias; var routeflag = this.validationroute(processor); var opinionflag = this.validationopinion(processor); return routeflag && opinionflag; }, validationroute: function (processor) { if (!this.json.validationroute) return true; if (!this.json.validationroute.code) return true; var flag = this.macro.exec(this.json.validationroute.code, this); if (!flag) flag = mwf.xapplication.process.xform.lp.notvalidation; if (flag.tostring() != "true") { this.notvalidationroutemode(flag, processor); return false; } return true; }, validationopinion: function (processor) { if (!this.json.validationopinion) return true; if (!this.json.validationopinion.code) return true; var flag = this.macro.exec(this.json.validationopinion.code, this); if (!flag) flag = mwf.xapplication.process.xform.lp.notvalidation; if (flag.tostring() != "true") { this.notvalidationopinionmode(flag, processor); return false; } return true; }, formcustomvalidation: function () { if (!this.json.validationformcustom) return true; if (!this.json.validationformcustom.code) return true; var flag = this.macro.exec(this.json.validationformcustom.code, this); if (!flag) flag = mwf.xapplication.process.xform.lp.notvalidation; if (flag.tostring() != "true") { this.notvalidationopinionmode(flag); return false; } return true; }, notvalidationroutemode: function (flag, processor) { if (processor) processor.routeselectorarea.setstyle("background-color", "#ffe9e9"); mwf.xdesktop.notice( "error", { "x": "center", "y": "top" }, flag, (processor) ? processor.routeselectorarea : (layout.mobile ? $(document.body) : this.app.content), null, //{"x": 0, "y": 30} { "closeonboxclick": true, "closeonbodyclick": true, "fixed": true, "delayclose": 6000 } ); //new mbox.notice({ // type: "error", // position: {"x": "center", "y": "top"}, // move: false, // target: (processor) ? processor.routeselectorarea : this.app.content, // delayclose: 6000, // content: flag //}); }, notvalidationopinionmode: function (flag, processor) { if (processor) processor.inputtextarea.setstyle("background-color", "#ffe9e9"); mwf.xdesktop.notice( "error", (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" }, flag, (processor) ? processor.inputtextarea : (layout.mobile ? $(document.body) : this.app.content), null, //{"x": 0, "y": 30} { "closeonboxclick": true, "closeonbodyclick": true, "fixed": true, "delayclose": 6000 } ); //new mbox.notice({ // type: "error", // position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"}, // move: false, // target: (processor) ? processor.inputtextarea : this.app.content, // delayclose: 6000, // content: flag //}); }, //firertevent: function(type, args, delay){ // type = removeon(type); // var events = this.$events[type]; // if (!events) return this; // if (!events.length) return this; // var event = events[events.length-1]; // args = array.from(args); // if (delay) fn.delay(delay, this, args); // else return fn.apply(this, args); // return this; //}, getignoreimpoweridentity: function (processororglist) { var list = []; var check = function (org, isprocessorg) { var moduledata = isprocessorg ? org.getvalue() : org.getdata(); var flag = false; if (typeof(moduledata) === "array" && moduledata.length) { moduledata.each(function (d) { if (d.ignoreempower) { list.push(d.distinguishedname || d.unique || d.id); d.ignoredempower = true; delete d.ignoreempower; flag = true; } }) } if (flag) org.setdata(moduledata); } var modules = this.modules; for (var i = 0; i < modules.length; i ) { var module = modules[i]; var modulename = module.json.modulename; if (!modulename) modulename = typeof(module.json.type) === "string" ? module.json.type.tolowercase() : ""; if (modulename === "org") { check(module) } } if (processororglist && processororglist.length > 0) { for (var i = 0; i < processororglist.length; i ) { check(processororglist[i], true) } } return list; }, //savedocumenteditor submitwork: function (routename, opinion, medias, callback, processor, data, appendtaskidentitylist, processororglist, callbackbeforesave) { if (!this.businessdata.control["allowprocessing"] && !this.businessdata.control["allowflow"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); this.app.content.unmask(); if (processor && processor.node) processor.node.unmask(); return false; } if (!this.formvalidation(routename, opinion, medias)) { this.app.content.unmask(); if (callback) callback(); return false; } if (!this.validation(routename, opinion, processor, medias)) { if (processor && processor.node) processor.node.unmask(); if (callback) callback(); return false; } if (!opinion) { var idx = this.businessdata.task.routenamelist.indexof(routename); if (this.businessdata.task.routeopinionlist[idx]) { opinion = this.businessdata.task.routeopinionlist[idx]; } } this.fireevent("beforeprocess"); if (this.app && this.app.fireevent) this.app.fireevent("beforeprocess"); //处理忽略授权 debugger; var ignoreempoweridentitylist = this.getignoreimpoweridentity(processororglist); var _self = this; mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); // 适配移动端 if (layout.mobile) { this.mask.load(); } else { this.mask.loadnode(this.app.content); } if (callbackbeforesave) callbackbeforesave(); this.fireevent("beforesave"); if (this.app && this.app.fireevent) this.app.fireevent("beforesave"); this.saveformdata(function (json) { this.businessdata.task.routename = routename; this.businessdata.task.opinion = opinion || ""; var mediaids = []; if (medias && medias.length) { medias.each(function (file, i) { var formdata = new formdata(); formdata.append("file", file); formdata.append("site", "$mediaopinion"); var filename = "mediaopinion_" i "_" new date().gettime(); if( file.type && file.type.contains("/") ) { file.name = filename "." file.type.split("/")[1]; }else{ file.name = filename ".unknow"; } this.workaction.uploadattachment(this.businessdata.work.id, formdata, file, function (json) { mediaids.push(json.data.id); }.bind(this), null, false); }.bind(this)); } if (mediaids.length) this.businessdata.task.mediaopinion = mediaids.join(","); if (appendtaskidentitylist && appendtaskidentitylist.length) { var list = []; appendtaskidentitylist.each(function (identity) { if (typeof(identity) === "object") { list.push(identity.distinguishedname || identity.unique || identity.id) } else { list.push(identity); } }.bind(this)); this.businessdata.task.appendtaskidentitylist = list; } this.businessdata.task.ignoreempoweridentitylist = ignoreempoweridentitylist; this.fireevent("aftersave"); if (this.app && this.app.fireevent) this.app.fireevent("aftersave"); // var promiselist = []; // if (this.documenteditorlist && this.documenteditorlist.length) { // var promiselist = []; // this.documenteditorlist.each(function (module) { // promiselist.push(module.checksavenewhistroy()); // }); // } // promise.all(promiselist).then(function(){ this.workaction.processtask(function (json) { //if (processor) processor.destroy(); //if (processnode) processnode.destroy(); if (callback) callback(json); debugger; this.tasklist = json.data; this.fireevent("afterprocess"); if (this.app && this.app.fireevent) this.app.fireevent("afterprocess"); // this.notice(mwf.xapplication.process.xform.lp.taskprocessed, "success"); this.addmessage(json.data, true); if (this.app.taskobject) this.app.taskobject.destroy(); this.finishonflow("process", json.data); //window.settimeout(function(){this.app.close();}.bind(this), 2000); }.bind(this), null, this.businessdata.task.id, this.businessdata.task); // }.bind(this), function(){}); }.bind(this), null, true, data, true); }.bind(this)); }, finishonflow: function(type, data, notclosewindow){ if (this.closeimmediatelyonprocess && !notclosewindow) { this.app.close(); } else if (typeof(this.showcustomsubmiteddialog) === "function") { this.showcustomsubmiteddialog(data); } else if (layout.mobile) { //移动端页面关闭 this.finishonmobile(); } else { if (this.app.inbrowser) { if (this.mask) this.mask.hide(); if (this.json.isprompt !== false) { switch (type) { case "process": case "goback": this.showsubmiteddialog(data); break; case "reset": this.addresetmessage(data, notclosewindow); break; case "addtask": this.addaddtaskmessage(data, notclosewindow); break; } } 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 { // this.app.close(); this.dingtalkpccloseorappclose(); } } //} } else { switch (type) { // case "process": // this.showsubmiteddialog(data); // break; case "reset": this.addresetmessage(data, notclosewindow); break; case "addtask": this.addaddtaskmessage(data, notclosewindow); break; case "goback": this.showsubmiteddialog(data, notclosewindow); break; } if( notclosewindow ){ this.app.refresh(); }else{ this.app.close(); } } } }, showsubmiteddialog: function (data) { var content = this.getmessagecontent(data, this.json.submiteddlgstyle ? this.json.submiteddlgstyle.maxtitlelength : 60); //if( this.json.submiteddlgusenotice ){ // mwf.xdesktop.notice("success", {x: "right", y:"top"}, content); // if (this.json.isprompt!==false){ // if (this.json.promptclosetime!=0){ // var t = this.json.promptclosetime || 2; // t = t.toint()*1000; // var _work = this; // window.settimeout(function(){ _work.app.close();}, t); // } // }else{ // this.app.close(); // } //}else{ var div = new element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden", "width": "270px" } }).inject(this.app.content); div.set("html", content); var timernode = new element("div", { "styles": { "margin-top": "5px" } }).inject(div); var options = { "content": div, "istitle": false, "width": 350, "height": 180, "buttonlist": [ { "text": this.app.lp.closepage, "action": function () { dlg.close(); if (this.json.afterprocessaction == "redirect" && this.json.afterprocessredirectscript && this.json.afterprocessredirectscript.code) { var url = this.macro.exec(this.json.afterprocessredirectscript.code, this); (new uri(url)).go(); } else { // this.app.close(); this.dingtalkpccloseorappclose(); } }.bind(this) } ] }; if (this.json.submiteddlgstyle) { options = object.merge(options, this.json.submiteddlgstyle); if (this.json.submiteddlgstyle.contentstyle) { div.setstyles(this.json.submiteddlgstyle.contentstyle); delete options.contentstyle; } } var size = this.app.content.getsize(); switch (options.promptposition || this.json.promptposition || "righttop") { case "lefttop": options.top = 10; options.left = 10; options.fromtop = 10; options.fromleft = 10; break; case "righttop": options.top = 10; options.left = size.x - options.width - 10; options.fromtop = 10; options.fromleft = size.x - 10; break; case "leftbottom": options.top = size.y - options.height - 10; options.left = 10; options.fromtop = size.y - 10; options.fromleft = 10; break; case "rightbottom": options.top = size.y - options.height - 10; options.left = size.x - options.width - 10; options.fromtop = size.y - 10; options.fromleft = size.x - 10; break; default: delete options.top; delete options.left; delete options.fromtop; delete options.fromleft; } var _work = this; options.onpostload = function () { var dialog = this; dialog.node.setstyle("display", "block"); var nodesize = div.getsize(); dialog.content.setstyles({ //"width" : nodesize.x, "height": nodesize.y }); dialog.setcontentsize(); if ((options.promptclosetime || _work.json.promptclosetime) != 0) { var t = options.promptclosetime || _work.json.promptclosetime || 2; t = t.toint() * 1000; if (options.iscountdown) { timernode.set("text", _work.app.lp.closepagecountdowntext.replace("{second}", math.ceil(t / 1000).tostring())); t = t - 1000; var countdown = function () { if (t > 0) { timernode.set("text", _work.app.lp.closepagecountdowntext.replace("{second}", math.ceil(t / 1000).tostring())); t = t - 1000; window.settimeout(countdown, 1000); } else { dlg.close(); if (_work.json.afterprocessaction == "redirect" && _work.json.afterprocessredirectscript && _work.json.afterprocessredirectscript.code) { var url = _work.macro.exec(_work.json.afterprocessredirectscript.code, _work); (new uri(url)).go(); } else { // _work.app.close(); _work.dingtalkpccloseorappclose(); } } }; window.settimeout(countdown, 1000); } else { window.settimeout(function () { if (_work.json.afterprocessaction == "redirect" && _work.json.afterprocessredirectscript && _work.json.afterprocessredirectscript.code) { var url = _work.macro.exec(_work.json.afterprocessredirectscript.code, _work); (new uri(url)).go(); } else { // _work.app.close(); _work.dingtalkpccloseorappclose(); } }, t); } } }; var dlg = o2.dl.open(options); }, startdraftprocess: function ( action ) { if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } if (!this.formvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } this.saveformdata(function () { this.workaction.startdraft(this.businessdata.work.id, function (json) { this.app.options.workid = json.data[0].work; if (layout.mobile || !layout.desktop.message) { if (layout.notice) { layout.notice(mwf.xapplication.process.xform.lp.processstartedmessage "“[" o2.txt(json.data[0].processname) "]" o2.txt(this.businessdata.data.title || this.businessdata.data.subject)); } } else { if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.processstarted, "content": "
" mwf.xapplication.process.xform.lp.processstartedmessage "“[" o2.txt(json.data[0].processname) "]" o2.txt(this.businessdata.data.title || this.businessdata.data.subject) "”
" }; var tooltip = layout.desktop.message.addtooltip(msg); var item = layout.desktop.message.addmessage(msg); } } // 多次加载的bug // if (layout.app && layout.app.inbrowser) { // if (layout.app) layout.app.$openwithself = true; // layout.desktop.openapplication(null, "process.work", { "workid": this.app.options.workid, "action": "processtask" }); // } this.app.options.action = action || "processtask"; this.app.reload(); //this.app.notice(mwf.xapplication.process.xform.lp.datasaved, "success"); //草稿模式暂时不能上传附件,不能直接流转文件 // o2.actions.invokeasync([ // {"action": this.workaction, "name": "loadwork"}, // {"action": this.workaction, "name": "getworkcontrol"}, // {"action": this.workaction, "name": "getworklog"}, // {"action": this.workaction, "name": "getrecordlog"}, // {"action": this.workaction, "name": "listattachments"} // ], {"success": function(json_work, json_control, json_log, json_record, json_att){ // if (json_work && json_control && json_log && json_att){ // this.app.parsedata(json_work.data, json_control.data, null, json_log.data, json_record.data, json_att.data); // var workdata = json_work.data; // this.businessdata.activity = workdata.activity; // this.businessdata.originaldata = object.clone( this.businessdata.data ); // this.businessdata.tasklist = workdata.tasklist; // this.businessdata.task = this.getcurrenttaskdata(workdata); // this.businessdata.tasklist = workdata.tasklist; // this.businessdata.readlist = workdata.readlist; // this.businessdata.work = workdata.work; // this.businessdata.workcompleted = (workdata.work.completedtime) ? workdata.work : null; // // this.businessdata.workloglist = json_log.data; // this.businessdata.recordlist = json_record.data; // this.businessdata.attachmentlist = json_att.data; // this.businessdata.control = json_control.data; // // if (this.businessdata.task){ // this.processwork(); // }else{ // this.app.options.workid = json.data[0].work; // this.app.reload(); // } // } // }.bind(this), "failure": function(){}}, json.data[0].work); }.bind(this)); }.bind(this), null, false, null, false, true) }, getcurrenttaskdata: function (data) { if ((data.currenttaskindex || data.currenttaskindex === 0) && data.currenttaskindex != -1) { this.app.options.taskid = this.businessdata.tasklist[data.currenttaskindex].id; return this.businessdata.tasklist[data.currenttaskindex]; } return null; }, flowwork: function ( defaultroute ) { if( !this.isloaded ){ //未加载完成需要等待加载完成再执行 var flowworkfun = function () { this.removeevent( "afterload", flowworkfun ); this._flowwork( defaultroute ) }.bind(this); this.addevent("afterload", flowworkfun) }else{ this._flowwork( defaultroute ); } }, _flowwork: function( defaultroute ){ if (!this.checkuploadattachment()) return false; if (!this.businessdata.work.starttime) { this.startdraftprocess(); } else { if (this.json.mode == "mobile") { settimeout(function () { this.flowwork_mobile( defaultroute ); }.bind(this), 100); } else { this.flowwork_pc( defaultroute ); } } }, flowwork_pc: function ( defaultroute ) { var _self = this; //? 添加事件 this.fireevent("beforeflowwork"); if (this.app && this.app.fireevent) this.app.fireevent("beforeflowwork"); if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } if (!this.formvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } var flownode = new element("div", { "styles": this.app.css.flownode_area }).inject(this.node); flownode.setstyle("opacity", 0); var setsize = function (notrecenter) { var dlg = this; if (!dlg || !dlg.node) return; dlg.node.setstyle("display", "block"); //var size = flownode.getsize(); //希望滚动条在flow里面 var maxheight = dlg.getcontentmaxheight(); var s = _self.flow.getsize(); dlg.content.setstyles({ "height": math.min(s.y, maxheight), "width": s.x, "padding-right": "0px" }); s = dlg.setcontentsize(); if (!notrecenter) dlg.recenter(); }; this.loadflow(flownode, "default", function (flow) { this.flowdlg = o2.dl.open({ "title": this.app.lp.flowwork, "style": this.json.dialogstyle || "user", "isresize": false, "content": flownode, "masknode": this.app.content, "positionheight": 900, "maxheight": 900, "maxheightpercent": "98%", "mintop": 5, "width": "auto", "height": "auto", "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { //避免双击 if (this.flowtimer) { cleartimeout(this.flowtimer); this.flowtimer = null; } this.flowtimer = settimeout(function(){ if (this.flow) this.flow.submit(); this.flowtimer = null; }.bind(this), 200) }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { this.flowdlg.close(); }.bind(this) } ], "onqueryclose": function(){ if (this.flow) this.flow.destroy(); }.bind(this), "onpostload": function () { flownode.setstyle("opacity", 1); setsize.call(this) } }) }.bind(this), function () { if (this.flowdlg) setsize.call(this.flowdlg, true) }.bind(this), defaultroute); }, flowwork_mobile: function ( defaultroute ) { if (this.app.inbrowser) { this.app.content.setstyle("height", document.body.getsize().y); } this.fireevent("beforeflowwork"); if (this.app && this.app.fireevent) this.app.fireevent("beforeflowwork"); // if (this.json.mode != "mobile") { // this.app.content.mask({ // "destroyonhide": true, // "style": this.app.css.masknode, // "useiframeshim": true, // "iframeshimoptions": { "browsers": true }, // "onshow": function () { // this.shim.shim.setstyles({ // "opacity": 0, // "top": "" position.y "px", // "left": "" position.x "px" // }); // } // }); // } if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } if (!this.formvalidation("", "")) { this.app.content.unmask(); return false; } var processnode = new element("div.flownode_mobile", { "styles": this.app.css.flownode_mobile }).inject(document.body); // processnode.position({ // relativeto: this.app.content, // position: "topcenter", // edge: "topcenter" // }); this.loadflow(processnode, null, null, null, defaultroute); }, loadflow: function (hanldernode, style, postloadfun, resizefun, defaultroute) { var _self = this; mwf.xdesktop.requireapp("process.work", layout.mobile ? "flowmobile" : "flow", null, false); var op = this.getopinion(); var mds = op.medias; var innernode; if (layout.mobile) { innernode = new element("div").inject(hanldernode); } var options = { "style": style || "default", "onresize": function () { if (resizefun) resizefun(); }, "onload": function () { if (postloadfun) postloadfun(this); }, "oncancel": function () { this.destroy(); hanldernode.destroy(); _self.app.content.unmask(); delete this; }, "opinionoptions": { "opinion": op.opinion, "tablettoolhidden": this.json.tablettoolhidden || [], "tabletwidth": this.json.tabletwidth || 0, "tabletheight": this.json.tabletheight || 0, }, "processoptions": { "defaultroute": defaultroute, "ishandwriting": this.json.ishandwriting === "no" ? false : true, "onsubmit": function (routename, opinion, medias, appendtaskidentitylist, processororglist, callbackbeforesave) { if (!medias || !medias.length) { medias = mds; } else { medias = medias.concat(mds) } var promise; if (_self.towordsubmitlist && _self.towordsubmitlist.length){ var p = []; _self.towordsubmitlist.each(function(editor){ if (editor.doctoword) p.push(new promise(function(resolve){ editor.doctoword(resolve) })); }); promise.all(p).then(function(){ _self.submitwork(routename, opinion, medias, function () { this.destroy(); hanldernode.destroy(); if (_self.flowdlg) _self.flowdlg.close(); delete this; }.bind(this), this, null, appendtaskidentitylist, processororglist, callbackbeforesave); }.bind(this)); }else{ _self.submitwork(routename, opinion, medias, function () { this.destroy(); hanldernode.destroy(); if (_self.flowdlg) _self.flowdlg.close(); delete this; }.bind(this), this, null, appendtaskidentitylist, processororglist, callbackbeforesave); } } }, "addtaskoptions":{ "ishandwriting": false, "onsubmit": function (names, opinion, mode, before, routename) { mwf.require("mwf.widget.mask", function () { _self.fireevent("beforeaddtask"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforeaddtask"); _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); if (layout.mobile) { _self.mask.load(); } else { _self.mask.loadnode(_self.app.content); } _self.fireevent("beforesave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforesave"); _self.saveformdata(function (json) { _self.fireevent("aftersave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("aftersave"); _self.addtasktopeson(names, opinion, mode, before, routename, function (workjson) { _self.fireevent("afteraddtask"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afteraddtask"); // _self.addresetmessage(workjson.data); this.destroy(); hanldernode.destroy(); if (_self.flowdlg) _self.flowdlg.close(); _self.finishonflow("addtask", workjson.data); }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", _self.flowdlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)) }.bind(this)); } }, "resetoptions":{ "ishandwriting": false, "onsubmit": function (names, opinion, routename) { mwf.require("mwf.widget.mask", function () { _self.fireevent("beforereset"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforereset"); _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); if (layout.mobile) { _self.mask.load(); } else { _self.mask.loadnode(_self.app.content); } _self.fireevent("beforesave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforesave"); _self.saveformdata(function (json) { _self.fireevent("aftersave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("aftersave"); _self.resettopeson(names, opinion, routename, function (workjson) { _self.fireevent("afterreset"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterreset"); // _self.addresetmessage(workjson.data); this.destroy(); hanldernode.destroy(); // if (!_self.app.inbrowser) _self.app.close(); if (_self.flowdlg) _self.flowdlg.close(); // if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.finishonflow("reset", workjson.data); }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", _self.flowdlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)) }.bind(this)); } }, "gobackoptions":{ "ishandwriting": false, "onsubmit": function (opinion, routename, activity, way) { mwf.require("mwf.widget.mask", function () { _self.fireevent("beforegoback"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforegoback"); _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); if (layout.mobile) { _self.mask.load(); } else { _self.mask.loadnode(_self.app.content); } _self.fireevent("beforesave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforesave"); _self.saveformdata(function (json) { _self.fireevent("aftersave"); if (_self.app && _self.app.fireevent) _self.app.fireevent("aftersave"); _self.gobacktoperson(routename, opinion, activity, way, function (workjson) { _self.fireevent("aftergoback"); if (_self.app && _self.app.fireevent) _self.app.fireevent("aftergoback"); this.destroy(); hanldernode.destroy(); if (_self.flowdlg) _self.flowdlg.close(); _self.addmessage(workjson.data, true); if (_self.app.taskobject) _self.app.taskobject.destroy(); _self.finishonflow("goback", workjson.data); }.bind(this)); }.bind(this)) }.bind(this)); } } }; if( this.json.mode == "mobile" ){ this.flow = new mwf.xapplication.process.work.flowmobile(innernode || hanldernode, this.businessdata.task, options, this); }else{ this.flow = new mwf.xapplication.process.work.flow(innernode || hanldernode, this.businessdata.task, options, this); } }, resettopeson: function (identitylist, opinion, routename, success, failure) { var data = { "opinion": opinion, "routename": routename || mwf.xapplication.process.xform.lp.reset, "identitylist": identitylist // "keep": !!keep }; o2.actions.load("x_processplatform_assemble_surface").taskaction.v2reset( //this.workaction.resetwork( function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.task.id, data ); }, addtasktopeson: function (names, opinion, mode, before, routename, success, failure) { var data = { "mode": mode, "before": !!before, "opinion": opinion, "routename": routename || mwf.xapplication.process.xform.lp.addtask, "distinguishednamelist": names }; o2.actions.load("x_processplatform_assemble_surface").taskaction.v3add( //this.workaction.resetwork( function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.task.id, data ); }, gobacktoperson: function(routename, opinion, activity, way, callback){ this.businessdata.task.decision = routename; this.businessdata.task.routename = routename; this.businessdata.task.opinion = opinion; this.businessdata.task.action = "goback"; this.businessdata.task.option = { "activity": activity, "way": way }; // this.submitwork(routename, opinion, null, function () { // if(callback)callback(); // }.bind(this)); this.workaction.processtask(function (json) { if (callback) callback(json); }.bind(this), null, this.businessdata.task.id, this.businessdata.task); }, processwork: function ( defaultroute ) { if( !this.isloaded ){ //未加载完成需要等待加载完成再执行 var processworkfun = function () { this.removeevent( "afterload", processworkfun ); this._processwork( defaultroute ) }.bind(this); this.addevent("afterload", processworkfun) }else{ this._processwork( defaultroute ); } }, checkuploadattachment: function(){ if (o2.runningrequestslist.length){ var runningrequests = []; var reg = /\/jaxrs\/attachment\/upload\/work\/([\w-]*)/; o2.runningrequestslist.foreach(function(r){ var method = (r.requestoptions[0] || "get").tolowercase(); var url = r.requestoptions[1] || ""; var m = url.match(reg); if (m && m[1]===this.businessdata.work.id && method==="post"){ runningrequests.push(r); } }.bind(this)); if (runningrequests.length){ this.app.notice(mwf.xapplication.process.xform.lp.uploading, "info"); return false; } } return true; }, _processwork: function( defaultroute ) { if (!this.checkuploadattachment()) return false; var _self = this; if (!this.businessdata.work.starttime) { this.startdraftprocess(); } else if (this.json.submitformtype === "select") { this.processwork_custom( defaultroute ); } else if (this.json.submitformtype === "script") { this.processwork_custom( defaultroute ); } else { if (this.json.mode == "mobile") { settimeout(function () { this.processwork_mobile( defaultroute ); }.bind(this), 100); } else { this.processwork_pc( defaultroute ); } } }, processwork_custom: function ( defaultroute ) { this.fireevent("beforeprocesswork"); if (this.app && this.app.fireevent) this.app.fireevent("beforeprocesswork"); if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } if (!this.formvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } debugger; if (!this.submitformmodule) { if (!mwf["appsubmitform"]) { mwf.xdesktop.requireapp("process.xform", "subform", null, false); } var submitformcontainer = new element("div").inject(layout.mobile ? $(document.body) : this.app.content); this.submitformmodule = new mwf["appsubmitform"](submitformcontainer, { id: this.json.id, submitformselected: this.json.submitformselected, submitformappselected: this.json.submitformappselected, submitformtype: this.json.submitformtype, submitformscript: this.json.submitformscript, submitscript: this.json.submitscript }, this); this.submitformmodule.addevent("aftermodulesload", function () { this.submitformmodule.show( defaultroute ); this.fireevent("afterloadprocessor", [this.submitformmodule]); }.bind(this)) this.submitformmodule.load(); } else { this.submitformmodule.show( defaultroute ); this.fireevent("afterloadprocessor", [this.submitformmodule]); } }, processwork_pc: function ( defaultroute ) { var _self = this; this.fireevent("beforeprocesswork"); if (this.app && this.app.fireevent) this.app.fireevent("beforeprocesswork"); if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } // mwf.require("mwf.widget.mask", function() { // this.mask = new mwf.widget.mask({"style": "desktop", "zindex": 50000}); // this.mask.loadnode(this.app.content); if (!this.formvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } var setsize = function (notrecenter) { var dlg = this; if (!dlg || !dlg.node) return; dlg.node.setstyle("display", "block"); var size = processnode.getsize(); dlg.content.setstyles({ "height": size.y, "width": size.x }); var s = dlg.setcontentsize(); // if ( dlg.content.getstyle("overflow-y") === "auto" && dlg.content.getstyle("overflow-x") !== "auto" ) { // var paddingright = (dlg.content.getstyle("padding-right").toint() || 0 ); // if( paddingright < 20 ){ // dlg.node.setstyle("width", dlg.node.getstyle("width").toint() 20 "px"); // dlg.content.setstyle("width", dlg.content.getstyle("width").toint() 20 "px"); // } // } if (!notrecenter) dlg.recenter(); } //var node = new element("div", {"styles": this.css.rollbackareanode}); var processnode = new element("div", { "styles": this.app.css.processnode_area }).inject(this.node); processnode.setstyle("opacity", 0); this.setprocessnode(processnode, "process", function (processor) { this.processdlg = o2.dl.open({ "title": this.app.lp.process, "style": this.json.dialogstyle || "user", "isresize": false, "content": processnode, "masknode": this.app.content, "positionheight": 800, "maxheight": 800, "maxheightpercent": "98%", "mintop": 5, "width": "auto", //processnode.retrieve("width") || 1000, //600, "height": "auto", //processnode.retrieve("height") || 401, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { //避免双击 if (this.processtimer) { cleartimeout(this.processtimer); this.processtimer = null; } this.processtimer = settimeout(function(){ if (this.processor) this.processor.okbutton.click(); this.processtimer = null; }.bind(this), 200) }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { this.processdlg.close(); }.bind(this) } ], "onqueryclose": function(){ if (this.processor) this.processor.destroy(); }.bind(this), "onpostload": function () { processnode.setstyle("opacity", 1); processor.options.medianode = this.content; setsize.call(this) } }) }.bind(this), function () { if (this.processdlg) setsize.call(this.processdlg, true) }.bind(this), defaultroute); }, processwork_mobile: function ( defaultroute ) { if (this.app.inbrowser) { this.app.content.setstyle("height", document.body.getsize().y); } this.fireevent("beforeprocesswork"); if (this.app && this.app.fireevent) this.app.fireevent("beforeprocesswork"); var position = this.app.content.getposition(this.app.content.getoffsetparent()); if (this.json.mode != "mobile") { this.app.content.mask({ "destroyonhide": true, "style": this.app.css.masknode, "useiframeshim": true, "iframeshimoptions": { "browsers": true }, "onshow": function () { this.shim.shim.setstyles({ "opacity": 0, "top": "" position.y "px", "left": "" position.x "px" }); } }); } if (!this.formcustomvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } // mwf.require("mwf.widget.mask", function() { // this.mask = new mwf.widget.mask({"style": "desktop", "zindex": 50000}); // this.mask.loadnode(this.app.content); if (!this.formvalidation("", "")) { this.app.content.unmask(); // if (callback) callback(); return false; } var processnode = this.createprocessnode(); //this.setprocessnode(processnode); this.setprocessnode(processnode, null, null, null, defaultroute); this.showprocessnode(processnode); processnode.setstyle("overflow", "auto"); //}.bind(this)); }, createprocessnode: function () { var fromcss = this.app.css.processnode_from; var css = this.app.css.processnode; if (layout.mobile) { fromcss = this.app.css.processnodemobile_from; css = this.app.css.processnodemobile; // var contentsize = this.app.content.getsize(); fromcss.width = "100%"; css.width = "100%"; fromcss.height = "100%"; css.height = "100%"; } if (this.json.mode == "mobile") { var processnode = new element("div", { "styles": fromcss }).inject(document.body); } else { var processnode = new element("div", { "styles": fromcss }).inject(this.app.content); } processnode.position({ relativeto: this.app.content, position: "topcenter", edge: "topcenter" }); return processnode; }, getopinion: function () { var opinion = ""; var medias = []; object.each(this.forms, function (m, id) { if (m.json.type === "opinion") if (this.businessdata.data[id]) opinion = " " m._getbusinesssectiondatabyperson(); if (m.handwritingfile) if (m.handwritingfile[layout.session.user.distinguishedname]) medias.push(m.handwritingfile[layout.session.user.distinguishedname]); if (m.soundfile) if (m.soundfile[layout.session.user.distinguishedname]) medias.push(m.soundfile[layout.session.user.distinguishedname]); if (m.videofile) if (m.videofile[layout.session.user.distinguishedname]) medias.push(m.videofile[layout.session.user.distinguishedname]); }.bind(this)); return { "opinion": opinion.trim(), "medias": medias }; }, setprocessnode: function (processnode, style, postloadfun, resizefun, defaultroute) { var _self = this; mwf.xdesktop.requireapp("process.work", "processor", function () { var op = this.getopinion(); var mds = op.medias; var innernode; if (layout.mobile) { innernode = new element("div").inject(processnode); } this.processor = new mwf.xapplication.process.work.processor(innernode || processnode, this.businessdata.task, { "style": (layout.mobile) ? "mobile" : (style || "default"), "opinion": op.opinion, "ishandwriting": this.json.ishandwriting === "no" ? false : true, "tablettoolhidden": this.json.tablettoolhidden || [], "tabletwidth": this.json.tabletwidth || 0, "tabletheight": this.json.tabletheight || 0, "defaultroute": defaultroute, "onpostload": function () { if (postloadfun) postloadfun(this); _self.fireevent("afterloadprocessor", [this]); }, "onresize": function () { if (resizefun) resizefun(); }, "oncancel": function () { processnode.destroy(); _self.app.content.unmask(); delete this; }, "onsubmit": function (routename, opinion, medias, appendtaskidentitylist, processororglist, callbackbeforesave) { if (!medias || !medias.length) { medias = mds; } else { medias = medias.concat(mds) } var promise; if (_self.towordsubmitlist && _self.towordsubmitlist.length){ var p = []; _self.towordsubmitlist.each(function(editor){ if (editor.doctoword) p.push(new promise(function(resolve){ editor.doctoword(resolve) })); }); promise.all(p).then(function(){ _self.submitwork(routename, opinion, medias, function () { this.destroy(); processnode.destroy(); if (_self.processdlg) _self.processdlg.close(); delete this; }.bind(this), this, null, appendtaskidentitylist, processororglist, callbackbeforesave); }.bind(this)); }else{ _self.submitwork(routename, opinion, medias, function () { debugger; this.destroy(); processnode.destroy(); if (_self.processdlg) _self.processdlg.close(); delete this; }.bind(this), this, null, appendtaskidentitylist, processororglist, callbackbeforesave); } } }, this); }.bind(this)); }, showprocessnode: function (processnode) { if (layout.mobile) { processnode.setstyles(this.app.css.processnodemobile) } else { var size = this.app.content.getsize(); var nodesize = processnode.getsize(); var top = size.y / 2 - nodesize.y / 2 - 20; var left = size.x / 2 - nodesize.x / 2; if (top < 0) top = 0; this.app.css.processnode.top = "" top "px"; this.app.css.processnode.left = "" left "px"; var morph = new fx.morph(processnode, { "duration": 300, "transition": fx.transitions.expo.easeout }); morph.start(this.app.css.processnode); } }, confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) { mwf.require("mwf.xdesktop.dialog", function () { var size = this.container.getsize(); var x = 0; var y = 0; if (typeof(e) === "element") { var position = e.getposition(this.app.content); x = position.x; y = position.y; } else { if (browser.name == "firefox") { x = parsefloat(e.event.clientx || e.event.x); y = parsefloat(e.event.clienty || e.event.y); } else { x = parsefloat(e.event.x); y = parsefloat(e.event.y); } if (e.target) { var position = e.target.getposition(this.app.content); //var position = e.target.getposition(); x = position.x; y = position.y; } } // if (browser.platform.ios){ // $("textdiv").set("text", "$(document.body).getscroll().y: " $(document.body).getscroll().y); // y = y-$(document.body).getscroll().y; // } if (x parsefloat(width) > size.x) { x = x - parsefloat(width); } if (x < 0) x = 10; if (y parsefloat(height) > size.y) { y = y - parsefloat(height); } if (y < 0) y = 10; //var x = parsefloat((browser.name==="firefox") ? e.event.clientx : e.event.x); //var y = parsefloat((browser.name==="firefox") ? e.event.clienty : e.event.y); // if (x parsefloat(width)>size.x){ // x = x-parsefloat(width); // } if (x < 0) x = 20; if (!layout.mobile) { // pc上鼠标位置偏移20 x = x - 20 } var opt = { "title": title, "style": style || "o2", "top": y, "left": x, "fromtop": e.event.y, "fromleft": (browser.name === "firefox") ? e.event.clientx - 20 : e.event.x - 20, "width": width, "height": height, "container": this.app.content, "masknode": mask || this.app.content, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": ok }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": cancel } ] }; if (typeof(text).tolowercase() === "object") { if( text.html )opt.html = text.html; if( text.text )opt.text = text.text; } else { if( /<\/?[a-z][\s\s]*>/i.test(text||"")){ opt.html = text; }else{ opt.text = text } } var dlg = new mwf.xdesktop.dialog(opt); switch (type.tolowercase()) { case "success": if (this.json.confirmicon && this.json.confirmicon.success) { dlg.content.setstyle("background-image", ""); } else { dlg.content.setstyle("background-image", ""); } break; case "error": if (this.json.confirmicon && this.json.confirmicon.error) { dlg.content.setstyle("background-image", ""); } else { dlg.content.setstyle("background-image", ""); } break; case "info": if (this.json.confirmicon && this.json.confirmicon.info) { dlg.content.setstyle("background-image", ""); } else { dlg.content.setstyle("background-image", ""); } break; case "warn": if (this.json.confirmicon && this.json.confirmicon.warn) { dlg.content.setstyle("background-image", ""); } else { dlg.content.setstyle("background-image", ""); } break; default: if (this.json.confirmicon && this.json.confirmicon.warn) { dlg.content.setstyle("background-image", ""); } break; } dlg.show(); }.bind(this)); }, alert: function (type, title, text, width, height) { this.app.alert(type, "center", title, text, width, height); }, notice: function (content, type, target, where, offset, option) { if (!where) where = { "x": "right", "y": "top" }; //if (!target) target = this.node; if (!type) type = "ok"; var type2; switch (type) { case "warn": case "wran": type2 = "notice"; break; case "success": type2 = "ok"; break; default: type2 = type; } var noticetarget = target || ((layout.mobile && document && document.body) ? $(document.body) : this.app.window.content); var off = offset; if (!off) { off = { x: 10, y: where.y.tostring().tolowercase() == "bottom" ? 10 : 10 }; } var options = { type: type2, position: where, move: false, target: noticetarget, delayclose: (type === "error") ? 10000 : 5000, //delayclose: 20000000, offset: off, content: content } if (this.json.noticestyle) { options = object.merge(options, this.json.noticestyle); } if (this.json["notice" type2.capitalize() "style"]) { options = object.merge(options, this.json["notice" type2.capitalize() "style"]); } if (option && typeof(option) === "object") { options = object.merge(options, option); } new mbox.notice(options); }, dialog: function( options ){ if( !options )options = {}; var opts = { "style" : options.style || "user", "title": options.title || "", "width": options.width || 300, "height" : options.height || 150, "ismax": o2.typeof( options.ismax ) === "boolean" ? options.ismax : false, "isclose": o2.typeof( options.isclose ) === "boolean" ? options.isclose : true, "isresize": o2.typeof( options.isresize ) === "boolean" ? options.isresize : true, "ismove": o2.typeof( options.ismove ) === "boolean" ? options.ismove : true, "istitle": o2.typeof( options.istitle ) === "boolean" ? options.istitle : true, "offset": options.offset || null, "mask": o2.typeof( options.mask ) === "boolean" ? options.mask : true, "container": options.container || ( layout.mobile ? $(document.body) : this.app.content ), "duration": options.duration || 200, "lp": options.lp || null, "zindex": ( options.zindex || 100 ).toint(), "buttonlist": options.buttonlist || [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function(){ if(options.ok){ var flag = options.ok.call( this ); if( flag === true || o2.typeof(flag) === "null" )this.close(); }else{ this.close(); } } }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function(){ if(options.close){ var flag = options.close.call(this); if( flag === true || o2.typeof(flag) === "null" )this.close(); }else{ this.close(); } } } ] }; var positionnode; if( options.modulename ){ var module, name = options.modulename, subformname = options.subformname; if( subformname && this.all[subformname "_" name] ){ module = this.all[subformname "_" name]; }else{ module = this.all[name]; } if( module ){ opts.content = module.node; positionnode = new element("div", {style:"display:none;"}).inject( opts.content, "before" ); } }else if( options.content ) { opts.content = options.content; var parent = opts.content.getparent(); if(parent)positionnode = new element("div", {style:"display:none;"}).inject( opts.content, "before" ); } if( options.url )opts.url = options.url; if( options.html )opts.html = options.html; if( options.text )opts.text = options.text; opts.onqueryclose = function(){ if( positionnode && opts.content ){ opts.content.inject( positionnode, "after" ); positionnode.destroy(); } if( o2.typeof(options.onqueryclose) === "function" )options.onqueryclose.call( this ); } if(opts.onpostclose)opts.onpostclose = options.onpostclose; if(opts.onqueryload)opts.onqueryload = options.onqueryload; if(opts.onpostload)opts.onpostload = options.onpostload; if(opts.onqueryshow)opts.onqueryshow = options.onqueryshow; if(opts.onpostshow)opts.onpostshow = options.onpostshow; for( var key in options ){ if( !opts.hasownproperty( key ) ){ opts[key] = options[key]; } } var dialog; mwf.require("mwf.xdesktop.dialog", function(){ dialog = o2.dl.open(opts) }, null, false); return dialog; }, addsplit: function () { if (!this.businessdata.control["allowaddsplit"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } mwf.require("mwf.xdesktop.dialog", function () { var width = 600; var height = 330; var p = mwf.getcenterposition(this.app.content, width, height); var _self = this; var dlg = new mwf.xdesktop.dialog({ "title": this.app.lp.addsplit, //"style": "work"," "style": this.json.dialogstyle || "user", "top": p.y - 100, "left": p.x, "fromtop": p.y - 100, "fromleft": p.x, "width": width, "height": height, "url": this.app.path "split.html", "lp": mwf.xapplication.process.xform.lp.form, "container": this.app.content, "isclose": true, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { //this.doresetwork(dlg); var input = dlg.content.getelement("input"); var checks = dlg.content.getelements(".o2_addsplit_radio"); var value = input.get("value"); var trimexist = true; if (checks[1].checked) trimexist = false; var opinion=""; var textarea = dlg.content.getelement(".addsplit_opinion"); if(textarea)opinion = textarea.get("value"); _self.doaddsplit(dlg, value, trimexist, opinion); }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ], "onpostshow": function () { //var okbutton = dlg.content.getelement(".o2_addsplit_okbutton"); //var cancelbutton = dlg.content.getelement(".o2_addsplit_cancelbutton"); var selectbutton = dlg.content.getelement(".o2_addsplit_selector"); var input = dlg.content.getelement("input"); var checks = dlg.content.getelements(".o2_addsplit_radio"); //okbutton.addevent("click", function(){ // var value = input.get("value"); // var trimexist = true; // if (checks[1].checked) trimexist = false; // _self.doaddsplit(this, value, trimexist); //}.bind(this)); //cancelbutton.addevent("click", function(){ // this.close(); //}.bind(this)); selectbutton.addevent("click", function () { var value = input.get("value"); mwf.xdesktop.requireapp("selector", "package", function () { new o2.o2selector(_self.app.content, { "type": "", "count": 0, "values": (value) ? value.split(o2.splitstr) : [], "types": ["unit", "identity", "group", "role"], "oncomplete": function (items) { var v = []; items.each(function (item) { v.push(item.data.distinguishedname); }); input.set("value", v.join(", ")); } }); }.bind(this)); //_self.selectsplitunit(this); }.bind(this)); } }); dlg.show(); }.bind(this)); }, doaddsplit: function (dlg, splitvalues, trimexist, opinion) { if (!splitvalues) { this.app.notice(mwf.xapplication.process.xform.lp.inputsplitvalue, "error", dlg.node); return false; } mwf.require("mwf.widget.mask", function () { var splitvalue = splitvalues.split(o2.splitstr); var splittext = splitvalue.map(function (svalue) { return svalue.split("@")[0]; }) var routename = mwf.xapplication.process.xform.lp.form.split ":" splittext.join(", "); if(!opinion)opinion = routename; this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforeaddsplit"); if (this.app && this.app.fireevent) this.app.fireevent("beforeaddsplit"); this.addsplitwork(splitvalue, trimexist, function (json) { this.fireevent("afteraddsplit"); if (this.app && this.app.fireevent) this.app.fireevent("afteraddsplit"); this.addaddsplitmessage(json.data); // this.workaction.loadwork(function(workjson){ // this.fireevent("afteraddsplit"); // if (this.app && this.app.fireevent) this.app.fireevent("afteraddsplit"); // this.addaddsplitmessage(workjson.data); // }.bind(this), null, this.businessdata.work.id); dlg.close(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error", dlg.node); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), routename, opinion); }.bind(this)); }, addsplitwork: function (splitvalue, trimexist, success, failure, routename, opinion) { var data = { "splitvaluelist": splitvalue, "trimexist": trimexist, "routename": routename, "opinion": opinion }; if (this.options.readonly) { o2.actions.load("x_processplatform_assemble_surface").workaction.v2addsplit(this.businessdata.work.id, data, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); // this.workaction.addsplit( // function (json) { // if (success) success(json); // }.bind(this), // function (xhr, text, error) { // if (failure) failure(xhr, text, error); // }, // this.businessdata.work.id, data // ); } else { this.saveformdata( function (json) { o2.actions.load("x_processplatform_assemble_surface").workaction.v2addsplit(this.businessdata.work.id, data, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); // this.workaction.addsplit( // function (json) { // if (success) success(json); // }.bind(this), // function (xhr, text, error) { // if (failure) failure(xhr, text, error); // }, // this.businessdata.work.id, data // ); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, true, null, true ); } }, setrollbackchecked: function (item) { item.store("isselected", true); item.setstyles(this.css.rollbackitemnode_current); item.getfirst().setstyles(this.css.rollbackitemiconnode_current); var node = item.getlast().getfirst(); node.getfirst().setstyles(this.css.rollbackitemactivitynode_current); node.getlast().setstyles(this.css.rollbackitemtimenode_current); node = item.getlast().getlast(); node.getfirst().setstyles(this.css.rollbackitemtasktitlenode_current); node.getlast().setstyles(this.css.rollbackitemtaskbodynode_current); var checkeds = item.getelements("input"); if (checkeds){ checkeds.set("checked", true); checkeds.set("disabled", false); } }, setrollbackunchecked: function (item) { item.store("isselected", false); item.setstyles(this.css.rollbackitemnode); item.getfirst().setstyles(this.css.rollbackitemiconnode); var node = item.getlast().getfirst(); node.getfirst().setstyles(this.css.rollbackitemactivitynode); node.getlast().setstyles(this.css.rollbackitemtimenode); node = item.getlast().getlast(); node.getfirst().setstyles(this.css.rollbackitemtasktitlenode); node.getlast().setstyles(this.css.rollbackitemtaskbodynode); var checkeds = item.getelements("input"); if (checkeds) { checkeds.set("checked", false); checkeds.set("disabled", true); } }, getrollbacklogs: function (rollbackitemnode) { var _self = this; o2.actions.load("x_processplatform_assemble_surface").worklogaction.listrollbackwithworkorworkcompleted(this.businessdata.work.id, function (json) { json.data.each(function (log) { //if (!log.splitting && log.connected && (log.taskcompletedlist.length || log.readlist.length || log.readcompletedlist.length)) { if (!log.splitting && log.connected) { var node = new element("div", { "styles": this.css.rollbackitemnode }).inject(rollbackitemnode); node.store("log", log); var iconnode = new element("div", { "styles": this.css.rollbackitemiconnode }).inject(node); var contentnode = new element("div", { "styles": this.css.rollbackitemcontentnode }).inject(node); var div = new element("div", { "styles": { "overflow": "hidden" } }).inject(contentnode); var activitynode = new element("div", { "styles": this.css.rollbackitemactivitynode, "text": log.fromactivityname }).inject(div); var timenode = new element("div", { "styles": this.css.rollbackitemtimenode, "text": log.arrivedtime }).inject(div); div = new element("div", { "styles": { "overflow": "hidden" } }).inject(contentnode); var tasktitlenode = new element("div", { "styles": this.css.rollbackitemtasktitlenode, "text": this.app.lp.taskcompletedperson ": " }).inject(div); var taskbodynode = new element("div", { "styles": this.css.rollbackitemtaskbodynode }).inject(div); if (log.taskcompletedlist.length) { log.taskcompletedlist.each(function (o) { var itemnode = new element("div", { style: "float:left;overflow:hidden;" }).inject(taskbodynode); var vfor = math.random().tostring(); var text = o2.name.cn(o.person) "(" o.completedtime ")"; var check = new element("input", { "id": vfor, "value": o.identity, "type": "checkbox", "disabled": true, "styles": this.css.rollbackitemtaskchecknode }).inject(itemnode); check.addevent("click", function (e) { e.stoppropagation(); }); var tasknode = new element("label", { "styles": this.css.rollbackitemtasknode, "text": text, "for": vfor }).inject(itemnode); tasknode.addevent("click", function (e) { e.stoppropagation(); }); }.bind(this)); } else { var text = this.app.lp.systemflow; var tasknode = new element("div", { "styles": this.css.rollbackitemtasknode, "text": text }).inject(taskbodynode); } node.addevents({ "mouseover": function () { var isselected = this.retrieve("isselected"); if (!isselected) this.setstyles(_self.css.rollbackitemnode_over); }, "mouseout": function () { var isselected = this.retrieve("isselected"); if (!isselected) this.setstyles(_self.css.rollbackitemnode) }, "click": function () { var isselected = this.retrieve("isselected"); if (isselected) { _self.setrollbackunchecked(this); } else { var items = rollbackitemnode.getchildren(); items.each(function (item) { _self.setrollbackunchecked(item); }); _self.setrollbackchecked(this); } } }); } }.bind(this)); }.bind(this), null, false); }, rollback: function () { if (!this.businessdata.control["allowrollback"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } var lp = mwf.xapplication.process.xform.lp; var node = new element("div", { "styles": this.css.rollbackareanode }); var html = "
" lp.selectrollbackactivity "
"; //html = "
" lp.trytoprocess "
"; html = "
"; node.set("html", html); if( layout.mobile ){ node.getfirst().setstyle("float", "none"); node.getfirst().getnext().setstyle("float", "none"); } var rollbackitemnode = node.getlast(); this.getrollbacklogs(rollbackitemnode); node.inject(this.app.content); var dlg = o2.dl.open({ "title": this.app.lp.rollback, "style": this.json.dialogstyle || "user", "isresize": false, "content": node, "width": layout.mobile ? "100%" : 600, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { this.dorollback(node, e, dlg); }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ] }); }, dorollback: function (node, e, dlg) { var rollbackitemnode = node.getlast(); var items = rollbackitemnode.getchildren(); //var flowoption = (node.getelement(".rollback_flowoption").checked); var _self = this; for (var i = 0; i < items.length; i ) { if (items[i].retrieve("isselected")) { var text = this.app.lp.rollbackconfirmcontent; var log = items[i].retrieve("log"); var checks = items[i].getelements("input:checked"); var idlist = []; checks.each(function (check) { var id = check.get("value"); if (idlist.indexof(id) == -1) idlist.push(id); }); text = text.replace("{log}", log.fromactivityname "(" log.arrivedtime ")"); this.app.confirm("infor", e, this.app.lp.rollbackconfirmtitle, text, 450, 120, function () { _self.dorollbackaction(log.id, dlg, idlist, log); dlg.close(); this.close(); }, function () { this.close(); }, null, null, this.json.confirmstyle); break; } } }, dorollbackaction: function (log, dlg, idlist, logobj) { mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforerollback"); if (this.app && this.app.fireevent) this.app.fireevent("beforerollback"); this.dorollbackactioninvoke(log, idlist, function (json) { if (json.data.properties) { if (this.app && this.app.fireevent) this.app.fireevent("afterrollback"); this.addrollbackmessage(json.data); if (!this.app.inbrowser) this.app.close(); if (this.mask) { this.mask.hide(); this.mask = null; } } else { var id = json.data.id; this.workaction.listtaskbywork(function (workjson) { this.fireevent("afterrollback"); if (this.app && this.app.fireevent) this.app.fireevent("afterrollback"); this.addrollbackmessage_old(workjson.data); //this.app.notice(mwf.xapplication.process.xform.lp.rollbackok ": " mwf.name.cns(names).join(", "), "success"); //if (!this.app.inbrowser) this.app.close(); if (!this.app.inbrowser) this.app.close(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), null, id); } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error"); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), logobj); }.bind(this)); }, dorollbackactioninvoke: function (id, idlist, success, failure, logobj) { var opinion = mwf.xapplication.process.xform.lp.rollbackto ":" logobj.fromactivityname; if (this.businessdata.work.completedtime) { var method = "rollbackworkcompleted"; o2.actions.get("x_processplatform_assemble_surface")[method](this.businessdata.work.id, { "worklog": id, "distinguishednamelist": idlist, //"processing": !!flowoption, "opinion": opinion }, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error) }.bind(this)); } else { var body = { "worklog": id, "distinguishednamelist": idlist, //"processing": !!flowoption, "opinion": opinion } o2.actions.load("x_processplatform_assemble_surface").workaction.v2rollback(this.businessdata.work.id, body, function (json) { //o2.actions.get("x_processplatform_assemble_surface")[method](this.businessdata.work.id, { "worklog": id }, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error) }.bind(this)); } }, inbrowserdkg: function (content, notclosewindow) { if (this.mask) this.mask.hide(); if (this.json.submiteddlgusenotice) { mwf.xdesktop.notice("success", { x: "right", y: "top" }, content); if (this.json.isprompt !== false) { if (this.json.promptclosetime != 0) { var t = this.json.promptclosetime || 2; t = t.toint() * 1000; var _work = this; window.settimeout(function () { _work.app.close(); }, t); } } else { this.app.close(); } } else { var div = new element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden" } }).inject(this.app.content); div.set("html", content); if (this.json.isprompt !== false) { var options = { "content": div, "istitle": false, "width": 350, "height": 180, "buttonlist": [ { "text": mwf.xapplication.process.xform.lp.ok, "action": function () { dlg.close(); this.app.close(); }.bind(this) } ] } var size = this.app.content.getsize(); switch (this.json.promptposition || "righttop") { case "lefttop": options.top = 10; options.left = 10; options.fromtop = 10; options.fromleft = 10; break; case "righttop": options.top = 10; options.left = size.x - 360; options.fromtop = 10; options.fromleft = size.x - 10; break; case "leftbottom": options.top = size.y - 190; options.left = 10; options.fromtop = size.y - 10; options.fromleft = 10; break; case "rightbottom": options.top = size.y - 190; options.left = size.x - 360; options.fromtop = size.y - 10; options.fromleft = size.x - 10; break; default: delete options.top; delete options.left; delete options.fromtop; delete options.fromleft; } var dlg = o2.dl.open(options); if (this.json.promptclosetime != 0) { var t = this.json.promptclosetime || 2; t = t.toint() * 1000; var _work = this; window.settimeout(function () { dlg.close(); if (notclosewindow){ window.location.reload(); }else{ _work.app.close(); } }, t); } } else { if (notclosewindow){ window.location.reload(); }else{ this.app.close(); } } } }, addrollbackmessage_old: function (data) { var users = []; data.each(function (task) { users.push(mwf.name.cn(task.person) "(" mwf.name.cn(task.unit) ")"); }.bind(this)); var content = "
" mwf.xapplication.process.xform.lp.currentactivity "" o2.txt(data[0].activityname) ", " mwf.xapplication.process.xform.lp.nextuser "" users.join(", ") "
"; if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.workrollback, "content": "
" mwf.xapplication.process.xform.lp.rollbackworkinfor "“" o2.txt(this.businessdata.work.title) "”
" content }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg("
" mwf.xapplication.process.xform.lp.rollbackworkinfor "“" o2.txt(this.businessdata.work.title) "”
" content); } } }, addrollbackmessage: function (data) { if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.workrollback, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.rollbackworkinfor) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.rollbackworkinfor)); } } }, /** * 需要判断权限 * @summary 给待办人发送提醒(催促办理). * @example * if( this.workcontext.getcontrol().allowpress ){ //判断流程节点是否设置了催办并且当前人员是否有催办权限 * this.form.getapp().appform.presswork(); * } */ presswork: function (e) { if (e && e.setdisable) e.setdisable(true); o2.actions.get("x_processplatform_assemble_surface").press(this.businessdata.work.id, function (json) { var users = o2.name.cns(json.data.valuelist).join(", "); this.app.notice(mwf.xapplication.process.xform.lp.sendtasknotice.replace("{users}", users), "success"); if (e && e.setdisable) e.setdisable(false); }.bind(this), function (xhr, text, error) { //e.setdisable(false); if (xhr.status != 0) { var errortext = error; if (xhr) { var json = json.decode(xhr.responsetext); if (json) { errortext = json.message.trim() || "request json error"; } else { errortext = "request json error: " xhr.responsetext; } } mwf.xdesktop.notice("error", { x: "right", y: "top" }, errortext); } }); }, /** * @summary 退回到之前流转过的活动(根据活动配置列出可退回的活动). * @example * this.form.getapp().appform.goback(); */ goback: function(){ if (!this.businessdata.control["allowgoback"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if( !this.businessdata.task ){ mwf.xdesktop.notice("error", { x: "right", y: "top" }, mwf.xapplication.process.xform.lp.form.notasktoreset); return false; } if (!this.checkuploadattachment()) return false; o2.actions.load('x_processplatform_assemble_surface').workaction.v2listactivitygoback(this.businessdata.task.work, function(json){ var activitys = json.data; // var activitys = [{ // name: "拟稿", // activity: "123", // way: "custom", // lastmodifytime: "2023-01-23 12:34:12", // lastidentitylist: ["张三", "李四"], // activitytokenlist: ["", ""] // },{ // name: "拟稿", // activity: "345", // way: "jump", // lastmodifytime: "2023-01-23 12:34:12", // lastidentitylist: ["王五六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六"], // activitytokenlist: ["", ""] // }]; if (activitys.length){ var h = this.app.content.getsize().y*0.7-271; var size = activitys.length*61; h = (size"}).inject(item); var radio = itemcheck.getelement('input'); var itemcontent = new element('div', {styles: this.css.goback_activity_content}).inject(item); var html = activity.name "(" activity.lastmodifytime ")" var itemname = new element('div', {styles: this.css.goback_activity_name, html: html}).inject(itemcontent); var ids = o2.name.cns(activity.lastidentitylist); var idsstr = (ids.length>8) ? ids.slice(0,8).join(', ') ' ...' : ids.join(', '); var iteminfo = new element('div', {styles: this.css.goback_activity_info, text: '处理人:' idsstr, title: ids.join(',')}).inject(itemcontent); item.addevent("click", function(e){ // var radio = this.getprevious('div').getelement('input'); var radio = this.getelement('input'); radio.click(); var items = area.getelements(".item"); items.each(function(i){ var actradio = i.getfirst().getelement('input'); var wayarea = i.getlast().getfirst(); if (actradio.checked){ wayarea.show(); i.addclass('lightcolor_bg'); }else{ wayarea.hide(); i.removeclass('lightcolor_bg'); } }); }); var wayradio = "
"; if (activity.way==="custom"){ wayradio = "
" "
" } var itemway = new element('div', {styles: this.css.goback_activity_way, html:wayradio}).inject(item); itemway.getfirst().hide(); }, dogoback: function(dlg, activitys){ var node = dlg.node; debugger; var check = node.queryselector('input[name="gobackactivity"]:checked'); if (!check) { this.app.notice(mwf.xapplication.process.xform.lp.form.selectgobackactivity, "error", dlg.node); return false; } var waynode = check.getparent().getparent().getlast().getfirst(); // var waynode = node.getelement('.item').getlast().getfirst(); var waychecknode = waynode.queryselector('input:checked'); var opinionnode = node.queryselector('textarea'); var activity = check.value; var way = (waychecknode) ? waychecknode.value : waynode.value; var opinion = opinionnode.value || o2.xapplication.process.xform.lp.form.gobackto check.dataset.text; var decision = o2.xapplication.process.xform.lp.form.goback; this.businessdata.task.decision = decision; this.businessdata.task.opinion = opinion; this.businessdata.task.action = "goback"; this.businessdata.task.option = { "activity": activity, "way": way } this.submitwork(decision, opinion, null, function () { dlg.close(); }.bind(this)); }, /** * @summary 将待办设置为挂起状态,不计算工作时长. * @example * this.form.getapp().appform.pausetask(); */ pausetask: function (e) { if (!this.businessdata.control["allowpause"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if (this.businessdata.task){ if (e && e.disable) e.disable(true); return o2.actions.get("x_processplatform_assemble_surface").pausetask(this.businessdata.task.id, function (json) { this.app.notice(mwf.xapplication.process.xform.lp.pausework, "success"); this.businessdata.control["allowresume"] = true; if (e && e.enable) e.enable(false); }.bind(this), function (xhr, text, error) { //e.setdisable(false); if (xhr.status != 0) { var errortext = error; if (xhr) { var json = json.decode(xhr.responsetext); if (json) { errortext = json.message.trim() || "request json error"; } else { errortext = "request json error: " xhr.responsetext; } } mwf.xdesktop.notice("error", { x: "right", y: "top" }, errortext); } }); } }, /** * @summary 将待办从挂起状态恢复为正常状态. * @example * this.form.getapp().appform.resumetask(); */ resumetask: function (e) { if (!this.businessdata.control["allowresume"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if (this.businessdata.task){ if (e && e.disable) e.disable(true); return o2.actions.get("x_processplatform_assemble_surface").resumetask(this.businessdata.task.id, function (json) { this.app.notice(mwf.xapplication.process.xform.lp.resumework, "success"); this.businessdata.control["allowpause"] = true; if (e && e.enable) e.enable(false); }.bind(this), function (xhr, text, error) { //e.setdisable(false); if (xhr.status != 0) { var errortext = error; if (xhr) { var json = json.decode(xhr.responsetext); if (json) { errortext = json.message.trim() || "request json error"; } else { errortext = "request json error: " xhr.responsetext; } } mwf.xdesktop.notice("error", { x: "right", y: "top" }, errortext); } }); } }, downloadall: function () { var htmlformid = ""; o2.actions.load("x_processplatform_assemble_surface").attachmentaction.uploadworkinfo(this.businessdata.work.id, "pdf", { "workhtml": encodeuricomponent(this.app.content.get("html")), "pagewidth": 1000 }, function (json) { htmlformid = json.data.id; }.bind(this), null, false); htmlformid = htmlformid.replace("#", "#"); var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" this.businessdata.work.id "/site/(0)/stream"; url = o2.filter url); var downloadurl = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; downloadurl = "&" o2.tokenname "=" xtoken; } window.open(downloadurl); }, monitor: function () { var node = new element("div"); var container = new element("div").inject(node); var monitor; var monitordlg = o2.dl.open({ "title": mwf.xapplication.process.xform.lp.monitor, "width": "1100", "isresize" : true, "height" : "720px", "maxheightpercent" : "98%", "mask": true, "ismax" : true, "content": node, "container": this.app.content, "masknode": this.app.content, "onqueryclose": function(){ }.bind(this), "buttonlist": [ { "text": mwf.xapplication.process.xform.lp.close, "action": function(){ monitordlg.close(); }.bind(this) } ], "onmax" : function(){ monitor.logprocesschartnode.setstyle("height",this.contentheight "px"); monitor.papernode.setstyle("height",(this.contentheight - 60) "px"); }, "onrestore" : function(){ monitor.logprocesschartnode.setstyle("height",this.contentheight "px"); monitor.papernode.setstyle("height",(this.contentheight - 60) "px"); }, "onpostshow": function(){ var dlg = monitordlg; var size = dlg.content.getsize(); dlg.options.contentwidth = size.x; dlg.options.contentheight = size.y; // 100; dlg.setcontentsize(); dlg.node.setstyles({ "height": "" dlg.options.height "px", "width": "" (dlg.options.width) "px" }); dlg.recenter(); dlg.content.setstyle("overflow","hidden"); mwf.xdesktop.requireapp("process.xform", "widget.monitor", null, false); var process = (this.businessdata.work) ? this.businessdata.work.process : this.businessdata.workcompleted.process; monitor = new mwf.xapplication.process.xform.widget.monitor(container, this.businessdata.workloglist, [],process,{ onpostload : function(){ monitor.papernode.setstyles({ "box-shadow":"none", "margin-bottom" : "0px" }); var logprocesschartnode = monitor.logprocesschartnode; logprocesschartnode.setstyle("border","0px"); logprocesschartnode.setstyle("height",(size.y) "px"); monitor.papernode.setstyle("height",(size.y-48) "px"); }.bind(this) }); }.bind(this) }); }, resetwork: function () { if (!this.businessdata.control["allowreset"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if (!this.checkuploadattachment()) return false; if( !this.businessdata.task ){ mwf.xdesktop.notice("error", { x: "right", y: "top" }, mwf.xapplication.process.xform.lp.form.notasktoreset); return false; } mwf.require("mwf.xdesktop.dialog", function () { var width = 680; var height = 300; var p; if(!layout.mobile)p = mwf.getcenterposition(this.app.content, width, height); var _self = this; o2.dl.open({ "title": this.app.lp.reset, "style": this.json.dialogstyle || "user", //|| "work", "top": (layout.mobile) ? 0 : (p.y - 100), "left": (layout.mobile) ? 0 : p.x, "fromtop": (layout.mobile) ? 0 : (p.y - 100), "fromleft": (layout.mobile) ? 0 : p.x, "width": (layout.mobile) ? "100%" : width, "height": (layout.mobile) ? "100%" : height, "url": this.app.path ( (layout.mobile) ? "resetmobile" : "reset") ".html", "lp": mwf.xapplication.process.xform.lp.form, "container": (layout.mobile) ? document.body : this.app.content, "isclose": !(layout.mobile), "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { _self.doresetwork(this); } }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { this.close(); } } ], "onpostshow": function () { //$("resetwork_okbutton").addevent("click", function(){ // _self.doresetwork(this); //}.bind(this)); //$("resetwork_cancelbutton").addevent("click", function(){ // this.close(); //}.bind(this)); $("resetwork_selpeoplebutton").addevent("click", function () { _self.selectpeople(this); }.bind(this)); } }); }.bind(this)); }, selectpeople: function(dlg){ // o2.actions.get("x_processplatform_assemble_surface").listtaskbywork(this.businessdata.work.id, function(json){ var identitylist = []; // json.data.each(function(task){ // identitylist.push(task.identity); // }); this._selectpeople(dlg, identitylist); // }.bind(this)) }, _selectpeople: function (dlg, exclude) { var range = this.businessdata.activity.resetrange || "department"; var count = this.businessdata.activity.resetcount || 0; switch (range) { case "unit": this.selectpeopleunit(dlg, this.businessdata.task.unitdn, count, null, exclude); // this.personactions.getdepartmentbyidentity(function(json){ // this.selectpeopledepartment(dlg, json.data, count); // }.bind(this), null, this.businessdata.task.identity); break; case "topunit": mwf.require("mwf.xscript.actions.unitactions", function () { orgactions = new mwf.xscript.actions.unitactions(); var data = { "unitlist": [this.businessdata.task.unitdn] }; orgactions.listunitsupnested(data, function (json) { v = json.data[0]; this.selectpeopleunit(dlg, v, count, null, exclude); }.bind(this)); }.bind(this)); // this.personactions.getcompanybyidentity(function(json){ // this.selectpeoplecompany(dlg, json.data, count) // }.bind(this), null, this.businessdata.task.identity); break; case "script": o2.actions.load("x_processplatform_assemble_surface").processaction.getactivity(this.businessdata.work.activity, "manual", function (activityjson) { var scripttext = activityjson.data.activity.resetrangescripttext; if (!scripttext) return; var resetrange = this.macro.exec(activityjson.data.activity.resetrangescripttext, this); this.selectpeopleunit(dlg, "", count, resetrange, exclude); }.bind(this)) break; default: this.selectpeopleall(dlg, count); } }, selectpeopleunit: function (dlg, unit, count, include, exclude) { var names = dlg.identitylist || []; var areanode = $("resetwork_selpeoplearea"); var options = { "values": names, "type": "identity", "count": count, "units": (unit) ? [unit] : [], "oncomplete": function (items) { areanode.empty(); var identitylist = []; items.each(function (item) { new mwf.widget.o2identity(item.data, areanode, { "style": "reset" }); identitylist.push(item.data.distinguishedname); }.bind(this)); dlg.identitylist = identitylist; }.bind(this) }; if (include) { options.nounit = true; options.include = typeof(include) === "array" ? include : [include]; } if( exclude ){ options.exclude = exclude; } mwf.xdesktop.requireapp("selector", "package", function () { var selector = new mwf.o2selector(this.app.content, options); }.bind(this)); }, selectpeopleall: function (dlg, count) { var names = dlg.identitylist || []; var areanode = $("resetwork_selpeoplearea"); var options = { "values": names, "type": "identity", "count": count, "oncomplete": function (items) { areanode.empty(); var identitylist = []; items.each(function (item) { new mwf.widget.o2identity(item.data, areanode, { "style": "reset" }); identitylist.push(item.data.distinguishedname); }.bind(this)); dlg.identitylist = identitylist; }.bind(this) }; mwf.xdesktop.requireapp("selector", "package", function () { var selector = new mwf.o2selector(this.app.content, options); }.bind(this)); }, doresetwork: function (dlg) { var names = dlg.identitylist || []; if (!names.length) { this.app.notice(mwf.xapplication.process.xform.lp.inputresetpeople, "error", dlg.node); return false; } var opinion = $("resetwork_opinion").get("value"); // var checkbox = dlg.content.getelement(".resetwork_keepoption"); // var keep = (checkbox.checked); mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforereset"); if (this.app && this.app.fireevent) this.app.fireevent("beforereset"); this.resetworktopeson(names, opinion, "", function (workjson) { //this.workaction.loadwork(function (workjson) { this.fireevent("afterreset"); if (this.app && this.app.fireevent) this.app.fireevent("afterreset"); this.addresetmessage(workjson.data); //this.app.notice(mwf.xapplication.process.xform.lp.resetok ": " mwf.name.cns(names).join(", "), "success"); if (!this.app.inbrowser) this.app.close(); //}.bind(this), null, this.businessdata.work.id); dlg.close(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error", dlg.node); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this)); }.bind(this)); //var data = { // "opinion": opinion, // "routename": mwf.xapplication.process.xform.lp.reset, // "identitylist": names //} // //this.workaction.resetwork(function(json){ // //}.bind(this), null, this.businessdata.task.id, data); }, resetworktopeson: function (identitylist, opinion, routename, success, failure) { var nametext = []; (identitylist || []).each(function (n) { nametext.push(mwf.name.cn(n)); }); if (!opinion) { opinion = mwf.xapplication.process.xform.lp.resetto ": " nametext.join(", "); } var n = nametext.length > 3 ? (nametext[0] "、" nametext[1] "、" nametext[2] "...") : nametext.join(", "); if(!routename)routename = mwf.xapplication.process.xform.lp.resetto ":" n; var data = { "opinion": opinion, "routename": routename, "identitylist": identitylist, //"keep": !!keep }; this.saveformdata( function (json) { o2.actions.load("x_processplatform_assemble_surface").taskaction.v2reset( //this.workaction.resetwork( function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.task.id, data ); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, true, null, true ); }, addaddsplitmessage: function (data) { // var content = ""; // if (data && data.length) { // data.each(function (work) { // var users = []; // work.tasklist.each(function (task) { // users.push(mwf.name.cn(task.person) "(" mwf.name.cn(task.unit) ")"); // }.bind(this)); // content = "
" mwf.xapplication.process.xform.lp.nextactivity "" work.activityname ", " mwf.xapplication.process.xform.lp.nextuser "" users.join(", ") "
"; // }.bind(this)); // } else { // content = mwf.xapplication.process.xform.lp.workcompleted; // } if (layout.desktop.message) { //var content = "
" mwf.xapplication.process.xform.lp.currentactivity "" data.work.activityname ", " mwf.xapplication.process.xform.lp.nextuser "" users.join(", ") "
"; var msg = { "subject": mwf.xapplication.process.xform.lp.addsplitwork, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.addsplitworkinfor) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.addsplitworkinfor)); } } }, addresetmessage: function (data) { // var content = ""; // if (data.completed){ // content = mwf.xapplication.process.xform.lp.workcompleted; // }else{ // if (data.properties.nextmanuallist && data.properties.nextmanuallist.length){ // var activityusers = []; // data.properties.nextmanuallist.each(function(a){ // var ids = []; // a.taskidentitylist.each(function(i){ // ids.push(o2.name.cn(i)) // }); // var t = "" mwf.xapplication.process.xform.lp.nextactivity "" a.activityname "" mwf.xapplication.process.xform.lp.nextuser "" ids.join(",") ""; // activityusers.push(t); // }); // content = activityusers.join("
"); // }else{ // content = mwf.xapplication.process.xform.lp.taskcompleted; // } // } if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.workreset, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.resetworkinfor) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.resetworkinfor)); } } }, retractwork: function (e, ev) { var _self = this; if (this.json.mode == "mobile") { //window.confirm 在ios移动端不可用 ?? // if (window.confirm(mwf.xapplication.process.xform.lp.retracttext)) { var p = mwf.getcenterposition(document.body, 300, 150); console.log("position x:" p.x " , y:" p.y); var x = p.x; if (p.x < 20) { x = 20; } else { x = p.x; } var event = { "event": { "x": x, "y": p.y - 200, "clientx": x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.process.xform.lp.retracttitle, mwf.xapplication.process.xform.lp.retracttext, 300, 120, function () { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforeretract"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforeretract"); _self.doretractwork(function () { //_self.workaction.getjobbywork(function(workjson){ _self.fireevent("afterretract"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterretract"); _self.app.notice(mwf.xapplication.process.xform.lp.workretract, "success"); _self.app.content.unmask(); if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.finishonmobile(); }.bind(this), function (xhr, text, error) { _self.app.content.unmask(); var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }); }.bind(this)); }, function () { this.close(); }, null, null, this.json.confirmstyle); } else { var p = mwf.getcenterposition(this.app.content, 300, 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.process.xform.lp.retracttitle, mwf.xapplication.process.xform.lp.retracttext, 300, 120, function () { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforeretract"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforeretract"); _self.doretractwork(function (json) { //_self.workaction.getjobbywork(function(workjson){ _self.fireevent("afterretract"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterretract"); //_self.addretractmessage(json.data); _self.app.notice(mwf.xapplication.process.xform.lp.workretract, "success"); _self.app.content.unmask(); if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.app.reload(); //}, null, _self.businessdata.work.id); this.close(); }.bind(this), function (xhr, text, error) { _self.app.content.unmask(); var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }); }.bind(this)); //this.close(); }, function () { this.close(); }, null, null, this.json.confirmstyle); } }, doretractwork: function (success, failure) { if (this.businessdata.control["allowretract"]) { o2.actions.load("x_processplatform_assemble_surface").workaction.v2retract(this.businessdata.work.id, null, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); // this.workaction.retractwork(function (json) { // if (success) success(); // }.bind(this), function (xhr, text, error) { // if (failure) failure(xhr, text, error); // }, this.businessdata.work.id); } else { if (failure) failure(null, "permission denied", ""); } }, addretractmessage: function (data) { // var users = []; // data.tasklist.each(function (task) { // users.push(mwf.name.cn(task.person) "(" mwf.name.cn(task.unit) ")"); // }.bind(this)); // var content = "
" mwf.xapplication.process.xform.lp.currentactivity "" data.work.activityname ", " mwf.xapplication.process.xform.lp.nextuser "" users.join(", ") "
"; if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.workretract, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.retractworkinfor) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.retractworkinfor)); } } }, /** * 如果当前人员没有调度权限或者流程节点未配置调度,则提醒permission denied. * @summary 弹出调度界面 * @example * this.form.getapp().appform.reroutework(); */ reroutework: function (e, ev) { if (!this.businessdata.control["allowreroute"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if (!this.checkuploadattachment()) return false; mwf.require("mwf.xdesktop.dialog", function () { var width = 660; var height = 350; var p = mwf.getcenterposition(this.app.content, width, height); var _self = this; var dlg = new mwf.xdesktop.dialog({ "title": this.app.lp.reroute, "style": this.json.dialogstyle || "user", //|| "work", "top": p.y - 100, "left": p.x, "fromtop": p.y - 100, "fromleft": p.x, "width": width, "height": height, "url": this.app.path "reroute.html", "lp": mwf.xapplication.process.xform.lp.form, "container": this.app.content, "isclose": true, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { _self.doreroutework(dlg); }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ], "onpostshow": function () { o2.actions.load("x_processplatform_assemble_surface").jobaction.findworkworkcompleted( _self.businessdata.work.job, function(json){ if( json.data.worklist && json.data.worklist.length > 1 ){ var checkbox = this.node.getelement(".reroutework_mergework"); if(checkbox)checkbox.getparent().getparent().show(); } }.bind(this)); var select = $("reroutework_selectactivity"); var createactivityoption = function(list, name){ list.each(function (activity) { var activitytype = name.replace("list", ""); new element("option", { "value": activity.id "#" activitytype, "text": activity.name }).inject(select); }.bind(_self)); } _self.workaction.getrerouteto(_self.businessdata.work.process, function (json) { [ "agentlist", "cancellist", "choicelist", "delaylist", "embedlist", "publishlist", "endlist", "invokelist", "manuallist", "mergelist", "parallellist", "servicelist", "splitlist" ].foreach(function(name){ createactivityoption(json.data[name], name); }); }.bind(_self)); var selpeoplebutton = this.content.getelement(".reroutework_selpeoplebutton"); selpeoplebutton.addevent("click", function () { _self.selectreroutepeople(this); }.bind(this)); } }); dlg.show(); }.bind(this)); }, selectreroutepeople: function (dlg) { var names = dlg.identitylist || []; var areanode = dlg.content.getelement(".reroutework_selpeoplearea"); var options = { "values": names, "type": "identity", "count": 0, "title": this.app.lp.reroute, "oncomplete": function (items) { areanode.empty(); var identitylist = []; items.each(function (item) { new mwf.widget.o2identity(item.data, areanode, { "style": "reset" }); identitylist.push(item.data.distinguishedname); }.bind(this)); dlg.identitylist = identitylist; }.bind(this) }; mwf.xdesktop.requireapp("selector", "package", function () { var selector = new mwf.o2selector(this.app.content, options); }.bind(this)); }, doreroutework: function (dlg) { var opinion = $("reroutework_opinion").get("value"); var select = $("reroutework_selectactivity"); debugger; var checkbox = dlg.node.getelement(".reroutework_mergework"); var mergework = !!(checkbox && checkbox.checked); var activity = select.options[select.selectedindex].get("value"); var activityname = select.options[select.selectedindex].get("text"); var tmp = activity.split("#"); activity = tmp[0]; var type = tmp[1]; var namearr = []; var names = dlg.identitylist || []; names.each(function (n) { namearr.push(n); }); var namecns = names.map(function(id){ return o2.name.cn(id); }); var routename = mwf.xapplication.process.xform.lp.rerouteto activityname; if( namearr.length ){ routename = ":" namecns.join(", "); } if( !opinion )opinion = routename; //var nametext = namearr.join(", "); // if (!opinion) { // opinion = mwf.xapplication.process.xform.lp.resetto ": " nametext.join(", "); // } mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforereroute"); if (this.app && this.app.fireevent) this.app.fireevent("afterretract"); this.rerouteworktoactivity(activity, type, opinion, namearr, function (workjson) { //this.workaction.loadwork(function (workjson) { this.fireevent("afterreroute"); if (this.app && this.app.fireevent) this.app.fireevent("afterreroute"); this.addreroutemessage(workjson.data); this.app.notice(mwf.xapplication.process.xform.lp.rerouteok ": " activityname, "success"); if (!this.app.inbrowser) this.app.close(); //}.bind(this), null, this.businessdata.work.id); dlg.close(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error", dlg.node); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), mergework, routename); }.bind(this)); }, rerouteworktoactivity: function (activity, type, opinion, namearr, success, failure, mergework, routename) { var body = { "activity": activity, "activitytype": type, "mergework": mergework || false, "distinguishednamelist": namearr, "routename": routename, "opinion": opinion }; if (this.businessdata.task) { this.saveformdata(function (json) { o2.actions.load("x_processplatform_assemble_surface").workaction.v2reroute(this.businessdata.work.id, body, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); // this.workaction.reroutework(function (json) { // if (success) success(); // }.bind(this), function (xhr, text, error) { // if (failure) failure(xhr, text, error); // }, this.businessdata.work.id, activity, type); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, true, null, true); } else { o2.actions.load("x_processplatform_assemble_surface").workaction.v2reroute(this.businessdata.work.id, body, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); // this.workaction.reroutework(function (json) { // if (success) success(); // }.bind(this), function (xhr, text, error) { // if (failure) failure(xhr, text, error); // }, this.businessdata.work.id, activity, type); } }, addreroutemessage: function (data) { if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.workreroute, "content": this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.rerouteworkinfor) }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.rerouteworkinfor)); } } }, deletedraftwork: function () { var _self = this; if (this.json.mode === "mobile") { var p = mwf.getcenterposition(document.body, 300, 150); console.log("position x:" p.x " , y:" p.y); var x = p.x; if (p.x < 20) { x = 20; } else { x = p.x; } var event = { "event": { "x": x, "y": p.y - 200, "clientx": x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.process.xform.lp.deleteworktitle, mwf.xapplication.process.xform.lp.deleteworktext.text, 300, 120, function () { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); // if (window.confirm(mwf.xapplication.process.xform.lp.deleteworktext.text)) { mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.dodeletework(function () { _self.app.notice(mwf.xapplication.process.xform.lp.workdelete ": “" _self.businessdata.work.title "”", "success"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.finishonmobile() }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); }, function () { this.close(); }, null, null, this.json.confirmstyle); } else { 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.process.xform.lp.deleteworktitle, mwf.xapplication.process.xform.lp.deleteworktext, 380, 120, function () { mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.dodeletework(function () { _self.app.notice(mwf.xapplication.process.xform.lp.workdelete ": “" _self.businessdata.work.title "”", "success"); _self.app.close(); this.close(); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); }, function () { this.close(); }, null, this.app.content, this.json.confirmstyle); } }, deletework: function () { if (!this.businessdata.work.starttime) { this.deletedraftwork(); } else { var _self = this; if (this.json.mode === "mobile") { var p = mwf.getcenterposition(document.body, 300, 150); console.log("position x:" p.x " , y:" p.y); var x = p.x; if (p.x < 20) { x = 20; } else { x = p.x; } var event = { "event": { "x": x, "y": p.y - 200, "clientx": x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.process.xform.lp.deleteworktitle, mwf.xapplication.process.xform.lp.deleteworktext.text, 300, 120, function () { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); // if (window.confirm(mwf.xapplication.process.xform.lp.deleteworktext.text)) { mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforedelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforedelete"); _self.dodeletework(function () { _self.fireevent("afterdelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterdelete"); _self.app.notice(mwf.xapplication.process.xform.lp.workdelete ": “" _self.businessdata.work.title "”", "success"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.finishonmobile() }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", dlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); }, function () { this.close(); }, null, this.app.content, this.json.confirmstyle); } else { 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.process.xform.lp.deleteworktitle, mwf.xapplication.process.xform.lp.deleteworktext, 380, 120, function () { // _self.app.content.mask({ // "style": { // "background-color": "#999", // "opacity": 0.6 // } // }); mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforedelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforedelete"); _self.dodeletework(function () { _self.fireevent("afterdelete"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterdelete"); _self.app.notice(mwf.xapplication.process.xform.lp.workdelete ": “" _self.businessdata.work.title "”", "success"); _self.app.close(); this.close(); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", dlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); //_self.workaction.deletework(function(json){ // _self.app.notice(mwf.xapplication.process.xform.lp.workdelete ": “" _self.businessdata.work.title "”", "success"); // _self.app.close(); // this.close(); //}.bind(this), null, _self.businessdata.work.id); //this.close(); }, function () { this.close(); }, null, this.app.content, this.json.confirmstyle); } } }, dodeletedraftwork: function (success, failure) { this.workaction.deletedraftwork(function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.work.id); }, dodeletework: function (success, failure) { if (!this.businessdata.work.starttime) { this.dodeletedraftwork(success, failure); } else { if (this.businessdata.control["allowdelete"]) { //this.workaction.deletework(function (json) { this.workaction.abandoned(function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.work.id); //} }else { if (failure) failure(null, "permission denied", ""); } } }, //printwork: function(){ // var form = this.json.id; // if (this.json.printform){ // form = this.json.printform; // } // window.open("../x_desktop/printwork.html?workid=" this.businessdata.work.id "&app=" this.businessdata.work.application "&form=" form); //}, printwork: function (app, form) { var application = app || (this.businessdata.work) ? this.businessdata.work.application : this.businessdata.workcompleted.application; var form = form; if (!form || form === "none") { form = this.json.id; if (this.json.printform && this.json.printform!=="none" ) form = this.json.printform; } if (this.businessdata.workcompleted) { var application = app || this.businessdata.workcompleted.application; var url = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; url = "&" o2.tokenname "=" xtoken; } window.open(url); } else { var application = app || this.businessdata.work.application; var url = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; url = "&" o2.tokenname "=" xtoken; } window.open(url); } }, /** * @summary 将当前处理人的待阅设置为已阅. * @param {event|element} [e] - event 或者mootools element,指定提示框弹出的位置 * @example * if( this.workcontext.getcontrol().allowreadprocessing ){ //是否有待阅 * this.form.getapp().appform.readedwork(); * } */ readedwork: function (e) { if (!this.businessdata.control["allowreadprocessing"]) { mwf.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } mwf.require("mwf.xdesktop.dialog", function () { // 判断是否在移动端 var content = layout.mobile ? $(document.body) : this.app.content || $(document.body); var size = content.getsize(); var width = 680; var height = 300; if (layout.mobile) { width = size.x - 40; } var p = mwf.getcenterposition(content, width, height); var _self = this; //"您确定要将“" title "”标记为已阅吗?"; var title = this.businessdata.work.title; var text = mwf.xapplication.process.xform.lp.setreadedconfirmcontent.replace("{title}",title); mwf.xapplication.process.xform.lp.form.setreadedconfirminfo = text; var dlg = new mwf.xdesktop.dialog({ "title": mwf.xapplication.process.xform.lp.setreadedconfirmtitle, "style": this.json.dialogstyle || "user", //|| "work", "top": layout.mobile ? p.y : p.y - 100, "left": p.x, "fromtop": layout.mobile ? p.y : p.y - 100, "fromleft": p.x, "width": width, "height": height, "url": this.app.path ( layout.mobile ? "readedmobile.html" : "readed.html" ), "lp": mwf.xapplication.process.xform.lp.form, "container": layout.mobile ? content : this.app.content, "isclose": true, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { this.doreadedwork(dlg); }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ] }); dlg.show(); }.bind(this)); // if( !e )e = new event(event); // this.fireevent("beforereaded"); // var _self = this; // var title = this.businessdata.work.title; // if (title.length > 75) { // title = title.substr(0, 74) "..." // } // //"您确定要将“" title "”标记为已阅吗?"; // var text = mwf.xapplication.process.xform.lp.setreadedconfirmcontent.replace("{title}",title); // // this.app.confirm("infor", e, mwf.xapplication.process.xform.lp.setreadedconfirmtitle, text, 300, 120, function () { // var confirmdlg = this; // var read = null; // for (var i = 0; i < _self.businessdata.readlist.length; i ) { // if (_self.businessdata.readlist[i].person === layout.session.user.distinguishedname) { // read = _self.businessdata.readlist[i]; // break; // } // } // // if (read) { // _self.app.action.setreaded(function () { // _self.fireevent("afterreaded"); // _self.app.reload(); // if (layout.mobile) { // // //移动端页面关闭 // _self.finishonmobile() // } else { // confirmdlg.close(); // } // }, null, read.id, read); // } else { // _self.app.reload(); // if (layout.mobile) { // // //移动端页面关闭 // _self.finishonmobile() // } else { // confirmdlg.close(); // } // } // // }, function () { // this.close(); // }, null, this.app.content, this.json.confirmstyle); }, doreadedwork: function(dlg){ var opinion = dlg.content.getelement(".readedwork_opinion").get("value"); var read = null; for (var i = 0; i < this.businessdata.readlist.length; i ) { if (this.businessdata.readlist[i].person === layout.session.user.distinguishedname) { read = this.businessdata.readlist[i]; break; } } var _self = this; if (read) { mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); read.opinion = opinion; this.app.action.setreaded(function () { if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.fireevent("afterreaded"); if (layout.mobile) { _self.finishonmobile(); } else { _self.app.reload(); dlg.close(); } }, null, read.id, read); }.bind(this)); } else { if (layout.mobile) { _self.finishonmobile(); } else { _self.app.reload(); dlg.close(); } } }, openwindow: function (form, app) { //var application = app || (this.businessdata.work) ? this.businessdata.work.application : this.businessdata.workcompleted.application; var form = form; if (!form) { form = this.json.id; //if (this.json.printform) form = this.json.printform; } if (this.businessdata.workcompleted) { var application = app || this.businessdata.workcompleted.application; var url = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; url = "&" o2.tokenname "=" xtoken; } window.open(url); } else { var application = app || this.businessdata.work.application; var url = o2.filter; if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc())) { var xtoken = layout.session.token; url = "&" o2.tokenname "=" xtoken; } window.open(url); } //window.open("../x_desktop/printwork.html?workid=" this.businessdata.work.id "&app=" this.businessdata.work.application "&form=" form); }, /** * @summary 将新上传的附件在指定的附件组件中展现. * @param {string} site - 附件组件的标识 * @param {string} id - 新上传的附件id * @example * this.form.getapp().appform.uploadedattachment(site, id); */ uploadedattachment: function (site, id) { this.workaction.getattachment(id, this.businessdata.work.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.workaction.getattachment(id, this.businessdata.work.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.workaction.getattachment(id, this.businessdata.work.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.workaction.getattachment(id, this.businessdata.work.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)) }, // 打开工作关联聊天 openimchatstarter: function(jobid) { mwf.xdesktop.requireapp("imv2", "starter", function () { var starter = new mwf.xapplication.imv2.starter({}, this.app, { "businessid":jobid, "businesstype": "process" }); starter.load(); }.bind(this)); }, // 分享到im聊天 sharetoimchat: function() { // app端 分享到聊天 if (window.o2android && window.o2android.postmessage) { var body = { type: "sharetoimchat", } window.o2android.postmessage(json.stringify(body)); } else { var imjson = {} if (this.businessdata.workcompleted) { imjson = { type: "process", title: this.businessdata.workcompleted.title, work: this.businessdata.workcompleted.id, process: this.businessdata.workcompleted.process, processname: this.businessdata.workcompleted.processname, application: this.businessdata.workcompleted.application, applicationname: this.businessdata.workcompleted.applicationname, job: this.businessdata.workcompleted.job, } } else if (this.businessdata.work) { imjson = { type: "process", title: this.businessdata.work.title, work: this.businessdata.work.id, process: this.businessdata.work.process, processname: this.businessdata.work.processname, application: this.businessdata.work.application, applicationname: this.businessdata.work.applicationname, job: this.businessdata.work.job, } } else { this.app.notice(mwf.xapplication.process.xform.lp.nopermissionorworknotexisted, "error") return } mwf.xdesktop.requireapp("imv2", "starter", function () { var share = new mwf.xapplication.imv2.sharetoconversation({ msgbody: imjson }, this.app); share.load(); }.bind(this)); } }, //移动端页面 工作处理完成后 finishonmobile: function () { var _self = this; //新建检查 // if (this.json.checkdraft){ // this.workaction.checkdraft(this.businessdata.work.id, function (json) { // // var str = json.stringify(json); // _self.finishonmobilereal(); // }.bind(this), function () { // _self.finishonmobilereal(); // }, false); // }else { // _self.finishonmobilereal(); // } this.workaction.checkdraft(this.businessdata.work.id, function (json) { // var str = json.stringify(json); _self.finishonmobilereal(); }.bind(this), function () { _self.finishonmobilereal(); }, false); }, finishonmobilereal: function () { if (window.o2android && window.o2android.postmessage) { var body = { type: "closework", } window.o2android.postmessage(json.stringify(body)); } else if (window.o2android && window.o2android.closework) { window.o2android.closework(""); } else if (window.webkit && window.webkit.messagehandlers && window.webkit.messagehandlers.closework) { window.webkit.messagehandlers.closework.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 len = window.history.length; // if (len > 1) { // history.back(); // } else { // var uri = new uri(window.location.href); // var redirectlink = uri.getdata("redirectlink"); // if (redirectlink) { // history.replacestate(null, "work", redirectlink); // redirectlink.touri().go(); // } else { // // window.location = o2.filter; // history.replacestate(null, "work", o2.filter); // o2.filter.touri().go(); // } // } var uri = new uri(window.location.href); var redirectlink = uri.getdata("redirectlink"); if (redirectlink) { history.replacestate(null, "work", redirectlink); redirectlink.touri().go(); } else { // window.location = o2.filter; history.replacestate(null, "work", o2.filter); o2.filter.touri().go(); } } }, // 判断是否是钉钉pc上 dingtalkpccloseorappclose: function () { if ((o2.thirdparty.isdingdingpc() || o2.thirdparty.isqywxpc()) && layout.inbrowser) { // 如果是钉钉pc上 并且是浏览器模式 var centerurl = o2.filter; history.replacestate(null, "work", centerurl); centerurl.touri().go(); } else { this.app.close(); } }, /** * @summary 获取组件的类型(小写). * @param {object|string} module - 组件或组件id * @return {string} 组件类型(小写) * @example * //假设有一个文本输入组件id为subject * var module = this.form.get("subject"); * //moduletype 为 textfield; * var moduletype = this.form.getapp().appform.getmoduletype(); * @example * //假设有一个附件组件id为att, * var moduletype = this.form.getapp().appform.getmoduletype("att"); * //moduletype 为 attachment; */ getmoduletype : function (module) { if( typeof(module) === "string" )module = this.all[module]; if( module ){ var moduletype = module.json.modulename || ""; if( !moduletype ){ moduletype = typeof(module.json.type) === "string" ? module.json.type.tolowercase() : ""; } return moduletype.tolowercase(); }else{ return ""; } }, sendread: function () { var opt = {}; mwf.require("mwf.xdesktop.dialog", function () { var width = 560; var height = 270; var p = mwf.getcenterposition(this.app.content, width, height); var _self = this; var dlg = new mwf.xdesktop.dialog({ "title": mwf.xapplication.process.xform.lp.sendread, "style": this.json.dialogstyle || "user", //|| "work", "top": p.y - 100, "left": p.x, "fromtop": p.y - 100, "fromleft": p.x, "width": width, "height": height, "url": this.app.path "sendread.html", "lp": mwf.xapplication.process.xform.lp.form, "container": this.app.content, "isclose": true, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { if( !opt.identitylist || !opt.identitylist.length ){ _self.app.notice(mwf.xapplication.process.xform.lp.inputsendreadpeople, "error", dlg.node); }else{ var notify = dlg.content.getelement(".sendread_notify").get("checked"); opt.notify = !!notify; _self.dosendread(opt); } }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ], "onpostshow": function () { opt.dlg = this; opt.workid = (_self.businessdata.work || _self.businessdata.workcompleted).id; opt.complete = !!(_self.businessdata.work || _self.businessdata.workcompleted).completedtime; var selpeoplebutton = this.content.getelement(".sendread_selpeoplebutton"); selpeoplebutton.addevent("click", function () { _self.selectreadpeople(this, opt); }.bind(this)); } }); dlg.show(); }.bind(this)); }, selectreadpeople: function (dlg, opt ) { var names = opt.identitylist || []; var areanode = dlg.content.getelement(".sendread_selpeoplearea"); var options = { "values": names, "type": "identity", "count": 0, "title": mwf.xapplication.process.xform.lp.sendread, "oncomplete": function (items) { areanode.empty(); var identitylist = []; items.each(function (item) { new mwf.widget.o2identity(item.data, areanode, { "style": "reset" }); identitylist.push(item.data.distinguishedname); }.bind(this)); opt.identitylist = identitylist; }.bind(this) }; mwf.xdesktop.requireapp("selector", "package", function () { var selector = new mwf.o2selector(this.app.content, options); }.bind(this)); }, dosendread: function(opt){ if( !opt.identitylist || !opt.identitylist.length ) { this.app.notice(mwf.xapplication.process.xform.lp.sendreadpeoplecannotempty, "error", opt.dlg ? opt.dlg.node : null); return false; } var namearr = []; var names = opt.identitylist || []; names.each(function (n) { namearr.push(n.split("@")[0]); }); mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforesendread"); if (this.app && this.app.fireevent) this.app.fireevent("beforesendread"); if( !opt.workid ){ opt.workid = (this.businessdata.work || this.businessdata.workcompleted).id; opt.complete = !!(this.businessdata.work || this.businessdata.workcompleted).completedtime; } var method = opt.complete ? "createwithworkcompleted" : "createwithwork"; o2.actions.load("x_processplatform_assemble_surface").readaction[method](opt.workid, { "identitylist": opt.identitylist, "notify": opt.notify }, function () { this.fireevent("aftersendread"); if (this.app && this.app.fireevent) this.app.fireevent("aftersendread"); this.app.notice(mwf.xapplication.process.xform.lp.sendreadok ": " namearr, "success"); if(opt.dlg)opt.dlg.close(); if(opt.success)opt.success(); if (this.mask) { this.mask.hide(); this.mask = null; } this.app.reload(); }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error", opt.dlg ? opt.dlg.node : null); if(opt.failure)opt.failure(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this)); }.bind(this)); }, addreview: function () { var opt = {}; mwf.require("mwf.xdesktop.dialog", function () { var width = 560; var height = 270; var p = mwf.getcenterposition(this.app.content, width, height); var _self = this; var dlg = new mwf.xdesktop.dialog({ "title": mwf.xapplication.process.xform.lp.sendreview, "style": this.json.dialogstyle || "user", //|| "work", "top": p.y - 100, "left": p.x, "fromtop": p.y - 100, "fromleft": p.x, "width": width, "height": height, "url": this.app.path "sendreview.html", "lp": mwf.xapplication.process.xform.lp.form, "container": this.app.content, "isclose": true, "buttonlist": [ { "type": "ok", "text": mwf.lp.process.button.ok, "action": function (d, e) { if( !opt.personlist || !opt.personlist.length ){ _self.app.notice(mwf.xapplication.process.xform.lp.inputsendreviewpeople, "error", dlg.node); }else{ _self.doaddreview(opt); } }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ], "onpostshow": function () { opt.dlg = this; opt.workid = (_self.businessdata.work || _self.businessdata.workcompleted).id; opt.complete = !!(_self.businessdata.work || _self.businessdata.workcompleted).completedtime; var selpeoplebutton = this.content.getelement(".sendreview_selpeoplebutton"); selpeoplebutton.addevent("click", function () { _self.selectreviewpeople(this, opt); }.bind(this)); } }); dlg.show(); }.bind(this)); }, selectreviewpeople: function (dlg, opt ) { var names = opt.personlist || []; var areanode = dlg.content.getelement(".sendreview_selpeoplearea"); var options = { "values": names, "type": "identity", "resulttype": "person", "count": 0, "title": mwf.xapplication.process.xform.lp.sendreview, "oncomplete": function (items) { areanode.empty(); var personlist = []; items.each(function (item) { new mwf.widget.o2person(item.data, areanode, { "style": "reset" }); personlist.push(item.data.distinguishedname); }.bind(this)); opt.personlist = personlist; }.bind(this) }; mwf.xdesktop.requireapp("selector", "package", function () { var selector = new mwf.o2selector(this.app.content, options); }.bind(this)); }, doaddreview: function(opt){ if( !opt.personlist || !opt.personlist.length ) { this.app.notice(mwf.xapplication.process.xform.lp.sendreviewpeoplecannotempty, "error", opt.dlg ? opt.dlg.node : null); return false; } var namearr = []; var names = opt.personlist || []; names.each(function (n) { namearr.push(n.split("@")[0]); }); mwf.require("mwf.widget.mask", function () { this.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); this.mask.loadnode(this.app.content); this.fireevent("beforeaddreview"); if (this.app && this.app.fireevent) this.app.fireevent("beforeaddreview"); if( !opt.workid ){ opt.workid = (this.businessdata.work || this.businessdata.workcompleted).id; opt.complete = !!(this.businessdata.work || this.businessdata.workcompleted).completedtime; } var method = opt.complete ? "createwithworkcompleted" : "createwithwork"; var data = { "personlist": opt.personlist }; if( opt.complete ){ data.workcompleted = opt.workid; }else{ data.work = opt.workid; } o2.actions.load("x_processplatform_assemble_surface").reviewaction[method]( data, function () { this.fireevent("afteraddreview"); if (this.app && this.app.fireevent) this.app.fireevent("afteraddreview"); this.app.notice(mwf.xapplication.process.xform.lp.sendreviewok ": " namearr, "success"); if(opt.dlg)opt.dlg.close(); if(opt.success)opt.success(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; this.app.notice("request json error: " errortext, "error", opt.dlg ? opt.dlg.node : null); if(opt.failure)opt.failure(); if (this.mask) { this.mask.hide(); this.mask = null; } }.bind(this)); }.bind(this)); }, checkcontrol: function(key){ if (!this.businessdata.control[key]) { o2.xdesktop.notice("error", { x: "right", y: "top" }, "permission denied"); return false; } if( !this.businessdata.task ){ o2.xdesktop.notice("error", { x: "right", y: "top" }, o2.xapplication.process.xform.lp.form.notasktoreset); return false; } return true; }, addtask: function(){ if (!this.checkuploadattachment()) return false; if (this.checkcontrol("allowaddtask")){ var _self = this; var opt = {}; o2.dl.open({ "title": o2.xapplication.process.xform.lp.form.addtask, "style": this.json.dialogstyle || "user", "width": (layout.mobile) ? "100%" : 680, "height": (layout.mobile) ? "100%" : 380, "url": this.app.path ( (layout.mobile) ? "addtaskmobile" : "addtask") ".html", "lp": o2.xapplication.process.xform.lp.form, "container": (layout.mobile) ? document.body : this.app.content, "masknode": this.app.content, "offset": (layout.mobile) ? null : {y: -120}, // "top": (layout.mobile) ? 0 : undefined, // "left": (layout.mobile) ? 0 : undefined, "buttonlist": [ { "type": "ok", "text": o2.lp.process.button.ok, "action": function (d, e) { if( !this.identitylist || !this.identitylist.length ){ _self.app.notice(o2.xapplication.process.xform.lp.inputaddtaskpeople, "error", this.node); }else{ _self.doaddtask(this); } } }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { this.close(); } } ], "onpostshow": function () { var selpeoplebutton = this.content.getelement(".addtask_selpeoplebutton"); selpeoplebutton.addevent("click", function () { _self.selectpeople(this); }.bind(this)); } }); } }, getradiovalue: function(node, selector){ var nodes = node.getelements(selector); for (var i=0; i 3 ? (namearr[0] "、" namearr[1] "、" namearr[2] "...") : namearr.join(", "); var routename = lefttext ":" n; if (!opinion) opinion = lefttext ":" namearr.join(", "); //o2.xapplication.process.xform.lp.form.addtask ":" namearr.join(", "); var data = { "mode": mode, "before": !!before, "opinion": opinion, "routename": routename, "distinguishednamelist": names }; this.saveformdata( function(json){ o2.actions.load("x_processplatform_assemble_surface").taskaction.v3add( //this.workaction.resetwork( function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }, this.businessdata.task.id, data ); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); }, addaddtaskmessage: function (data, notclosewindow) { var content = this.getmessagecontent(data, 0, mwf.xapplication.process.xform.lp.addtaskinfor); if (layout.desktop.message) { var msg = { "subject": mwf.xapplication.process.xform.lp.form.addtask, "content": content }; layout.desktop.message.addtooltip(msg); return layout.desktop.message.addmessage(msg); } else { if (this.app.inbrowser) { this.inbrowserdkg(content, notclosewindow); } } }, terminatework: function(e, ev){ var _self = this; if (this.json.mode === "mobile") { var p = mwf.getcenterposition(document.body, 300, 150); var x = p.x; if (p.x < 20) { x = 20; } else { x = p.x; } var event = { "event": { "x": x, "y": p.y - 200, "clientx": x, "clienty": p.y - 200 } }; this.app.confirm("infor", event, mwf.xapplication.process.xform.lp.terminateworktitle, mwf.xapplication.process.xform.lp.terminateworktext, 300, 120, function () { _self.app.content.mask({ "style": { "background-color": "#999", "opacity": 0.6 } }); mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforeterminat"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforeterminat"); _self.doterminatework(function () { _self.fireevent("afterterminat"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterterminat"); _self.app.notice(mwf.xapplication.process.xform.lp.workterminate ": “" _self.businessdata.work.title "”", "success"); if (_self.mask) { _self.mask.hide(); _self.mask = null; } _self.finishonmobile() }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", dlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); }, function () { this.close(); }, null, this.app.content, this.json.confirmstyle); } else { 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.process.xform.lp.terminateworktitle, mwf.xapplication.process.xform.lp.terminateworktext, 380, 120, function () { // _self.app.content.mask({ // "style": { // "background-color": "#999", // "opacity": 0.6 // } // }); mwf.require("mwf.widget.mask", function () { _self.mask = new mwf.widget.mask({ "style": "desktop", "zindex": 50000 }); _self.mask.loadnode(_self.app.content); _self.fireevent("beforeterminat"); if (_self.app && _self.app.fireevent) _self.app.fireevent("beforeterminat"); _self.doterminatework(function () { _self.fireevent("afterterminat"); if (_self.app && _self.app.fireevent) _self.app.fireevent("afterterminat"); _self.app.notice(mwf.xapplication.process.xform.lp.workterminate ": “" _self.businessdata.work.title "”", "success"); _self.app.close(); this.close(); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this), function (xhr, text, error) { var errortext = error ":" text; if (xhr) errortext = xhr.responsetext; _self.app.notice("request json error: " errortext, "error", dlg.node); if (_self.mask) { _self.mask.hide(); _self.mask = null; } }.bind(this)); }.bind(this)); }, function () { this.close(); }, null, this.app.content, this.json.confirmstyle); } }, doterminatework: function (success, failure) { if (this.businessdata.control["allowterminate"]) { o2.actions.load("x_processplatform_assemble_surface").workaction.v2terminate(this.businessdata.work.id, function (json) { if (success) success(json); }.bind(this), function (xhr, text, error) { if (failure) failure(xhr, text, error); }); }else { if (failure) failure(null, "permission denied", ""); } } }); /** * @class portalpage 门户页面。 * @o2cn 门户页面 * @o2category formcomponents * @o2range {portal} * @extends mwf.xapplication.process.xform.form * @example * //可以在脚本中获取页面 * //方法1: * var page = this.form.getapp().appform; //获取页面 * //方法2 * var page = this.target; //在页面本身的事件脚本中获取 * @hideconstructor */ var portalpage=""; /** * @event portalpage#beforeprocesswork * @ignore */ /** * @event portalpage#beforeprocess * @ignore */ /** * @event portalpage#afterprocess * @ignore */ /** * @event portalpage#beforereset * @ignore */ /** * @event portalpage#afterreset * @ignore */ /** * @event portalpage#beforeretract * @ignore */ /** * @event portalpage#afterretract * @ignore */ /** * @event portalpage#beforereroute * @ignore */ /** * @event portalpage#afterreroute * @ignore */ /** * @event portalpage#beforedelete * @ignore */ /** * @event portalpage#afterdelete * @ignore */ /** * @event portalpage#beforereaded * @ignore */ /** * @event portalpage#afterreaded * @ignore */ /** * @event portalpage#afterloadprocessor * @ignore */ /** * @event portalpage#beforeaddtask * @ignore */ /** * @event portalpage#afteraddtask * @ignore */ /** * @method portalpage#getroutedatalist * @ignore */ /** * @method portalpage#presswork * @ignore */ /** * @method portalpage#reroutework * @ignore */ /** * @method portalpage#readedwork * @ignore */ /** * @method portalpage#uploadedattachment * @ignore */ /** * @method portalpage#pausetask * @ignore */ /** * @method portalpage#resumetask * @ignore */
网站地图