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

source

var global_items=function(){var t=[];for(var e in this)t.push(e);return t}();!function(){this.mootools={version:"1.5.0dev",build:"%build%"};var t=this.typeof=function(t){if(null==t)return"null";if(null!=t.$family)return t.$family();if(t.nodename){if(1==t.nodetype)return"element";if(3==t.nodetype)return/\s/.test(t.nodevalue)?"textnode":"whitespace"}else if("number"==typeof t.length){if(t.callee)return"arguments";if("item"in t)return"collection"}return typeof t},e=(this.instanceof=function(t,e){if(null==t)return!1;for(var n=t.$constructor||t.constructor;n;){if(n===e)return!0;n=n.parent}return!!t.hasownproperty&&t instanceof e},this.function),n=!0;for(var r in{tostring:1})n=null;n&&(n=["hasownproperty","valueof","isprototypeof","propertyisenumerable","tolocalestring","tostring","constructor"]),e.prototype.overloadsetter=function(t){var e=this;return function(r,i){if(null==r)return this;if(t||"string"!=typeof r){for(var a in r)e.call(this,a,r[a]);if(n)for(var o=n.length;o--;)a=n[o],r.hasownproperty(a)&&e.call(this,a,r[a])}else e.call(this,r,i);return this}},e.prototype.overloadgetter=function(t){var e=this;return function(n){var r,i;if("string"!=typeof n?r=n:arguments.length>1?r=arguments:t&&(r=[n]),r){i={};for(var a=0;a>>0;n>>0;i>>0,r=e<0?math.max(0,n e):e||0;r>>0,r=array(n),i=0;i>>0;n-1:string(this).indexof(t)>-1},trim:function(){return string(this).replace(/^\s |\s $/g,"")},clean:function(){return string(this).replace(/\s /g," ").trim()},camelcase:function(){return string(this).replace(/-\d/g,(function(t){return t.charat(1).touppercase()}))},hyphenate:function(){return string(this).replace(/[a-z]/g,(function(t){return"-" t.charat(0).tolowercase()}))},capitalize:function(){return string(this).replace(/\b[a-z]/g,(function(t){return t.touppercase()}))},escaperegexp:function(){return string(this).replace(/([-.* ?^${}()|[\]\/\\])/g,"\\$1")},toint:function(t){return parseint(this,t||10)},tofloat:function(){return parsefloat(this)},hextorgb:function(t){var e=string(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return e?e.slice(1).hextorgb(t):null},rgbtohex:function(t){var e=string(this).match(/\d{1,3}/g);return e?e.rgbtohex(t):null},substitute:function(t,e){return string(this).replace(e||/\\?\{([^{}] )\}/g,(function(e,n){return"\\"==e.charat(0)?e.slice(1):null!=t[n]?t[n]:""}))}}),function.extend({attempt:function(){for(var t=0,e=arguments.length;t1?array.slice(arguments,1):null,r=function(){},i=function(){var a=t,o=arguments.length;this instanceof i&&(r.prototype=e.prototype,a=new r);var s=n||o?e.apply(a,n&&o?n.concat(array.slice(arguments)):n||arguments):e.call(a);return a==t?s:a};return i},pass:function(t,e){var n=this;return null!=t&&(t=array.from(t)),function(){return n.apply(e,t||arguments)}},delay:function(t,e,n){return settimeout(this.pass(null==n?[]:n,e),t)},periodical:function(t,e,n){return setinterval(this.pass(null==n?[]:n,e),t)}}),number.implement({limit:function(t,e){return math.min(e,math.max(t,this))},round:function(t){return t=math.pow(10,t||0).tofixed(t<0?-t:0),math.round(this*t)/t},times:function(t,e){for(var n=0;n3&&t<21?"th":["th","st","nd","rd","th"][math.min(t,4)]},lessthanminuteago:"less than a minute ago",minuteago:"about a minute ago",minutesago:"{delta} minutes ago",hourago:"about an hour ago",hoursago:"about {delta} hours ago",dayago:"1 day ago",daysago:"{delta} days ago",weekago:"1 week ago",weeksago:"{delta} weeks ago",monthago:"1 month ago",monthsago:"{delta} months ago",yearago:"1 year ago",yearsago:"{delta} years ago",lessthanminuteuntil:"less than a minute from now",minuteuntil:"about a minute from now",minutesuntil:"{delta} minutes from now",houruntil:"about an hour from now",hoursuntil:"about {delta} hours from now",dayuntil:"1 day from now",daysuntil:"{delta} days from now",weekuntil:"1 week from now",weeksuntil:"{delta} weeks from now",monthuntil:"1 month from now",monthsuntil:"{delta} months from now",yearuntil:"1 year from now",yearsuntil:"{delta} years from now"}),function(){var t=this.date,e=t.methods={ms:"milliseconds",year:"fullyear",min:"minutes",mo:"month",sec:"seconds",hr:"hours"};["date","day","fullyear","hours","milliseconds","minutes","month","seconds","time","timezoneoffset","week","timezone","gmtoffset","dayofyear","lastmonth","lastdayofmonth","utcdate","utcday","utcfullyear","ampm","ordinal","utchours","utcmilliseconds","utcminutes","utcmonth","utcseconds","utcmilliseconds"].each((function(e){t.methods[e.tolowercase()]=e}));var n=function(t,e,r){return 1==e?t:t28)return 1;0==o&&s<-2&&(r=new t(r).decrement("day",i),i=0),(n=new t(r.get("year"),0,1).get("day")||7)>4&&(a=-7)}else n=new t(r.get("year"),0,1).get("day");return a =r.get("dayofyear"),a =6-i,(a =(7 n-e)%7)/7},getordinal:function(e){return t.getmsg("ordinal",e||this.get("date"))},gettimezone:function(){return this.tostring().replace(/^.*? ([a-z]{3}).[0-9]{4}.*$/,"$1").replace(/^.*?\(([a-z])[a-z]  ([a-z])[a-z]  ([a-z])[a-z] \)$/,"$1$2$3")},getgmtoffset:function(){var t=this.get("timezoneoffset");return(t>0?"-":" ") n((t.abs()/60).floor(),2) n(t`,2)},setampm:function(t){t=t.touppercase();var e=this.get("hr");return e>11&&"am"==t?this.decrement("hour",12):e<12&&"pm"==t?this.increment("hour",12):this},getampm:function(){return this.get("hr")<12?"am":"pm"},parse:function(e){return this.set("time",t.parse(e)),this},isvalid:function(t){return t||(t=this),"date"==typeof(t)&&!isnan(t.valueof())},format:function(e){if(!this.isvalid())return"invalid date";if(e||(e="%x %x"),"string"==typeof e&&(e=a[e.tolowercase()]||e),"function"==typeof e)return e(this);var r=this;return e.replace(/%([a-z%])/gi,(function(e,i){switch(i){case"a":return t.getmsg("days_abbr")[r.get("day")];case"a":return t.getmsg("days")[r.get("day")];case"b":return t.getmsg("months_abbr")[r.get("month")];case"b":return t.getmsg("months")[r.get("month")];case"c":return r.format("%a %b %d %h:%m:%s %y");case"d":return n(r.get("date"),2);case"e":return n(r.get("date"),2," ");case"h":return n(r.get("hr"),2);case"i":return n(r.get("hr")||12,2);case"j":return n(r.get("dayofyear"),3);case"k":return n(r.get("hr"),2," ");case"l":return n(r.get("hr")||12,2," ");case"l":return n(r.get("ms"),3);case"m":return n(r.get("mo") 1,2);case"m":return n(r.get("min"),2);case"o":return r.get("ordinal");case"p":return t.getmsg(r.get("ampm"));case"s":return math.round(r/1e3);case"s":return n(r.get("seconds"),2);case"t":return r.format("%h:%m:%s");case"u":return n(r.get("week"),2);case"w":return r.get("day");case"x":return r.format(t.getmsg("shortdate"));case"x":return r.format(t.getmsg("shorttime"));case"y":return r.get("year").tostring().substr(2);case"y":return r.get("year");case"z":return r.get("gmtoffset");case"z":return r.get("timezone")}return i}))},toisostring:function(){return this.format("iso8601")}}).alias({tojson:"toisostring",compare:"diff",strftime:"format"});var r=["sun","mon","tue","wed","thu","fri","sat"],i=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],a={db:"%y-%m-%d %h:%m:%s",compact:"%y%m%dt%h%m%s",short:"%d %b %h:%m",long:"%b %d, %y %h:%m",rfc822:function(t){return r[t.get("day")] t.format(", %d ") i[t.get("month")] t.format(" %y %h:%m:%s %z")},rfc2822:function(t){return r[t.get("day")] t.format(", %d ") i[t.get("month")] t.format(" %y %h:%m:%s %z")},iso8601:function(t){return t.getutcfullyear() "-" n(t.getutcmonth() 1,2) "-" n(t.getutcdate(),2) "t" n(t.getutchours(),2) ":" n(t.getutcminutes(),2) ":" n(t.getutcseconds(),2) "." n(t.getutcmilliseconds(),3) "z"}},o=[],s=t.parse,u=function(e,n,r){var i=-1,a=t.getmsg(e "s");switch(typeof(n)){case"object":i=a[n.get(e)];break;case"number":if(!(i=a[n]))throw new error("invalid " e " index: " n);break;case"string":var o=a.filter((function(t){return this.test(t)}),new regexp("^" n,"i"));if(!o.length)throw new error("invalid " e " string");if(o.length>1)throw new error("ambiguous " e);i=o[0]}return r?a.indexof(i):i},c=1900,l=70;t.extend({getmsg:function(t,e){return locale.get("date." t,e)},units:{ms:function.convert(1),second:function.convert(1e3),minute:function.convert(6e4),hour:function.convert(36e5),day:function.convert(864e5),week:function.convert(6084e5),month:function(e,n){var r=new t;return 864e5*t.daysinmonth(null!=e?e:r.get("mo"),null!=n?n:r.get("year"))},year:function(e){return e=e||(new t).get("year"),t.isleapyear(e)?316224e5:31536e6}},daysinmonth:function(e,n){return[31,t.isleapyear(n)?29:28,31,30,31,30,31,31,30,31,30,31][e]},isleapyear:function(t){return t%4==0&&t0!=0||t@0==0},parse:function(e){var n,r=typeof(e);return"number"==r?new t(e):"string"!=r?e:(e=e.clean()).length?(o.some((function(t){var r=t.re.exec(e);return!!r&&(n=t.handler(r))})),n&&n.isvalid()||(n=new t(s(e)))&&n.isvalid()||(n=new t(e.toint())),n):null},parseday:function(t,e){return u("day",t,e)},parsemonth:function(t,e){return u("month",t,e)},parseutc:function(e){var n=new t(e),r=t.utc(n.get("year"),n.get("mo"),n.get("date"),n.get("hr"),n.get("min"),n.get("sec"),n.get("ms"));return new t(r)},orderindex:function(e){return t.getmsg("dateorder").indexof(e) 1},defineformat:function(t,e){return a[t]=e,this},defineparser:function(t){return o.push(t.re&&t.handler?t:g(t)),this},defineparsers:function(){return array.flatten(arguments).each(t.defineparser),this},define2digityearstart:function(t){return c=t-(l=t0),this}}).extend({defineformats:t.defineformat.overloadsetter()});var h,f=function(e){return new regexp("(?:" t.getmsg(e).map((function(t){return t.substr(0,3)})).join("|") ")[a-z]*")},d={d:/[0-2]?[0-9]|3[01]/,h:/[01]?[0-9]|2[0-3]/,i:/0?[1-9]|1[0-2]/,m:/[0-5]?\d/,s:/\d /,o:/[a-z]*/,p:/[ap]\.?m\.?/,y:/\d{2}|\d{4}/,y:/\d{4}/,z:/z|[ -]\d{2}(?::?\d{2})?/};d.m=d.i,d.s=d.m;var g=function(e){if(!h)return{format:e};var n=[],r=(e.source||e).replace(/%([a-z])/gi,(function(e,n){return function(e){switch(e){case"t":return"%h:%m:%s";case"x":return(1==t.orderindex("month")?"%m[-./]%d":"%d[-./]%m") "([-./]%y)?";case"x":return"%h([.:]%m)?([.:]%s([.:]%s)?)? ?%p? ?%z?"}return null}(n)||e})).replace(/\((?!\?)/g,"(?:").replace(/ (?!\?|\*)/g,",? ").replace(/%([a-z%])/gi,(function(t,e){var r=d[e];return r?(n.push(e),"(" r.source ")"):e})).replace(/\[a-z\]/gi,"[a-z\\u00c0-\\uffff;&]");return{format:e,re:new regexp("^" r "$","i"),handler:function(e){e=e.slice(1).associate(n);var r=(new t).cleartime(),i=e.y||e.y;for(var a in null!=i&&p.call(r,"y",i),"d"in e&&p.call(r,"d",1),("m"in e||e.b||e.b)&&p.call(r,"m",1),e)p.call(r,a,e[a]);return r}}},p=function(e,n){if(!n)return this;switch(e){case"a":case"a":return this.set("day",t.parseday(n,!0));case"b":case"b":return this.set("mo",t.parsemonth(n,!0));case"d":return this.set("date",n);case"h":case"i":return this.set("hr",n);case"m":return this.set("mo",n-1);case"m":return this.set("min",n);case"p":return this.set("ampm",n.replace(/\./g,""));case"s":return this.set("sec",n);case"s":return this.set("ms",1e3*("0." n));case"w":return this.set("day",n);case"y":return this.set("year",n);case"y":return(n= n)<100&&(n =c (n>> 0;
                for (var i = (from < 0) ? math.max(0, length   from) : from || 0; i < length; i  ){
                    if (this[i] === item) return i;
                }
                return -1;
            }
        }};
    object.defineproperties(array.prototype, o);
})();
bind.library = library;
//print 重载, console, error
/**
 * this.print是一个方法,在服务器控制台输出信息。
* @module print() * @o2cn 控制台输出打印 * @o2category server.common * @o2ordernumber 145 * * @param {(string)} text 要输出的文本信息。 * @param {(string)} type 要输出的文本信息的类型,会添加到输出信息的前面,默认为“print”。 * @example * this.print("这是我要输出的信息"); * //2021-12-20 13:26:24.739 [script] print 这是我要输出的信息 * * this.print("这是一个自定义类型的信息", "mytype"); * //2021-12-20 13:26:24.765 [script] mytype 这是一个自定义类型的信息 */ if (!bind.oprint) bind.oprint = print; var print = function(str, type){ var d = new date(); var t = (type || "print").touppercase(); var l = "[script]"; bind.oprint(d.format("db") "." d.getmilliseconds() " " l " " t " " str); } var _parseprint = function(str){ if (!str && str!==0 && str!==false) return str; var text = (typeof(str)!=="string") ? str.tostring() : str; try{ var i = 1; while (text.indexof("%s")!==-1 && i * @module console * @o2category server.common * @o2ordernumber 155 * @o2cn 分等级控制台输出 * @example * console.log("这是我要输出的信息"); * //2021-12-20 13:26:24.739 [script] print 这是我要输出的信息 * * console.error("这是一个错误信息"); * //2021-12-20 13:26:24.765 [script] error 这是一个错误信息 * * console.info("这是一个普通信息"); * //2021-12-20 13:26:24.765 [script] info 这是一个普通信息 * * console.warn("这是一个警告信息"); * //2021-12-20 13:26:24.765 [script] warn 这是一个警告信息 */ var console = { log: function(){ print(_parseprint.apply(this, arguments)); }, error: function(){ print(_parseprint.apply(this, arguments), "error"); }, info: function(){ print(_parseprint.apply(this, arguments), "info"); }, warn: function(){ print(_parseprint.apply(this, arguments), "warn"); } } var error = function(msg){ this.msg = msg; } error.prototype.tostring = function(){ return this.msg; } var exec = function(code, _self){ var returnvalue; //try{ if (!_self) _self = this; try { var f = eval("(function(){return function(){\n" code "\n}})();"); returnvalue = f.apply(_self); }catch(e){ console.log("exec", new error("exec script error")); console.log(e); } return returnvalue; } bind.print = print; bind.exec = exec; //方法定义 /** * this.define是一个方法,您在脚本中您可以通过this.define()来定义自己的方法。
* 通过这种方式定义方法,在不同的应用使用相同的方法名称也不会造成冲突。 * @module define() * @o2category server.common * @o2ordernumber 160 * @o2cn 方法定义 * @param {(string)} name 定义的方法名称。 * @param {function} fun 定义的方法 * @param {boolean} [overwrite] 定义的方法是否能被覆盖重写。默认值为true。 * @o2syntax * this.define(name, fun, overwrite) * @example * * 样例一:在通用脚本中定义一个通用的方法去获取公文管理所有的文种,在查询语句中根据该方法来拼接jpql。
* 1、在内容管理应用中有一个fileres的应用,在该应用中创建一个脚本,命名为filesql,并定义方法。 * * * //定义一个方法 * this.define("getfilesql",function(){ * var application = ["公司发文","部门发文","党委发文"]; * var appsql = " ( "; * for(var i=0;i * 2、在查询语句中使用该方法。 * * * this.include({ * type : "cms", * application : "fileres", * name : "filesql" * }) * * var sql = this.getfilesql(); * * return "select o from com.x.processplatform.core.entity.content.task o where " sql */ bind.define = function(name, fun, overwrite){ var over = true; if (overwrite===false) over = false; var o = {}; o[name] = {"value": fun, "configurable": over}; object.defineproperties(bind, o); } //restful服务action bind.action = function(root, json){ this.actions = json; // object.keys(json).foreach(function(key){ // this.actions[key] = json[key]; // }); //object.merge(actions[root], json); this.root = root; //this.actions = actions[root]; var invokefunction = function(service, parameters, key){ var _self = this; return function(){ var i = parameters.length-1; var n = arguments.length; var functionarguments = arguments; var parameter = {}; var success, failure, async, data, file; if (typeof(functionarguments[0])==="function"){ i=-1; success = (n> i) ? functionarguments[i] : null; failure = (n> i) ? functionarguments[i] : null; parameters.each(function(p, x){ parameter[p] = (n> i) ? functionarguments[i] : null; }); if (service.method && (service.method.tolowercase()==="post" || service.method.tolowercase()==="put")){ data = (n> i) ? functionarguments[i] : null; } }else{ parameters.each(function(p, x){ parameter[p] = (n>x) ? functionarguments[x] : null; }); if (service.method && (service.method.tolowercase()==="post" || service.method.tolowercase()==="put")){ data = (n> i) ? functionarguments[i] : null; } success = (n> i) ? functionarguments[i] : null; failure = (n> i) ? functionarguments[i] : null; } return _self.invoke({"name": key, "data": data, "parameter": parameter, "success": success, "failure": failure}); }; }; var createmethod = function(service, key){ var jaxrsuri = service.uri; var re = new regexp("\{. ?\}", "g"); var replacewords = jaxrsuri.match(re); var parameters = []; if (replacewords) parameters = replacewords.map(function(s){ return s.substring(1,s.length-1); }); this[key] = invokefunction.call(this, service, parameters, key); }; object.keys(this.actions).foreach(function(key){ var service = this.actions[key]; if (service.uri) if (!this[key]) createmethod.call(this, service, key); }, this); this.invoke = function(option){ if (this.actions[option.name]){ var uri = this.actions[option.name].uri; var method = this.actions[option.name].method || "get"; if (option.parameter){ object.keys(option.parameter).foreach(function(key){ var v = option.parameter[key]; uri = uri.replace("{" key "}", v); }); } var res = null; try{ switch (method.tolowercase()){ case "get": res = bind.applications.getquery(this.root, uri); break; case "post": res = bind.applications.postquery(this.root, uri, json.stringify(option.data)); break; case "put": res = bind.applications.putquery(this.root, uri, json.stringify(option.data)); break; case "delete": res = bind.applications.deletequery(this.root, uri); break; default: res = bind.applications.getquery(this.root, uri); } if (res && res.gettype().tostring()==="success"){ var json = json.parse(res.tostring()); if (option.success) option.success(json); }else{ if (option.failure) option.failure(((res) ? json.parse(res.tostring()) : null)); } return res; }catch(e){ if (option.failure) option.failure(e); } } }; } bind.action.applications = bind.applications; /** * 本文档说明如何在后台脚本中使用actions调用平台的restful服务。
* 通过访问以下地址来查询服务列表:http://server/x_program_center/jest/list.html (v7.2之前版本需要加端口20030) * @module server.actions * @o2cn 服务调用 * @o2category server.common * @o2ordernumber 165 * @o2syntax * //获取actions * this.actions */ bind.actions = { "loadedactions": {}, /** * 平台预置了actions对象用于调用平台提供的服务,您可以使用this.actions.load来获取这些方法。由于是运行在服务器端,服务都是同步调用。 * @method load * @methodof module:server.actions * @instance * @param {string} root 平台restful服务根,具体服务列表参见:http://server/x_program_center/jest/list.html。(v7.2之前版本需要加端口20030) * 如: *

     * "x_processplatform_assemble_surface" //流程平台相关服务根
     * 
* @return {object} 返回action对象,用于后续服务调用 * @o2syntax * var actions = this.actions.load( root ); * @o2syntax * //获取流程平台服务对象。 * var processaction = this.actions.load("x_processplatform_assemble_surface"); * @o2syntax * * 通过this.actions.load(root)方法得到action对象,就可以访问此服务下的方法了。
* 访问方法的规则如下: * * var requeststring = this.actions.load( root )[actionname][methodname]( arguements ); * * requeststring : 服务返回的响应数据,字符串格式,可以通过 requestobjest = json.parse(requeststring);解析成对象 * * root : 平台服务根名称,如果 x_processplatform_assemble_surface * * actionname : 服务下的action分类名称,如 taskaction * * methodname : action分类下的方法名称,如 get * * arguements : 需调用的restful服务的相关参数。这些参数需要按照先后顺序传入。根据实际情况可以省略某些参数。参数序列分别是: * * uri的参数, data(post, put方法), success, failure, async。 * * uri参数:如果有uri有多个参数,需要按先后顺序传入。 * * data参数:要提交到后台的数据。post 和 put 方法需要传入,get方法和delete方法省略。 * * success参数:服务执行成功时的回调方法,形如 function(json){ * json为后台服务传回的数据 * }。 * * failure 参数:服务执行失败时的回调方法,形如 function(xhr){ * xhr xmlhttprequest对象,服务器请求失败时有值 * } * 此参数可以省略,如果省略,系统会自动弹出错误信息。 * @o2syntax * * 处理返回的数据有两种方式,二选一即可:
* 1、该方法返回的结果是响应数据字符串,通过json.parse(responsestring)获取对象。
* 2、通过success方法作为第一个参数来处理结果,建议此方法处理请求结果 * * //success:arguements中的第一个function对象 * function(json){ * //json为后台服务传回的数据 * } * @example * * 样例1: * 根据x_processplatform_assemble_surface服务获取当前用户的待办列表:
* 可以通过对应服务的查询页面,http://server/x_processplatform_assemble_surface/jest/index.html (v7.2之前版本需要加端口20020)
* 可以看到以下界面: * 我们可以找到taskaction的v2listpaging服务是列式当前用户待办的服务。
* 该服务有以下信息:
* 1、actionname是:taskaction
* 2、methodname是:v2listpaging
* 3、有两个url参数,分别是 page(分页), size(每页数量)
* 4、有一系列的body参数
* 5、该服务方法类型是post
* 根据这些信息我们可以组织出下面的方法: * * var processaction = this.actions.load("x_processplatform_assemble_surface"); //获取action * var method = processaction.taskaction.v2listpaging; //获取列式方法 * //执行方法1 * method( * 1, //uri 第1个参数,如果无uri参数,可以省略 * 20, //uri 第2个参数,如果无uri参数,可以省略,如果还有其他uri参数,可以用逗号, 分隔 * { //body 参数,对post和put请求,该参数必须传,可以为空对象 * processlist : [xxx] //具体参数 * }, * function(json){ //正确调用的回调 * //json.data得到服务返回数据 * }, * function(responsejson){ //可选,错误信息, json格式 * print( json.stringify(responsejson) ) * } * ); * * //执行方法2 * var responsestring = method( 1, 20, {processlist : [xxx]} ) * var responseobject = json.parse(responseobject); * @example * 出错信息responsejson的格式 * { * "type": "error", //类型为错误 * "message": "标识为:343434 的 task 对象不存在.", //提示文本 * "date": "2020-12-29 17:02:13", //出错时间 * "prompt": "com.x.base.core.project.exception.exceptionentitynotexist" //后台错误类 *} * @example * * 样例2: * 已知流程实例的workid,在脚本中获取数据,修改后进行保存。 * * //查询服务列表找到获取data数据服务为dataaction的getwithwork方法 * //查询服务列表找到更新data数据服务为dataaction的updatewithwork方法 * * var workid = "cce8bc22-225a-4f85-8132-7374d546886e"; * var data; * this.actions.load("x_processplatform_assemble_surface").dataaction.getwithwork( //平台封装好的方法 * workid, //uri的参数 * function( json ){ //服务调用成功的回调函数, json为服务传回的数据 * data = json.data; //为变量data赋值 * }.bind(this) * ) * * data.subject = "新标题"; //修改数据 * this.actions.load("x_processplatform_assemble_surface").dataaction.updatewithwork( * workid, //uri的参数 * data, //保存的数据 * function(){ //服务调用成功的回调函数 * * }.bind(this) * ); */ "load": function(root){ if (this.loadedactions[root]) return this.loadedactions[root]; var jaxrsstring = bind.applications.describeapi(root); var json = json.parse(jaxrsstring.tostring()); if (json && json.jaxrs){ var actionobj = {}; json.jaxrs.each(function(o){ if (o.methods && o.methods.length){ var actions = {}; o.methods.each(function(m){ var o = {"uri": "/" m.uri}; if (m.method) o.method = m.method; if (m.enctype) o.enctype = m.enctype; actions[m.name] = o; }.bind(this)); actionobj[o.name] = new bind.action(root, actions); } }.bind(this)); this.loadedactions[root] = actionobj; return actionobj; } return null; } }; //组织相关 var getnameflag = function(name){ var t = library.typeof(name); if (t==="array"){ var v = []; name.foreach(function(id){ v.push((library.typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id); }); return v; }else{ return [(t==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name]; } }; /** * 您可以通过this.org获取组织中的人员、人员属性、组织、组织属性、身份、群组和角色。后端调用都是同步的。 * @module server.org * @o2cn 组织查询 * @o2category server.common * @o2ordernumber 170 * @property {groupfactory} group 后端的groupfactory实例,可用于获取group群组相关数据, * @property {identityfactory} identity 后端的identityfactory实例,可用于获取identity身份相关数据, * @property {personfactory} person 后端的personfactory实例,可用于获取person人员相关数据, * @property {personattributefactory} personattribute 后端的groupfactory实例,可用于获取personattribute人员属性相关数据, * @property {rolefactory} role 后端的rolefactory实例,可用于获取role角色相关数据, * @property {unitfactory} unit 后端的unitfactory实例,可用于获取unit相关数据, * @property {unitattributefactory} unitattribute 后端的unitattributefactory实例,可用于获取unitattribute组织属性相关数据, * @property {unitdutyfactory} unitduty 后端的unitdutyfactory实例,可用于获取unitduty组织属性相关数据, * @o2syntax * //您可以通过this来获取当前实例的org对象,如下: * var org = this.org; * *@example * //通过后端java类,来获取当前人所在的部门名称 * var unit = this.org.unit; * var unitnames = unit.listwithperson("张三@xxx@p"); */ bind.org = { "group": function() { return this.ogroup}, "identity": function() { return this.oidentity}, "person": function() { return this.operson}, "personattribute": function() { return this.opersonattribute}, "role": function() { return this.orole}, "unit": function() { return this.ounit}, "unitattribute": function() { return this.ounitattribute}, "unitduty": function() { return this.ounitduty}, "getobject": function(o, v){ var arr = []; if (!v || !v.length){ return null; }else{ for (var i=0; i[ value1, value2 ]
* @o2syntax * //返回该人员的属性值数组。 * var attributelist = this.org.getpersonattribute( person, attr ); */ getpersonattribute: function(person, attr){ var personflag = (library.typeof(person)==="object") ? (person.distinguishedname || person.id || person.unique || person.name) : person; var v = this.opersonattribute.listattributewithpersonwithname(personflag, attr); var v_json = []; if (v && v.length){ for (var i=0; i[ attributename1, attributename2 ] * @o2syntax * //返回人员所有属性的名称数组。 * var attributenamelist = this.org.listpersonattributename( person ); */ listpersonattributename: function(name){ var p = getnameflag(name); var namelist = []; for (var i=0; i 当值为字符串的时候,表示获取指定类型的组织。
当值为空的时候,表示获取直接所在组织。 * @return {unitdata|unitdata[]} 返回对应组织,单个为对象,多个为数组。 * @o2actionout x_organization_assemble_express.unitaction.getwithidentitywithlevelobject|example=unit * @o2syntax * //返回直接所在组织,单个为对象,多个为数组。 * var unitlist = this.org.getunitbyidentity( name ); * * //返回第一层组织,单个为对象,多个为数组。 * var unitlist = this.org.getunitbyidentity( name, 1 ); * * * //返回类型为company的组织,单个为对象,多个为数组。 * var unitlist = this.org.getunitbyidentity( name, "company" ); */ getunitbyidentity: function(name, flag){ //getorgactions(); var getunitmethod = "current"; var v; if (flag){ if (library.typeof(flag)==="string") getunitmethod = "type"; if (library.typeof(flag)==="number") getunitmethod = "level"; } var n = getnameflag(name)[0]; switch (getunitmethod){ case "current": v = this.ounit.getwithidentity(n); break; case "type": v = this.ounit.getwithidentitywithtype(n, flag); break; case "level": v = this.ounit.getwithidentitywithlevel(n, flag); break; } var o = this.getobject(this.ounit, [v]); return (o && o.length===1) ? o[0] : o; }, //列出身份所在组织的所有上级组织 /** * 批量查询身份所在的组织,并递归查找其上级组织对象. * @method listallsupunitwithidentity * @o2membercategory unit * @methodof module:server.org * @static * @param {identityflag|identityflag[]} name - 身份的distinguishedname、id、unique属性值,身份对象,或上述属性值和对象的数组。 * @return {unitdata[]} 返回组织数组。 * @o2actionout x_organization_assemble_express.unitaction.listwithidentitysupnestedobject|example=unit * @o2syntax * //返回组织数组。 * var unitlist = this.org.listallsupunitwithidentity( name ); */ listallsupunitwithidentity: function(name){ var v = this.ounit.listwithidentitysupnested(getnameflag(name)); return this.getobject(this.ounit, v); }, //获取人员所在的所有组织(直接所在组织) /** * 根据个人标识批量获取组织对象成员:unit对象数组。 * @method listunitwithperson * @o2membercategory unit * @methodof module:server.org * @static * @param {personflag|personflag[]} name - 人员的distinguishedname、id、unique属性值,人员对象,或上述属性值和对象的数组。 * @return {unitdata[]} 返回组织数组。 * @o2actionout x_organization_assemble_express.unitaction.listwithpersonobject|example=unit * @o2syntax * //返回组织数组。 * var unitlist = this.org.listunitwithperson( name ); */ listunitwithperson: function(name){ var v = this.ounit.listwithperson(getnameflag(name)); return this.getobject(this.ounit, v); }, //列出人员所在组织的所有上级组织 /** * 根据个人标识批量查询所在组织及所有上级组织:unit对象数组。 * @method listallsupunitwithperson * @o2membercategory unit * @methodof module:server.org * @static * @param {personflag|personflag[]} name - 人员的distinguishedname、id、unique属性值,人员对象,或上述属性值和对象的数组。 * @return {unitdata[]} 返回个人所在组织及所有上级组织。 * @o2actionout x_organization_assemble_express.unitaction.listwithpersonsupnestedobject|example=unit * @o2syntax * //返回组织数组。 * var unitlist = this.org.listallsupunitwithperson( name ); */ listallsupunitwithperson: function(name){ var v = this.ounit.listwithpersonsupnested(getnameflag(name)); return this.getobject(this.ounit, v); }, //根据组织属性,获取所有符合的组织 /** * 根据组织属性,获取所有符合的组织。 * @method listunitwithattribute * @o2membercategory unit * @methodof module:server.org * @static * @param {string} attributename 组织属性名称。 * @param {string} attributevalue 组织属性值。 * @return {unitdata[]} 返回组织数组。 * @o2actionout x_organization_assemble_express.unitaction.listwithunitattributeobject|example=unit * @o2syntax * //返回组织数组。 * var unitlist = this.org.listunitwithattribute( attributename, attributename ); */ listunitwithattribute: function(name, attribute){ var v = this.ounit.listwithunitattribute(name, attribute); return this.getobject(this.ounit, v); }, //根据组织职务,获取所有符合的组织 /** * 根据组织职务,获取所有符合的组织。 * @method listunitwithduty * @o2membercategory unit * @methodof module:server.org * @static * @param {string} dutyname 组织职务名称。 * @param {identityflag} identity 身份的distinguishedname、id、unique属性值,身份对象。 * @return {unitdata[]} 返回组织数组。 * @o2actionout x_organization_assemble_express.unitaction.listwithunitdutyobject|example=unit * @o2syntax * //返回组织数组。 * var unitlist = this.org.listunitwithduty( dutyname, identity ); */ listunitwithduty: function(name, id){ var idflag = (library.typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id; var v = this.ounit.listwithunitduty(name, idflag); return this.getobject(this.ounit, v); }, //组织职务*********** //获取指定的组织职务的身份 /** * 根据职务名称和组织名称获取身份。 * @method getduty * @o2membercategory duty * @methodof module:server.org * @static * @param {string} dutyname 组织职务名称。 * @param {unitflag} unit 组织的distinguishedname、id、unique属性值,组织对象。 * @return {identitydata[]} 返回身份数组。 * @o2actionout x_organization_assemble_express.unitdutyaction.getwithunitwithname|example=identity * @o2syntax * //返回身份数组。 * var identitylist = this.org.getduty( dutyname, unit ); */ getduty: function(duty, id){ var unit = (library.typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id; var v = this.ounitduty.listidentitywithunitwithname(unit, duty); return this.getobject(this.oidentity, v); }, //获取身份的所有职务名称 /** * 批量获取身份的所有职务名称。 * @method listdutynamewithidentity * @o2membercategory duty * @methodof module:server.org * @static * @param {identityflag|identityflag[]} identity - 身份的distinguishedname、id、unique属性值,身份对象,或上述属性值和对象的数组。 * @return {string[]} 返回职务名称数组。 * @o2syntax * //返回职务名称数组。 * var dutynamelist = this.org.listdutynamewithidentity( identity ); */ listdutynamewithidentity: function(name){ var ids = getnameflag(name); var namelist = []; for (var i=0; i[ value1, value2 ] * @o2syntax * //返回该组织的属性值数组。 * var attributelist = this.org.getunitattribute( unit, attr ); */ getunitattribute: function(unit, attr){ var unitflag = (library.typeof(unit)==="object") ? (unit.distinguishedname || unit.id || unit.unique || unit.name) : unit; var v = this.ounitattribute.listattributewithunitwithname(unitflag, attr); var v_json = []; if (v && v.length){ for (var i=0; i[ attributename1, attributename2 ] * @o2syntax * //返回组织所有属性的名称数组。 * var attributenamelist = this.org.listunitattributename( unit ); */ listunitattributename: function(name){ var p = getnameflag(name); var namelist = []; for (var i=0; i[{ * "name": "部门类别", * "unit": "开发部@kfb@u", * "attributelist": [ * "生产部门", * "二级部门" * ] * }] * @o2syntax * //返回组织所有属性的对象数组。 * var attributeobjectlist = this.org.listunitallattribute( unit ); */ listunitallattribute: function(name){ var u = getnameflag(name)[0]; var ds = this.ounitattribute.listnamewithunit(u); var o = [] for (var i=0; i * v8.0及以后版本中增加了服务管理的脚本配置。
* @module include() * @o2cn 脚本引用 * @o2category server.common * @o2ordernumber 175 * * @param {(string|object)} optionsorname 可以是脚本标识字符串或者是对象。 *

 *
 * //如果需要引用其他应用的脚本配置,将options设置为object;
 * this.include({
 *       //type: 应用类型。可以为 portal  process  cms  service。流程脚本默认为process,服务管理中默认为service
 *       type : "portal",
 *       application : "游戏厅捕鱼达人首页", // 门户、流程、cms的名称、别名、id。 引用服务管理的脚本则忽略该参数。
 *       name : "initscript" // 脚本配置的名称、别名或id
 * });
 *
 * //引用服务管理中的脚本
 * this.include({
 *   "type": "service",
 *   "name": "scriptname"
 * });
 *
 * //引用流程管理中的脚本
 * this.include({
 *   "type": "process",
 *   "application": "appname",
 *   "name": "scriptname"
 * });
 *
 * //引用内容管理中的脚本
 * this.include({
 *   "type": "cms",
 *   "application": "appname",
 *   "name": "scriptname"
 * });
 *
 * //引用门户管理中的脚本
 * this.include({
 *   "type": "portal",
 *   "application": "appname",
 *   "name": "scriptname"
 * });
 * 
* @param {function} [callback] 加载后执行的回调方法。 * * @o2syntax * //您可以在表单、流程、视图和查询视图的各个嵌入脚本中,通过this.include()来引用本应用或其他应用的脚本配置,如下: * this.include( optionsorname, callback ) * @example * * 样例一:在通用脚本中定义一个通用的方法去获取公文管理所有的文种,在查询语句中根据该方法来拼接jpql。
* 1、在内容管理应用中有一个fileres的应用,在该应用中创建一个脚本,命名为filesql,并定义方法。 * * * //定义一个方法 * this.define("getfilesql",function(){ * var application = ["公司发文","部门发文","党委发文"]; * var appsql = " ( "; * for(var i=0;i * 2、在查询语句中使用该方法。 * * * this.include({ * type : "cms", * application : "fileres", * name : "filesql" * }) * * var sql = this.getfilesql(); * * return "select o from com.x.processplatform.core.entity.content.task o where " sql */ bind.include = function( optionsorname , callback ){ var options = optionsorname; if( typeof( options ) == "string" ){ options = { name : options }; } var name = options.name; var type; if( options.type === "service" ){ type = options.type; }else{ type = ( options.type && options.application ) ? options.type : "process"; } var application = type === "service" ? "service" : options.application; if (!name || !type || !application){ console.log("include", new error("can not find script. missing script name or application")); return false; } if (!includedscripts[application]) includedscripts[application] = []; if (includedscripts[application].indexof( name )> -1){ if (callback) callback.apply(this); return; } var scriptaction; var scriptdata; switch ( type ){ case "portal" : bind.portalactions.getscript( application, name, {"importedlist":includedscripts[application]}, function(json){ if (json.data){ includedscripts[application] = includedscripts[application].concat(json.data.importedlist); scriptdata = json.data; } }.bind(this)); break; case "process" : bind.processactions.getscript( name, application, {"importedlist":includedscripts[application]}, function(json){ if (json.data){ includedscripts[application] = includedscripts[application].concat(json.data.importedlist); scriptdata = json.data; } }.bind(this)); break; case "cms" : bind.cmsactions.getscript(name, application, {"importedlist":includedscripts[application]}, function(json){ if (json.data){ includedscripts[application] = includedscripts[application].concat(json.data.importedlist); scriptdata = json.data; } }.bind(this)); break; case "service" : bind.serviceactions.getscript(name, {"importedlist":includedscripts[application]}, function(json){ if (json.data){ includedscripts[application] = includedscripts[application].concat(json.data.importedlist); scriptdata = json.data; } }.bind(this)); break; } includedscripts[application].push(name); if (scriptdata && scriptdata.text){ exec(scriptdata.text, this); if (callback) callback.apply(this); } }; //optionsorname : { // type : "", //默认为process, 可以为 process cms // application : "", //流程/cms的名称/别名/id, 默认为当前应用 // name : "", // 数据字典名称/别名/id // enableanonymous : false //允许在未登录的情况下读取cms的数据字典 //} //或者name: "" // 数据字典名称/别名/id /** * this.dict是一个工具类,如果您在流程、内容管理、门户和服务管理中创建了数据字典,可以使用this.dict类对数据字典进行增删改查操作。
* 从v8.0版本开始,支持在门户和服务管理中创建数据字典。 * @module server.dict * @o2cn 数据字典 * @o2category server.common * @o2ordernumber 180 * @o2syntax * //您可以通过this.dict()对本应用或其他应用的数据字典中的数据进行增删改查,如下: * var dict = new this.dict( options ) * @example * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。流程脚本默认为process,服务管理中默认为service。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * //引用服务管理中的数据字典 * var dict = new this.dict({ * "type": "service", * "name": "dictname" * }); * * //引用流程管理中的数据字典 * var dict = new this.dict({ * "type": "process", * "application": "appname", * "name": "dictname" * }); * * //引用内容管理中的数据字典 * var dict = new this.dict({ * "type": "cms", * "application": "appname", * "name": "dictname" * }); * * //引用门户管理中的数据字典 * var dict = new this.dict({ * "type": "portal", * "application": "appname", * "name": "dictname" * }); */ bind.dict = function(optionsorname){ var options = optionsorname; if( typeof( options ) == "string" ){ options = { name : options }; } var name = this.name = options.name; var type; if( options.type === "service"){ type = options.type; }else{ type = ( options.type && options.application ) ? options.type : "process"; } var applicationid = options.application || ((bind.java_workcontext) ? bind.java_workcontext.getwork().application : ""); var enableanonymous = options.enableanonymous || false; //mwf.require("mwf.xscript.actions.dictactions", null, false); var action; if( type == "cms" ){ action = bind.cmsactions; }else if( type == "service" ){ action = bind.serviceactions; }else if( type == "portal" ){ action = bind.portalactions; }else{ action = bind.processactions; } var encodepath = function( path ){ var arr = path.split(/\./g); var ar = arr.map(function(v){ return encodeuricomponent(v); }); return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/"); }; /** * 根据路径获取数据字典中的数据。 * @method get * @methodof module:server.dict * @static * @param {string} [path] 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。当值为空的时候,表示获取数据字典中的所有数据。 * @param {function} [success] 获取数据成功时的回调函数。流程设计后台脚本中无此参数。 * @param {function} [failure] 获取数据失败时的回调。流程设计后台脚本中无此参数。 * @return {(object|array|string|number|boolean)} * 返回数据字典的数据,类型和配置数据字典时候指定的一致。 * @o2syntax * var data = dict.get( path, success, failure ) * @example * * 已经配置好了如下图所示的数据字典 * * * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * var data = dict.get(); * //data的值为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * } * ] * } * * var category = dict.get("category"); * //category的值为 * [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * } * ] * * var array0 = dict.get("category.0"); * //array0 的值为 * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * } * * var enable = dict.get("category.0.eanble"); * //enable 的值为 true */ this.get = function(path, success, failure){ var value = null; if( type === "service" ){ if (path){ var p = encodepath( path ); action.getdictdata(encodeuricomponent(this.name), p, function(json){ value = json.data; if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }); }else{ action.getdictroot(encodeuricomponent(this.name), function(json){ value = json.data; if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false); } }else{ if (path){ var p = encodepath( path ); action[(enableanonymous && type == "cms") ? "getdictdataanonymous" : "getdictdata"](encodeuricomponent(this.name), applicationid, p, function(json){ value = json.data; if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }); }else{ action[(enableanonymous && type == "cms") ? "getdictrootanonymous" : "getdictroot"](encodeuricomponent(this.name), applicationid, function(json){ value = json.data; if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false); } } return value; }; /** * 根据路径修改数据字典的数据。 * @method set * @methodof module:dict * @instance * @param {string} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。 * @param {(object|array|string|number|boolean)} data 修改后的数据 * @param {function} [success] 设置数据成功时的回调函数。流程设计后台脚本中无此参数。 * @param {function} [failure] 设置数据错误时的回调函数。流程设计后台脚本中无此参数。 * @o2syntax * dict.set( path, data, success, failure ) * @example * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * dict.set( "category", { text : "系统公告", value : "system" }, function(data){ * //data 形如 * //{ * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典id * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); * @example * * 对example add的数据字典进行赋值,如下: * * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * dict.set( "archiveoptions", [ { text : "是" }, { text : "否" } ]); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * }, * { * "sequence" : 3.0, * "text": "系统公告", * "value": "system" * } * * ], * "archiveoptions" : [ { text : "是" }, { text : "否" } ] * } * * dict.set( "category.2", { text : "县级公告", value : "county" }, function(data){ * //data 形如 * //{ * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典id * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); * * /数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * }, * { * "text": "县级公告", * "value": "county" * } * ], * "archiveoptions" : [ { text : "是" }, { text : "否" } ] * } * * dict.set( "category.1.sequence", 3 ); * dict.set( "category.2.sequence", 2 ); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 3.0, * "text": "部门公告", * "value": "department" * }, * { * "sequence": 2.0, * "text": "县级公告", * "value": "county" * } * ], * "archiveoptions" : [ { text : "是" }, { text : "否" } ] * } * @example * * 下面是错误的赋值: * * dict.set( "category_1", { text : "公司公告" } ); //出错,因为category_1在数据字典中不存在 */ this.set = function(path, value, success, failure){ var p = encodepath( path ); //var p = path.replace(/\./g, "/"); if( type === "service" ){ action.setdictdata(encodeuricomponent(this.name), p, value, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); }else{ action.setdictdata(encodeuricomponent(this.name), applicationid, p, value, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); } }; /** * 根据路径新增数据字典的数据。 * @method add * @methodof module:dict * @instance * @param {string} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果path在数据字典中已有数据,且原有数据是数组,则数组添加一项;如果原有数据不是数组,则报错。 * @param {(object|array|string|number|boolean)} data 需要新增的数据 * @param {function} [success] 增加数据成功时的回调函数。流程设计后台脚本中无此参数。 * @param {function} [failure] 增加数据错误时的回调函数。流程设计后台脚本中无此参数。 * @o2syntax * dict.add( path, data, success, failure ) * @example * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * dict.add( "category", { text : "系统公告", value : "system" }, function(data){ * //data 形如 * //{ * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典id * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); * @example * * 对get方法样例的数据字典进行赋值,如下: * * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * name : "bulletindictionary", // 数据字典的名称、别名、id * }); * * dict.add( "category", { text : "系统公告", value : "system" }, function(data){ * //data 形如 * //{ * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典id * //} * }, function(xhr, text, error){ * //xhr 为 xmlhttprequest, text 为错误文本, error为error对象 * }); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * }, * { * "text": "系统公告", * "value": "system" * } * ] * } * * dict.add( "category.2.sequence", 3 ); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * }, * { * "sequence" : 3.0, * "text": "系统公告", * "value": "system" * } * ] * } * dict.add( "archiveoptions", { * "yes" : "是", * "no" : "否" * }); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 2.0, * "text": "部门公告", * "value": "department" * }, * { * "sequence" : 3.0, * "text": "系统公告", * "value": "system" * } * * ], * "archiveoptions" : { * "yes" : "是", * "no" : "否" * } * } * @example * 下面是错误的赋值,如下: * dict.add( "category.3", { text : "系统公告", value : "system" }); //出错,因为不能对数组下标直接赋值 * * dict.add( "category.1.value", { text : "系统公告" } ); //出错,因为不能对已经存在的非数组路径赋值 */ this.add = function(path, value, success, failure){ var p = encodepath( path ); //var p = path.replace(/\./g, "/"); if( type === "service" ) { action.adddictdata(encodeuricomponent(this.name), p, value, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); }else{ action.adddictdata(encodeuricomponent(this.name), applicationid, p, value, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); } }; /** * 根据路径删除数据字典的数据。流程设计后台脚本中无此方法。 * @method delete * @methodof module:dict * @instance * @param {string} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。 * @param {function} [success] 删除数据成功时的回调函数。 * @param {function} [failure] 删除数据错误时的回调函数。 * @o2syntax * dict.delete( path, success, failure ) * @example * var dict = new this.dict({ * //type: 应用类型。可以为process cms portal service。默认为process。 * type : "cms", * application : "bulletin", //流程、cms的名称、别名、id, 默认为当前应用 * name : "bulletindictionary", //流程、cms、门户管理的名称、别名、id。引用服务管理的数组字典则忽略该参数。 * }); * * dict.delete( "category", function(){ * }, function(xhr){ * //xhr 为 xmlhttprequest * }); * @example * * 对example set的数据字典进行赋值,如下: * * var dict = new this.dict("bulletindictionary"); * * dict.delete( "archiveoptions"); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * * "value": "company" * }, * { * "enable": "false", * "sequence": 3.0, * "text": "部门公告", * "value": "department" * }, * { * "sequence": 2.0, * "text": "县级公告", * "value": "county" * } * ] * } * * dict.delete( "category.2.sequence", function(data){ * //data 形如 * //{ * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典id * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 3.0, * "text": "部门公告", * "value": "department" * }, * { * "text": "县级公告", * "value": "county" * } * ] * } * * dict.delete( "category.2"); * //数据字典的值变为 * { * "category": [ * { * "enable": true, * "sequence": 1.0, * "text": "公司公告", * "value": "company" * }, * { * "enable": "false", * "sequence": 3.0, * "text": "部门公告", * "value": "department" * } * ] * } * @example * * 下面是错误的删除: * * dict.delete( "category_1" ); //出错,因为category_1在数据字典中不存在 */ this["delete"] = function(path, success, failure){ var p = encodepath( path ); //var p = path.replace(/\./g, "/"); if( type === "service" ) { action.deletedictdata(encodeuricomponent(this.name), p, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); }else{ action.deletedictdata(encodeuricomponent(this.name), applicationid, p, function(json){ if (success) success(json.data); }, function(xhr, text, error){ if (failure) failure(xhr, text, error); }, false, false); } }; this.destory = this["delete"]; }; /** * this.table是一个工具类,您可以使用这个类对数据中心的数据表进行增删改查操作。 * @module server.table * @o2cn 数据表执行 * @o2category server.common * @o2ordernumber 185 * @param {string} tablename 数据表的id、名称或别名。 * @return {object} table对象 * @o2syntax * //您可以在脚本中,通过this.table()来返回table的对象,如下: * var table = new this.table( tablename ) */ bind.table = function(name){ this.name = name; this.action = actions.load("x_query_assemble_surface").tableaction; /** * 列示表中的行对象,下一页。 * @method listrownext * @methodof module:server.table * @instance * @param {string} id 当前页最后一条数据的id,如果是第一页使用"(0)"。 * @param {string|number} count 下一页的行数 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.listrownext( id, count, success, failure ) * @example * var table = new this.table("table1"); * * table.listrownext( "0", 20, function(data){ * //data 形如 * //{ * // "type": "success", * // "data":[ * // { * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id * // "createtime": "2021-11-01 16:23:41", //数据创建时间 * // "updatetime": "2021-11-01 16:23:41", //数据更新时间 * // ... //定义的字段(列)和值 * // } * // ], * // "message": "", * // "date": "2021-11-01 18:34:19", * // "spent": 13, * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.listrownext = function(id, count, success, error, async){ this.action.listrownext(this.name, id, count, success, error, async); }; /** * 列示表中的行对象,上一页。 * @method listrowprev * @methodof module:server.table * @instance * @param {string} id 当前页第一条数据的id,如果是最后一页使用"(0)"。 * @param {string|number} count 上一页的行数 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.listrowprev( id, count, success, failure ) * @example * var table = new this.table("table1"); * * table.listrowprev( "0", 20, function(data){ * //data 形如 * //{ * // "type": "success", * // "data":[ * // { * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id * // "createtime": "2021-11-01 16:23:41", //数据创建时间 * // "updatetime": "2021-11-01 16:23:41", //数据更新时间 * // ... //定义的字段(列)和值 * // } * // ], * // "message": "", * // "date": "2021-11-01 18:34:19", * // "spent": 13, * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.listrowprev = function(id, count, success, error, async){ this.action.listrowprev(this.name, id, count, success, error, async); }; /** * 根据条件获取表中的数据。 * @method listrowselect * @methodof module:server.table * @instance * @param {string} [where] 查询条件,格式为jpql语法,o.name='zhangsan',允许为空。 * @param {string} [orderby] 排序条件,格式为:o.updatetime desc,允许为空 * @param {string|number} [size] 返回结果集数量,允许为空。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.listrowselect( where, orderby, size, success, failure ) * @example * var table = new this.table("table1"); * * //查询字段name等于zhangsan的数据,结果按updatetime倒序 * table.listrowselect( "o.name='zhangsan'", "o.updatetime desc", 20, function(data){ * //data 形如 * //{ * // "type": "success", * // "data":[ * // { * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id * // "createtime": "2021-11-01 16:23:41", //数据创建时间 * // "updatetime": "2021-11-01 16:23:41", //数据更新时间 * // ... //定义的字段(列)和值 * // } * // ], * // "message": "", * // "date": "2021-11-01 18:34:19", * // "spent": 13, * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.listrowselect = function(where, orderby, size, success, error, async){ this.action.listrowselect(this.name, {"where": where, "orderby": orderby, "size": size || ""}, success, error, async); }; this.listrowselectwhere = function(where, success, error, async){ this.action.listrowselectwhere(this.name, where, success, error, async); }; /** * 通过where 统计数量。 * @method rowcountwhere * @methodof module:server.table * @instance * @param {string} where 查询条件,格式为jpql语法,o.name='zhangsan',允许为空。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.rowcountwhere( where, success, failure ) * @example * var table = new this.table("table1"); * * //查询字段name等于zhangsan的数据,结果按updatetime倒序 * table.rowcountwhere( "o.name='zhangsan'", function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "value": 5 //符合条件数据的总条数 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.rowcountwhere = function(where, success, error, async){ this.action.rowcountwhere(this.name, where, success, error, async); }; /** * 删除数据表中指定id的记录。 * @method deleterow * @methodof module:server.table * @instance * @param {id} 需要删除记录的id。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.deleterow( id, success, failure ) * @example * var table = new this.table("table1"); * * table.deleterow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "value": true //true表示删除成功,false表示无此数据 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.deleterow = function(id, success, error, async){ this.action.rowdelete(this.name, id, success, error, async); }; /** * 更新指定表中所有行的数据。 * @method deleteallrow * @methodof module:server.table * @instance * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.deleteallrow( success, failure, async ) * @example * var table = new this.table("table1"); * * table.deleteallrow( function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "value": 1 //表示删除的条数,0表示无数据 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.deleteallrow = function(success, error, async){ this.action.rowdeleteall(this.name, success, error, async); }; /** * 获取数据表中指定id的记录。 * @method getrow * @methodof module:server.table * @instance * @param {id} 需要获取记录的id。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.getrow( id, success, failure ) * @example * var table = new this.table("table1"); * * table.getrow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){ * //data 形如 * //{ * // "type": "success", * // "data":{ * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id * // "createtime": "2021-11-01 16:23:41", //数据创建时间 * // "updatetime": "2021-11-01 16:23:41", //数据更新时间 * // ... //定义的字段(列)和值 * // }, * // "message": "", * // "date": "2021-11-01 18:34:19", * // "spent": 13, * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.getrow = function(id, success, error, async){ this.action.rowget(this.name, id, success, error, async); }; /** * 往数据表中批量插入数据。 * @method insertrow * @methodof module:server.table * @instance * @param {object[]} data 需要插入的数据。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.insertrow( data, success, failure ) * @example * var table = new this.table("table1"); * var data = [ * { * "subject": "标题一", * ... //其他字段 * }, * ... * ]; * table.insertrow( data, function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "value": true //true表示插入成功 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.insertrow = function(data, success, error, async){ this.action.rowinsert(this.name, data, success, error, async); }; /** * 往数据表中插入单条数据。 * @method addrow * @methodof module:table * @instance * @param {object} data 需要插入的数据。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.addrow( data, success, failure, async ) * @example * var table = new this.table("table1"); * var data = { * "subject": "标题一", * ... //其他字段 * }; * table.addrow( data, function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "id": 2cf3a20d-b166-490b-8d29-05544db3d79b //true表示修改成功 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.addrow = function(data, success, error, async){ this.action.rowinsertone(this.name, data, success, error, async); }; /** * 往数据表中修改单条数据。 * @method updaterow * @methodof module:server.table * @instance * @param {string} id 需要修改的数据id。 * @param {object} data 需要修改的数据。 * @param {function} [success] 调用成功时的回调函数。 * @param {function} [failure] 调用错误时的回调函数。 * @o2syntax * table.updaterow( id, data, success, failure ) * @example * var table = new this.table("table1"); * var data = { * "id" : "2cf3a20d-b166-490b-8d29-05544db3d79b", * "subject": "标题一", * ... //其他字段 * }; * table.updaterow( "2cf3a20d-b166-490b-8d29-05544db3d79b", data, function(data){ * //data 形如 * //{ * // "type": "success", * // "data": { * // "value": true //true表示修改成功 * // }, * // "message": "", * // "date": "2021-11-01 18:32:27" * //} * }, function(xhr){ * //xhr 为 xmlhttprequest * }); */ this.updaterow = function(id, data, success, error, async){ this.action.rowupdate(this.name, id, data, success, error, async); }; } /** * 您可以通过statement对象,获取执行查询语句或者对查询结果进行选择。
* @module server.statement * @o2cn 查询视图执行 * @o2category server.common * @o2ordernumber 190 * @o2syntax * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下: * var statement = this.statement; */ bind.statement = { /** * 执行指定的查询语句。 * @method execute * @static * @param {object} statement - 要执行的查询语句的信息。数据格式如下: *
以下的filter参数参考statementfilter, * parameter参数参考statementparameter
*

     * {
     *  "name" : "tesstatement", //(string)必选,查询配置的名称、别名或id
     *  "mode" : "all", //(string)必选,“all”、“data”或者“count”,all表示同时执行查询语句和总数语句,data表示执行查询语句,count表示执行总数语句
     *  "page" : 1, //(number)可选,当前页码,默认为1
     *  "pagesize" : 20, //(number)可选,每页的数据条数,默认为20
     *  "filter": [ //(array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
     *       {
     *           "path":"o.title",  //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
     *           "comparison":"like",
     *           "value":"关于",
     *           "formattype":"textvalue"
     *       }
     *  ],
     *  parameter : {
     *       "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identitylist(当前人身份列表),unitlist(当前人所在直接组织), unitalllist(当前人所在所有组织), grouplist(当前人所在群组)
     *       "starttime" : (new date("2020-01-01")), //如果对比的是日期,需要传入 date 类型
     *       "applicationname" : "%test%", //如果运算符用的是 like, nolike,模糊查询
     *       "processname" : "test流程", //其他写确定的值
     *       "?1": "关于" //v8.0后查询语句支持问号加数字的传参
     *     }
     * }
     * 
* @param {function} callback - 访问成功后的回调函数 * @param {boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。 * @o2syntax * this.statement.execute(statement, callback, async); * @example * //获取“task”查询中的数据 * //查询语句为 select o from task o where (o.person = :person) and (o.starttime > :starttime) and (o.applicationname like :applicationname) and (o.processname = :processname) * //总数语句为 select count(o.id) from task o where (o.person = :person) and (o.starttime > :starttime) and (o.applicationname like :applicationname) and (o.processname = :processname) * //过滤条件为标题o.title包含包含(like))“7月”。 * this.statement.execute({ * "name": "task", * "mode" : "all", * "filter": [ * { * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle * "comparison":"like", * "value":"7月", * "formattype":"textvalue" * } * ], * "parameter" : { * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identitylist(当前人身份列表),unitlist(当前人所在直接组织), unitalllist(当前人所在所有组织), grouplist(当前人所在群组) * "starttime" : (new date("2020-01-01")), //如果对比的是日期,需要传入 date 类型 * "applicationname" : "%test%", //如果运算符用的是 like, nolike,模糊查询 * "processname" : "test流程", //其他写确定的值 * "?1": "关于" //v8.0后查询语句支持问号加数字的传参 * } * }, function(json){ * var count = json.count; //总数语句执行后返回的数字 * var list = json.data; //查询语句后返回的数组 * //...... * }); */ execute: function (obj, callback) { if( obj.format ){ return this._execute(obj, callback, obj.format); }else{ if( this.needcheckformat(obj) ){ var value; var _self = this; bind.actions.load("x_query_assemble_surface").statementaction.getformat(obj.name, function(json){ value = _self._execute(obj, callback, json.data.format); }); return value; }else{ return this._execute(obj, callback, ""); } } }, needcheckformat: function(s){ if( s.format )return false; if( typeof(s.parameter) === "object" ){ for( var p in s.parameter ){ if( typeof( s.parameter[p] ) === "date" )return true; } } if( typeof(s.filter) === "array" ){ for( var i=0; i< s.filter.length; i ){ var ftype = s.filter[i].formattype; if( ["datetimevalue", "datetimevalue", "datevalue", "timevalue"].indexof( ftype ) > -1 )return true; } } return false; }, _execute: function (statement, callback, format) { var parameter = this.parseparameter(statement.parameter, format); var filterlist = this.parsefilter(statement.filter, parameter, format); var obj = { "filterlist": filterlist, "parameter" : parameter }; var value; bind.actions.load("x_query_assemble_surface").statementaction.executev2( statement.name, statement.mode || "data", statement.page || 1, statement.pagesize || 20, obj, function (json) { if (callback) callback(json); value = json; } ); return value; }, parsefilter : function( filter, parameter, format ){ if( typeof(filter) !== "array" )return []; if( !parameter )parameter = {}; var filterlist = []; ( filter || [] ).each( function (d) { //var parametername = d.path.replace(/\./g, "_"); var pname = d.path.replace(/\./g, "_"); var parametername = pname; var suffix = 1; while( parameter[parametername] ){ parametername = pname "_" suffix; suffix ; } var value = d.value; if( d.comparison === "like" || d.comparison === "notlike" ){ if( value.substr(0, 1) !== "%" )value = "%" value; if( value.substr(value.length-1,1) !== "%" )value = value "%"; parameter[ parametername ] = value; //"%" value "%"; }else{ if( ["sql", "sqlscript"].contains(format) ) { if (d.formattype === "numbervalue") { value = parsefloat(value); } }else{ if (d.formattype === "datetimevalue" || d.formattype === "datetimevalue") { value = "{ts '" value "'}" } else if (d.formattype === "datevalue") { value = "{d '" value "'}" } else if (d.formattype === "timevalue") { value = "{t '" value "'}" } else if (d.formattype === "numbervalue") { value = parsefloat(value); } } parameter[ parametername ] = value; } d.value = parametername; filterlist.push( d ); }); return filterlist; }, parseparameter : function( obj, format ){ if( typeof(obj) !== "object" )return {}; var parameter = {}; //传入的参数 for( var p in obj ){ var value = obj[p]; if( typeof( value ) === "date" ){ if( ["sql", "sqlscript"].contains(format) ){ value = value.format("db"); }else{ value = "{ts '" value.format("db") "'}" } } parameter[ p ] = value; } return parameter; }, "select": function () {} }; /** * 您可以通过view对象,获取视图数据或选择视图数据。
* @module server.view * @o2cn 视图执行 * @o2category server.common * @o2ordernumber 195 * @o2syntax * //您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下: * var view = this.view; */ bind.view = { /** * 获取指定视图的数据。 * @method lookup * @static * @param {object} view - 要访问的视图信息。数据格式如下:
* 以下的filter参数参考viewfilter *

     * {
     *  "view" : "testview", //(string)必选,视图的名称、别名或id
     *  "application" : "test数据中心应用", //(string)必选,视图所在数据应用的名称、别名或id
     *  "filter": [ //(array of object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
     *       {
     *           "logic":"and",
     *           "path":"$work.title",
     *           "comparison":"like",
     *           "value":"7月",
     *           "formattype":"textvalue"
     *       }
     *  ]
     * }
     * 
* @param {function} callback - 访问成功后的回调函数 * @param {boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。 * @o2syntax * this.view.lookup(view, callback, async); * @example * //获取“财务管理”应用中“报销审批数据”视图中的数据 * //过滤条件为标题($work.title)包含包含(like))“7月”。 * this.view.lookup({ * "view": "报销审批数据", * "application": "财务管理", * "filter": [ * { * "logic":"and", * "path":"$work.title", * "comparison":"like", * "value":"7月", * "formattype":"textvalue" * } * ] *}, function(data){ * var grid = data.grid; //得到过滤后的数据 * var groupgrid = data.groupgrid; //如果有分类,得到带分类的数据 * //...... *}); * @example * //获取“财务管理”应用中“报销审批数据”视图中的数据 * //过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000 * this.view.lookup({ * "view": "报销审批数据", * "application": "财务管理", * "filter": [ * { * "logic":"and", * "path":"$work.title", * "comparison":"like", * "value":"7月", * "formattype":"textvalue" * }, * { * "logic":"and", * "path":"amount", * "comparison":"range", * "value":500, * "othervalue":5000, * "formattype":"numbervalue" * }, * ] *}, function(data){ * var grid = data.grid; //得到过滤后的数据 * var groupgrid = data.groupgrid; //如果有分类,得到带分类的数据 * //...... *}); */ "lookup": function(view, callback){ var filterlist = {"filterlist": (view.filter || null)}; var value; bind.actions.load("x_query_assemble_surface").viewaction.executewithquery(view.view, view.application, filterlist, function(json){ var data = { "grid": json.data.grid || json.data.groupgrid, "groupgrid": json.data.groupgrid }; if (callback) callback(data); value = data; }); return value; }, "select": function(view, callback, options){} }; /** * 可以通过service对象发起restful请求,或soap协议的webservice调用。 * @module service * @o2cn 通用service调用 * @o2category server.common * @o2syntax * var service = this.service; * @example * //通过get方法发起restful请求,获取json数据 * var res = this.service.restful("get", "config/myjson.json"); * if (res.responsecode>=200 && responsecode<300){ * var jsondata = res.json; * } */ bind.service = { /** * 发起restful请求。 * @method restful * @o2category server.common * @param {string} [method] - restful请求方法:get、post、put、delete ... * @param {string} [url] - restful请求地址 * @param {object} [headers] - 可选,json对象,请求的header,默认content-type为:“application/json charset=utf-8” * @param {string|object} [body] - 可选,post、put请求的消息体,传入文本或json对象 * @param {number} [connecttimeout] - 可选,连接超时时间(毫秒),默认是2000。 * @param {number} [readtimeout] - 可选,传输超时时间(毫秒),默认是300000。 * @return {object} 返回json格式的请求结果对象,格式如下: *

     * {
     *  "responsecode" : 200,   //请求返回的code
     *  "headers" : {},         //响应头
     *  "body": "",             //响应的body文本内容
     *  "json": {}              //响应的body的json格式内容
     * }
     * 
* @o2syntax * var res = this.service.restful(method, url, headers, body, connecttimeout, readtimeout); * @example * //通过get方法发起restful请求,获取json数据 * var res = this.service.restful("get", "config/myjson.json"); * if (res.responsecode>=200 && res.responsecode<300){ * var jsondata = res.json; * } */ restful: function(method, url, headers, body, connecttimeout, readtimeout){ var service = bind.java_resources.getwebservicesclient(); var bodydata = ((typeof body)==="object") ? json.stringify(body) : (body||""); var res = service.restful(method, url, (headers||null), bodydata, (connecttimeout||2000), (readtimeout||300000)); var o = { "responsecode" : res.responsecode, "headers" : res.headers, "body": res.body } try { o.json = json.parse(res.body); }catch(e){} return o; }, /** * 通过get方法发起restful请求。 * @method get * @methodof restful * @static * @param {string} [url] - restful请求地址 * @param {object} [headers] - 可选,json对象,请求的header,默认content-type为:“application/json charset=utf-8” * @param {number} [connecttimeout] - 可选,连接超时时间(毫秒),默认是2000。 * @param {number} [readtimeout] - 可选,传输超时时间(毫秒),默认是300000。 * @return {object} 返回json格式的请求结果对象,格式如下: *

     * {
     *  "responsecode" : 200,   //请求返回的code
     *  "headers" : {},         //响应头
     *  "body": "",             //响应的body文本内容
     *  "json": {}              //响应的body的json格式内容
     * }
     * 
* @o2syntax * var res = this.service.get(url, headers, connecttimeout, readtimeout); */ "get": function(url, headers, connecttimeout, readtimeout){ return this.restful("get", url, headers, "", connecttimeout, readtimeout); }, /** * 通过post方法发起restful请求。 * @method post * @static * @param {string} [url] - restful请求地址 * @param {object} [headers] - 可选,json对象,请求的header,默认content-type为:“application/json charset=utf-8” * @param {string|object} [body] - 可选,post、put请求的消息体,传入文本或json对象 * @param {number} [connecttimeout] - 可选,连接超时时间(毫秒),默认是2000。 * @param {number} [readtimeout] - 可选,传输超时时间(毫秒),默认是300000。 * @return {object} 返回json格式的请求结果对象,格式如下: *

     * {
     *  "responsecode" : 200,   //请求返回的code
     *  "headers" : {},         //响应头
     *  "body": "",             //响应的body文本内容
     *  "json": {}              //响应的body的json格式内容
     * }
     * 
* @o2syntax * var res = this.service.post(url, headers, body, connecttimeout, readtimeout); */ "post": function(url, headers, body, connecttimeout, readtimeout){ return this.restful("post", url, headers, body, connecttimeout, readtimeout); }, /** * 发起soap协议的webservice请求。 * @method soap * @o2category server.common * @param {string} [wsdl] - wsdl文件地址 * @param {string} [method] - 要调用的方法名称 * @param {array} [pars] - 方法所需要的参数 * @return {object} 与服务返回的类型有关: * @o2syntax * var res = this.service.soap(wsdl, method, pars); * @example * //模拟通过webservice获取用户 * var res = this.service.soap("wsdl/mywsdl.wsdl", "getperson", ["张三", "李四"]); */ soap: function(wsdl, method, pars){ var service = bind.java_resources.getwebservicesclient(); return service.soap(wsdl, method, pars); }, soapxml: function(wsdl, xml){ var service = bind.java_resources.getwebservicesclient(); return service.jaxwsxml(wsdl, xml); } } //---------------------------------------------------------- //java_workcontext work上下文对象,流程相关的脚本中可获取 /** * 您可以在流程事件、流程路由事件、流程活动事件中通过workcontext获取和流程相关的流程实例对象数据。 * @module server.workcontext * @o2cn 流程实例 * @o2category server.process * @o2range {process} 所有流程配置中的脚本可以使用此对象 * @o2ordernumber 200 * @o2syntax * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前流程实例数据,如下: * var context = this.workcontext; */ bind.workcontext = { /** * 当前流程实例正在流转中,并且当前用户有待办,则返回当前用户的待办对象。 * 事实上在后端的活动事件中,大部分的情况下,此方法获取到的是taskcompleted对象,因为在人工活动的事件中,除了“待办处理前”事件,其他事件处理时,当前用户的待办都已经转为已办了。 * @summary 获取当前流程与当前用户相关的待办或已办对象:task对象或taskcompleted对象。 * @methodof module:server.workcontext * @o2actionout x_processplatform_assemble_surface.taskaction.get|example=task|task对象: * @method gettask * @static * @return {(task|taskcompleted|null)} 当前用户的待办任务对象:task。当前用户没有对此流程实例的待办时,或流程实例已经流转结束,返回null。 * @o2syntax * var task = this.workcontext.gettask(); */ "gettask": function(){ //根据work获取当前处理的的task或者taskcompleted json字符串 只能在流转的过程中获取到 var taskstring = bind.java_workcontext.gettaskortaskcompleted(); var task = (taskstring) ? json.parse(taskstring) : null; if (task){ task.persondn = task.person || ""; task.unitdn = task.unit || ""; task.unitdnlist = task.unitlist || ""; task.identitydn = task.identity || ""; task.creatorpersondn = task.creatorperson ||""; task.creatorunitdn = task.creatorunit ||""; task.creatorunitdnlist = task.creatorunitlist ||""; task.creatoridentitydn = task.creatoridentity ||""; } return task; }, /** * 获取当前流程实例对象:work对象或workcompleted对象。 * @method getwork * @methodof module:server.workcontext * @static * @return {(work|workcompleted)} 流程实例对象;如果流程已结束,返回已结束的流程实例对象。 * @o2actionout x_processplatform_assemble_surface.workaction.manageget|example=work|ignorenodescr=true|ignoreprops=[properties,manualtaskidentitymatrix]|work对象: * @o2actionout x_processplatform_assemble_surface.workcompletedaction.get|example=workcompleted|ignoreprops=[properties,data,taskcompletedlist,readcompletedlist,reviewlist,recordlist,workloglist,storeform,mobilestoreform]|workcompleted对象: * @o2syntax * var work = this.workcontext.getwork(); */ "getwork": function(){ //work的字符串 var work = json.parse(bind.java_workcontext.getwork()); work.creatorpersondn = work.creatorperson ||""; work.creatorunitdn = work.creatorunit ||""; work.creatorunitdnlist = work.creatorunitlist ||""; work.creatoridentitydn = work.creatoridentity ||""; return work; }, /** * 获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。 * @method gettasklist * @methodof module:server.workcontext * @o2actionout x_processplatform_assemble_surface.taskaction.listwithwork|example=task * @static * @return {(task[])} 待办任务列表. * @o2syntax * var tasklist = this.workcontext.gettasklist(); */ "gettasklist": function(){return json.parse(bind.java_workcontext.gettasklist());}, //根据work获取所有的task数组 json字符串 /** * 获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。 * @method gettaskcompletedlist * @methodof module:server.workcontext * @static * @return {(taskcompleted[])} 已办任务列表. * @o2actionout x_processplatform_assemble_surface.taskcompletedaction.listwithwork|example=task * @o2syntax * var taskcompletedlist = this.workcontext.gettaskcompletedlist(); */ "gettaskcompletedlist": function(){return json.parse(bind.java_workcontext.gettaskcompletedlist());}, //根据work获取所有的taskcompleted数组 json字符串 /** * @summary 获取当前流程实例的所有待阅对象数组。如果流程实例无待阅,则返回一个空数组。 * @method getreadlist * @methodof module:server.workcontext * @static * @return {(read[])} 当前流程实例的所有待阅对象数组. * @o2actionout x_processplatform_assemble_surface.readaction.get|example=read * @o2syntax * var readlist = this.workcontext.getreadlist(); */ "getreadlist": function(){return json.parse(bind.java_workcontext.getreadlist());}, //根据work获取所有的read数组 json字符串 /** * @summary 获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。 * @method getreadcompletedlist * @methodof module:server.workcontext * @static * @return {(readcompleted[])} 当前流程实例的所有已阅对象数组. * @o2actionout x_processplatform_assemble_surface.readcompletedaction.listwithwork|example=read * @o2syntax * var readcompletedlist = this.workcontext.getreadcompletedlist(); */ "getreadcompletedlist": function(){return json.parse(bind.java_workcontext.getreadcompletedlist());}, //根据work获取所有的readcompleted数组 json字符串 /** * @summary 获取当前流程实例的所有review对象。如果流程实例没有review,则返回一个空数组。 * @method getreviewlist * @alias getreviewlistbyjob * @methodof module:server.workcontext * @static * @return {(review[])} 当前流程实例的所有review对象数组. * @o2actionout x_processplatform_assemble_surface.reviewaction.listwithjob|example=review * @o2syntax * var reviewlist = this.workcontext.getreviewlist(); */ "getreviewlist": function(){return json.parse(bind.java_workcontext.getjobreviewlist());}, /** * @summary gettasklistbyjob方法的别名。 * @method getjobtasklist * @static * @see server.module:workcontext.gettasklistbyjob */ "getjobtasklist": function(){return json.parse(bind.java_workcontext.getjobtasklist());}, //根据jobid获取所有的task数组 json字符串 /** * @summary gettaskcompletedlistbyjob方法的别名。 * @method getjobtaskcompletedlist * @static * @see server.module:workcontext.gettaskcompletedlistbyjob */ "getjobtaskcompletedlist": function(){return json.parse(bind.java_workcontext.getjobtaskcompletedlist());}, //根据jobid获取所有的taskcompleted数组 json字符串 /** * @summary getreadlistbyjob方法的别名。 * @method getjobreadlist * @static * @see server.module:workcontext.getreadlistbyjob */ "getjobreadlist": function(){return json.parse(bind.java_workcontext.getjobreadlist());}, //根据jobid获取所有的read数组 json字符串 /** * @summary getreadcompletedlistbyjob方法的别名。 * @method getjobreadcompletedlist * @static * @see server.module:workcontext.getreadcompletedlistbyjob */ "getjobreadcompletedlist": function(){return json.parse(bind.java_workcontext.getjobreadcompletedlist());}, //根据jobid获取所有的readcompleted数组 json字符串 /** * @summary getreviewlist方法的别名。 * @method getjobreviewlist * @static * @see server.module:workcontext.getreviewlist */ "getjobreviewlist": function (){return this.getreviewlist();}, //根据jobid获取所有的review数组 json字符串 /** * 根据当前工作的job获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。 * @method gettasklistbyjob * @methodof module:server.workcontext * @o2actionout x_processplatform_assemble_surface.taskaction.listwithjob|example=task * @static * @return {(task[])} 待办任务列表. * @o2syntax * var tasklist = this.workcontext.gettasklistbyjob(); */ "gettasklistbyjob": function(){return this.getjobtasklist();}, /** * 根据当前工作的job获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。 * @method gettaskcompletedlistbyjob * @methodof module:server.workcontext * @static * @return {(taskcompleted[])} 已办任务列表. * @o2actionout x_processplatform_assemble_surface.taskcompletedaction.listwithjob|example=task * @o2syntax * var taskcompletedlist = this.workcontext.gettaskcompletedlistbyjob(); */ "gettaskcompletedlistbyjob": this.getjobtaskcompletedlist, /** * @summary 根据当前工作的job获取当前流程实例的所有待阅对象。如果流程实例无待阅,则返回一个空数组。 * @method getreadlistbyjob * @methodof module:server.workcontext * @static * @return {(read[])} 当前流程实例的所有待阅对象数组. * @o2actionout x_processplatform_assemble_surface.readaction.listwithjob|example=read * @o2syntax * var readlist = this.workcontext.getreadlistbyjob(); */ "getreadlistbyjob": function(){return this.getjobreadlist();}, /** * @summary 根据当前工作的job获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。 * @method getreadcompletedlistbyjob * @methodof module:server.workcontext * @static * @return {(readcompleted[])} 当前流程实例的所有已阅对象数组. * @o2actionout x_processplatform_assemble_surface.readcompletedaction.listwithjob|example=read * @o2syntax * var readcompletedlist = this.workcontext.getreadcompletedlistbyjob(); */ "getreadcompletedlistbyjob": function(){return this.getjobreadcompletedlist();}, /** * @summary getreviewlist方法的别名。 * @method getreviewlistbyjob * @static * @see server.module:workcontext.getreviewlist */ "getreviewlistbyjob": function(){return this.getjobreviewlist();}, /** * 获取当前流程实例所在的活动节点对象:activity对象。 * @method getactivity * @static * @return {(activity|null)} 当前流程实例所在的活动节点对象,如果当前流程实例已流转完成,则返回null. *
{
     *      "id": "801087c5-a4e6-4b91-bf4d-a81cdaa04471", //节点id
     *      "name": "办理",  //节点名称
     *      "description": "", //节点描述
     *      "alias": "",  //节点别名
     *      "resetrange": "department", //重置处理人范围
     *      "resetcount": 0,  //重置处理人数字
     *      "allowreset": true, //是否允许重置
     *      "manualmode": "single", //处理方式 单人single, 并行parallel, 串行queue, grab抢办
     *      "customdata": { //节点上的自定义属性,如果没有设置,不输出该值
     *
     *      }
     * }
* @o2syntax * var activity = this.workcontext.getactivity(); */ "getactivity": function(){return json.parse(bind.java_workcontext.getactivity());}, //活动对象字符串 /** * @summary 获取当前流程实例的所有流程记录(worklog)。 * @method getworkloglist * @static * @return {worklog[]} 流程记录对象. * @o2actionout x_processplatform_assemble_surface.worklogaction.listwithjob|example=worklog|ignoreprops=[properties,gobackfromactivitytype] * @o2syntax * var workloglist = this.workcontext.getworkloglist(); */ "getworkloglist": function(){return json.parse(bind.java_workcontext.getworkloglist());}, //workloglist对象数组的字符串 /** * @summary 获取当前流程实例的所有流程记录(record)。 * @method getrecordlist * @o2actionout x_processplatform_assemble_surface.recordaction.listwithjob|example=record * @static * @return {record[]} 流程记录(record)对象. * @o2syntax * var recordlist = this.workcontext.getrecordlist(); */ "getrecordlist": function(){return json.parse(bind.java_workcontext.getrecordlist());}, //recordlist对象数组的字符串,需要新增 /** * @summary 最后一条record对象,在活动流转完成事件中,获取本次流转的record;在其它事件中获取的是整个job的最后一条record,并不是本次流转的record。 * @method getrecord * @o2actionout x_processplatform_assemble_surface.recordaction.listwithjob|example=record * @static * @return {record[]} 流程记录(record)对象. * @o2syntax * var record = this.workcontext.getrecord(); */ "getrecord": function(){return json.parse(bind.java_workcontext.getrecord());}, //最后一条record对象,(在活动流转完成事件中,获取本次流转的record;在其它事件中获取的是整个job的最后一条record,并不是本次流转的record) /** * @summary 获取当前流程实例的附件对象列表。 * @method getattachmentlist * @static * @return {workattachmentdata[]} 附件数据. * @o2actionout x_processplatform_assemble_surface.attachmentaction.getwithworkorworkcompleted|example=attachment|ignoreprops=[properties] * @o2syntax * //获取附件列表 * var attachmentlist = this.workcontext.getattachmentlist(); */ "getattachmentlist": function(){return json.parse(bind.java_workcontext.getattachmentlist());}, //附件对象数组的字符串 /** * @summary 获取可选路由对象数组的字符串(流转事件中,获取到流转中的可选路由列表,根据当前work状态获取)。 * @method getroutelist * @static * @return {string[]} 路由字符串数组. * @o2syntax * var routelist = this.workcontext.getroutelist(); */ "getroutelist": function(){return json.parse(bind.java_workcontext.getroutelist());}, //可选路由对象数组的字符串(流转事件中,获取到流转中的可选路由列表,根据当前work状态获取) /** * @summary 重新设置流程实例标题 * @method settitle * @static * @param {string} title - 标题字符串. * @o2syntax * this.workcontext.settitle(title); * @example * this.workcontext.settitle("标题"); */ "settitle": function(title){bind.java_workcontext.settitle(title);}, //设置title "getcontrol": function(){return null;}, "getinquiredroutelist": function(){return null;} }; bind.workcontent = bind.workcontext; //person, 直接注入,oauth配置和默认生成口令脚本中 /** * 在流程事件、流程路由事件、流程活动事件中通过this.data获取流程实例的业务数据。(内容管理无后台脚本)。
* 这些数据一般情况下是通过您创建的表单收集而来的,也可以通过脚本进行创建和增删改查操作。
* data对象基本上是一个json对象,您可以用访问json对象的方法访问data对象的所有数据。 * @module server.data * @o2cn 流程数据 * @o2category server.process * @o2ordernumber 205 * @example * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下: * var data = this.data; * @borrows module:data#[property] as [property] */ //bind.data = this.java_data; //业务数据data,直接注入 //流程调用脚本,数据脚本-------------------------------------------- //{ // data:{}, // application:"", // process:"", // identity: "", // attachmentlist: [], // title: "", // processing: true //} //后续计划通过return 返回assigndata, /** * 用于流程配置的流程调用活动中的“数据脚本”,可以通过assigndata对象获取要调用的流程的相关信息,以及要传递给被调用流程实例的业务数据。
* 也可以修改业务数据,并通过assigndata的set方法,将业务数据传递到被调用的流程实例。
* @o2range 流程配置-流程调用活动中的“数据脚本”中可用 * @module server.assigndata * @o2cn 流程实例业务数据 * @o2category server.process * @o2ordernumber 210 * @example * //在流程调用活动中的“数据脚本”,通过下面的代码修改业务数据,并传递给被调用流程的实例: * var data = this.assigndata.get(); * data.data.parentprocessdata = "父流程实例的信息"; * this.assigndata.set(data); * @example * * assigndata.set方法是为了兼容以前的版本。
* 建议通过return一个json对象的方式来设置data内容 * * //也可以通过return一个json对象的方式来代替assigndata.set方法 * var data = this.assigndata.get(); * data.data.parentprocessdata = "父流程实例的信息"; * return data; */ bind.assigndata = { //java_assigndata 应用调用活动的创建的流程实例的业务数据处理对象,get set 方法 _data: null, /** * @summary 获取要调用的流程的相关信息,以及要传递给被调用流程实例的业务数据。 * @method get * @methodof module:server.assigndata * @static * @return {object} 描述被调用的流程的信息,及要传递的业务数据. *
{
     *        "application": "application id",  //被调用的应用id
     *        "process": "process id",          //被调用的流程id
     *        "identity": "xxx@xxx@i",          //被调用流程的启动这身份
     *        "title": "title",                 //被调用流程实例的标题
     *        "attachmentlist": [],             //要传递到被调用的流程实例的附件对象
     *        "data": {}                        //要传递到被调用的流程实例的业务数据
     * }
* @o2syntax * var data = this.assigndata.get(); */ "get": function(){ this.data = json.parse(bind.java_assigndata.get()); return this.data; }, /** * @summary 设置修改后的assigndata对象。(set方法为了兼容早期的版本。建议使用 return data; 方式直接返回json对象) * @method set * @methodof module:server.assigndata * @static * @param {object} [data] 要设置的assigndata对象,一般情况都是通过assigndata.get()获取并做必要修改的对象。 * @o2syntax * this.assigndata.set(data); * @deprecated set方法已不建议使用了。建议return一个json对象或数组的方式来设置data。 * @example * var data = this.assigndata.get(); * data.data.parentprocessdata = "父流程实例的信息"; * return data; */ "set": function(data){ bind.java_assigndata.set(json.stringify(data || this.data)); } }; object.defineproperties(bind.assigndata, {"data": { "configurable": true, "get": function(){ if (this._data) return this._data; return json.parse(bind.java_assigndata.get()); }, "set": function(v){this._data = v;} }}); //-------------------------------------------------------------- //封装java对象data, 以兼容javascript对象 (function (bind) { object.prototype.containskey = function(key){ return object.keys(this).indexof(key)!==-1; } object.prototype.put = function(key, value){ this[key] = value; } var javaclass; try { javaclass = { map: java.util.map, array: java.util.arraylist, work: com.x.processplatform.core.entity.content.data$datawork } }catch (e){ javaclass = { map: object, array: array, work: new function() } } function proxywork(data) { return (data instanceof javaclass.work) && json.parse(data.tostring()); } function proxyjavaobject(data) { return (data instanceof javaclass.map) && new proxydata(data); } function proxyarray(data) { return ((data instanceof javaclass.array) || typeof(data) === "array") && createproxyarray(data); } function createproxyarray(data) { var arr = []; data.foreach(function (d) { arr.push(createproxydata(d)); }); return arr; // return data.map(function (d) { // return createproxydata(d); // }); } function createproxydata(data) { var proxydata; [proxyjavaobject, proxyarray, proxywork].some(function (fun) { return proxydata = fun(data); }); return proxydata || data; } function _getter(key, tdata, proxy) { return function () { if (!proxy.proxydata.hasownproperty(key)) { proxy.proxydata[key] = createproxydata(tdata[key], proxy); } return proxy.proxydata[key]; } } function _setter(key, data, proxy) { return function (value) { proxy.proxydata[key] = createproxydata(value, proxy); data.put(key, value); // data[key] = value; } } function _adddata(data, proxy) { return function (key, value) { if (proxy.hasownproperty(key)) { proxy[key] = value; } else { data.put(key, value); //data[key] = value; object.defineproperty(proxy, key, { configurable: true, enumerable: true, get: _getter(key, data, proxy), set: _setter(key, data, proxy) }) } } } function _deldata(data, proxy) { return function (key) { if (proxy.hasownproperty(key)) { data.remove(key); delete proxy[key]; } } } function isproxydata(data){ return proxydata.prototype.isprototypeof(data); } function commitarray(arrlist, proxy){ proxy.foreach(function(d, i){ if (array.isarray(d)){ if (arrlist.length<=i) arrlist.add(new java.util.arraylist()); commitarray(arrlist[i], d) }else if (isproxydata(d)){ d.commit(); }else if (d instanceof object) { if (arrlist.length<=i) arrlist.add(new java.util.linkedhashmap()); commitobject(arrlist[i], d) }else{ if (arrlist.length<=i){ arrlist.add(d); }else if (arrlist[i]!==d){ arrlist[i]=d; } } }); } function commitobject(map, proxy){ object.keys(proxy).foreach(function(key){ var d = proxy[key]; if (array.isarray(d)){ if (!map.containskey(key)) map.put(key, new java.util.arraylist()); commitarray(map[key], d) }else if (isproxydata(d)){ d.commit(); }else if (d instanceof object) { if (!map.containskey(key)) map.put(key, new java.util.linkedhashmap()); commitobject(map[key], d) }else{ if (!map.containskey(key) || map[key] !== d) map.put(key, d); } }); } function commitdata(data, proxy) { object.keys(proxy).foreach(function (key) { var d = proxy[key]; if (isproxydata(d)){ d.commit(); }else if (array.isarray(d)) { if (!data.containskey(key)) data[key] = new java.util.arraylist(); commitarray(data[key], d) }else if (!data.containskey(key)){ data[key] = d; } }) } function proxydata(tdata) { object.defineproperty(this, "proxydata", { value: {} }); var _self = this; var keys = tdata.keyset(); var o = {}; keys.foreach(function (key) { o[key] = { configurable: true, enumerable: true, get: _getter(key, tdata, _self), set: _setter(key, tdata, _self) } }); o.add = { value: _adddata(tdata, _self) }; o.del = { value: _deldata(tdata, _self) }; o.commit = { value: function(){ commitdata(tdata, _self); } }; object.defineproperties(this, o); } object.defineproperty(bind, "data", { configurable: true, enumerable: true, get: function(){ if (!this.__data__) this.__data__ = (bind.java_data) && new proxydata(bind.java_data); return this.__data__; } }) })(this); //服务调用活动,相关脚本-------------------------------------------- //调用活动中的参数 java_jaxwsparameters webservice调用; java_jaxrsparameterss rest调用 //后续计划通过return 返回json(jaxrs)或数组(jaxws) /** * 用于流程配置的服务调用活动中的“参数脚本”,为jaxrs和jaxws两种服务调用方式传递参数。
* 当调用类型为jaxrs时:可使用parameters.put和parameters.remove方法
* 当调用类型为jaxws时:可使用parameters.add和parameters.remove方法
* @o2range 流程配置-服务调用活动中的“参数脚本”中可用 * @module server.parameters * @o2cn 服务调用参数 * @o2category server.process * @o2ordernumber 215 * @deprecated parameters对象已经不建议使用了。建议return一个json对象或数组的方式来设置参数。 * @example * //使用jaxrs方式的服务调用活动的参数脚本中 * //如果rest服务地址为:xxx/{id}/xx/{name},则需要传入两个参数:id和name,可使用如下代码: * this.parameters.put("id", "id value"); * this.parameters.put("name", "name value"); * * //或者 * this.parameters.put({ * "id": "id value", * "name": "name value" * }); * * @example * //使用jaxws方式的服务调用活动的参数脚本中 * //如果需要传入三个参数,可使用如下代码: * this.parameters.add("参数1"); * this.parameters.add("参数2"); * this.parameters.add("参数3"); * * //或者 * this.parameters.add(["参数1", "参数2", "参数3"]); * * @example * * 以上两个例子中使用了parameters对象来收集参数,这主要是为了兼容以前的版本。
* 我们更建议通过return一个json对象或数组的方式来设置参数 * * //以上两个例子中使用了parameters对象来收集参数 * //更好的方式是:通过return一个json对象或数组的方式来设置参数 * //对于jaxrs方式: * return { * "id": "id value", * "name": "name value" * } * * //对于jaxws方式: * return ["参数1", "参数2", "参数3"]; */ bind.parameters = { /** * @summary jaxws方式的服务调用活动,“参数脚本”中,使用parameters.add设置参数。 * @method add * @methodof module:server.parameters * @static * @param {any|array} [value] 要设置的参数值。 * @o2syntax * this.parameters.add(value); * @deprecated 不建议使用,建议return一个数组的方式来设置参数。如: *
return ["参数1", "参数2", "参数3"];
*/ "add": function(value){ try{ if (bind.java_jaxwsparameters){ if (array.isarray(value)){ value.foreach(function(v){ bind.java_jaxwsparameters.add(v); }); }else{ bind.java_jaxwsparameters.add(value); } } }catch(e){} }, /** * @summary jaxrs方式的服务调用活动,“参数脚本”中,使用parameters.put设置参数。 * @method put * @methodof module:server.parameters * @static * @param {string|object} [name] 要设置的参数key,或参数json对象。 * @param {string|number|boolean} [value] 要设置的参数值。 * @o2syntax * this.parameters.put(name, value); * this.parameters.put(obj); * @deprecated 不建议使用,建议return一个json对象的方式来设置参数。如: *
return {
     *     "id": "id value",
     *     "name": "name value"
     * };
*/ "put": function(name, value){ try{ if ((typeof name)==="object"){ var _keys = object.keys(name); for (var i=0; i<_keys.length; i ){ if (bind.java_jaxrsparameters) bind.java_jaxrsparameters.put(_keys[i], name[_keys[i]]); } }else{ if (bind.java_jaxrsparameters) bind.java_jaxrsparameters.put(name, value); } }catch(e){} }, /** * @summary 服务调用活动,“参数脚本”中,删除已设置参数。 * @method remove * @methodof module:server.parameters * @static * @param {string|number} [name] jaxrs方式的服务调用活动,传入要删除参数的key;jaxws方式的服务调用活动,传入要删除的参数的索引。 * @o2syntax * this.parameters.remove(name); * @deprecated 不建议使用 */ "remove": function(name){ try{ if (bind.java_jaxwsparameters) bind.java_jaxwsparameters.remove(name); if (bind.java_jaxrsparameters) bind.java_jaxrsparameters.remove(name); }catch(e){} } }; //java_jaxrsbody //调用活动的 body //后续计划通过return返回 /** * 用于流程配置的服务调用活动中的“消息体脚本”,仅在jaxrs方式的服务调用活动中可用。
* @o2range 流程配置-服务调用活动中的“消息体脚本”,服务协议为jaxrs * @module server.body * @o2cn 服务调用消息体 * @o2category server.process * @o2ordernumber 220 * @deprecated body对象已经不建议使用了。建议return一个json对象的方式来设置body。如: *
return {
 *     "key1": "value1",
 *     "key2": "value2",
 *     "key3": "value3"
 * };
* @example * //设置jaxrs服务调用的消息体 * this.body.set({ * "key1": "value1", * "key2": "value2", * "key3": "value3" * }) * * //或者设置 * this.body.set("this is body data"); * * @example * * body.set方法是为了兼容以前的版本。
* 建议通过return一个json对象的方式来设置消息体内容 * * return { * "key1": "value1", * "key2": "value2", * "key3": "value3" * }; * * //或 * return "this is body data"; */ bind.body = { /** * @summary 服务调用活动中的“消息体脚本”,用于设置消息体内容。 * @method set * @methodof module:server.body * @static * @param {string|object} [data] 消息体内容。 * @o2syntax * this.body.set(data); * @deprecated 不建议使用,建议return一个json对象或数组的方式来设置body。 */ "set": function(data){ if ((typeof data)==="string"){ bind.java_jaxrsbody.set(data); } if ((typeof data)==="object"){ bind.java_jaxrsbody.set(json.stringify(data)); } } }; //java_jaxrsheaders //调用活动的 headers //后续计划通过return返回 /** * 用于流程配置的服务调用活动中的“消息头脚本”,仅在jaxrs方式的服务调用活动中可用。
* @o2range 流程配置-服务调用活动中的“消息头脚本”,服务协议为jaxrs * @module server.headers * @o2cn 服务调用消息头 * @o2category server.process * @o2ordernumber 225 * @deprecated headers对象已经不建议使用了,建议return一个json对象的方式来设置headers。如: *
return {
 *     "content-type": "application/x-www-form-urlencoded",
 *     "accept-language": "en"
 * };
* @example * //设置jaxrs服务调用的消息头 * this.headers.put("content-type", "application/x-www-form-urlencoded"); * * //或者 * this.headers.put({ * "content-type": "application/x-www-form-urlencoded", * "accept-language": "en" * }); * * @example * * headers.put方法是为了兼容以前的版本。
* 建议通过return一个json对象的方式来设置消息头内容 * * return { * "content-type": "application/x-www-form-urlencoded", * "accept-language": "en" * }; */ bind.headers = { /** * @summary jaxrs方式的服务调用活动,“消息头脚本”中,headers.put设置消息头。 * @method add * @methodof module:server.headers * @static * @param {string|object} [name] 要设置的消息头名称,或消息头json对象。 * @param {string} [value] 要设置的消息头值。 * @o2syntax * this.headers.put(name, value); * this.headers.put(obj); * @deprecated 不建议使用,建议return一个json对象的方式来设置headers。如: *
return {
     *     "content-type": "application/x-www-form-urlencoded",
     *     "accept-language": "en"
     * };
*/ "put": function(name, value){ try{ if ((typeof name)==="object"){ var _keys = object.keys(name); for (var i=0; i<_keys.length; i ){ if (bind.java_jaxrsheaders) bind.java_jaxrsheaders.put(_keys[i], name[_keys[i]]); } }else{ if (bind.java_jaxrsheaders) bind.java_jaxrsheaders.put(name, value); } }catch(e){} }, /** * @summary jaxrs方式的服务调用活动,“消息头脚本”中,删除已经设置消息头。 * @method remove * @methodof module:server.headers * @static * @param {string} [name] 要删除的消息头名称。 * @o2syntax * this.headers.remove(name); * @deprecated 不建议使用 */ "remove": function(name){ try{ if (bind.java_jaxrsheaders) bind.java_jaxrsheaders.remove(name); }catch(e){} } }; //java_jaxrsresponse, type() //java_jaxrsresponse, get() 字符串 //java_jaxwsresponse 直接返回不做处理 /** * 用于流程配置的服务调用活动中的“响应脚本”,描述调用服务后得到的响应。(注意:调用方式为异步时,“响应脚本”不会执行)
* @o2range 流程配置-服务调用活动中的“响应脚本” * @module server.response * @o2cn 服务调用的响应 * @o2category server.process * @o2ordernumber 230 * @o2syntax * var res = this.response; */ bind.response = {}; /** * @summary jaxrs方式的服务调用活动,请求返回的状态。有四个可能的值: *
success : 表示请求成功
 * warn : 当调用的是平台内部服务时,虽然请求成功,但产生了警告
 * error : 请求调用错误
 * connectfatal : 网络连接错误
* @member {string} status * @memberof server.module:response * @o2syntax * var status = this.response.status; */ object.defineproperty(bind.response, "status", {enumerable: true,configurable: true, get: function(){ return (bind.java_jaxrsresponse) ? bind.java_jaxrsresponse.type() : ""; } }); /** * @summary 请求返回的值,如果是jaxrs服务,得到的是响应的文本,如果是jaxws服务,响应类型取决于服务的返回。 * @member {string|any} value * @memberof server.module:response * @o2syntax * var value = this.response.value; * @example * //处理json对象的返回信息 * var value = this.response.value; * var resdata = json.parse(value); */ object.defineproperty(bind.response, "value", {enumerable: true,configurable: true, get: function(){ if (bind.java_jaxrsresponse){ return bind.java_jaxrsresponse.get(); }else if(_self.jaxwsresponse){ return bind.java_jaxwsresponse; } } }); /** * @summary 获取请求返回的值,如果是jaxrs服务,会尽可能将响应数据转换为json对象,如果不能解析为json对象的,则返回文本,如果是jaxws服务,响应类型取决于服务的返回。 * @method get * @methodof server.module:response * @static * @return {object|string|any} 响应的内容. * @o2syntax * var res = this.response.get(); */ object.defineproperty(bind.response, "get", {enumerable: true,configurable: true, get: function(){ return function(){ if (bind.java_jaxrsresponse){ var value = bind.java_jaxrsresponse.get(); if (json.validate(value)){ return json.decode(value); } return value; }else if(bind.java_jaxwsresponse){ return bind.java_jaxwsresponse || null } }; } }); //----------------------------------------------------------------------------------- //后端没有form bind.form = null; //java_requesttext, 服务活动,请求数据字符串 /** * 用于流程配置的服务活动中的“服务响应脚本”,描述发起服务的请求对象。
* @o2range 流程配置-服务活动中的“响应脚本” * @module server.request * @o2cn 服务调用请求对象 * @o2category server.process * @o2ordernumber 235 * @o2syntax * var res = this.request; */ bind.request = { /** * @summary 获取请求的body内容。 * @method getbody * @methodof server.module:request * @static * @return {object|string} 请求的body内容,如果能转换为json,则返回json对象,否则返回请求的内容的文本. * @o2syntax * var req = this.request.getbody(); */ "getbody": function(){ try{ return json.parse(bind.java_requesttext); }catch(e){ return bind.java_requesttext; } } } /** * @summary 获取请求的body的原始内容。 * @member {string} text * @memberof server.module:request * @o2syntax * var req = this.request.text; */ object.defineproperties(bind, { "text": { "configurable": true, "get": function(){return bind.java_requesttext;} } }); //活动时效计算对象,流程时效得去掉 //java_expire, //脚本返回json数据: //{ // hour: 3 //几小时后超时 // workhour: 5 //几个工作小时后超时 // date: '2016-08-01' //到达指定时间后超时 //} //设置指定的超时时间: //this.expire.setdate([date or string] date) //设置几小时后超时: //this.expire.sethour([int] hour) //设置几个工作小时后超时: //this.expire.setworkhour([int] hour) /** * 用于流程配置的人工活动的“时效脚本”中,用于设置超时时间。可以通过设置小时数,工作小时数,和指定时间点来设置超时,如果全部设置,则优先级为:工作小时>小时>时间
* @o2range 流程配置-人工活动中的“时效脚本” * @module server.expire * @o2cn 超时时间设置 * @o2category server.process * @o2ordernumber 240 * @deprecated expire对象已经不建议使用了。建议return一个json对象的方式来设置超时时间。 * @example * //设置超时时限为待办产生后5小时 * this.expire.sethour(5); * * //设置超时时限为待办产生后5个工作小时(只计算工作时间) * this.expire.setworkhour(5); * * //设置超时时限为指定时间,如业务数据中的设定的办理期限(processingtime) * this.expire.setdate(this.data.processingtime); * * @example * * expire对象是为了兼容以前的版本。
* 建议可以直接返回一个json对象来设置超时时间 * * //设置超时时限为待办产生后5小时 * return {"hour": 5}; * * //设置超时时限为待办产生后5个工作小时(只计算工作时间) * return {"workhour": 5}; * * //设置超时时限为指定时间,如业务数据中的设定的办理期限(processingtime) * return {"date": this.data.processingtime}; */ bind.expire = { /** * @summary 设置超时小时数。 * @method sethour * @methodof server.module:expire * @static * @param {number} [hour] 超时的小时数。 * @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如: *
return {"hour": 5}
*/ "sethour": function(hour){ try{bind.java_expire.sethour(hour);}catch(e){} }, /** * @summary 设置超时工作小时数。 * @method setworkhour * @methodof server.module:expire * @static * @param {number} [hour] 超时的工作小时数。 * @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如: *
return {"workhour": 5}
*/ "setworkhour": function(hour){ try{bind.java_expire.setworkhour(hour);}catch(e){} }, /** * @summary 设置超时时间。 * @method setdate * @methodof server.module:expire * @static * yyyy-mm-dd hh:mm:ss * @param {string} [date] 一个表示日期时间的字符串,按以下格式: *
yyyy-mm-dd hh:mm:ss   //如2021-09-12 18:26:51
* @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如: *
return {"date": "2021-09-12 18:26:51"}
*/ "setdate": function(date){ try{bind.java_expire.setdate(date);}catch(e){} } }; /** * 在流程调用活动中。当启用流程等待的情况下,在"子流程成功后"、"子流程取消后"、"子流程完成后",三个事件脚本中,可以访问到embeddata对象
* embeddata对象就是被调用的子流程的业务数据,它是一个类似json的对象,您可以用访问json对象的方法访问embeddata对象的所有数据。
* 如果您需要获取embeddata的json文本,请使用embeddata.tostring()f方法。注意:json.stringify()方法不能用于embeddata对象
* 您可以通过work对象的embedcompleted值来判断被调用的子流程是否正常完成。 cancel end *

 *  var embedstatus = this.workcontext.getwork().embedcompleted;
 *  if (embedstatus=="end"){
 *      //被调用的子流程正常流转到了结束活动
 *  }
 *  if (embedstatus=="cancel"){
 *      //被调用的子流程流转到了取消活动
 *  }
 * 
* @o2range 流程配置-流程调用活动中,当启用流程等待的情况下,在"子流程成功后"、"子流程取消后"、"子流程完成后",三个事件中可用 * @module server.embeddata * @o2cn 调用活动的子流程业务数据 * @o2category server.process * @o2ordernumber 205 * @example * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下: * var embeddata = this.embeddata; */ var o= { "context": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getcontext() : null)} }, "applications": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getapplications() : null)} }, "organization": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getorganization() : null)} }, // "service": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getwebservicesclient() : null)} }, "currentperson": { "configurable": true, "get": function(){return (bind.java_effectiveperson || null)} }, "effectiveperson": { "configurable": true, "get": function(){return (bind.java_effectiveperson || null)} }, "resources": { "configurable": true, "get": function(){return (bind.java_resources || null)} } } object.defineproperties(bind, o); /* 清除 engine */ this.engine = null;
网站地图