ViewEnvironment.js 138 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181
  1. /**
  2. * StatementInfor 查询配置信息
  3. * @typedef {Object} StatementInfor
  4. * @example
  5. * {
  6. "query": "26d21c71-5114-4496-8ca1-a69e56324841", //所属应用id
  7. "id": "ee334220-66d3-4f78-afce-8ccf6b995c8c", //查询id
  8. "name": "测试查询", //名称
  9. "alias": "", //别名
  10. "description": "", //描述
  11. "table": "", //自建表的id
  12. "entityClassName": "com.x.processplatform.core.entity.content.Task", //系统表表名
  13. "entityCategory": "official", //表类型 official(系统表) 或 dynamic(自建表)
  14. "format": "jpql", //语句类型,jpql 或者 script(脚本)
  15. "type": "select", //select/update/delete
  16. "data": "SELECT o FROM Task o where o.person = :person", //查询语句
  17. "countData": "SELECT count(o.id) FROM Task o where o.person = :person", //总数语句
  18. "countScriptText" : "", //总数语句脚本
  19. "scriptText" : "", //查询语句脚本
  20. "viewJson": { ... } //视图相关信息
  21. }
  22. */
  23. /**
  24. * ViewInfor 视图配置信息
  25. * @typedef {Object} ViewInfor
  26. * @example
  27. * {
  28. "application": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用
  29. "query": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用,同application
  30. "name": "视图自定义测试", //视图名称
  31. "viewName": "视图自定义测试", //视图名称,同name
  32. "isExpand": "no", //如果有分类,默认是否展开开
  33. "id": "705ce967-2f9c-425c-8873-3bd729249e1d", //视图id
  34. "alias": "", //视图别名
  35. "description": "", //视图描述
  36. "display": true, //视图是否显示
  37. "type": "cms", //视图嵌入的数据类型, cms 或 process
  38. "count": 2000, //最多返回2000条
  39. "pageSize": 20, //每页的条数
  40. "createTime": "2019-09-02 10:18:27",
  41. "updateTime": "2020-03-26 15:53:03"
  42. }
  43. */
  44. /**
  45. * @readonly
  46. * @enum {String} ViewFilterDataLogic
  47. * @property {String} or color for a white square or piece.
  48. * @property {String} and color for a black square or piece.
  49. */
  50. /**
  51. * ViewFilter 视图过滤条件
  52. * @typedef {Object} ViewFilter
  53. * @property {String} logic - 可选值:“and”或者“or”,表示和前一个条件的逻辑运算关系。
  54. * @property {String} path - 要过滤的data数据的路径。
  55. * @property {String} comparison - 比较运算符,可选值:<br/>
  56. * <div style='padding-left:150px;'>
  57. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  58. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  59. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  60. * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
  61. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  62. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  63. * <b>like</b> :表示部分匹配。<br/>
  64. * <b>notLike</b> :表示不匹配。<br/>
  65. * <b>range</b> :表示一定的范围。<br/>
  66. * <b>in</b> :表示在某几个特定的值当中。<br/>
  67. * </div>
  68. * @property {String} formatType - 过滤数据的数据类型,可选值:
  69. * <div style='padding-left:150px;'>
  70. * <b>textValue</b> :文本。<br/>
  71. * <b>numberValue</b> :数字。<br/>
  72. * <b>dateTimeValue</b> :日期时间。<br/>
  73. * <b>booleanValue</b> :布尔值。<br/>
  74. * </div>
  75. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。当comparison值为“range”时,此值表示范围中的第一个值。当comparison值为“in”时,多个值用半角逗号","分开。
  76. * @property {(String|Number|Boolean)} otherValue - 当comparison值为“range”时,此值表示范围中的第二个值。当comparison值不为“range”时,忽略此值。
  77. * @example
  78. * {
  79. * "logic":"and",
  80. * "path":"$work.title",
  81. * "comparison":"like",
  82. * "value":"7月",
  83. * "formatType":"textValue"
  84. * }
  85. */
  86. /**
  87. * StatementFilter 查询视图的过滤条件
  88. * @typedef {Object} StatementFilter
  89. * @property {String} path - 要过滤的data数据的路径,形式为查询语句中的"表别名.字段名",如"o.title"。
  90. * @property {String} comparison - 比较运算符,可选值:<br/>
  91. * <div style='padding-left:150px;'>
  92. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  93. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  94. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  95. * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
  96. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  97. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  98. * <b>like</b> :表示部分匹配。<br/>
  99. * <b>notLike</b> :表示不匹配。<br/>
  100. * </div>
  101. * @property {String} formatType - 过滤数据的数据类型,可选值:
  102. * <div style='padding-left:150px;'>
  103. * <b>textValue</b> :文本。<br/>
  104. * <b>numberValue</b> :数字。<br/>
  105. * <b>dateTimeValue</b> :日期时间。<br/>
  106. * <b>booleanValue</b> :布尔值。<br/>
  107. * </div>
  108. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。
  109. * @example
  110. *{
  111. * "path":"o.title",
  112. * "comparison":"like",
  113. * "value":"关于",
  114. * "formatType":"textValue"
  115. *}
  116. */
  117. /**
  118. * StatementParameter 查询视图的过滤条件值参数,对查询语句where语句的形如":person"的参数部分进行赋值<br/>
  119. * 有以下规则:<br/>
  120. * 1、参数名称为下列值时,后台自动赋值:person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)。<br/>
  121. * 2、如果对比的是日期,需要传入 Date 类型。<br/>
  122. * 3、如果运算符用的是 like, noLike,模糊查询,值为 "%{value}%"。
  123. * @typedef {Object} StatementParameter
  124. * @example
  125. * {
  126. * "person" : "",
  127. * "startTime" : (new Date("2020-01-01")),
  128. * "applicationName" : "%test%",
  129. * "processName" : "test流程" //其他写确定的值
  130. * }
  131. */
  132. MWF.xScript = MWF.xScript || {};
  133. MWF.xScript.ViewEnvironment = function (ev) {
  134. var _form = ev.view;
  135. this.library = COMMON;
  136. //this.library.version = "4.0";
  137. //data
  138. // var getJSONData = function (jData) {
  139. // return new MWF.xScript.JSONData(jData, function (data, key, _self) {
  140. // var p = { "getKey": function () { return key; }, "getParent": function () { return _self; } };
  141. // while (p && !_forms[p.getKey()]) p = p.getParent();
  142. // if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  143. // });
  144. // };
  145. // this.setData = function (data) {
  146. // this.data = getJSONData(data);
  147. // this.data.save = function (callback) {
  148. // var formData = {
  149. // "data": data,
  150. // "sectionList": _form.getSectionList()
  151. // };
  152. // form.workAction.saveData(function (json) { if (callback) callback(); }.bind(this), null, work.id, jData);
  153. // }
  154. // };
  155. // this.setData(_data);
  156. //dict
  157. this.Dict = MWF.xScript.createDict();
  158. //org
  159. var orgActions = null;
  160. var getOrgActions = function () {
  161. if (!orgActions) {
  162. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  163. orgActions = new MWF.xScript.Actions.UnitActions();
  164. }
  165. };
  166. var getNameFlag = function (name) {
  167. var t = typeOf(name);
  168. if (t === "array") {
  169. var v = [];
  170. name.each(function (id) {
  171. v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  172. });
  173. return v;
  174. } else {
  175. return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  176. }
  177. };
  178. this.org = {
  179. //群组***************
  180. //获取群组--返回群组的对象数组
  181. getGroup: function(name, async){
  182. getOrgActions();
  183. var data = {"groupList": getNameFlag(name)};
  184. var v = null;
  185. var cb = function(json){
  186. v = json.data;
  187. v = (v && v.length===1) ? v[0] : v
  188. if (async && o2.typeOf(async)=="function") return async(v);
  189. return v;
  190. };
  191. var promise = orgActions.listGroup(data, cb, null, !!async);
  192. return (!!async) ? promise : v;
  193. // var v = null;
  194. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  195. // return (v && v.length===1) ? v[0] : v;
  196. },
  197. //查询下级群组--返回群组的对象数组
  198. //nested 布尔 true嵌套下级;false直接下级;默认false;
  199. listSubGroup: function(name, nested, async){
  200. getOrgActions();
  201. var data = {"groupList": getNameFlag(name)};
  202. var v = null;
  203. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  204. // v = json.data;
  205. // return v;
  206. // }.ag().catch(function(json){ return json; });
  207. var cb = function(json){
  208. v = json.data;
  209. if (async && o2.typeOf(async)=="function") return async(v);
  210. return v;
  211. };
  212. var promise;
  213. if (nested){
  214. promise = orgActions.listSubGroupNested(data, cb, null, !!async);
  215. }else{
  216. promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
  217. }
  218. return (!!async) ? promise : v;
  219. // var v = null;
  220. // if (nested){
  221. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  222. // }else{
  223. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  224. // }
  225. // return v;
  226. },
  227. //查询上级群组--返回群组的对象数组
  228. //nested 布尔 true嵌套上级;false直接上级;默认false;
  229. listSupGroup:function(name, nested, async){
  230. getOrgActions();
  231. var data = {"groupList": getNameFlag(name)};
  232. var v = null;
  233. var cb = function(json){
  234. v = json.data;
  235. if (async && o2.typeOf(async)=="function") return async(v);
  236. return v;
  237. };
  238. var promise
  239. if (nested){
  240. var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
  241. }else{
  242. var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
  243. }
  244. return (!!async) ? promise : v;
  245. // var v = null;
  246. // if (nested){
  247. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  248. // }else{
  249. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  250. // }
  251. // return v;
  252. },
  253. //人员所在群组(嵌套)--返回群组的对象数组
  254. listGroupWithPerson:function(name, async){
  255. getOrgActions();
  256. var data = {"personList": getNameFlag(name)};
  257. var v = null;
  258. var cb = function(json){
  259. v = json.data;
  260. if (async && o2.typeOf(async)=="function") return async(v);
  261. return v;
  262. };
  263. var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
  264. return (!!async) ? promise : v;
  265. // var v = null;
  266. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  267. // return v;
  268. },
  269. //群组是否拥有角色--返回true, false
  270. groupHasRole: function(name, role, async){
  271. getOrgActions();
  272. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  273. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  274. var v = false;
  275. var cb = function(json){
  276. v = json.data.value;
  277. if (async && o2.typeOf(async)=="function") return async(v);
  278. return v;
  279. };
  280. var promise = orgActions.groupHasRole(data, cb, null, !!async);
  281. return (!!async) ? promise : v;
  282. // var v = false;
  283. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  284. // return v;
  285. },
  286. //角色***************
  287. //获取角色--返回角色的对象数组
  288. getRole: function(name, async){
  289. getOrgActions();
  290. var data = {"roleList": getNameFlag(name)};
  291. var v = null;
  292. var cb = function(json){
  293. v = json.data;
  294. v = (v && v.length===1) ? v[0] : v;
  295. if (async && o2.typeOf(async)=="function") return async(v);
  296. return v;
  297. };
  298. var promise = orgActions.listRole(data, cb, null, !!async);
  299. return (!!async) ? promise : v;
  300. // var v = null;
  301. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  302. // return (v && v.length===1) ? v[0] : v;
  303. },
  304. //人员所有角色(嵌套)--返回角色的对象数组
  305. listRoleWithPerson:function(name, async){
  306. getOrgActions();
  307. var data = {"personList": getNameFlag(name)};
  308. var v = null;
  309. var cb = function(json){
  310. v = json.data;
  311. if (async && o2.typeOf(async)=="function") return async(v);
  312. return v;
  313. };
  314. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  315. return (!!async) ? promise : v;
  316. // var v = null;
  317. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  318. // return v;
  319. },
  320. //人员***************
  321. //人员是否拥有角色--返回true, false
  322. personHasRole: function(name, role, async){
  323. getOrgActions();
  324. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  325. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  326. var v = false;
  327. var cb = function(json){
  328. v = json.data.value;
  329. if (async && o2.typeOf(async)=="function") return async(v);
  330. return v;
  331. };
  332. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  333. return (!!async) ? promise : v;
  334. // var v = false;
  335. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  336. // return v;
  337. },
  338. //获取人员--返回人员的对象数组
  339. getPerson: function(name, async){
  340. getOrgActions();
  341. var data = {"personList": getNameFlag(name)};
  342. var v = null;
  343. var cb = function(json){
  344. v = json.data;
  345. v = (v && v.length===1) ? v[0] : v;
  346. if (async && o2.typeOf(async)=="function") return async(v);
  347. return v;
  348. };
  349. var promise = orgActions.listPerson(data, cb, null, !!async);
  350. return (!!async) ? promise : v;
  351. // var v = null;
  352. // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  353. // return (v && v.length===1) ? v[0] : v;
  354. },
  355. //查询下级人员--返回人员的对象数组
  356. //nested 布尔 true嵌套下级;false直接下级;默认false;
  357. listSubPerson: function(name, nested, async){
  358. getOrgActions();
  359. var data = {"personList": getNameFlag(name)};
  360. var v = null;
  361. var cb = function(json){
  362. v = json.data;
  363. if (async && o2.typeOf(async)=="function") return async(v);
  364. return v;
  365. };
  366. var promise;
  367. if (nested){
  368. promise = orgActions.listPersonSubNested(data, cb, null, !!async);
  369. }else{
  370. promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
  371. }
  372. return (!!async) ? promise : v;
  373. },
  374. //查询上级人员--返回人员的对象数组
  375. //nested 布尔 true嵌套上级;false直接上级;默认false;
  376. listSupPerson: function(name, nested, async){
  377. getOrgActions();
  378. var data = {"personList": getNameFlag(name)};
  379. var v = null;
  380. var cb = function(json){
  381. v = json.data;
  382. if (async && o2.typeOf(async)=="function") return async(v);
  383. return v;
  384. };
  385. var promise;
  386. if (nested){
  387. promise = orgActions.listPersonSupNested(data, cb, null, !!async);
  388. }else{
  389. promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
  390. }
  391. return (!!async) ? promise : v;
  392. },
  393. //获取群组的所有人员--返回人员的对象数组
  394. listPersonWithGroup: function(name, async){
  395. getOrgActions();
  396. var data = {"groupList": getNameFlag(name)};
  397. var v = null;
  398. var cb = function(json){
  399. v = json.data;
  400. if (async && o2.typeOf(async)=="function") return async(v);
  401. return v;
  402. };
  403. var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
  404. return (!!async) ? promise : v;
  405. },
  406. //获取角色的所有人员--返回人员的对象数组
  407. listPersonWithRole: function(name, async){
  408. getOrgActions();
  409. var data = {"roleList": getNameFlag(name)};
  410. var v = null;
  411. var cb = function(json){
  412. v = json.data;
  413. if (async && o2.typeOf(async)=="function") return async(v);
  414. return v;
  415. };
  416. var promise
  417. promise = orgActions.listPersonWithRole(data, cb, null, !!async);
  418. return (!!async) ? promise : v;
  419. },
  420. //获取身份的所有人员--返回人员的对象数组
  421. listPersonWithIdentity: function(name, async){
  422. getOrgActions();
  423. var data = {"identityList": getNameFlag(name)};
  424. var v = null;
  425. var cb = function(json){
  426. v = json.data;
  427. if (async && o2.typeOf(async)=="function") return async(v);
  428. return v;
  429. };
  430. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  431. return (!!async) ? promise : v;
  432. },
  433. //获取身份的所有人员--返回人员的对象数组或人员对象
  434. getPersonWithIdentity: function(name, async){
  435. getOrgActions();
  436. var data = {"identityList": getNameFlag(name)};
  437. var v = null;
  438. var cb = function(json){
  439. v = json.data;
  440. v = (v && v.length===1) ? v[0] : v;
  441. if (async && o2.typeOf(async)=="function") return async(v);
  442. return v;
  443. };
  444. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  445. return (!!async) ? promise : v;
  446. },
  447. //查询组织成员的人员--返回人员的对象数组
  448. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  449. listPersonWithUnit: function(name, nested, async){
  450. getOrgActions();
  451. var data = {"unitList": getNameFlag(name)};
  452. var v = null;
  453. var cb = function(json){
  454. v = json.data;
  455. if (async && o2.typeOf(async)=="function") return async(v);
  456. return v;
  457. };
  458. var promise;
  459. if (nested){
  460. promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  461. }else{
  462. promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  463. }
  464. return (!!async) ? promise : v;
  465. },
  466. //根据属性查询人员--返回人员的对象数组
  467. //name string 属性名
  468. //value string 属性值
  469. listPersonWithAttribute: function(name, value, async){
  470. getOrgActions();
  471. var data = {"name": name, "attribute": value};
  472. var v = null;
  473. var cb = function(json){
  474. v = json.data;
  475. if (async && o2.typeOf(async)=="function") return async(v);
  476. return v;
  477. };
  478. var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
  479. return (!!async) ? promise : v;
  480. },
  481. //根据属性查询人员--返回人员的全称数组
  482. //name string 属性名
  483. //value string 属性值
  484. listPersonNameWithAttribute: function(name, value, async){
  485. getOrgActions();
  486. var data = {"name": name, "attribute": value};
  487. var v = null;
  488. var cb = function(json){
  489. v = json.data.personList;
  490. if (async && o2.typeOf(async)=="function") return async(v);
  491. return v;
  492. };
  493. var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  494. return (!!async) ? promise : v;
  495. },
  496. //人员属性************
  497. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  498. appendPersonAttribute: function(person, attr, values, success, failure, async){
  499. getOrgActions();
  500. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  501. var data = {"attributeList":values,"name":attr,"person":personFlag};
  502. var cb = function(json){
  503. if (success) return success(json);
  504. }.ag().catch(function(xhr, text, error){
  505. if (failure) return failure(xhr, text, error);
  506. });
  507. orgActions.appendPersonAttribute(data, cb, null, !!async);
  508. },
  509. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  510. setPersonAttribute: function(person, attr, values, success, failure, async){
  511. getOrgActions();
  512. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  513. var data = {"attributeList":values,"name":attr,"person":personFlag};
  514. var cb = function(json){
  515. if (success) return success(json);
  516. }.ag().catch(function(xhr, text, error){
  517. if (failure) return failure(xhr, text, error);
  518. });
  519. orgActions.setPersonAttribute(data, cb, null, !!async);
  520. },
  521. //获取人员属性值
  522. getPersonAttribute: function(person, attr, async){
  523. getOrgActions();
  524. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  525. var data = {"name":attr,"person":personFlag};
  526. var v = null;
  527. var cb = function(json){
  528. v = json.data.attributeList;
  529. if (async && o2.typeOf(async)=="function") return async(v);
  530. return v;
  531. };
  532. var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
  533. return (!!async) ? promise : v;
  534. },
  535. //列出人员所有属性的名称
  536. listPersonAttributeName: function(name, async){
  537. getOrgActions();
  538. var data = {"personList":getNameFlag(name)};
  539. var v = null;
  540. var cb = function(json){
  541. v = json.data.nameList;
  542. if (async && o2.typeOf(async)=="function") return async(v);
  543. return v;
  544. };
  545. var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
  546. return (!!async) ? promise : v;
  547. },
  548. //列出人员的所有属性
  549. listPersonAllAttribute: function(name, async){
  550. getOrgActions();
  551. var data = {"personList":getNameFlag(name)};
  552. var v = null;
  553. var cb = function(json){
  554. v = json.data;
  555. if (async && o2.typeOf(async)=="function") return async(v);
  556. return v;
  557. };
  558. var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
  559. return (!!async) ? promise : v;
  560. },
  561. //身份**********
  562. //获取身份
  563. getIdentity: function(name, async){
  564. getOrgActions();
  565. var data = {"identityList":getNameFlag(name)};
  566. var v = null;
  567. var cb = function(json){
  568. v = json.data;
  569. v = (v && v.length===1) ? v[0] : v;
  570. if (async && o2.typeOf(async)=="function") return async(v);
  571. return v;
  572. };
  573. var promise = orgActions.listIdentity(data, cb, null, !!async);
  574. return (!!async) ? promise : v;
  575. },
  576. //列出人员的身份
  577. listIdentityWithPerson: function(name, async){
  578. getOrgActions();
  579. var data = {"personList":getNameFlag(name)};
  580. var v = null;
  581. var cb = function(json){
  582. v = json.data;
  583. if (async && o2.typeOf(async)=="function") return async(v);
  584. return v;
  585. };
  586. var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
  587. return (!!async) ? promise : v;
  588. },
  589. //查询组织成员身份--返回身份的对象数组
  590. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  591. listIdentityWithUnit: function(name, nested, async){
  592. getOrgActions();
  593. var data = {"unitList": getNameFlag(name)};
  594. var v = null;
  595. // var cb = function(json){
  596. // v = json.data;
  597. // if (async && o2.typeOf(async)=="function") return async(v);
  598. // return v;
  599. // }.ag().catch(function(json){ return json; });
  600. var cb = function(json){
  601. v = json.data;
  602. if (async && o2.typeOf(async)=="function") return async(v);
  603. return v;
  604. };
  605. var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
  606. var promise = orgActions[method](data, cb, null, !!async);
  607. promise.name = "org";
  608. //
  609. // if (nested){
  610. // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  611. // }else{
  612. // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  613. // }
  614. return (!!async) ? promise : v;
  615. },
  616. //组织**********
  617. //获取组织
  618. getUnit: function(name, async){
  619. getOrgActions();
  620. var data = {"unitList":getNameFlag(name)};
  621. var v = null;
  622. var cb = function(json){
  623. v = json.data;
  624. v = (v && v.length===1) ? v[0] : v;
  625. if (async && o2.typeOf(async)=="function") return async(v);
  626. return v;
  627. };
  628. var promise = orgActions.listUnit(data, cb, null, !!async);
  629. return (!!async) ? promise : v;
  630. },
  631. //查询组织的下级--返回组织的对象数组
  632. //nested 布尔 true嵌套下级;false直接下级;默认false;
  633. listSubUnit: function(name, nested, async){
  634. getOrgActions();
  635. var data = {"unitList": getNameFlag(name)};
  636. var v = null;
  637. var cb = function(json){
  638. v = json.data;
  639. if (async && o2.typeOf(async)=="function") return async(v);
  640. return v;
  641. };
  642. var promise;
  643. if (nested){
  644. promise = orgActions.listUnitSubNested(data, cb, null, !!async);
  645. }else{
  646. promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
  647. }
  648. return (!!async) ? promise : v;
  649. },
  650. //查询组织的上级--返回组织的对象数组
  651. //nested 布尔 true嵌套上级;false直接上级;默认false;
  652. //async 布尔 true异步请求
  653. listSupUnit: function(name, nested, async){
  654. getOrgActions();
  655. var data = {"unitList": getNameFlag(name)};
  656. var v = null;
  657. var cb = function(json){
  658. v = json.data;
  659. if (async && o2.typeOf(async)=="function") return async(v);
  660. return v;
  661. };
  662. var promise;
  663. if (nested){
  664. promise = orgActions.listUnitSupNested(data, cb, null, !!async);
  665. }else{
  666. promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
  667. }
  668. return (!!async) ? promise : v;
  669. // if (callback){
  670. // if (nested){
  671. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  672. // }else{
  673. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  674. // }
  675. // }else{
  676. // var v = null;
  677. // if (nested){
  678. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  679. // }else{
  680. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  681. // }
  682. // return v;
  683. // }
  684. },
  685. //根据个人身份获取组织
  686. //flag 数字 表示获取第几层的组织
  687. // 字符串 表示获取指定类型的组织
  688. // 空 表示获取直接所在的组织
  689. getUnitByIdentity: function(name, flag, async){
  690. getOrgActions();
  691. var getUnitMethod = "current";
  692. var v;
  693. if (flag){
  694. if (typeOf(flag)==="string") getUnitMethod = "type";
  695. if (typeOf(flag)==="number") getUnitMethod = "level";
  696. }
  697. var cb;
  698. var promise;
  699. switch (getUnitMethod){
  700. case "current":
  701. var data = {"identityList":getNameFlag(name)};
  702. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  703. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  704. // }.ag().catch(function(json){ return json; });
  705. cb = function(json){
  706. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  707. if (async && o2.typeOf(async)=="function") return async(v);
  708. return v;
  709. };
  710. promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
  711. break;
  712. case "type":
  713. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  714. cb = function(json){
  715. v = json.data;
  716. if (async && o2.typeOf(async)=="function") return async(v);
  717. return v;
  718. };
  719. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  720. // v = json.data; return v;
  721. // }.ag().catch(function(json){ return json; });
  722. promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  723. break;
  724. case "level":
  725. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  726. cb = function(json){
  727. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  728. if (async && o2.typeOf(async)=="function") return async(v);
  729. return v;
  730. };
  731. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  732. // v = json.data; return v;
  733. // }.ag().catch(function(json){ return json; });
  734. promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  735. break;
  736. }
  737. return (!!async) ? promise : v;
  738. },
  739. //列出身份所在组织的所有上级组织
  740. listAllSupUnitWithIdentity: function(name, async){
  741. getOrgActions();
  742. var data = {"identityList":getNameFlag(name)};
  743. var v = null;
  744. var cb = function(json){
  745. v = json.data;
  746. if (async && o2.typeOf(async)=="function") return async(v);
  747. return v;
  748. };
  749. var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  750. return (!!async) ? promise : v;
  751. },
  752. //获取人员所在的所有组织
  753. listUnitWithPerson: function(name, async){
  754. getOrgActions();
  755. var data = {"personList":getNameFlag(name)};
  756. var v = null;
  757. var cb = function(json){
  758. v = json.data;
  759. if (async && o2.typeOf(async)=="function") return async(v);
  760. return v;
  761. };
  762. var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
  763. return (!!async) ? promise : v;
  764. },
  765. //列出人员所在组织的所有上级组织
  766. listAllSupUnitWithPerson: function(name, async){
  767. getOrgActions();
  768. var data = {"personList":getNameFlag(name)};
  769. var v = null;
  770. var cb = function(json){
  771. v = json.data;
  772. if (async && o2.typeOf(async)=="function") return async(v);
  773. return v;
  774. };
  775. var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  776. return (!!async) ? promise : v;
  777. },
  778. //根据组织属性,获取所有符合的组织
  779. listUnitWithAttribute: function(name, attribute, async){
  780. getOrgActions();
  781. var data = {"name":name,"attribute":attribute};
  782. var v = null;
  783. var cb = function(json){
  784. v = json.data;
  785. if (async && o2.typeOf(async)=="function") return async(v);
  786. return v;
  787. };
  788. promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
  789. return (!!async) ? promise : v;
  790. },
  791. //根据组织职务,获取所有符合的组织
  792. listUnitWithDuty: function(name, id, async){
  793. getOrgActions();
  794. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  795. var v = null;
  796. var cb = function(json){
  797. v = json.data;
  798. if (async && o2.typeOf(async)=="function") return async(v);
  799. return v;
  800. };
  801. var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
  802. return (!!async) ? promise : v;
  803. },
  804. //组织职务***********
  805. //获取指定的组织职务的身份
  806. getDuty: function(duty, id, async){
  807. getOrgActions();
  808. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  809. var v = null;
  810. var cb = function(json){
  811. v = json.data;
  812. if (async && o2.typeOf(async)=="function") return async(v);
  813. return v;
  814. };
  815. var promise = orgActions.getDuty(data, cb, null, !!async);
  816. return (!!async) ? promise : v;
  817. },
  818. //获取身份的所有职务名称
  819. listDutyNameWithIdentity: function(name, async){
  820. getOrgActions();
  821. var data = {"identityList":getNameFlag(name)};
  822. var v = null;
  823. var cb = function(json){
  824. v = json.data.nameList;
  825. if (async && o2.typeOf(async)=="function") return async(v);
  826. return v;
  827. };
  828. var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  829. return (!!async) ? promise : v;
  830. },
  831. //获取组织的所有职务名称
  832. listDutyNameWithUnit: function(name, async){
  833. getOrgActions();
  834. var data = {"unitList":getNameFlag(name)};
  835. var v = null;
  836. var cb = function(json){
  837. v = json.data.nameList;
  838. if (async && o2.typeOf(async)=="function") return async(v);
  839. return v;
  840. };
  841. var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  842. return (!!async) ? promise : v;
  843. },
  844. //获取组织的所有职务
  845. listUnitAllDuty: function(name, async){
  846. getOrgActions();
  847. var data = {"unitList":getNameFlag(name)};
  848. var v = null;
  849. var cb = function(json){
  850. v = json.data;
  851. if (async && o2.typeOf(async)=="function") return async(v);
  852. return v;
  853. };
  854. var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
  855. return (!!async) ? promise : v;
  856. },
  857. //列出顶层组织
  858. listTopUnit: function(async){
  859. var action = MWF.Actions.get("x_organization_assemble_control");
  860. var v = null;
  861. var cb = function(json){
  862. v = json.data;
  863. if (async && o2.typeOf(async)=="function") return async(v);
  864. return v;
  865. };
  866. var promise = action.listTopUnit(cb, null, !!async);
  867. return (!!async) ? promise : v;
  868. },
  869. //组织属性**************
  870. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  871. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  872. getOrgActions();
  873. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  874. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  875. var cb = function(json){
  876. if (success) return success(json);
  877. }.ag().catch(function(xhr, text, error){
  878. if (failure) return failure(xhr, text, error);
  879. });
  880. orgActions.appendPersonAttribute(data, cb, null, !!async);
  881. // orgActions.appendUnitAttribute(data, function(json){
  882. // if (json.data.value){
  883. // if (success) success();
  884. // }else{
  885. // if (failure) failure(null, "", "append values failed");
  886. // }
  887. // }, function(xhr, text, error){
  888. // if (failure) failure(xhr, text, error);
  889. // }, false);
  890. },
  891. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  892. setUnitAttribute: function(unit, attr, values, success, failure, async){
  893. getOrgActions();
  894. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  895. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  896. var cb = function(json){
  897. if (success) return success(json);
  898. }.ag().catch(function(xhr, text, error){
  899. if (failure) return failure(xhr, text, error);
  900. });
  901. orgActions.setUnitAttribute(data, cb, null, !!async);
  902. // orgActions.setUnitAttribute(data, function(json){
  903. // if (json.data.value){
  904. // if (success) success();
  905. // }else{
  906. // if (failure) failure(null, "", "append values failed");
  907. // }
  908. // }, function(xhr, text, error){
  909. // if (failure) failure(xhr, text, error);
  910. // }, false);
  911. },
  912. //获取组织属性值
  913. getUnitAttribute: function(unit, attr, async){
  914. getOrgActions();
  915. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  916. var data = {"name":attr,"unit":unitFlag};
  917. var v = null;
  918. var cb = function(json){
  919. v = json.data.attributeList;
  920. if (async && o2.typeOf(async)=="function") return async(v);
  921. return v;
  922. };
  923. var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
  924. return (!!async) ? promise : v;
  925. },
  926. //列出组织所有属性的名称
  927. listUnitAttributeName: function(name, async){
  928. getOrgActions();
  929. var data = {"unitList":getNameFlag(name)};
  930. var v = null;
  931. var cb = function(json){
  932. v = json.data.nameList;
  933. if (async && o2.typeOf(async)=="function") return async(v);
  934. return v;
  935. };
  936. var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
  937. return (!!async) ? promise : v;
  938. },
  939. //列出组织的所有属性
  940. listUnitAllAttribute: function(name, async){
  941. getOrgActions();
  942. var data = {"unitList":getNameFlag(name)};
  943. var v = null;
  944. var cb = function(json){
  945. v = json.data;
  946. if (async && o2.typeOf(async)=="function") return async(v);
  947. return v;
  948. };
  949. var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
  950. return (!!async) ? promise : v;
  951. }
  952. };
  953. this.Action = (function () {
  954. var actions = [];
  955. return function (root, json) {
  956. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  957. action.getActions = function (callback) {
  958. if (!this.actions) this.actions = {};
  959. Object.merge(this.actions, json);
  960. if (callback) callback();
  961. };
  962. this.invoke = function (option) {
  963. action.invoke(option)
  964. }
  965. }
  966. })();
  967. this.service = {
  968. "jaxwsClient": {},
  969. "jaxrsClient": {}
  970. };
  971. var lookupAction = null;
  972. var getLookupAction = function (callback) {
  973. if (!lookupAction) {
  974. MWF.require("MWF.xDesktop.Actions.RestActions", function () {
  975. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  976. lookupAction.getActions = function (actionCallback) {
  977. this.actions = {
  978. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  979. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  980. "lookup": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method": "PUT" },
  981. "getView": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}" }
  982. };
  983. if (actionCallback) actionCallback();
  984. }
  985. if (callback) callback();
  986. });
  987. } else {
  988. if (callback) callback();
  989. }
  990. };
  991. /**
  992. * 你可以通过view对象,获取视图数据或选择视图数据。<br/>
  993. * @module view
  994. * @example
  995. * //您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下:
  996. * var view = this.view;
  997. */
  998. this.view = {
  999. /**
  1000. * 获取指定视图的数据。
  1001. * @method lookup
  1002. * @static
  1003. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  1004. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  1005. * <pre><code class='language-js'>
  1006. * {
  1007. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  1008. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  1009. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  1010. * {
  1011. * "logic":"and",
  1012. * "path":"$work.title",
  1013. * "comparison":"like",
  1014. * "value":"7月",
  1015. * "formatType":"textValue"
  1016. * }
  1017. * ]
  1018. * }
  1019. * </pre></code>
  1020. * @param {Function} callback - 访问成功后的回调函数
  1021. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  1022. * @example
  1023. * this.view.lookup(view, callback, async);
  1024. * @example
  1025. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  1026. * //过滤条件为标题($work.title)包含包含(like))“7月”。
  1027. * this.view.lookup({
  1028. * "view": "报销审批数据",
  1029. * "application": "财务管理",
  1030. * "filter": [
  1031. * {
  1032. * "logic":"and",
  1033. * "path":"$work.title",
  1034. * "comparison":"like",
  1035. * "value":"7月",
  1036. * "formatType":"textValue"
  1037. * }
  1038. * ]
  1039. *}, function(data){
  1040. * var result = data.grid; //得到过滤后的数据
  1041. * //......
  1042. *});
  1043. * @example
  1044. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  1045. * //过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000
  1046. * this.view.lookup({
  1047. * "view": "报销审批数据",
  1048. * "application": "财务管理",
  1049. * "filter": [
  1050. * {
  1051. * "logic":"and",
  1052. * "path":"$work.title",
  1053. * "comparison":"like",
  1054. * "value":"7月",
  1055. * "formatType":"textValue"
  1056. * },
  1057. * {
  1058. * "logic":"and",
  1059. * "path":"amount",
  1060. * "comparison":"range",
  1061. * "value":500,
  1062. * "otherValue":5000,
  1063. * "formatType":"numberValue"
  1064. * },
  1065. * ]
  1066. *}, function(data){
  1067. * var result = data.grid; //得到过滤后的数据
  1068. * //......
  1069. *});
  1070. */
  1071. "lookup": function (view, callback, async) {
  1072. var filterList = { "filterList": (view.filter || null) };
  1073. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function (json) {
  1074. var data = {
  1075. "grid": json.data.grid || json.data.groupGrid,
  1076. "groupGrid": json.data.groupGrid
  1077. };
  1078. if (callback) callback(data);
  1079. }, null, async);
  1080. },
  1081. "lookupV1": function (view, callback) {
  1082. getLookupAction(function () {
  1083. lookupAction.invoke({
  1084. "name": "lookup", "async": true, "parameter": { "view": view.view, "application": view.application }, "success": function (json) {
  1085. var data = {
  1086. "grid": json.data.grid,
  1087. "groupGrid": json.data.groupGrid
  1088. };
  1089. if (callback) callback(data);
  1090. }.bind(this)
  1091. });
  1092. }.bind(this));
  1093. },
  1094. /**
  1095. * 通过视图进行数据选择。
  1096. * @method select
  1097. * @static
  1098. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  1099. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  1100. * <pre><code class='language-js'>
  1101. * {
  1102. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  1103. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  1104. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  1105. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  1106. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  1107. * "height" : 400, //(Number)可选,选择框的高度。默认400
  1108. * "caption" : "标题", //(String)可选,选择框的标题
  1109. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  1110. * {
  1111. * "logic":"and",
  1112. * "path":"$work.title",
  1113. * "comparison":"like",
  1114. * "value":"7月",
  1115. * "formatType":"textValue"
  1116. * }
  1117. * ]
  1118. * }
  1119. * </pre></code>
  1120. * @param {Function} callback - 必选,当选择完成,点击“确定”之后的回调函数。
  1121. * @example
  1122. * this.view.select(view, callback);
  1123. * @example
  1124. * this.view.select({
  1125. * "application": "物业材料", //数据中心中的应用
  1126. * "view": "物业材料视图", //视图的名称
  1127. * "isMulti": false, //只允许单选
  1128. * }, function(items) {
  1129. * //如果选择了某个数据,将数据赋值给表单输入框
  1130. * if (items.length) {
  1131. * //物料名称,表单中输入框名为“materialName”, 视图中列的名称为“ylmc”
  1132. * this.data.materialName = items[0].data.ylmc;
  1133. * //规格,表单中输入框名为“specification”, 视图中列的名称为“gg”
  1134. * this.data.specification = items[0].data.gg;
  1135. * //单价,表单中输入框名为“price”, 视图中列的名称为“dj”
  1136. * this.data.price = items[0].data.dj;
  1137. * }
  1138. * }.bind(this));
  1139. */
  1140. "select": function (view, callback, options) {
  1141. if (view.view) {
  1142. var viewJson = {
  1143. "application": view.application || _form.json.application,
  1144. "viewName": view.view || "",
  1145. "isTitle": (view.isTitle === false) ? "no" : "yes",
  1146. "select": (view.isMulti === false) ? "single" : "multi",
  1147. "filter": view.filter
  1148. };
  1149. if (!options) options = {};
  1150. options.width = view.width;
  1151. options.height = view.height;
  1152. options.title = view.caption;
  1153. var width = options.width || "700";
  1154. var height = options.height || "400";
  1155. if (layout.mobile) {
  1156. var size = document.body.getSize();
  1157. width = size.x;
  1158. height = size.y;
  1159. options.style = "viewmobile";
  1160. }
  1161. width = width.toInt();
  1162. height = height.toInt();
  1163. var size = _form.app.content.getSize();
  1164. var x = (size.x - width) / 2;
  1165. var y = (size.y - height) / 2;
  1166. if (x < 0) x = 0;
  1167. if (y < 0) y = 0;
  1168. if (layout.mobile) {
  1169. x = 20;
  1170. y = 0;
  1171. }
  1172. var _self = this;
  1173. MWF.require("MWF.xDesktop.Dialog", function () {
  1174. var dlg = new MWF.xDesktop.Dialog({
  1175. "title": options.title || "select view",
  1176. "style": options.style || "view",
  1177. "top": y,
  1178. "left": x - 20,
  1179. "fromTop": y,
  1180. "fromLeft": x - 20,
  1181. "width": width,
  1182. "height": height,
  1183. "html": "<div style='height: 100%;'></div>",
  1184. "maskNode": _form.app.content,
  1185. "container": _form.app.content,
  1186. "buttonList": [
  1187. {
  1188. "text": MWF.LP.process.button.ok,
  1189. "action": function () {
  1190. //if (callback) callback(_self.view.selectedItems);
  1191. if (callback) callback(_self.view.getData());
  1192. this.close();
  1193. }
  1194. },
  1195. {
  1196. "text": MWF.LP.process.button.cancel,
  1197. "action": function () { this.close(); }
  1198. }
  1199. ]
  1200. });
  1201. dlg.show();
  1202. if (layout.mobile) {
  1203. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1204. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1205. if (backAction) backAction.addEvent("click", function (e) {
  1206. dlg.close();
  1207. }.bind(this));
  1208. if (okAction) okAction.addEvent("click", function (e) {
  1209. //if (callback) callback(this.view.selectedItems);
  1210. if (callback) callback(this.view.getData());
  1211. dlg.close();
  1212. }.bind(this));
  1213. }
  1214. MWF.xDesktop.requireApp("query.Query", "Viewer", function () {
  1215. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, { "style": "select" }, _form.app, _form.Macro);
  1216. }.bind(this));
  1217. }.bind(this));
  1218. }
  1219. }
  1220. };
  1221. /**
  1222. * 你可以通过statement对象,获取执行查询语句或者对查询结果进行选择。<br/>
  1223. * @module statement
  1224. * @example
  1225. * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下:
  1226. * var statement = this.statement;
  1227. */
  1228. this.statement = {
  1229. /**
  1230. * 执行指定的查询语句。
  1231. * @method execute
  1232. * @static
  1233. * @param {Object} statement - 要执行的查询语句的信息。数据格式如下:
  1234. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  1235. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  1236. * <pre><code class='language-js'>
  1237. * {
  1238. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  1239. * "mode" : "all", //(String)必选,“all”、“data”或者“count”,all表示同时执行查询语句和总数语句,data表示执行查询语句,count表示执行总数语句
  1240. * "page" : 1, //(number)可选,当前页码,默认为1
  1241. * "pageSize" : 20, //(number)可选,每页的数据条数,默认为20
  1242. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  1243. * {
  1244. * "path":"o.title",
  1245. * "comparison":"like",
  1246. * "value":"关于",
  1247. * "formatType":"textValue"
  1248. * }
  1249. * ],
  1250. * parameter : {
  1251. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  1252. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  1253. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  1254. * "processName" : "test流程" //其他写确定的值
  1255. * }
  1256. * }
  1257. * </pre></code>
  1258. * @param {Function} callback - 访问成功后的回调函数
  1259. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  1260. * @example
  1261. * this.statement.execute(statement, callback, async);
  1262. * @example
  1263. * //获取“task”查询中的数据
  1264. * //查询语句为 select o from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  1265. * //总数语句为 select count(o.id) from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  1266. * //过滤条件为标题o.title包含包含(like))“7月”。
  1267. * this.statement.execute({
  1268. * "name": "task",
  1269. * "mode" : "all",
  1270. * "filter": [
  1271. * {
  1272. * "path":"o.title",
  1273. * "comparison":"like",
  1274. * "value":"7月",
  1275. * "formatType":"textValue"
  1276. * }
  1277. * ],
  1278. * "parameter" : {
  1279. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  1280. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  1281. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  1282. * "processName" : "test流程" //其他写确定的值
  1283. * }
  1284. * }, function(json){
  1285. * var count = json.count; //总数语句执行后返回的数字
  1286. * var list = json.data; //查询语句后返回的数组
  1287. * //......
  1288. * });
  1289. */
  1290. "execute": function (statement, callback, async) {
  1291. var parameter = this.parseParameter(statement.parameter);
  1292. var filterList = this.parseFilter(statement.filter, parameter);
  1293. var obj = {
  1294. "filterList": filterList,
  1295. "parameter" : parameter
  1296. };
  1297. MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  1298. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  1299. function (json) {
  1300. if (callback) callback(json);
  1301. }, null, async);
  1302. },
  1303. parseFilter : function( filter, parameter ){
  1304. if( typeOf(filter) !== "array" )return [];
  1305. var filterList = [];
  1306. ( filter || [] ).each( function (d) {
  1307. var parameterName = d.path.replace(/\./g, "_");
  1308. var value = d.value;
  1309. if( d.comparison === "like" || d.comparison === "notLike" ){
  1310. if( value.substr(0, 1) !== "%" )value = "%"+value;
  1311. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  1312. parameter[ parameterName ] = value; //"%"+value+"%";
  1313. }else{
  1314. if( d.formatType === "dateTimeValue" || d.formatType === "datetimeValue"){
  1315. value = "{ts '"+value+"'}"
  1316. }else if( d.formatType === "dateValue" ){
  1317. value = "{d '"+value+"'}"
  1318. }else if( d.formatType === "timeValue" ){
  1319. value = "{t '"+value+"'}"
  1320. }
  1321. parameter[ parameterName ] = value;
  1322. }
  1323. d.value = parameterName;
  1324. filterList.push( d );
  1325. }.bind(this));
  1326. return filterList;
  1327. },
  1328. parseParameter : function( obj ){
  1329. if( typeOf(obj) !== "object" )return {};
  1330. var parameter = {};
  1331. //传入的参数
  1332. for( var p in obj ){
  1333. var value = obj[p];
  1334. if( typeOf( value ) === "date" ){
  1335. value = "{ts '"+value.format("db")+"'}"
  1336. }
  1337. parameter[ p ] = value;
  1338. }
  1339. return parameter;
  1340. },
  1341. /**
  1342. * 如果查询的类型是"select",并且配置了查询视图,可以通过本方法进行数据选择。
  1343. * @method select
  1344. * @static
  1345. * @param {Object} statement - 要访问的查询配置的信息。数据格式如下:
  1346. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  1347. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  1348. * <pre><code class='language-js'>
  1349. * {
  1350. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  1351. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  1352. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  1353. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  1354. * "height" : 400, //(Number)可选,选择框的高度。默认400
  1355. * "caption" : "标题", //(String)可选,选择框的标题
  1356. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  1357. * {
  1358. * "path":"o.title",
  1359. * "comparison":"like",
  1360. * "value":"关于",
  1361. * "formatType":"textValue"
  1362. * }
  1363. * ],
  1364. * parameter : {
  1365. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  1366. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  1367. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  1368. * "processName" : "test流程" //其他写确定的值
  1369. * }
  1370. * }
  1371. * </pre></code>
  1372. * @param {Function} callback - 访问成功后的回调函数
  1373. * @example
  1374. * this.statement.select(statement, callback);
  1375. * @example
  1376. * this.statement.select({
  1377. * "name": "物业材料查询", //查询的名称
  1378. * "isMulti": false, //只允许单选
  1379. * }, function(items) {
  1380. * //如果选择了某个数据,将数据赋值给表单输入框
  1381. * if (items.length) {
  1382. * //物料名称,表单中输入框名为“materialName”, 查询语句返回的字段名为“ylmc”
  1383. * this.data.materialName = items[0].ylmc;
  1384. * //规格,表单中输入框名为“specification”, 查询语句返回的字段名为“gg”
  1385. * this.data.specification = items[0].gg;
  1386. * //单价,表单中输入框名为“price”, 查询语句返回的字段名为“dj”
  1387. * this.data.price = items[0].dj;
  1388. * }
  1389. * }.bind(this));
  1390. */
  1391. "select": function (statement, callback, options) {
  1392. if (statement.name) {
  1393. // var parameter = this.parseParameter(statement.parameter);
  1394. // var filterList = this.parseFilter(statement.filter, parameter);
  1395. var statementJson = {
  1396. "statementId": statement.name || "",
  1397. "isTitle": (statement.isTitle === false) ? "no" : "yes",
  1398. "select": (statement.isMulti === false) ? "single" : "multi",
  1399. "filter": statement.filter,
  1400. "parameter": statement.parameter
  1401. };
  1402. if (!options) options = {};
  1403. options.width = statement.width;
  1404. options.height = statement.height;
  1405. options.title = statement.caption;
  1406. var width = options.width || "700";
  1407. var height = options.height || "400";
  1408. if (layout.mobile) {
  1409. var size = document.body.getSize();
  1410. width = size.x;
  1411. height = size.y;
  1412. options.style = "viewmobile";
  1413. }
  1414. width = width.toInt();
  1415. height = height.toInt();
  1416. var size = _form.app.content.getSize();
  1417. var x = (size.x - width) / 2;
  1418. var y = (size.y - height) / 2;
  1419. if (x < 0) x = 0;
  1420. if (y < 0) y = 0;
  1421. if (layout.mobile) {
  1422. x = 20;
  1423. y = 0;
  1424. }
  1425. var _self = this;
  1426. MWF.require("MWF.xDesktop.Dialog", function () {
  1427. var dlg = new MWF.xDesktop.Dialog({
  1428. "title": options.title || "select statement view",
  1429. "style": options.style || "view",
  1430. "top": y,
  1431. "left": x - 20,
  1432. "fromTop": y,
  1433. "fromLeft": x - 20,
  1434. "width": width,
  1435. "height": height,
  1436. "html": "<div style='height: 100%;'></div>",
  1437. "maskNode": _form.app.content,
  1438. "container": _form.app.content,
  1439. "buttonList": [
  1440. {
  1441. "text": MWF.LP.process.button.ok,
  1442. "action": function () {
  1443. //if (callback) callback(_self.view.selectedItems);
  1444. if (callback) callback(_self.statement.getData());
  1445. this.close();
  1446. }
  1447. },
  1448. {
  1449. "text": MWF.LP.process.button.cancel,
  1450. "action": function () { this.close(); }
  1451. }
  1452. ]
  1453. });
  1454. dlg.show();
  1455. if (layout.mobile) {
  1456. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1457. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1458. if (backAction) backAction.addEvent("click", function (e) {
  1459. dlg.close();
  1460. }.bind(this));
  1461. if (okAction) okAction.addEvent("click", function (e) {
  1462. //if (callback) callback(this.view.selectedItems);
  1463. if (callback) callback(this.statement.getData());
  1464. dlg.close();
  1465. }.bind(this));
  1466. }
  1467. MWF.xDesktop.requireApp("query.Query", "Statement", function () {
  1468. this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
  1469. }.bind(this));
  1470. }.bind(this));
  1471. }
  1472. }
  1473. };
  1474. //include 引用脚本
  1475. //optionsOrName : {
  1476. // type : "", 默认为portal, 可以为 portal process cms
  1477. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  1478. // name : "" // 脚本名称/别名/id
  1479. //}
  1480. //或者name: "" // 脚本名称/别名/id
  1481. // if( !window.includedScripts ){
  1482. // var includedScripts = window.includedScripts = [];
  1483. // }else{
  1484. // var includedScripts = window.includedScripts;
  1485. // }
  1486. var includedScripts = [];
  1487. this.include = function (optionsOrName, callback) {
  1488. var options = optionsOrName;
  1489. if (typeOf(options) == "string") {
  1490. options = { name: options };
  1491. }
  1492. var name = options.name;
  1493. var type = (options.type && options.application) ? options.type : "portal";
  1494. var application = options.application || _form.json.application;
  1495. var key = type + "-" + application + "-" + name;
  1496. if (includedScripts.indexOf(key) > -1) {
  1497. if (callback) callback.apply(this);
  1498. return;
  1499. }
  1500. //if (includedScripts.indexOf( name )> -1){
  1501. // if (callback) callback.apply(this);
  1502. // return;
  1503. //}
  1504. var scriptAction;
  1505. switch (type) {
  1506. case "portal":
  1507. if (this.scriptActionPortal) {
  1508. scriptAction = this.scriptActionPortal;
  1509. } else {
  1510. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  1511. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  1512. }
  1513. break;
  1514. case "process":
  1515. if (this.scriptActionProcess) {
  1516. scriptAction = this.scriptActionProcess;
  1517. } else {
  1518. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  1519. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  1520. }
  1521. break;
  1522. case "cms":
  1523. if (this.scriptActionCMS) {
  1524. scriptAction = this.scriptActionCMS;
  1525. } else {
  1526. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  1527. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  1528. }
  1529. break;
  1530. }
  1531. scriptAction.getScriptByName(application, name, includedScripts, function (json) {
  1532. if (json.data) {
  1533. includedScripts.push(key);
  1534. //名称、别名、id
  1535. json.data.importedList.each( function ( flag ) {
  1536. if( type === "portal" ){
  1537. includedScripts.push( type + "-" + json.data.portal + "-" + flag );
  1538. if( json.data.portalName )includedScripts.push( type + "-" + json.data.portalName + "-" + flag );
  1539. if( json.data.portalAlias )includedScripts.push( type + "-" + json.data.portalAlias + "-" + flag );
  1540. }else if( type === "cms" ){
  1541. includedScripts.push( type + "-" + json.data.appId + "-" + flag );
  1542. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  1543. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  1544. }else if( type === "process" ){
  1545. includedScripts.push( type + "-" + json.data.application + "-" + flag );
  1546. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  1547. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  1548. }
  1549. });
  1550. includedScripts = includedScripts.concat(json.data.importedList);
  1551. MWF.Macro.exec(json.data.text, this);
  1552. if (callback) callback.apply(this);
  1553. } else {
  1554. if (callback) callback.apply(this);
  1555. }
  1556. }.bind(this), null, false);
  1557. };
  1558. this.define = function (name, fun, overwrite) {
  1559. var over = true;
  1560. if (overwrite === false) over = false;
  1561. var o = {};
  1562. o[name] = { "value": fun, "configurable": over };
  1563. MWF.defineProperties(this, o);
  1564. }.bind(this);
  1565. //仅前台对象-----------------------------------------
  1566. //form
  1567. /**
  1568. * 当查询设计中使用了select语句,并且配置了视图,可以在查询视图中使用本章API。<br/>
  1569. * queryStatement对象在查询视图中可用。它的很多方法与queryView类似。<b>(仅前端脚本可用)</b><br/>
  1570. * @module queryStatement
  1571. * @borrows module:queryView.confirm as confirm
  1572. * @borrows module:queryView.alert as alert
  1573. * @borrows module:queryView.notice as notice
  1574. * @borrows module:queryView.addEvent as addEvent
  1575. * @borrows module:queryView.openWork as openWork
  1576. * @borrows module:queryView.openJob as openJob
  1577. * @borrows module:queryView.openDocument as openDocument
  1578. * @borrows module:queryView.openPortal as openPortal
  1579. * @borrows module:queryView.openCMS as openCMS
  1580. * @borrows module:queryView.openProcess as openProcess
  1581. * @borrows module:queryView.openApplication as openApplication
  1582. * @borrows module:queryView.createDocument as createDocument
  1583. * @borrows module:queryView.startProcess as startProcess
  1584. * @example
  1585. * //您可以在查询视图中,通过this来获取queryStatement对象,如下:
  1586. * var queryStatement = this.queryStatement;
  1587. */
  1588. /**
  1589. * 当查询视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
  1590. * @method getParentEnvironment
  1591. * @memberOf module:queryStatement
  1592. * @static
  1593. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  1594. * @example
  1595. * this.queryStatement.getParentEnvironment();
  1596. * @example
  1597. * var env = this.queryStatement.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  1598. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  1599. */
  1600. /**
  1601. * 获取查询视图当前页的基本信息。
  1602. * @method getPageInfor
  1603. * @memberOf module:queryStatement
  1604. * @static
  1605. * @return {Object} 当前页的信息,格式如下:
  1606. *<pre><code class='language-js'>{
  1607. * "pages": 3, //总页数
  1608. * "perPageCount": 50, //每页的条数
  1609. * "currentPageNumber": 1 // 当前页数
  1610. * }
  1611. * </pre></code>
  1612. * @example
  1613. * this.queryStatement.getPageInfor();
  1614. */
  1615. /**
  1616. * 获取当前页的数据。
  1617. * @method getPageData
  1618. * @memberOf module:queryStatement
  1619. * @static
  1620. * @return {Object[]} 当前页数据。
  1621. * <div>数据格式和 jpql 语句的写法有关</div>
  1622. * 如: "select o from table o" 返回 json数组
  1623. *<pre><code class='language-js'>[
  1624. {
  1625. "id" : "id1",
  1626. "title" : "title1"
  1627. },
  1628. {
  1629. "id" : "id2",
  1630. "title" : "title2"
  1631. },
  1632. ...
  1633. *]
  1634. * </pre></code>
  1635. * 如:"select id, title from table o" 返回 二维数组:
  1636. *<pre><code class='language-js'>[
  1637. ["id1", "title1"],
  1638. ["id2", "title2"],
  1639. ...
  1640. *]
  1641. *</pre></code>
  1642. * @example
  1643. * var data = this.queryStatement.getPageData();
  1644. */
  1645. /**
  1646. * 跳转到指定的页面。
  1647. * @method toPage
  1648. * @memberOf module:queryStatement
  1649. * @static
  1650. * @param {Number} pageNumber - 需要跳转的页码。
  1651. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  1652. * @example
  1653. * var data = this.queryStatement.toPage( pageNumber, callback );
  1654. * @example
  1655. * // 跳转到第2页并且获取该页的数据。
  1656. * this.queryStatement.toPage( 2, function(){
  1657. * var data = this.queryStatement.getPageData();
  1658. * }.bind(this) )
  1659. */
  1660. /**
  1661. * 当查询视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  1662. * @method selectAll
  1663. * @memberOf module:queryStatement
  1664. * @static
  1665. * @example
  1666. * this.queryStatement.selectAll();
  1667. */
  1668. /**
  1669. * 当查询视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  1670. * @method unSelectAll
  1671. * @memberOf module:queryStatement
  1672. * @static
  1673. * @example
  1674. * this.queryStatement.unSelectAll();
  1675. */
  1676. /**
  1677. * 获取选中的条目的数据。
  1678. * @method getSelectedData
  1679. * @memberOf module:queryStatement
  1680. * @static
  1681. * @return {Object[]} 选中的条目的数据。
  1682. * <div>数据格式和 jpql 语句的写法有关</div>
  1683. * 如: "select o from table o" 返回 json数组
  1684. *<pre><code class='language-js'>[
  1685. {
  1686. "id" : "id1",
  1687. "title" : "title1"
  1688. },
  1689. {
  1690. "id" : "id2",
  1691. "title" : "title2"
  1692. },
  1693. ...
  1694. *]
  1695. * </pre></code>
  1696. * 如:"select id, title from table o" 返回 二维数组:
  1697. *<pre><code class='language-js'>[
  1698. ["id1", "title1"],
  1699. ["id2", "title2"],
  1700. ...
  1701. *]
  1702. *</pre></code>
  1703. * @example
  1704. * var data = this.queryStatement.getSelectedData();
  1705. */
  1706. /**获取queryStatement对应的DOM对象。
  1707. * @method node
  1708. * @static
  1709. * @methodOf module:queryStatement
  1710. * @see module:form.node
  1711. */
  1712. /**
  1713. * queryView对象可在视图中可用。它的很多方法与form类似。<b>(仅前端脚本可用)</b><br/>
  1714. * @module queryView
  1715. * @example
  1716. * //您可以在视图中,通过this来获取queryView对象,如下:
  1717. * var queryView = this.queryView;
  1718. */
  1719. this.page = this.form = this.queryView = this.queryStatement = {
  1720. /**
  1721. * 当视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
  1722. * @method getParentEnvironment
  1723. * @static
  1724. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  1725. * @example
  1726. * this.queryView.getParentEnvironment();
  1727. * @example
  1728. * var env = this.queryView.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  1729. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  1730. */
  1731. "getParentEnvironment" : function () { return _form.getParentEnvironment(); }, //视图嵌入的表单或页面的上下文
  1732. /**
  1733. * 获取查询的配置信息。
  1734. * @method getStatementInfor
  1735. * @memberOf module:queryStatement
  1736. * @static
  1737. * @return {StatementInfor} 查询的配置信息.
  1738. * @example
  1739. * this.queryStatement.getStatementInfor();
  1740. */
  1741. "getStatementInfor" : function () { return _form.getStatementInfor ? _form.getStatementInfor() : null; },
  1742. /**
  1743. * 获取查询的配置信息。
  1744. * @method getViewInfor
  1745. * @memberOf module:queryView
  1746. * @static
  1747. * @return {ViewInfor} 视图的配置信息.
  1748. * @example
  1749. * this.queryView.getViewInfor();
  1750. */
  1751. "getViewInfor" : function () { return _form.getViewInfor(); },
  1752. /**
  1753. * 获取视图当前页的基本信息。
  1754. * @method getPageInfor
  1755. * @memberOf module:queryView
  1756. * @static
  1757. * @return {Object} 当前页的信息,格式如下:
  1758. *<pre><code class='language-js'>{
  1759. * "pages": 3, //总页数
  1760. * "perPageCount": 50, //每页的条数
  1761. * "currentPageNumber": 1 // 当前页数
  1762. * }
  1763. * </pre></code>
  1764. * @example
  1765. * this.queryView.getPageInfor();
  1766. */
  1767. "getPageInfor" : function () { return _form.getPageInfor(); },
  1768. /**
  1769. * 获取当前页的数据。
  1770. * @method getPageData
  1771. * @memberOf module:queryView
  1772. * @static
  1773. * @return {Object[]} 当前页数据。
  1774. * <div>没有分类时候,数据格式如下:</div>
  1775. *<pre><code class='language-js'>[
  1776. * {
  1777. * "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  1778. * "data": { //视图中配置的数据
  1779. * "title": "考勤管理-配置-统计周期设置", //列名称及列值
  1780. * "time": "2018-08-25 11:29:45"
  1781. * }
  1782. * },
  1783. * ...
  1784. *]
  1785. * </pre></code>
  1786. * 有分类的时候,数据格式如下:
  1787. *<pre><code class='language-js'>[
  1788. * {
  1789. * "group": "工作日志", //分类1
  1790. * "list": [ //分类下的数据
  1791. * {
  1792. * "bundle": "001257be-725a-43cf-9679-3892bbab696a", //cms 的 documentId, process 的 jobId
  1793. * "data": { //视图中配置的数据
  1794. * "title": "标题", //列名称及列值
  1795. * "time": "2018-07-31 15:39:13",
  1796. * "category": "工作日志"
  1797. * }
  1798. * },
  1799. * ...
  1800. * ]
  1801. * },
  1802. * ...
  1803. *]
  1804. *</pre></code>
  1805. * @example
  1806. * var data = this.queryView.getPageData();
  1807. */
  1808. "getPageData" : function () { return _form.getPageData(); },
  1809. /**
  1810. * 跳转到指定的页面。
  1811. * @method toPage
  1812. * @memberOf module:queryView
  1813. * @static
  1814. * @param {Number} pageNumber - 需要跳转的页码。
  1815. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  1816. * @example
  1817. * var data = this.queryView.toPage( pageNumber, callback );
  1818. * @example
  1819. * // 跳转到第2页并且获取该页的数据。
  1820. * this.queryView.toPage( 2, function(){
  1821. * var data = this.queryView.getPageData();
  1822. * }.bind(this) )
  1823. */
  1824. "toPage" : function ( pageNumber, callback ) { return _form.toPage(pageNumber, callback); },
  1825. /**
  1826. * 当视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  1827. * @method selectAll
  1828. * @memberOf module:queryView
  1829. * @static
  1830. * @example
  1831. * this.queryView.selectAll();
  1832. */
  1833. "selectAll" : function () { return _form.selectAll(); },
  1834. /**
  1835. * 当视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  1836. * @method unSelectAll
  1837. * @memberOf module:queryView
  1838. * @static
  1839. * @example
  1840. * this.queryView.unSelectAll();
  1841. */
  1842. "unSelectAll" : function () { return _form.unSelectAll(); },
  1843. /**
  1844. * 获取选中的条目的数据。
  1845. * @method getSelectedData
  1846. * @memberOf module:queryView
  1847. * @static
  1848. * @return {Object[]} 选中的条目的数据。
  1849. * <div>格式如下:</div>
  1850. * <pre><code class='language-js'>
  1851. * [
  1852. {
  1853. "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  1854. "data": { //视图中配置的数据
  1855. "title": "考勤管理-配置-统计周期设置", //列名称及列值
  1856. "time": "2018-08-25 11:29:45"
  1857. }
  1858. },
  1859. ...
  1860. * ]
  1861. </pre></code>
  1862. * @example
  1863. * var data = this.queryView.getSelectedData();
  1864. */
  1865. "getSelectedData" : function () { return _form.getSelectedData(); },
  1866. /**
  1867. * 设置视图的过滤条件,该方法不能修改视图中默认的过滤条件(在开发视图的时候添加的过滤条件),而是在这上面新增。
  1868. * @method setFilter
  1869. * @memberOf module:queryView
  1870. * @static
  1871. * @param {(ViewFilter[]|ViewFilter|Null)} [filter] 过滤条件。<br/>
  1872. * 当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  1873. * 如果传入对象或者非空数组的时候,参数如下:
  1874. * <pre><code class='language-js'>[
  1875. * {
  1876. * "logic":"and",
  1877. * "path":"$work.title",
  1878. * "comparison":"like",
  1879. * "value":"7月",
  1880. * "formatType":"textValue"
  1881. * }
  1882. *]
  1883. * </pre></code>
  1884. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  1885. * @example
  1886. * this.queryView.setFilter( filter );
  1887. */
  1888. "setFilter" : function ( filter, callback ) { return _form.setFilter(filter, callback); },
  1889. /**
  1890. * 增加查询语句where子句的过滤条件。
  1891. * @method setStatementFilter
  1892. * @memberOf module:queryStatement
  1893. * @static
  1894. * @param {(StatementFilter[]|Null)} [filter] 过滤条件。<br/>
  1895. * 过滤条件。当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  1896. * 如果传入非空数组的时候,参数如下:
  1897. * <pre><code class='language-js'>[
  1898. * {
  1899. * "path":"o.title",
  1900. * "comparison":"like",
  1901. * "value":"关于",
  1902. * "formatType":"textValue"
  1903. * }
  1904. *]
  1905. * </pre></code>
  1906. * @param {StatementParameter} [parameter] 过滤条件。对查询语句where子句的形如":person"的参数部分进行赋值,参数如下:
  1907. * <pre><code class='language-js'>
  1908. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)。
  1909. * //那么可能的参数如下:
  1910. * {
  1911. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  1912. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  1913. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  1914. * "processName" : "test流程" //其他写确定的值
  1915. * }
  1916. * </pre></code>
  1917. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  1918. * @example
  1919. * this.queryStatement.setStatementFilter( filter, parameter, callback );
  1920. */
  1921. "setStatementFilter" : function ( filter , parameter, callback) { return _form.setFilter(filter, parameter, callback); },
  1922. /**
  1923. * 把当前视图切换成另外一个视图。
  1924. * @method switchView
  1925. * @memberOf module:queryView
  1926. * @static
  1927. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  1928. * <div>下列说明的filter属性参考<a href='global.html#ViewFilter'>ViewFilter</a></div>
  1929. * <pre><code class='language-js'>{
  1930. * "application": application, //必选,视图的所在应用id
  1931. * "viewName": viewName, //必选,视图的名称
  1932. * "filter": [
  1933. * {
  1934. * "logic":"and",
  1935. * "path":"$work.title",
  1936. * "comparison":"like",
  1937. * "value":"7月",
  1938. * "formatType":"textValue"
  1939. * }
  1940. * ], //可选,增加视图的过滤条件(ViewFilter),如果不传,则使用原视图的配置;如果需要去掉原视图的配置,则传入空数组 []
  1941. * "isTitle": "yes", //可选,是否显示t视图的标题行,可选值有:yes no
  1942. * "select": "none", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  1943. * "titleStyles": {
  1944. * "color" : "red",
  1945. * "font-size" : "14px"
  1946. * }, //可选,标题行样式,如果不传,则使用原视图的配置
  1947. * "itemStyles": {
  1948. * "color" : "#333",
  1949. * "font-size" : "12px"
  1950. * }, //可选,内容行样式,如果不传,则使用原视图的配置
  1951. * "isExpand": "no", //可选,默认是否展开分类,如果不传,则使用原视图的配置, 可选值有:yes no
  1952. * }
  1953. * </pre></code>
  1954. * @example
  1955. * this.queryView.switchView( options );
  1956. */
  1957. "switchView" : function ( options ) { return _form.switchView(options); },
  1958. /**
  1959. * 把当前查询视图切换成另外一个查询视图。
  1960. * @method switchStatement
  1961. * @memberOf module:queryStatement
  1962. * @static
  1963. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  1964. * <div>下列说明的filter属性参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  1965. * parameter属性参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  1966. * <pre><code class='language-js'>this.queryStatement.switchStatement({
  1967. * "statementId": statementId, //必选,查询的名称、别名、id
  1968. * "isTitle": "yes", //可选,是否显示视图的标题行,可选值有:yes no
  1969. * "select": "multi", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  1970. * "showActionbar": false, //可选,是否显示操作条
  1971. * "filter": [ //可选,增加查询语句where子句的过滤条件
  1972. * {
  1973. * "path": "o.title",
  1974. * "title": "标题",
  1975. * "type": "filter",
  1976. * "comparison": "like",
  1977. * "formatType": "textValue",
  1978. * "value": "测试"
  1979. * }
  1980. * ],
  1981. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  1982. * "parameter" : { //可选,对查询语句where语句的形如":person"的参数部分进行赋值
  1983. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  1984. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  1985. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  1986. * "processName" : "test流程" //其他写确定的值
  1987. * }
  1988. * })
  1989. * </pre></code>
  1990. * @example
  1991. * this.queryStatement.switchStatement( options );
  1992. */
  1993. "switchStatement" : function ( options ) { if(_form.switchStatement)_form.switchStatement(options) ; },
  1994. /**
  1995. * 重新加载视图。
  1996. * @method reload
  1997. * @methodOf module:queryView
  1998. * @static
  1999. * @example
  2000. * this.queryView.reload();
  2001. */
  2002. "reload" : function () { _form.reload(); },
  2003. // "getInfor": function () { return ev.pageInfor; },
  2004. // "infor": ev.pageInfor,
  2005. // "getApp": function () { return _form.app; },
  2006. // "app": _form.app,
  2007. /**获取queryView对应的DOM对象。
  2008. * @method node
  2009. * @static
  2010. * @methodOf module:queryView
  2011. * @see module:form.node
  2012. */
  2013. "node": function () { return _form.node; },
  2014. // "get": function (name) { return (_form.all) ? _form.all[name] : null; },
  2015. // "getWidgetModule": function (widget, moduleName) {
  2016. // if (!_form.widgetModules || !_form.widgetModules[widget]) return null;
  2017. // var module = _form.widgetModules[widget][moduleName];
  2018. // return module || null;
  2019. // },
  2020. // "getField": function (name) { return _forms[name]; },
  2021. // "getAction": function () { return _form.workAction },
  2022. "getDesktop": function () { return _form.app ? _form.app.desktop : null},
  2023. // "getData": function () { return new MWF.xScript.JSONData(_form.getData()); },
  2024. //"save": function(callback){_form.saveWork(callback);},
  2025. // "close": function () { _form.closeWork(); },
  2026. // "print": function (application, form) {
  2027. // _form.printWork(application, form);
  2028. // },
  2029. /**弹出一个确认框。
  2030. * @method confirm
  2031. * @static
  2032. * @methodOf module:queryView
  2033. * @see module:form.confirm
  2034. */
  2035. "confirm": function (type, title, text, width, height, ok, cancel, callback, mask, style) {
  2036. // var p = MWF.getCenter({"x": width, "y": height});
  2037. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  2038. // _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  2039. if ((arguments.length <= 1) || o2.typeOf(arguments[1]) === "string") {
  2040. var p = MWF.getCenter({ "x": width, "y": height });
  2041. e = { "event": { "clientX": p.x, "x": p.x, "clientY": p.y, "y": p.y } };
  2042. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  2043. } else {
  2044. e = (arguments.length > 1) ? arguments[1] : null;
  2045. title = (arguments.length > 2) ? arguments[2] : null;
  2046. text = (arguments.length > 3) ? arguments[3] : null;
  2047. width = (arguments.length > 4) ? arguments[4] : null;
  2048. height = (arguments.length > 5) ? arguments[5] : null;
  2049. ok = (arguments.length > 6) ? arguments[6] : null;
  2050. cancel = (arguments.length > 7) ? arguments[7] : null;
  2051. callback = (arguments.length > 8) ? arguments[8] : null;
  2052. mask = (arguments.length > 9) ? arguments[9] : null;
  2053. style = (arguments.length > 10) ? arguments[10] : null;
  2054. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  2055. }
  2056. },
  2057. /**显示一个带关闭按钮的信息框。
  2058. * @method alert
  2059. * @static
  2060. * @methodOf module:queryView
  2061. * @see module:form.alert
  2062. */
  2063. "alert": function(type, title, text, width, height){
  2064. _form.alert(type, title, text, width, height);
  2065. },
  2066. /**显示一个信息框。
  2067. * @method notice
  2068. * @static
  2069. * @methodOf module:queryView
  2070. * @see module:form.notice
  2071. */
  2072. "notice": function (content, type, target, where, offset, option) {
  2073. _form.notice(content, type, target, where, offset, option);
  2074. },
  2075. /** 给视图添加事件。
  2076. * @method addEvent
  2077. * @static
  2078. * @methodOf module:queryView
  2079. * @see module:form.addEvent
  2080. */
  2081. "addEvent": function (e, f) { _form.addEvent(e, f); },
  2082. // "openWindow": function (form, app) {
  2083. // _form.openWindow(form, app);
  2084. // },
  2085. // "toPage": function (name, par, nohis) {
  2086. // _form.app.toPage(name, par, nohis);
  2087. // },
  2088. // "toPortal": function (portal, page, par) {
  2089. // _form.app.toPortal(portal, page, par);
  2090. // },
  2091. /**打开一个在流转或已完成的流程实例。
  2092. * @method openWork
  2093. * @static
  2094. * @methodOf module:queryView
  2095. * @see module:form.openWork
  2096. */
  2097. "openWork": function (id, completedId, title, options) {
  2098. var op = options || {};
  2099. op.workId = id;
  2100. op.workCompletedId = completedId;
  2101. op.docTitle = title;
  2102. op.appId = "process.Work" + (op.workId || op.workCompletedId);
  2103. return layout.desktop.openApplication(this.event, "process.Work", op);
  2104. },
  2105. /**根据流程的jobId打开工作。
  2106. * @method openJob
  2107. * @static
  2108. * @methodOf module:queryView
  2109. * @see module:form.openJob
  2110. */
  2111. "openJob": function (id, choice, options) {
  2112. var workData = null;
  2113. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function (json) {
  2114. if (json.data) workData = json.data;
  2115. }.bind(this), null, false);
  2116. if (workData) {
  2117. var len = workData.workList.length + workData.workCompletedList.length;
  2118. if (len) {
  2119. if (len > 1 && choice) {
  2120. var node = new Element("div", { "styles": { "padding": "20px", "width": "500px" } }).inject(_form.node);
  2121. workData.workList.each(function (work) {
  2122. var workNode = new Element("div", {
  2123. "styles": {
  2124. "background": "#ffffff",
  2125. "border-radius": "10px",
  2126. "clear": "both",
  2127. "margin-bottom": "10px",
  2128. "height": "40px",
  2129. "padding": "10px 10px"
  2130. }
  2131. }).inject(node);
  2132. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  2133. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>" + o2.LP.widget.open + "</div></div>" +
  2134. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
  2135. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + work.activityName + "</div>" +
  2136. "<div style='color:#999999; float: left; margin-right: 10px'>" + work.activityArrivedTime + "</div>" +
  2137. "<div style='color:#999999; float: left; margin-right: 10px'>" + (work.manualTaskIdentityText || "") + "</div></div>";
  2138. workNode.set("html", html);
  2139. var action = workNode.getElement(".MWFAction");
  2140. action.store("work", work);
  2141. action.addEvent("click", function (e) {
  2142. var work = e.target.retrieve("work");
  2143. if (work) this.openWork(work.id, null, work.title, options);
  2144. dlg.close();
  2145. }.bind(this));
  2146. }.bind(this));
  2147. workData.workCompletedList.each(function (work) {
  2148. var workNode = new Element("div", {
  2149. "styles": {
  2150. "background": "#ffffff",
  2151. "border-radius": "10px",
  2152. "clear": "both",
  2153. "margin-bottom": "10px",
  2154. "height": "40px",
  2155. "padding": "10px 10px"
  2156. }
  2157. }).inject(node);
  2158. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  2159. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>" + o2.LP.widget.open + "</div></div>" +
  2160. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
  2161. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + o2.LP.widget.workcompleted + "</div>" +
  2162. "<div style='color:#999999; float: left; margin-right: 10px'>" + work.completedTime + "</div>";
  2163. workNode.set("html", html);
  2164. var action = workNode.getElement(".MWFAction");
  2165. action.store("work", work);
  2166. action.addEvent("click", function (e) {
  2167. var work = e.target.retrieve("work");
  2168. if (work) this.openWork(null, work.id, work.title, options);
  2169. dlg.close();
  2170. }.bind(this));
  2171. }.bind(this));
  2172. var height = node.getSize().y + 20;
  2173. if (height > 600) height = 600;
  2174. var dlg = o2.DL.open({
  2175. "title": o2.LP.widget.choiceWork,
  2176. "style": "user",
  2177. "isResize": false,
  2178. "content": node,
  2179. "buttonList": [
  2180. {
  2181. "type": "cancel",
  2182. "text": o2.LP.widget.close,
  2183. "action": function () { dlg.close(); }
  2184. }
  2185. ]
  2186. });
  2187. } else {
  2188. if (workData.workList.length) {
  2189. var work = workData.workList[0];
  2190. return this.openWork(work.id, null, work.title, options);
  2191. } else {
  2192. var work = workData.workCompletedList[0];
  2193. return this.openWork(null, work.id, work.title, options);
  2194. }
  2195. }
  2196. }
  2197. }
  2198. },
  2199. /**打开一个内容管理文档。
  2200. * @method openDocument
  2201. * @static
  2202. * @methodOf module:queryView
  2203. * @see module:form.openDocument
  2204. */
  2205. "openDocument": function (id, title, options) {
  2206. var op = options || {};
  2207. op.documentId = id;
  2208. op.docTitle = title || "";
  2209. layout.desktop.openApplication(this.event, "cms.Document", op);
  2210. },
  2211. /**打开一个门户页面。
  2212. * @method openPortal
  2213. * @static
  2214. * @methodOf module:queryView
  2215. * @see module:form.openPortal
  2216. */
  2217. "openPortal": function (name, page, par) {
  2218. var action = MWF.Actions.get("x_portal_assemble_surface");
  2219. action.getApplication(name, function (json) {
  2220. if (json.data) {
  2221. if (page) {
  2222. action.getPageByName(page, json.data.id, function (pageJson) {
  2223. var pageId = (pageJson.data) ? pageJson.data.id : "";
  2224. layout.desktop.openApplication(null, "portal.Portal", {
  2225. "portalId": json.data.id,
  2226. "pageId": pageId,
  2227. "parameters": par,
  2228. "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
  2229. })
  2230. });
  2231. } else {
  2232. layout.desktop.openApplication(null, "portal.Portal", {
  2233. "portalId": json.data.id,
  2234. "parameters": par,
  2235. "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
  2236. })
  2237. }
  2238. }
  2239. });
  2240. },
  2241. /**打开一个内容管理栏目。
  2242. * @method openCMS
  2243. * @static
  2244. * @methodOf module:queryView
  2245. * @see module:form.openCMS
  2246. */
  2247. "openCMS": function (name) {
  2248. var action = MWF.Actions.get("x_cms_assemble_control");
  2249. action.getColumn(name, function (json) {
  2250. if (json.data) {
  2251. layout.desktop.openApplication(null, "cms.Module", {
  2252. "columnId": json.data.id,
  2253. "appId": "cms.Module" + json.data.id
  2254. });
  2255. }
  2256. });
  2257. },
  2258. /**打开一个流程应用。
  2259. * @method openProcess
  2260. * @static
  2261. * @methodOf module:queryView
  2262. * @see module:form.openProcess
  2263. */
  2264. "openProcess": function (name) {
  2265. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  2266. action.getApplication(name, function (json) {
  2267. if (json.data) {
  2268. layout.desktop.openApplication(null, "process.Application", {
  2269. "id": json.data.id,
  2270. "appId": "process.Application" + json.data.id
  2271. });
  2272. }
  2273. });
  2274. },
  2275. /**打开一个任意一个component应用。
  2276. * @method openApplication
  2277. * @static
  2278. * @methodOf module:queryView
  2279. * @see module:form.openApplication
  2280. */
  2281. "openApplication": function (name, options) {
  2282. layout.desktop.openApplication(null, name, options);
  2283. },
  2284. /**创建一个内容管理文档。
  2285. * @method createDocument
  2286. * @static
  2287. * @methodOf module:queryView
  2288. * @see module:form.createDocument
  2289. */
  2290. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
  2291. var column = columnOrOptions;
  2292. var onAfterPublish, onPostPublish;
  2293. if (typeOf(columnOrOptions) == "object") {
  2294. column = columnOrOptions.column;
  2295. category = columnOrOptions.category;
  2296. data = columnOrOptions.data;
  2297. identity = columnOrOptions.identity;
  2298. callback = columnOrOptions.callback;
  2299. target = columnOrOptions.target;
  2300. latest = columnOrOptions.latest;
  2301. selectColumnEnable = columnOrOptions.selectColumnEnable;
  2302. ignoreTitle = columnOrOptions.ignoreTitle;
  2303. onAfterPublish = columnOrOptions.onAfterPublish;
  2304. onPostPublish = columnOrOptions.onPostPublish;
  2305. }
  2306. if (target) {
  2307. if (layout.app && layout.app.inBrowser) {
  2308. layout.app.content.empty();
  2309. layout.app = null;
  2310. }
  2311. }
  2312. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  2313. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  2314. "documentData": data,
  2315. "identity": identity,
  2316. "ignoreTitle": ignoreTitle === true,
  2317. "ignoreDrafted": latest === false,
  2318. "selectColumnEnable": !category || selectColumnEnable === true,
  2319. "restrictToColumn": !!category && selectColumnEnable !== true,
  2320. "categoryFlag": category, //category id or name
  2321. "columnFlag": column, //column id or name,
  2322. "onStarted": function (documentId, data) {
  2323. if (callback) callback();
  2324. },
  2325. "onPostPublish": function () {
  2326. if(onPostPublish)onPostPublish();
  2327. },
  2328. "onAfterPublish": function () {
  2329. if(onAfterPublish)onAfterPublish();
  2330. }
  2331. });
  2332. starter.load();
  2333. })
  2334. },
  2335. /** 启动一个流程实例。
  2336. * @method startProcess
  2337. * @static
  2338. * @methodOf module:queryView
  2339. * @see module:form.startProcess
  2340. */
  2341. "startProcess": function (app, process, data, identity, callback, target, latest) {
  2342. if (arguments.length > 2) {
  2343. for (var i = 2; i < arguments.length; i++) {
  2344. if (typeOf(arguments[i]) == "boolean") {
  2345. target = arguments[i];
  2346. break;
  2347. }
  2348. }
  2349. }
  2350. if (target) {
  2351. if (layout.app && layout.app.inBrowser) {
  2352. //layout.app.content.empty();
  2353. layout.app.$openWithSelf = true;
  2354. }
  2355. }
  2356. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function (json) {
  2357. if (json.data) {
  2358. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function () {
  2359. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  2360. "workData": data,
  2361. "identity": identity,
  2362. "latest": latest,
  2363. "onStarted": function (data, title, processName) {
  2364. if (data.work){
  2365. var work = data.work;
  2366. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
  2367. layout.desktop.openApplication(null, "process.Work", options);
  2368. }else{
  2369. var currentTask = [];
  2370. data.each(function(work){
  2371. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  2372. }.bind(this));
  2373. if (currentTask.length==1){
  2374. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  2375. layout.desktop.openApplication(null, "process.Work", options);
  2376. }else{}
  2377. }
  2378. // var currentTask = [];
  2379. // data.each(function (work) {
  2380. // if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  2381. // }.bind(this));
  2382. //
  2383. // if (currentTask.length == 1) {
  2384. // var options = { "workId": currentTask[0], "appId": currentTask[0] };
  2385. // layout.desktop.openApplication(null, "process.Work", options);
  2386. // } else { }
  2387. if (callback) callback(data);
  2388. }.bind(this)
  2389. });
  2390. starter.load();
  2391. }.bind(this));
  2392. }
  2393. });
  2394. }
  2395. //"app": _form.app
  2396. };
  2397. // this.form.currentRouteName = _form.json.currentRouteName;
  2398. // this.form.opinion = _form.json.opinion;
  2399. this.target = ev.target;
  2400. this.event = ev.event;
  2401. this.status = ev.status;
  2402. /**
  2403. * 在前端脚本中,可以通过this.session.user来获取当前用户信息。<br/>
  2404. * @module session
  2405. * @example
  2406. * //获取当前用户信息
  2407. * var user = this.session.user
  2408. * @return {Object} 当前用户信息,内容和格式如下:
  2409. * <pre><code class='language-js'>{
  2410. * "id": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  2411. * "genderType": "m", //性别
  2412. * "icon": "...", //头像
  2413. * "signature": "", //个人签名
  2414. * "name": "胡起", //姓名
  2415. * "employee": "huqi", //员工号
  2416. * "unique": "huqi", //唯一标识
  2417. * "distinguishedName": "xx@huqi@P", //人员全称
  2418. * "superior": "", //上级人员id
  2419. * "changePasswordTime": "2017-03-13", //修改密码时间
  2420. * "lastLoginTime": "2019-01-02", //最后登录时间
  2421. * "mail": "huqi@zoneland.net", //邮件地址
  2422. * "weixin": "", //微信号
  2423. * "qq": "", //QQ
  2424. * "mobile": "18057190078", //手机号码
  2425. * "officePhone": "", //办公电话
  2426. * "createTime": "2017-03-13 12:27:04", //人员创建时间
  2427. * "updateTime": "2019-01-02 13:00:04", //人员修改时间
  2428. * "token": "...", //当前用户token
  2429. * "roleList": [ //人员角色
  2430. * "ProcessPlatformCreator@ProcessPlatformCreatorSystemRole@R",
  2431. * "ProcessPlatformManager@ProcessPlatformManagerSystemRole@R",
  2432. * "Manager@ManagerSystemRole@R"
  2433. * ],
  2434. * "identityList": [ //人员身份列表
  2435. * {
  2436. * "id": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份ID
  2437. * "name": "xx", //身份名称
  2438. * "unique": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份唯一标识
  2439. * "distinguishedName": "xx@709328c8-44a0-4f5d-a3fa-3c31208232d5@I", //身份全称
  2440. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  2441. * "unit": "d5356fd4-6675-45ad-9a00-5eff20b83dfa", //所属组织ID
  2442. * "unitName": "开发部", //所属组织名称
  2443. * "unitLevel": 2, //所属组织层级
  2444. * "unitLevelName": "兰德纵横/开发部", //所属组织层次名
  2445. * "major": true //是否是主身份
  2446. * },
  2447. * {
  2448. * "id": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  2449. * "description": "",
  2450. * "name": "xx",
  2451. * "unique": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  2452. * "distinguishedName": "xx@343510af-57c2-4a55-a1f2-f30d7af6d284@I",
  2453. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a",
  2454. * "unit": "108b1b7c-cc78-49ab-9ab1-e67073bd6541",
  2455. * "unitName": "开发部",
  2456. * "unitLevel": 2,
  2457. * "unitLevelName": "浙江兰德纵横/开发部",
  2458. * "major": false
  2459. * }
  2460. * ]
  2461. * }
  2462. * </pre></code>
  2463. */
  2464. this.session = layout.desktop.session;
  2465. /**
  2466. * 本文档说明如何在前台脚本中使用Actions调用平台的RESTful服务。<br/>
  2467. * 通过访问以下地址来查询服务列表:http://server:20030/x_program_center/jest/list.html
  2468. * @module Actions
  2469. * @example
  2470. * //获取Actions
  2471. * this.Actions
  2472. * //或者
  2473. * o2.Actions
  2474. */
  2475. /**
  2476. * 您可以使用this.Actions.getHost来获取服务根的host。
  2477. * @method getHost
  2478. * @methodOf module:Actions
  2479. * @static
  2480. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  2481. *如:<pre><code class='language-js'>
  2482. * "x_processplatform_assemble_surface" //流程平台相关服务根
  2483. * </pre></code>
  2484. * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
  2485. * @example
  2486. * var actions = this.Actions.getHost( root );
  2487. */
  2488. /**
  2489. * 平台预置了Actions对象用于调用平台提供的服务,您可以使用this.Actions.load来获取这些方法。
  2490. * @method load
  2491. * @methodOf module:Actions
  2492. * @static
  2493. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  2494. * 如:
  2495. *<pre><code class='language-js'>
  2496. * "x_processplatform_assemble_surface" //流程平台相关服务根
  2497. * </pre></code>
  2498. * @return {Object} 返回action对象,用于后续服务调用
  2499. * @example
  2500. * var actions = o2.Actions.load( root );
  2501. * //或
  2502. * var actions = this.Actions.load( root );
  2503. * @example
  2504. * //获取流程平台服务对象。
  2505. * var processAction = this.Actions.load("x_processplatform_assemble_surface");
  2506. * @example
  2507. * <caption>
  2508. * 通过this.Actions.load(root)方法得到的action对象,就可以访问此服务下的方法了。<br/>
  2509. * 访问方法的规则如下:
  2510. * </caption>
  2511. * this.Actions.load( root )[actionName][methodName]( arguements );
  2512. *
  2513. * root : 平台服务根
  2514. *
  2515. * actionName : 服务下的Action分类名称,如 TaskAction
  2516. *
  2517. * methodName : Action分类的服务名称,如 get
  2518. *
  2519. * arguements : 需调用的RESTful服务的相关参数。这些参数需要按照先后顺序传入。根据实际情况可以省略某些参数。参数序列分别是:
  2520. *
  2521. * uri的参数, data/formData(Post, Put方法), file(附件), success, failure, async。
  2522. *
  2523. * uri参数:如果有uri有多个参数,需要按先后顺序传入。
  2524. *
  2525. * data(formData)参数:提交到后台的数据,如果是上传附件,传入formData。POST 和 PUT 方法需要传入,GET方法和DELETE方法省略。
  2526. *
  2527. * file参数:POST 或者 PUT方法中有效,当需要上传附件时传入,否则可以省略。
  2528. *
  2529. * success参数:服务执行成功时的回调方法,形如 function(json){
  2530. * json为后台服务传回的数据
  2531. * }。
  2532. *
  2533. * failure 参数:服务执行失败时的回调方法,形如 function(xhr){
  2534. * xhr XmlHttpRequest对象,服务器请求失败时有值
  2535. * }
  2536. * 此参数可以省略,如果省略,系统会自动弹出错误信息。
  2537. *
  2538. * async : 方法同步或者异步执行,默认为true。
  2539. * @example
  2540. * <caption>
  2541. * <b>样例1:</b>
  2542. * 根据x_processplatform_assemble_surface服务获取当前用户的待办列表:<br/>
  2543. * 可以通过对应服务的查询页面,http://server:20020/x_processplatform_assemble_surface/jest/index.html<br/>
  2544. * 可以看到以下界面:<img src="img/module/Actions/Actions.png"/>
  2545. * 我们可以找到TaskAction的V2ListPaging服务是列式当前用户待办的服务。<br/>
  2546. * 该服务有以下信息:<br/>
  2547. * 1、actionName是:TaskAction<br/>
  2548. * 2、methodName是:V2ListPaging<br/>
  2549. * 2、有两个url参数,分别是 page(分页), size(每页数量)<br/>
  2550. * 3、有一系列的body参数<br/>
  2551. * 4、该服务方法类型是POST<br/>
  2552. * 根据这些信息我们可以组织出下面的方法:
  2553. * </caption>
  2554. * var processAction = this.Actions.load("x_processplatform_assemble_surface"); //获取action
  2555. * var method = processAction.TaskAction.V2ListPaging; //获取列式方法
  2556. * method(
  2557. * 1, //uri 第1个参数,如果无uri参数,可以省略
  2558. * 20, //uri 第2个参数,如果无uri参数,可以省略,如果还有其他uri参数,可以用逗号, 分隔
  2559. * { //body 参数,对POST和PUT请求,该参数必须传,可以为空对象
  2560. * processList : [xxx] //具体参数
  2561. * },
  2562. * function(json){ //正确调用的回调
  2563. * //json.data得到服务返回数据
  2564. * },
  2565. * function(xhr){ //可选,错误调用的回调
  2566. * //xhr为XmlHttpRequest对象,服务器请求失败时有值
  2567. * var responseJSON = JSON.parse( xhr.responseText ) //xhr.responseText {String}是后台返回的出错信息
  2568. * //responseJSON见下面的说明
  2569. *
  2570. * var message = responseJSON.message; //message为错误提示文本
  2571. * },
  2572. * true //可选,true为异步调用,false为同步调用,默认为true
  2573. * );
  2574. * @example
  2575. * <caption>出错信息responseJSON的格式</caption>
  2576. * {
  2577. * "type": "error", //类型为错误
  2578. * "message": "标识为:343434 的 Task 对象不存在.", //提示文本
  2579. * "date": "2020-12-29 17:02:13", //出错时间
  2580. * "prompt": "com.x.base.core.project.exception.ExceptionEntityNotExist" //后台错误类
  2581. *}
  2582. * @example
  2583. * <caption>
  2584. * <b>样例2:</b>
  2585. * 已知流程实例的workid,在脚本中获取数据,修改后进行保存。
  2586. * </caption>
  2587. * //查询服务列表找到获取data数据服务为DataAction的getWithWork方法
  2588. * //查询服务列表找到更新data数据服务为DataAction的updateWithWork方法
  2589. *
  2590. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  2591. * var data;
  2592. * this.Actions.load("x_processplatform_assemble_surface").DataAction.getWithWork( //平台封装好的方法
  2593. * workid, //uri的参数
  2594. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  2595. * data = json.data; //为变量data赋值
  2596. * }.bind(this),
  2597. * false //同步执行
  2598. * )
  2599. *
  2600. * data.subject = "新标题"; //修改数据
  2601. * this.Actions.load("x_processplatform_assemble_surface").DataAction.updateWithWork(
  2602. * workid, //uri的参数
  2603. * data, //保存的数据
  2604. * function(){ //服务调用成功的回调函数
  2605. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  2606. * }.bind(this)
  2607. * );
  2608. */
  2609. /**
  2610. * <b>已过时。</b>平台预置了Action的调用方法,您可以使用o2.Actions.get来获取这些方法。RESTful配置文件在{服务器目录}/webServer/o2_core/o2/xAction/services下。
  2611. * @method get
  2612. * @deprecated
  2613. * @methodOf module:Actions
  2614. * @static
  2615. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  2616. *如:<pre><code class='language-js'>
  2617. * "x_processplatform_assemble_surface" //流程平台相关服务根
  2618. * </pre></code>
  2619. * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
  2620. * @example
  2621. * var actions = o2.Actions.get( root );
  2622. * actions[ methodName ]( arguements );
  2623. *
  2624. * or
  2625. *
  2626. * o2.Actions.get( root )[methodName]( arguements );
  2627. * @example
  2628. * methodName :(string)方法名称。
  2629. * arguements : 见load方法的arguements说明
  2630. * @example
  2631. * <caption><b>样例一:</b>已知流程实例的workid,在脚本中获取数据,修改后进行保存。</caption>
  2632. * //现已知获取数据的方法名称是 getWorkData uri为: /jaxrs/data/work/{workid}
  2633. * //已知更新数据的方法名称是 saveData uri为: /jaxrs/data/work/{workid}
  2634. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  2635. * var action = o2.Actions.get("x_processplatform_assemble_surface");
  2636. * var data;
  2637. * action.getWorkData( //平台封装好的方法
  2638. * workid, //uri的参数
  2639. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  2640. * data = json.data; //为变量data赋值
  2641. * }.bind(this),
  2642. * false //同步执行
  2643. * );
  2644. * data.subject = "新标题"; //修改数据
  2645. * action.saveData(
  2646. * workid, //uri的参数
  2647. * data, //保存的数据
  2648. * function(){ //服务调用成功的回调函数
  2649. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  2650. * }.bind(this)
  2651. * );
  2652. * @example
  2653. * <caption><b>样例二:</b>已知流程应用的workid,分页列式出流程实例。</caption>
  2654. * //现已知获取数据的方法名称是 listWorkNext uri为: {"uri": "/jaxrs/work/list/{id}/next/{count}/application/{applicationId}"},
  2655. * var id = "(0)"; //如果是第一页id是(0),否则传上一页最后一个流程实例的id
  2656. * var count = 10;
  2657. * var applicationId = "dde8bc22-225a-4f85-8132-7374d546886e";
  2658. * o2.Actions.get("x_processplatform_assemble_surface").listWorkNext(
  2659. * id, //listWorkNext服务有3个uri参数,要按先后顺序列出
  2660. * count,
  2661. * applicationId,
  2662. * function( json ){
  2663. * //json.data
  2664. * }.bind(this)
  2665. * );
  2666. */
  2667. this.Actions = o2.Actions;
  2668. this.query = function (option) {
  2669. // options = {
  2670. // "name": "statementName",
  2671. // "data": "json data",
  2672. // "firstResult": 1,
  2673. // "maxResults": 100,
  2674. // "success": function(){},
  2675. // "error": function(){},
  2676. // "async": true or false, default is true
  2677. // }
  2678. if (option) {
  2679. var json = (option.data) || {};
  2680. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  2681. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  2682. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  2683. }
  2684. };
  2685. // this.Table = MWF.xScript.createTable();
  2686. };
  2687. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  2688. if( !MWF.xScript.createDict ){
  2689. MWF.xScript.addDictToCache = function ( options, path, json ) {
  2690. if( !path )path = "root";
  2691. if( path.indexOf("root") !== 0 )path = "root." + path ;
  2692. var type = options.appType || "process";
  2693. var enableAnonymous = options.enableAnonymous || false;
  2694. var appFlagList = [];
  2695. if( options.application )appFlagList.push( options.application );
  2696. if( options.appId )appFlagList.push( options.appId );
  2697. if( options.appName )appFlagList.push( options.appName );
  2698. if( options.appAlias )appFlagList.push( options.appAlias );
  2699. var dictFlagList = [];
  2700. if( options.id )dictFlagList.push( options.id );
  2701. if( options.name )dictFlagList.push( options.name );
  2702. if( options.alias )dictFlagList.push( options.alias );
  2703. var cache = {};
  2704. cache[path] = json;
  2705. for( var i=0; i<appFlagList.length; i++ ){
  2706. for( var j=0; j<dictFlagList.length; j++ ){
  2707. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  2708. if( !MWF.xScript.dictLoaded[k] ){
  2709. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  2710. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  2711. }else if( i===0 && j===0 ){
  2712. MWF.xScript.setDictToCache( k, path ,json );
  2713. var arr = path.split(/\./g);
  2714. var p;
  2715. var cache = MWF.xScript.dictLoaded[k];
  2716. for( var l=0 ; l<arr.length; l++ ){
  2717. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  2718. if( cache[ p ] )break;
  2719. }
  2720. if( p ){
  2721. var mathP = p+".";
  2722. Object.keys( cache ).each( function( path, idx){
  2723. if( path.indexOf( mathP ) === 0 )delete cache[path];
  2724. })
  2725. }
  2726. }
  2727. }
  2728. }
  2729. };
  2730. MWF.xScript.getMatchedDict = function(key, path){
  2731. if( !path )path = "root";
  2732. if( path.indexOf("root") !== 0 )path = "root." + path ;
  2733. var arr = path.split(/\./g);
  2734. if( MWF.xScript.dictLoaded[key] ){
  2735. var dicts = MWF.xScript.dictLoaded[key];
  2736. var list = Array.clone(arr);
  2737. var p;
  2738. var dict;
  2739. for( var i=0 ; i<arr.length; i++ ){
  2740. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  2741. list.shift();
  2742. if( dicts[ p ] ){
  2743. dict = dicts[ p ];
  2744. break;
  2745. }
  2746. }
  2747. return {
  2748. dict : dict,
  2749. unmatchedPathList : list
  2750. }
  2751. }
  2752. return {
  2753. dict : null,
  2754. unmatchedPathList : list
  2755. }
  2756. };
  2757. MWF.xScript.insertDictToCache = function(key, path, json){
  2758. if( MWF.xScript.dictLoaded[key] ){
  2759. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2760. var dict = matchedDict.dict;
  2761. var list = matchedDict.unmatchedPathList;
  2762. if( !dict ){
  2763. MWF.xScript.dictLoaded[key][path] = json;
  2764. }else{
  2765. for( var j=0; j<list.length-1; j++ ){
  2766. if( !dict[ list[j] ] ){
  2767. dict[ list[j] ] = {};
  2768. }
  2769. dict = dict[ list[j] ];
  2770. }
  2771. var lastPath = list[list.length-1];
  2772. if( !dict[lastPath] ){
  2773. dict[lastPath] = json;
  2774. }else if( typeOf( dict[lastPath] ) === "array" ){
  2775. dict[lastPath].push( json );
  2776. }
  2777. }
  2778. }else{
  2779. MWF.xScript.dictLoaded[key] = {};
  2780. MWF.xScript.dictLoaded[key][path] = json;
  2781. }
  2782. };
  2783. MWF.xScript.setDictToCache = function(key, path, json){
  2784. if( MWF.xScript.dictLoaded[key] ){
  2785. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2786. var dict = matchedDict.dict;
  2787. var list = matchedDict.unmatchedPathList;
  2788. if( !dict ){
  2789. MWF.xScript.dictLoaded[key][path] = json;
  2790. }else{
  2791. for( var j=0; j<list.length-1; j++ ){
  2792. if( !dict[ list[j] ] ){
  2793. dict[ list[j] ] = {};
  2794. }
  2795. dict = dict[ list[j] ];
  2796. }
  2797. dict[list[list.length-1]] = json;
  2798. }
  2799. }else{
  2800. MWF.xScript.dictLoaded[key] = {};
  2801. MWF.xScript.dictLoaded[key][path] = json;
  2802. }
  2803. };
  2804. MWF.xScript.getDictFromCache = function( key, path ){
  2805. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2806. var dict = matchedDict.dict;
  2807. var list = matchedDict.unmatchedPathList;
  2808. if( dict ){
  2809. for( var j=0; j<list.length; j++ ){
  2810. dict = dict[ list[j] ];
  2811. if( !dict )return null;
  2812. }
  2813. return dict;
  2814. }
  2815. return null;
  2816. };
  2817. MWF.xScript.deleteDictToCache = function(key, path){
  2818. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2819. var dict = matchedDict.dict;
  2820. var list = matchedDict.unmatchedPathList;
  2821. if( dict){
  2822. for( var j=0; j<list.length-1; j++ ){
  2823. dict = dict[ list[j] ];
  2824. if( !dict )return;
  2825. }
  2826. delete dict[list[list.length-1]];
  2827. }
  2828. };
  2829. MWF.xScript.createDict = function(application){
  2830. //optionsOrName : {
  2831. // type : "", //默认为process, 可以为 process cms
  2832. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  2833. // name : "", // 数据字典名称/别名/id
  2834. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  2835. //}
  2836. //或者name: "" // 数据字典名称/别名/id
  2837. return function(optionsOrName){
  2838. var options = optionsOrName;
  2839. if( typeOf( options ) == "string" ){
  2840. options = { name : options };
  2841. }
  2842. var name = this.name = options.name;
  2843. var type = ( options.type && options.application ) ? options.type : "process";
  2844. var applicationId = options.application || application;
  2845. var enableAnonymous = options.enableAnonymous || false;
  2846. var opt = {
  2847. "appType" : type,
  2848. "name" : name,
  2849. "appId" : applicationId,
  2850. "enableAnonymous" : enableAnonymous
  2851. };
  2852. var key = name+type+applicationId+enableAnonymous;
  2853. // if (!dictLoaded[key]) dictLoaded[key] = {};
  2854. // this.dictData = dictLoaded[key];
  2855. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  2856. if( type == "cms" ){
  2857. var action = MWF.Actions.get("x_cms_assemble_control");
  2858. }else{
  2859. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  2860. }
  2861. var encodePath = function( path ){
  2862. var arr = path.split(/\./g);
  2863. var ar = arr.map(function(v){
  2864. return encodeURIComponent(v);
  2865. });
  2866. return ar.join("/");
  2867. };
  2868. this.get = function(path, success, failure, async, refresh){
  2869. var value = null;
  2870. if (!refresh ){
  2871. var data = MWF.xScript.getDictFromCache( key, path );
  2872. if( data ){
  2873. if (success && o2.typeOf(success)=="function") success( data );
  2874. return data;
  2875. }
  2876. }
  2877. if (success===true) async=true;
  2878. if (failure===true) async=true;
  2879. // var cb = function(json){
  2880. // value = json.data;
  2881. // MWF.xScript.addDictToCache(opt, path, value);
  2882. // if (success && o2.typeOf(success)=="function") value = success(json.data);
  2883. // return value;
  2884. // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  2885. var cb = function(json){
  2886. value = json.data;
  2887. MWF.xScript.addDictToCache(opt, path, value);
  2888. if (success && o2.typeOf(success)=="function") value = success(json.data);
  2889. return value;
  2890. };
  2891. var promise;
  2892. if (path){
  2893. var p = encodePath( path );
  2894. //var p = path.replace(/\./g, "/");
  2895. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
  2896. }else{
  2897. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
  2898. }
  2899. return (!!async) ? promise : value;
  2900. // if (path){
  2901. // var p = encodePath( path );
  2902. // //var p = path.replace(/\./g, "/");
  2903. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  2904. // value = json.data;
  2905. // // this.dictData[path] = value;
  2906. // MWF.xScript.addDictToCache(opt, path, value);
  2907. // if (success) success(json.data);
  2908. // }.bind(this), function(xhr, text, error){
  2909. // if (failure) failure(xhr, text, error);
  2910. // }, !!async);
  2911. // }else{
  2912. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  2913. // value = json.data;
  2914. // // this.dictData["root"] = value;
  2915. // MWF.xScript.addDictToCache(opt, path, value);
  2916. // if (success) success(json.data);
  2917. // }.bind(this), function(xhr, text, error){
  2918. // if (failure) failure(xhr, text, error);
  2919. // }, !!async);
  2920. // }
  2921. //return value;
  2922. };
  2923. this.set = function(path, value, success, failure){
  2924. var p = encodePath( path );
  2925. //var p = path.replace(/\./g, "/");
  2926. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  2927. MWF.xScript.setDictToCache(key, path, value);
  2928. if (success) return success(json.data);
  2929. }, function(xhr, text, error){
  2930. if (failure) return failure(xhr, text, error);
  2931. }, false, false);
  2932. };
  2933. this.add = function(path, value, success, failure){
  2934. var p = encodePath( path );
  2935. //var p = path.replace(/\./g, "/");
  2936. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  2937. MWF.xScript.insertDictToCache(key, path, value);
  2938. if (success) return success(json.data);
  2939. }, function(xhr, text, error){
  2940. if (failure) return failure(xhr, text, error);
  2941. }, false, false);
  2942. };
  2943. this["delete"] = function(path, success, failure){
  2944. var p = encodePath( path );
  2945. //var p = path.replace(/\./g, "/");
  2946. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  2947. MWF.xScript.deleteDictToCache(key, path);
  2948. if (success) return success(json.data);
  2949. }, function(xhr, text, error){
  2950. if (failure) return failure(xhr, text, error);
  2951. }, false, false);
  2952. };
  2953. this.destory = this["delete"];
  2954. }
  2955. };
  2956. }