Environment.js 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315
  1. MWF.xScript = MWF.xScript || {};
  2. MWF.xScript.Environment = function(ev){
  3. var _data = ev.data;
  4. var _form = ev.form;
  5. var _forms = ev.forms;
  6. this.library = COMMON;
  7. //this.library.version = "4.0";
  8. this.power = {
  9. "isManager": MWF.AC.isProcessManager() || _form.businessData.control.allowReroute,
  10. "isReseter": _form.businessData.control.allowReset,
  11. "isDelete": _form.businessData.control.allowDeleteWork,
  12. "isPront": true,
  13. "isPrint": true
  14. };
  15. //data
  16. var getJSONData = function(jData){
  17. return new MWF.xScript.JSONData(jData, function(data, key, _self){
  18. var p = {"getKey": function(){return key;}, "getParent": function(){return _self;}};
  19. while (p && !_forms[p.getKey()]) p = p.getParent();
  20. if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  21. }, "", null, _form);
  22. };
  23. this.setData = function(data){
  24. this.data = getJSONData(data);
  25. this.data.save = function(callback){
  26. _form.saveFormData(callback)
  27. // var formData = {
  28. // "data": data,
  29. // "sectionList": _form.getSectionList()
  30. // };
  31. // _form.workAction.saveSectionData(function(){if (callback) callback();}.bind(this), null, (ev.work.id || ev.workCompleted.id), formData);
  32. }
  33. };
  34. this.setData(_data);
  35. //task
  36. //this.task = ev.task;
  37. //this.task.process = function(routeName, opinion, callback){
  38. // _form.submitWork(routeName, opinion, callback);
  39. //};
  40. //inquiredRouteList
  41. //this.inquiredRouteList = null;
  42. //workContext
  43. this.workContext = {
  44. "getTask": function(){return ev.task || null;},
  45. "getWork": function(){return ev.work || ev.workCompleted;},
  46. "getActivity": function(){return ev.activity || null;},
  47. "getTaskList": function(callback, error){
  48. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  49. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  50. var list;
  51. o2.Actions.get("x_processplatform_assemble_surface").listTaskByWork(ev.work.id, function(json){
  52. list = json.data;
  53. if (cb) cb(list);
  54. }, ecb, !!cb);
  55. return list;
  56. },
  57. "getTaskListByJob": function(callback, error){
  58. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  59. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  60. var list;
  61. o2.Actions.get("x_processplatform_assemble_surface").listTaskByJob(ev.work.job, function(json){
  62. list = json.data;
  63. if (cb) cb(list);
  64. }, ecb, !!cb);
  65. return list;
  66. },
  67. "getReadList": function(callback, error){
  68. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  69. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  70. var list;
  71. o2.Actions.get("x_processplatform_assemble_surface").listReadByWork(ev.work.id, function(json){
  72. list = json.data;
  73. if (cb) cb(list);
  74. }, ecb, !!cb);
  75. return list;
  76. },
  77. "getReadListByJob": function(callback, error){
  78. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  79. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  80. var list;
  81. o2.Actions.get("x_processplatform_assemble_surface").listReadByJob(ev.work.job, function(json){
  82. list = json.data;
  83. if (cb) cb(list);
  84. }, ecb, !!cb);
  85. return list;
  86. },
  87. "getTaskCompletedList": function(callback, error){
  88. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  89. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  90. var list;
  91. o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByWork(ev.work.id, function(json){
  92. list = json.data;
  93. if (cb) cb(list);
  94. }, ecb, !!cb);
  95. return list;
  96. },
  97. "getTaskCompletedListByJob": function(callback, error){
  98. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  99. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  100. var list;
  101. o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByJob(ev.work.job, function(json){
  102. list = json.data;
  103. if (cb) cb(list);
  104. }, ecb, !!cb);
  105. return list;
  106. },
  107. "getReadCompletedList": function(callback, error){
  108. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  109. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  110. var list;
  111. o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByWork(ev.work.id, function(json){
  112. list = json.data;
  113. if (cb) cb(list);
  114. }, ecb, !!cb);
  115. return list;
  116. },
  117. "getReadCompletedListByJob": function(callback, error){
  118. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  119. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  120. var list;
  121. o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByJob(ev.work.job, function(json){
  122. list = json.data;
  123. if (cb) cb(list);
  124. }, ecb, !!cb);
  125. return list;
  126. },
  127. "getJobTaskList": this.getTaskListByJob,
  128. "getJobReadList": this.getReadListByJob,
  129. "getJobTaskCompletedList": this.getTaskCompletedListByJob,
  130. "getJobReadCompletedList": this.getReadCompletedListByJob,
  131. "getControl": function(){return ev.control;},
  132. "getWorkLogList": function(){return ev.workLogList;},
  133. "getRecordList": function(){return ev.recordList;},
  134. "getAttachmentList": function(){return ev.attachmentList;},
  135. "getRouteList": function(){return (ev.task) ? ev.task.routeNameList: null;},
  136. "getInquiredRouteList": function(){return null;},
  137. "setTitle": function(title){
  138. if (!this.workAction){
  139. MWF.require("MWF.xScript.Actions.WorkActions", null, false);
  140. this.workAction = new MWF.xScript.Actions.WorkActions();
  141. }
  142. this.workAction.setTitle(ev.work.id, {"title": title});
  143. }
  144. };
  145. this.workContent = this.workContext;
  146. var _redefineWorkProperties = function(work){
  147. if (work){
  148. work.creatorPersonDn = work.creatorPerson ||"";
  149. work.creatorUnitDn = work.creatorUnit ||"";
  150. work.creatorUnitDnList = work.creatorUnitList ||"";
  151. work.creatorIdentityDn = work.creatorIdentity ||"";
  152. var o = {
  153. "creatorPerson": {"get": function(){return this.creatorPersonDn.substring(0, this.creatorPersonDn.indexOf("@"));}},
  154. "creatorUnit": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  155. "creatorDepartment": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  156. "creatorIdentity": {"get": function(){return this.creatorIdentityDn.substring(0, this.creatorIdentityDn.indexOf("@"));}},
  157. // "creatorUnitList": {
  158. // "get": function(){
  159. // var v = [];
  160. // this.creatorUnitDnList.each(function(dn){
  161. // v.push(dn.substring(0, dn.indexOf("@")))
  162. // });
  163. // return v;
  164. // }
  165. // },
  166. "creatorCompany": {"get": function(){
  167. if (this.creatorUnitLevel){
  168. var level = this.creatorUnitLevel.split("/");
  169. return level[0];
  170. }else{
  171. return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));
  172. }
  173. }}
  174. };
  175. MWF.defineProperties(work, o);
  176. }
  177. return work;
  178. };
  179. var _redefineTaskProperties = function(task){
  180. if (task){
  181. task.personDn = task.person || "";
  182. task.unitDn = task.unit || "";
  183. task.unitDnList = task.unitList || "";
  184. task.identityDn = task.identity || "";
  185. var o = {
  186. "person": {"get": function(){return this.personDn.substring(0, this.personDn.indexOf("@"));}},
  187. "unit": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  188. "department": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  189. "identity": {"get": function(){return this.identityDn.substring(0, this.identityDn.indexOf("@"));}},
  190. // "unitList": {
  191. // "get": function(){
  192. // var v = [];
  193. // this.unitDnList.each(function(dn){
  194. // v.push(dn.substring(0, dn.indexOf("@")))
  195. // });
  196. // return v;
  197. // }
  198. // },
  199. "company": {"get": function(){return this.unitList[0];}}
  200. };
  201. MWF.defineProperties(task, o);
  202. }
  203. return task;
  204. };
  205. _redefineWorkProperties(this.workContext.getWork());
  206. _redefineTaskProperties(_redefineWorkProperties(this.workContext.getTask()));
  207. //dict
  208. this.Dict = MWF.xScript.createDict(_form.json.application);
  209. //unit
  210. var orgActions = null;
  211. var getOrgActions = function(){
  212. // if (!orgActions){
  213. // MWF.xDesktop.requireApp("Org", "Actions.RestActions", null, false);
  214. // orgActions = new MWF.xApplication.Org.Actions.RestActions ();
  215. // }
  216. if (!orgActions){
  217. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  218. orgActions = new MWF.xScript.Actions.UnitActions();
  219. }
  220. };
  221. var getNameFlag = function(name){
  222. var t = typeOf(name);
  223. if (t==="array"){
  224. var v = [];
  225. name.each(function(id){
  226. v.push((typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  227. });
  228. return v;
  229. }else{
  230. return [(t==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  231. }
  232. };
  233. this.org = {
  234. //群组***************
  235. //获取群组--返回群组的对象数组
  236. getGroup: function(name, async){
  237. getOrgActions();
  238. var data = {"groupList": getNameFlag(name)};
  239. var v = null;
  240. var cb = function(json){
  241. v = json.data;
  242. v = (v && v.length===1) ? v[0] : v
  243. if (async && o2.typeOf(async)=="function") return async(v);
  244. return v;
  245. }.ag().catch(function(json){ return json; });
  246. orgActions.listGroup(data, cb, null, !!async);
  247. return (!!async) ? cb : v;
  248. // var v = null;
  249. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  250. // return (v && v.length===1) ? v[0] : v;
  251. },
  252. //查询下级群组--返回群组的对象数组
  253. //nested 布尔 true嵌套下级;false直接下级;默认false;
  254. listSubGroup: function(name, nested, async){
  255. getOrgActions();
  256. var data = {"groupList": getNameFlag(name)};
  257. var v = null;
  258. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  259. // v = json.data;
  260. // return v;
  261. // }.ag().catch(function(json){ return json; });
  262. var cb = function(json){
  263. v = json.data;
  264. if (async && o2.typeOf(async)=="function") return async(v);
  265. return v;
  266. }.ag().catch(function(json){ return json; });
  267. if (nested){
  268. orgActions.listSubGroupNested(data, cb, null, !!async);
  269. }else{
  270. orgActions.listSubGroupDirect(data, cb, null, !!async);
  271. }
  272. return (!!async) ? cb : v;
  273. // var v = null;
  274. // if (nested){
  275. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  276. // }else{
  277. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  278. // }
  279. // return v;
  280. },
  281. //查询上级群组--返回群组的对象数组
  282. //nested 布尔 true嵌套上级;false直接上级;默认false;
  283. listSupGroup:function(name, nested, async){
  284. getOrgActions();
  285. var data = {"groupList": getNameFlag(name)};
  286. var v = null;
  287. var cb = function(json){
  288. v = json.data;
  289. if (async && o2.typeOf(async)=="function") return async(v);
  290. return v;
  291. }.ag().catch(function(json){ return json; });
  292. if (nested){
  293. orgActions.listSupGroupNested(data, cb, null, !!async);
  294. }else{
  295. orgActions.listSupGroupDirect(data, cb, null, !!async);
  296. }
  297. return (!!async) ? cb : v;
  298. // var v = null;
  299. // if (nested){
  300. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  301. // }else{
  302. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  303. // }
  304. // return v;
  305. },
  306. //人员所在群组(嵌套)--返回群组的对象数组
  307. listGroupWithPerson:function(name, async){
  308. getOrgActions();
  309. var data = {"personList": getNameFlag(name)};
  310. var v = null;
  311. var cb = function(json){
  312. v = json.data;
  313. if (async && o2.typeOf(async)=="function") return async(v);
  314. return v;
  315. }.ag().catch(function(json){ return json; });
  316. orgActions.listGroupWithPerson(data, cb, null, !!async);
  317. return (!!async) ? cb : v;
  318. // var v = null;
  319. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  320. // return v;
  321. },
  322. //群组是否拥有角色--返回true, false
  323. groupHasRole: function(name, role, async){
  324. getOrgActions();
  325. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  326. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  327. var v = false;
  328. var cb = function(json){
  329. v = json.data.value;
  330. if (async && o2.typeOf(async)=="function") return async(v);
  331. return v;
  332. }.ag().catch(function(json){ return json; });
  333. orgActions.groupHasRole(data, cb, null, !!async);
  334. return (!!async) ? cb : v;
  335. // var v = false;
  336. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  337. // return v;
  338. },
  339. //角色***************
  340. //获取角色--返回角色的对象数组
  341. getRole: function(name, async){
  342. getOrgActions();
  343. var data = {"roleList": getNameFlag(name)};
  344. var v = null;
  345. var cb = function(json){
  346. v = json.data;
  347. v = (v && v.length===1) ? v[0] : v;
  348. if (async && o2.typeOf(async)=="function") return async(v);
  349. return v;
  350. }.ag().catch(function(json){ return json; });
  351. orgActions.listRole(data, cb, null, !!async);
  352. return (!!async) ? cb : v;
  353. // var v = null;
  354. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  355. // return (v && v.length===1) ? v[0] : v;
  356. },
  357. //人员所有角色(嵌套)--返回角色的对象数组
  358. listRoleWithPerson:function(name, async){
  359. getOrgActions();
  360. var data = {"personList": getNameFlag(name)};
  361. var v = null;
  362. var cb = function(json){
  363. v = json.data;
  364. if (async && o2.typeOf(async)=="function") return async(v);
  365. return v;
  366. }.ag().catch(function(json){ return json; });
  367. orgActions.listRoleWithPerson(data, cb, null, !!async);
  368. return (!!async) ? cb : v;
  369. // var v = null;
  370. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  371. // return v;
  372. },
  373. //人员***************
  374. //人员是否拥有角色--返回true, false
  375. personHasRole: function(name, role, async){
  376. getOrgActions();
  377. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  378. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  379. var v = false;
  380. var cb = function(json){
  381. v = json.data.value;
  382. if (async && o2.typeOf(async)=="function") return async(v);
  383. return v;
  384. }.ag().catch(function(json){ return json; });
  385. orgActions.listRoleWithPerson(data, cb, null, !!async);
  386. return (!!async) ? cb : v;
  387. // var v = false;
  388. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  389. // return v;
  390. },
  391. //获取人员--返回人员的对象数组
  392. getPerson: function(name, async){
  393. getOrgActions();
  394. var data = {"personList": getNameFlag(name)};
  395. var v = null;
  396. var cb = function(json){
  397. v = json.data;
  398. v = (v && v.length===1) ? v[0] : v;
  399. if (async && o2.typeOf(async)=="function") return async(v);
  400. return v;
  401. }.ag().catch(function(json){ return json; });
  402. orgActions.listPerson(data, cb, null, !!async);
  403. return (!!async) ? cb : v;
  404. // var v = null;
  405. // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  406. // return (v && v.length===1) ? v[0] : v;
  407. },
  408. //查询下级人员--返回人员的对象数组
  409. //nested 布尔 true嵌套下级;false直接下级;默认false;
  410. listSubPerson: function(name, nested, async){
  411. getOrgActions();
  412. var data = {"personList": getNameFlag(name)};
  413. var v = null;
  414. var cb = function(json){
  415. v = json.data;
  416. if (async && o2.typeOf(async)=="function") return async(v);
  417. return v;
  418. }.ag().catch(function(json){ return json; });
  419. if (nested){
  420. orgActions.listPersonSubNested(data, cb, null, !!async);
  421. }else{
  422. orgActions.listPersonSubDirect(data, cb, null, !!async);
  423. }
  424. return (!!async) ? cb : v;
  425. },
  426. //查询上级人员--返回人员的对象数组
  427. //nested 布尔 true嵌套上级;false直接上级;默认false;
  428. listSupPerson: function(name, nested, async){
  429. getOrgActions();
  430. var data = {"personList": getNameFlag(name)};
  431. var v = null;
  432. var cb = function(json){
  433. v = json.data;
  434. if (async && o2.typeOf(async)=="function") return async(v);
  435. return v;
  436. }.ag().catch(function(json){ return json; });
  437. if (nested){
  438. orgActions.listPersonSupNested(data, cb, null, !!async);
  439. }else{
  440. orgActions.listPersonSupDirect(data, cb, null, !!async);
  441. }
  442. return (!!async) ? cb : v;
  443. },
  444. //获取群组的所有人员--返回人员的对象数组
  445. listPersonWithGroup: function(name, async){
  446. getOrgActions();
  447. var data = {"groupList": getNameFlag(name)};
  448. var v = null;
  449. var cb = function(json){
  450. v = json.data;
  451. if (async && o2.typeOf(async)=="function") return async(v);
  452. return v;
  453. }.ag().catch(function(json){ return json; });
  454. orgActions.listPersonWithGroup(data, cb, null, !!async);
  455. return (!!async) ? cb : v;
  456. },
  457. //获取角色的所有人员--返回人员的对象数组
  458. listPersonWithRole: function(name, async){
  459. getOrgActions();
  460. var data = {"roleList": getNameFlag(name)};
  461. var v = null;
  462. var cb = function(json){
  463. v = json.data;
  464. if (async && o2.typeOf(async)=="function") return async(v);
  465. return v;
  466. }.ag().catch(function(json){ return json; });
  467. orgActions.listPersonWithRole(data, cb, null, !!async);
  468. return (!!async) ? cb : v;
  469. },
  470. //获取身份的所有人员--返回人员的对象数组
  471. listPersonWithIdentity: function(name, async){
  472. getOrgActions();
  473. var data = {"identityList": getNameFlag(name)};
  474. var v = null;
  475. var cb = function(json){
  476. v = json.data;
  477. if (async && o2.typeOf(async)=="function") return async(v);
  478. return v;
  479. }.ag().catch(function(json){ return json; });
  480. orgActions.listPersonWithIdentity(data, cb, null, !!async);
  481. return (!!async) ? cb : v;
  482. },
  483. //获取身份的所有人员--返回人员的对象数组或人员对象
  484. getPersonWithIdentity: function(name, async){
  485. getOrgActions();
  486. var data = {"identityList": getNameFlag(name)};
  487. var v = null;
  488. var cb = function(json){
  489. v = json.data;
  490. v = (v && v.length===1) ? v[0] : v;
  491. if (async && o2.typeOf(async)=="function") return async(v);
  492. return v;
  493. }.ag().catch(function(json){ return json; });
  494. orgActions.listPersonWithIdentity(data, cb, null, !!async);
  495. return (!!async) ? cb : v;
  496. },
  497. //查询组织成员的人员--返回人员的对象数组
  498. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  499. listPersonWithUnit: function(name, nested, async){
  500. getOrgActions();
  501. var data = {"unitList": getNameFlag(name)};
  502. var v = null;
  503. var cb = function(json){
  504. v = json.data;
  505. if (async && o2.typeOf(async)=="function") return async(v);
  506. return v;
  507. }.ag().catch(function(json){ return json; });
  508. if (nested){
  509. orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  510. }else{
  511. orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  512. }
  513. return (!!async) ? cb : v;
  514. },
  515. //根据属性查询人员--返回人员的对象数组
  516. //name string 属性名
  517. //value string 属性值
  518. listPersonWithAttribute: function(name, value, async){
  519. getOrgActions();
  520. var data = {"name": name, "attribute": value};
  521. var v = null;
  522. var cb = function(json){
  523. v = json.data;
  524. if (async && o2.typeOf(async)=="function") return async(v);
  525. return v;
  526. }.ag().catch(function(json){ return json; });
  527. orgActions.listPersonWithAttribute(data, cb, null, !!async);
  528. return (!!async) ? cb : v;
  529. },
  530. //根据属性查询人员--返回人员的全称数组
  531. //name string 属性名
  532. //value string 属性值
  533. listPersonNameWithAttribute: function(name, value, async){
  534. getOrgActions();
  535. var data = {"name": name, "attribute": value};
  536. var v = null;
  537. var cb = function(json){
  538. v = json.data.personList;
  539. if (async && o2.typeOf(async)=="function") return async(v);
  540. return v;
  541. }.ag().catch(function(json){ return json; });
  542. orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  543. return (!!async) ? cb : v;
  544. },
  545. //人员属性************
  546. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  547. appendPersonAttribute: function(person, attr, values, success, failure, async){
  548. getOrgActions();
  549. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  550. var data = {"attributeList":values,"name":attr,"person":personFlag};
  551. var cb = function(json){
  552. if (success) return success(json);
  553. }.ag().catch(function(xhr, text, error){
  554. if (failure) return failure(xhr, text, error);
  555. });
  556. orgActions.appendPersonAttribute(data, cb, null, !!async);
  557. },
  558. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  559. setPersonAttribute: function(person, attr, values, success, failure, async){
  560. getOrgActions();
  561. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  562. var data = {"attributeList":values,"name":attr,"person":personFlag};
  563. var cb = function(json){
  564. if (success) return success(json);
  565. }.ag().catch(function(xhr, text, error){
  566. if (failure) return failure(xhr, text, error);
  567. });
  568. orgActions.setPersonAttribute(data, cb, null, !!async);
  569. },
  570. //获取人员属性值
  571. getPersonAttribute: function(person, attr, async){
  572. getOrgActions();
  573. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  574. var data = {"name":attr,"person":personFlag};
  575. var v = null;
  576. var cb = function(json){
  577. v = json.data.attributeList;
  578. if (async && o2.typeOf(async)=="function") return async(v);
  579. return v;
  580. }.ag().catch(function(json){ return json; });
  581. orgActions.getPersonAttribute(data, cb, null, !!async);
  582. return (!!async) ? cb : v;
  583. },
  584. //列出人员所有属性的名称
  585. listPersonAttributeName: function(name, async){
  586. getOrgActions();
  587. var data = {"personList":getNameFlag(name)};
  588. var v = null;
  589. var cb = function(json){
  590. v = json.data.nameList;
  591. if (async && o2.typeOf(async)=="function") return async(v);
  592. return v;
  593. }.ag().catch(function(json){ return json; });
  594. orgActions.listPersonAttributeName(data, cb, null, !!async);
  595. return (!!async) ? cb : v;
  596. },
  597. //列出人员的所有属性
  598. listPersonAllAttribute: function(name, async){
  599. getOrgActions();
  600. var data = {"personList":getNameFlag(name)};
  601. var v = null;
  602. var cb = function(json){
  603. v = json.data;
  604. if (async && o2.typeOf(async)=="function") return async(v);
  605. return v;
  606. }.ag().catch(function(json){ return json; });
  607. orgActions.listPersonAllAttribute(data, cb, null, !!async);
  608. return (!!async) ? cb : v;
  609. },
  610. //身份**********
  611. //获取身份
  612. getIdentity: function(name, async){
  613. getOrgActions();
  614. var data = {"identityList":getNameFlag(name)};
  615. var v = null;
  616. var cb = function(json){
  617. v = json.data;
  618. v = (v && v.length===1) ? v[0] : v;
  619. if (async && o2.typeOf(async)=="function") return async(v);
  620. return v;
  621. }.ag().catch(function(json){ return json; });
  622. orgActions.listIdentity(data, cb, null, !!async);
  623. return (!!async) ? cb : v;
  624. },
  625. //列出人员的身份
  626. listIdentityWithPerson: function(name, async){
  627. getOrgActions();
  628. var data = {"personList":getNameFlag(name)};
  629. var v = null;
  630. var cb = function(json){
  631. v = json.data;
  632. if (async && o2.typeOf(async)=="function") return async(v);
  633. return v;
  634. }.ag().catch(function(json){ return json; });
  635. orgActions.listIdentityWithPerson(data, cb, null, !!async);
  636. return (!!async) ? cb : v;
  637. },
  638. //查询组织成员身份--返回身份的对象数组
  639. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  640. listIdentityWithUnit: function(name, nested, async){
  641. getOrgActions();
  642. var data = {"unitList": getNameFlag(name)};
  643. var v = null;
  644. var cb = function(json){
  645. v = json.data;
  646. if (async && o2.typeOf(async)=="function") return async(v);
  647. return v;
  648. }.ag().catch(function(json){ return json; });
  649. if (nested){
  650. orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  651. }else{
  652. orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  653. }
  654. return (!!async) ? cb : v;
  655. },
  656. //组织**********
  657. //获取组织
  658. getUnit: function(name, async){
  659. getOrgActions();
  660. var data = {"unitList":getNameFlag(name)};
  661. var v = null;
  662. var cb = function(json){
  663. v = json.data;
  664. v = (v && v.length===1) ? v[0] : v;
  665. if (async && o2.typeOf(async)=="function") return async(v);
  666. return v;
  667. }.ag().catch(function(json){ return json; });
  668. orgActions.listUnit(data, cb, null, !!async);
  669. return (!!async) ? cb : v;
  670. },
  671. //查询组织的下级--返回组织的对象数组
  672. //nested 布尔 true嵌套下级;false直接下级;默认false;
  673. listSubUnit: function(name, nested){
  674. getOrgActions();
  675. var data = {"unitList": getNameFlag(name)};
  676. var v = null;
  677. var cb = function(json){
  678. v = json.data;
  679. if (async && o2.typeOf(async)=="function") return async(v);
  680. return v;
  681. }.ag().catch(function(json){ return json; });
  682. if (nested){
  683. orgActions.listUnitSubNested(data, cb, null, !!async);
  684. }else{
  685. orgActions.listUnitSubDirect(data, cb, null, !!async);
  686. }
  687. return (!!async) ? cb : v;
  688. },
  689. //查询组织的上级--返回组织的对象数组
  690. //nested 布尔 true嵌套上级;false直接上级;默认false;
  691. //async 布尔 true异步请求
  692. listSupUnit: function(name, nested, async){
  693. getOrgActions();
  694. var data = {"unitList": getNameFlag(name)};
  695. var v = null;
  696. var cb = function(json){
  697. v = json.data;
  698. if (async && o2.typeOf(async)=="function") return async(v);
  699. return v;
  700. }.ag().catch(function(json){ return json; });
  701. if (nested){
  702. orgActions.listUnitSupNested(data, cb, null, !!async);
  703. }else{
  704. orgActions.listUnitSupDirect(data, cb, null, !!async);
  705. }
  706. return (!!async) ? cb : v;
  707. // if (callback){
  708. // if (nested){
  709. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  710. // }else{
  711. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  712. // }
  713. // }else{
  714. // var v = null;
  715. // if (nested){
  716. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  717. // }else{
  718. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  719. // }
  720. // return v;
  721. // }
  722. },
  723. //根据个人身份获取组织
  724. //flag 数字 表示获取第几层的组织
  725. // 字符串 表示获取指定类型的组织
  726. // 空 表示获取直接所在的组织
  727. getUnitByIdentity: function(name, flag, async){
  728. getOrgActions();
  729. var getUnitMethod = "current";
  730. var v;
  731. if (flag){
  732. if (typeOf(flag)==="string") getUnitMethod = "type";
  733. if (typeOf(flag)==="number") getUnitMethod = "level";
  734. }
  735. var cb;
  736. switch (getUnitMethod){
  737. case "current":
  738. var data = {"identityList":getNameFlag(name)};
  739. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  740. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  741. // }.ag().catch(function(json){ return json; });
  742. var cb = function(json){
  743. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  744. if (async && o2.typeOf(async)=="function") return async(v);
  745. return v;
  746. }.ag().catch(function(json){ return json; });
  747. orgActions.listUnitWithIdentity(data, cb, null, !!async);
  748. break;
  749. case "type":
  750. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  751. var cb = function(json){
  752. v = json.data;
  753. if (async && o2.typeOf(async)=="function") return async(v);
  754. return v;
  755. }.ag().catch(function(json){ return json; });
  756. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  757. // v = json.data; return v;
  758. // }.ag().catch(function(json){ return json; });
  759. orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  760. break;
  761. case "level":
  762. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  763. var cb = function(json){
  764. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  765. if (async && o2.typeOf(async)=="function") return async(v);
  766. return v;
  767. }.ag().catch(function(json){ return json; });
  768. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  769. // v = json.data; return v;
  770. // }.ag().catch(function(json){ return json; });
  771. orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  772. break;
  773. }
  774. return (!!async) ? cb : v;
  775. },
  776. //列出身份所在组织的所有上级组织
  777. listAllSupUnitWithIdentity: function(name, async){
  778. getOrgActions();
  779. var data = {"identityList":getNameFlag(name)};
  780. var v = null;
  781. var cb = function(json){
  782. v = json.data;
  783. if (async && o2.typeOf(async)=="function") return async(v);
  784. return v;
  785. }.ag().catch(function(json){ return json; });
  786. orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  787. return (!!async) ? cb : v;
  788. },
  789. //获取人员所在的所有组织
  790. listUnitWithPerson: function(name, async){
  791. getOrgActions();
  792. var data = {"personList":getNameFlag(name)};
  793. var v = null;
  794. var cb = function(json){
  795. v = json.data;
  796. if (async && o2.typeOf(async)=="function") return async(v);
  797. return v;
  798. }.ag().catch(function(json){ return json; });
  799. orgActions.listUnitWithPerson(data, cb, null, !!async);
  800. return (!!async) ? cb : v;
  801. },
  802. //列出人员所在组织的所有上级组织
  803. listAllSupUnitWithPerson: function(name, async){
  804. getOrgActions();
  805. var data = {"personList":getNameFlag(name)};
  806. var v = null;
  807. var cb = function(json){
  808. v = json.data;
  809. if (async && o2.typeOf(async)=="function") return async(v);
  810. return v;
  811. }.ag().catch(function(json){ return json; });
  812. orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  813. return (!!async) ? cb : v;
  814. },
  815. //根据组织属性,获取所有符合的组织
  816. listUnitWithAttribute: function(name, attribute, async){
  817. getOrgActions();
  818. var data = {"name":name,"attribute":attribute};
  819. var v = null;
  820. var cb = function(json){
  821. v = json.data;
  822. if (async && o2.typeOf(async)=="function") return async(v);
  823. return v;
  824. }.ag().catch(function(json){ return json; });
  825. orgActions.listUnitWithAttribute(data, cb, null, !!async);
  826. return (!!async) ? cb : v;
  827. },
  828. //根据组织职务,获取所有符合的组织
  829. listUnitWithDuty: function(name, id, async){
  830. getOrgActions();
  831. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  832. var v = null;
  833. var cb = function(json){
  834. v = json.data;
  835. if (async && o2.typeOf(async)=="function") return async(v);
  836. return v;
  837. }.ag().catch(function(json){ return json; });
  838. orgActions.listUnitWithDuty(data, cb, null, !!async);
  839. return (!!async) ? cb : v;
  840. },
  841. //组织职务***********
  842. //获取指定的组织职务的身份
  843. getDuty: function(duty, id, async){
  844. getOrgActions();
  845. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  846. var v = null;
  847. var cb = function(json){
  848. v = json.data;
  849. if (async && o2.typeOf(async)=="function") return async(v);
  850. return v;
  851. }.ag().catch(function(json){ return json; });
  852. orgActions.getDuty(data, cb, null, !!async);
  853. return (!!async) ? cb : v;
  854. },
  855. //获取身份的所有职务名称
  856. listDutyNameWithIdentity: function(name, async){
  857. getOrgActions();
  858. var data = {"identityList":getNameFlag(name)};
  859. var v = null;
  860. var cb = function(json){
  861. v = json.data;
  862. if (async && o2.typeOf(async)=="function") return async(v);
  863. return v;
  864. }.ag().catch(function(json){ return json; });
  865. orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  866. return (!!async) ? cb : v;
  867. },
  868. //获取组织的所有职务名称
  869. listDutyNameWithUnit: function(name, async){
  870. getOrgActions();
  871. var data = {"unitList":getNameFlag(name)};
  872. var v = null;
  873. var cb = function(json){
  874. v = json.data.nameList;
  875. if (async && o2.typeOf(async)=="function") return async(v);
  876. return v;
  877. }.ag().catch(function(json){ return json; });
  878. orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  879. return (!!async) ? cb : v;
  880. },
  881. //获取组织的所有职务
  882. listUnitAllDuty: function(name, async){
  883. getOrgActions();
  884. var data = {"unitList":getNameFlag(name)};
  885. var v = null;
  886. var cb = function(json){
  887. v = json.data;
  888. if (async && o2.typeOf(async)=="function") return async(v);
  889. return v;
  890. }.ag().catch(function(json){ return json; });
  891. orgActions.listUnitAllDuty(data, cb, null, !!async);
  892. return (!!async) ? cb : v;
  893. },
  894. //列出顶层组织
  895. listTopUnit: function(async){
  896. var action = MWF.Actions.get("x_organization_assemble_control");
  897. var v = null;
  898. var cb = function(json){
  899. v = json.data;
  900. if (async && o2.typeOf(async)=="function") return async(v);
  901. return v;
  902. }.ag().catch(function(json){ return json; });
  903. action.listTopUnit(cb, null, !!async);
  904. return (!!async) ? cb : v;
  905. },
  906. //组织属性**************
  907. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  908. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  909. getOrgActions();
  910. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  911. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  912. var cb = function(json){
  913. if (success) return success(json);
  914. }.ag().catch(function(xhr, text, error){
  915. if (failure) return failure(xhr, text, error);
  916. });
  917. orgActions.appendPersonAttribute(data, cb, null, !!async);
  918. // orgActions.appendUnitAttribute(data, function(json){
  919. // if (json.data.value){
  920. // if (success) success();
  921. // }else{
  922. // if (failure) failure(null, "", "append values failed");
  923. // }
  924. // }, function(xhr, text, error){
  925. // if (failure) failure(xhr, text, error);
  926. // }, false);
  927. },
  928. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  929. setUnitAttribute: function(unit, attr, values, success, failure, async){
  930. getOrgActions();
  931. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  932. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  933. var cb = function(json){
  934. if (success) return success(json);
  935. }.ag().catch(function(xhr, text, error){
  936. if (failure) return failure(xhr, text, error);
  937. });
  938. orgActions.setUnitAttribute(data, cb, null, !!async);
  939. // orgActions.setUnitAttribute(data, function(json){
  940. // if (json.data.value){
  941. // if (success) success();
  942. // }else{
  943. // if (failure) failure(null, "", "append values failed");
  944. // }
  945. // }, function(xhr, text, error){
  946. // if (failure) failure(xhr, text, error);
  947. // }, false);
  948. },
  949. //获取组织属性值
  950. getUnitAttribute: function(unit, attr, async){
  951. getOrgActions();
  952. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  953. var data = {"name":attr,"unit":unitFlag};
  954. var v = null;
  955. var cb = function(json){
  956. v = json.data.attributeList;
  957. if (async && o2.typeOf(async)=="function") return async(v);
  958. return v;
  959. }.ag().catch(function(json){ return json; });
  960. orgActions.getUnitAttribute(data, cb, null, !!async);
  961. return (!!async) ? cb : v;
  962. },
  963. //列出组织所有属性的名称
  964. listUnitAttributeName: function(name, async){
  965. getOrgActions();
  966. var data = {"unitList":getNameFlag(name)};
  967. var v = null;
  968. var cb = function(json){
  969. v = json.data.nameList;
  970. if (async && o2.typeOf(async)=="function") return async(v);
  971. return v;
  972. }.ag().catch(function(json){ return json; });
  973. orgActions.listUnitAttributeName(data, cb, null, !!async);
  974. return (!!async) ? cb : v;
  975. },
  976. //列出组织的所有属性
  977. listUnitAllAttribute: function(name, async){
  978. getOrgActions();
  979. var data = {"unitList":getNameFlag(name)};
  980. var v = null;
  981. var cb = function(json){
  982. v = json.data;
  983. if (async && o2.typeOf(async)=="function") return async(v);
  984. return v;
  985. }.ag().catch(function(json){ return json; });
  986. orgActions.listUnitAllAttribute(data, cb, null, !!async);
  987. return (!!async) ? cb : v;
  988. }
  989. };
  990. this.Action = (function(){
  991. var actions = [];
  992. return function(root, json){
  993. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  994. action.getActions = function(callback){
  995. if (!this.actions) this.actions = {};
  996. Object.merge(this.actions, json);
  997. if (callback) callback();
  998. };
  999. this.invoke = function(option){
  1000. action.invoke(option)
  1001. }
  1002. }
  1003. })();
  1004. this.service = {
  1005. "jaxwsClient":{},
  1006. "jaxrsClient":{}
  1007. };
  1008. var lookupAction = null;
  1009. var getLookupAction = function(callback){
  1010. if (!lookupAction){
  1011. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  1012. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  1013. lookupAction.getActions = function(actionCallback){
  1014. this.actions = {
  1015. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  1016. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  1017. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  1018. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  1019. };
  1020. if (actionCallback) actionCallback();
  1021. };
  1022. if (callback) callback();
  1023. });
  1024. }else{
  1025. if (callback) callback();
  1026. }
  1027. };
  1028. this.view = {
  1029. "lookup": function(view, callback, async){
  1030. var filterList = {"filterList": (view.filter || null)};
  1031. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function(json){
  1032. var data = {
  1033. "grid": json.data.grid || json.data.groupGrid,
  1034. "groupGrid": json.data.groupGrid
  1035. };
  1036. if (callback) callback(data);
  1037. }, null, async);
  1038. },
  1039. "lookupV1": function(view, callback){
  1040. getLookupAction(function(){
  1041. lookupAction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
  1042. var data = {
  1043. "grid": json.data.grid,
  1044. "groupGrid": json.data.groupGrid
  1045. };
  1046. if (callback) callback(data);
  1047. }.bind(this)});
  1048. }.bind(this));
  1049. },
  1050. "select": function(view, callback, options){
  1051. if (view.view){
  1052. var viewJson = {
  1053. "application": view.application || _form.json.application,
  1054. "viewName": view.view || "",
  1055. "isTitle": (view.isTitle===false) ? "no" : "yes",
  1056. "select": (view.isMulti===false) ? "single" : "multi",
  1057. "filter": view.filter
  1058. };
  1059. if (!options) options = {};
  1060. options.width = view.width;
  1061. options.height = view.height;
  1062. options.title = view.caption;
  1063. var width = options.width || "700";
  1064. var height = options.height || "400";
  1065. if (layout.mobile){
  1066. var size = document.body.getSize();
  1067. width = size.x;
  1068. height = size.y;
  1069. options.style = "viewmobile";
  1070. }
  1071. width = width.toInt();
  1072. height = height.toInt();
  1073. var size = _form.app.content.getSize();
  1074. var x = (size.x-width)/2;
  1075. var y = (size.y-height)/2;
  1076. if (x<0) x = 0;
  1077. if (y<0) y = 0;
  1078. if (layout.mobile){
  1079. x = 20;
  1080. y = 0;
  1081. }
  1082. var _self = this;
  1083. MWF.require("MWF.xDesktop.Dialog", function(){
  1084. var dlg = new MWF.xDesktop.Dialog({
  1085. "title": options.title || "select view",
  1086. "style": options.style || "view",
  1087. "top": y,
  1088. "left": x-20,
  1089. "fromTop":y,
  1090. "fromLeft": x-20,
  1091. "width": width,
  1092. "height": height,
  1093. "html": "<div style='height: 100%;'></div>",
  1094. "maskNode": _form.app.content,
  1095. "container": _form.app.content,
  1096. "buttonList": [
  1097. {
  1098. "text": MWF.LP.process.button.ok,
  1099. "action": function(){
  1100. //if (callback) callback(_self.view.selectedItems);
  1101. if (callback) callback(_self.view.getData());
  1102. this.close();
  1103. }
  1104. },
  1105. {
  1106. "text": MWF.LP.process.button.cancel,
  1107. "action": function(){this.close();}
  1108. }
  1109. ]
  1110. });
  1111. dlg.show();
  1112. if (layout.mobile){
  1113. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1114. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1115. if (backAction) backAction.addEvent("click", function(e){
  1116. dlg.close();
  1117. }.bind(this));
  1118. if (okAction) okAction.addEvent("click", function(e){
  1119. //if (callback) callback(this.view.selectedItems);
  1120. if (callback) callback(this.view.getData());
  1121. dlg.close();
  1122. }.bind(this));
  1123. }
  1124. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  1125. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, {"style": "select"}, _form.app, _form.Macro);
  1126. }.bind(this));
  1127. }.bind(this));
  1128. }
  1129. }
  1130. };
  1131. //include 引用脚本
  1132. //optionsOrName : {
  1133. // type : "", 默认为process, 可以为 portal process cms
  1134. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  1135. // name : "" // 脚本名称/别名/id
  1136. //}
  1137. //或者name: "" // 脚本名称/别名/id
  1138. // if( !window.includedScripts ){
  1139. // var includedScripts = window.includedScripts = [];
  1140. // }else{
  1141. // var includedScripts = window.includedScripts;
  1142. // }
  1143. var includedScripts = [];
  1144. var _includeSingle = function( optionsOrName , callback, async){
  1145. var options = optionsOrName;
  1146. if( typeOf( options ) == "string" ){
  1147. options = { name : options };
  1148. }
  1149. var name = options.name;
  1150. var type = ( options.type && options.application ) ? options.type : "process";
  1151. var application = options.application || _form.json.application;
  1152. var key = type +"-" + application + "-" + name;
  1153. if (includedScripts.indexOf( key )> -1){
  1154. if (callback) callback.apply(this);
  1155. return;
  1156. }
  1157. //if (includedScripts.indexOf( name )> -1){
  1158. // if (callback) callback.apply(this);
  1159. // return;
  1160. //}
  1161. var scriptAction;
  1162. switch ( type ){
  1163. case "portal" :
  1164. if( this.scriptActionPortal ){
  1165. scriptAction = this.scriptActionPortal;
  1166. }else{
  1167. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  1168. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  1169. }
  1170. break;
  1171. case "process" :
  1172. if( this.scriptActionProcess ){
  1173. scriptAction = this.scriptActionProcess;
  1174. }else{
  1175. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  1176. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  1177. }
  1178. break;
  1179. case "cms" :
  1180. if( this.scriptActionCMS ){
  1181. scriptAction = this.scriptActionCMS;
  1182. }else{
  1183. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  1184. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  1185. }
  1186. break;
  1187. }
  1188. debugger;
  1189. scriptAction.getScriptByName( application, name, includedScripts, function(json){
  1190. if (json.data){
  1191. includedScripts.push( key );
  1192. //名称、别名、id
  1193. json.data.importedList.each( function ( flag ) {
  1194. if( type === "portal" ){
  1195. includedScripts.push( type + "-" + json.data.portal + "-" + flag );
  1196. if( json.data.portalName )includedScripts.push( type + "-" + json.data.portalName + "-" + flag );
  1197. if( json.data.portalAlias )includedScripts.push( type + "-" + json.data.portalAlias + "-" + flag );
  1198. }else if( type === "cms" ){
  1199. includedScripts.push( type + "-" + json.data.appId + "-" + flag );
  1200. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  1201. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  1202. }else if( type === "process" ){
  1203. includedScripts.push( type + "-" + json.data.application + "-" + flag );
  1204. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  1205. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  1206. }
  1207. });
  1208. includedScripts = includedScripts.concat(json.data.importedList);
  1209. MWF.Macro.exec(json.data.text, this);
  1210. if (callback) callback.apply(this);
  1211. }else{
  1212. if (callback) callback.apply(this);
  1213. }
  1214. }.bind(this), null, !!async);
  1215. }
  1216. this.include = function( optionsOrName , callback, async){
  1217. if (o2.typeOf(optionsOrName)=="array"){
  1218. if (!!async){
  1219. var count = optionsOrName.length;
  1220. var loaded = 0;
  1221. optionsOrName.each(function(option){
  1222. _includeSingle.apply(this, [option, function(){
  1223. loaded++;
  1224. if (loaded>=count) if (callback) callback.apply(this);;
  1225. }.bind(this), true]);
  1226. }.bind(this));
  1227. }else{
  1228. optionsOrName.each(function(option){
  1229. _includeSingle.apply(this, [option]);
  1230. if (callback) callback.apply(this);
  1231. }.bind(this));
  1232. }
  1233. }else{
  1234. _includeSingle.apply(this, [optionsOrName , callback, async])
  1235. }
  1236. };
  1237. this.define = function(name, fun, overwrite){
  1238. var over = true;
  1239. if (overwrite===false) over = false;
  1240. var o = {};
  1241. o[name] = {"value": fun, "configurable": over};
  1242. MWF.defineProperties(this, o);
  1243. }.bind(this);
  1244. //如果前端事件有异步调用,想要在异步调用结束后继续运行页面加载,
  1245. //可在调用前执行 var resolve = this.wait();
  1246. //在异步调用结束后 执行 resolve.cb();
  1247. //目前只有表单的queryload事件支持此方法。
  1248. this.wait = function(){
  1249. resolve = {};
  1250. var setResolve = function(callback){
  1251. resolve.cb = callback;
  1252. }.bind(this);
  1253. this.target.event_resolve = setResolve;
  1254. return resolve;
  1255. }
  1256. //和this.wait配合使用,
  1257. //如果没有异步,则resolve.cb方法不存在,
  1258. //所以在回调中中使用this.goon();使表单继续加载
  1259. this.goon = function(){
  1260. this.target.event_resolve = null;
  1261. }
  1262. //仅前台对象-----------------------------------------
  1263. //form
  1264. this.page = this.form = {
  1265. "getInfor": function(){return ev.formInfor;},
  1266. "infor": ev.formInfor,
  1267. "getApp": function(){return _form.app;},
  1268. "app": _form.app,
  1269. "node": function(){return _form.node;},
  1270. "readonly": _form.options.readonly,
  1271. "get": function(name){return (_form.all) ? _form.all[name] : null;},
  1272. "getField": function(name){return _forms[name];},
  1273. "getAction": function(){return _form.workAction},
  1274. "getDesktop": function(){return _form.app.desktop},
  1275. "getData": function(){return new MWF.xScript.JSONData(_form.getData());},
  1276. "save": function(callback, silent){_form.saveWork(callback, silent); },
  1277. "close": function(){_form.closeWork();},
  1278. "verify": function(){
  1279. return !(!_form.formCustomValidation("", "") || !_form.formValidation("", ""));
  1280. },
  1281. "process": function(option){
  1282. var op = _form.getOpinion();
  1283. var mds = op.medias;
  1284. if (option){
  1285. _form.submitWork(option.routeName, option.opinion, mds, option.callback,
  1286. option.processor, null, option.appendTaskIdentityList, option.processorOrgList, option.callbackBeforeSave );
  1287. }else{
  1288. _form.processWork();
  1289. }
  1290. },
  1291. "reset": function(option){
  1292. if (!option){
  1293. if (_form.businessData.control["allowReset"]) _form.resetWork();
  1294. }else{
  1295. _form.resetWorkToPeson(option.names, option.opinion, option.keep, option.success, option.failure);
  1296. }
  1297. },
  1298. "retract": function(option){
  1299. if (!option){
  1300. if (_form.businessData.control["allowAddSplit"]) _form.addSplit();
  1301. }else{
  1302. _form.doRetractWork(option.success, option.failure);
  1303. }
  1304. },
  1305. "addSplit": function(option){
  1306. if (!option){
  1307. if (_form.businessData.control["allowRetract"]) _form.retractWork();
  1308. }else{
  1309. _form.addSplitWork(option.value, option.success, option.failure);
  1310. }
  1311. },
  1312. "rollback": function(option){
  1313. if (!option){
  1314. if (_form.businessData.control["allowRollback"]) _form.rollback();
  1315. }else{
  1316. _form.doRollbackActionInvoke(option.log, option.flow, option.success, option.failure);
  1317. }
  1318. },
  1319. "print": function(application, form){
  1320. if (arguments.length){
  1321. var app = (arguments.length>1) ? arguments[0] : null;
  1322. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  1323. _form.printWork(app, formName);
  1324. }else{
  1325. _form.printWork();
  1326. }
  1327. },
  1328. "deleteWork": function(option){
  1329. if (!option){
  1330. if (_form.businessData.control["allowDelete"]) _form.deleteWork();
  1331. }else{
  1332. _form.doDeleteWork(option.success, option.failure);
  1333. }
  1334. },
  1335. "confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
  1336. if ((arguments.length<=1) || o2.typeOf(arguments[1])==="string"){
  1337. var p = MWF.getCenter({"x": width, "y": height});
  1338. e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  1339. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  1340. }else{
  1341. e = (arguments.length>1) ? arguments[1] : null;
  1342. title = (arguments.length>2) ? arguments[2] : null;
  1343. text = (arguments.length>3) ? arguments[3] : null;
  1344. width = (arguments.length>4) ? arguments[4] : null;
  1345. height = (arguments.length>5) ? arguments[5] : null;
  1346. ok = (arguments.length>6) ? arguments[6] : null;
  1347. cancel = (arguments.length>7) ? arguments[7] : null;
  1348. callback = (arguments.length>8) ? arguments[8] : null;
  1349. mask = (arguments.length>9) ? arguments[9] : null;
  1350. style = (arguments.length>10) ? arguments[10] : null;
  1351. // var p = MWF.getCenter({"x": width, "y": height});
  1352. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  1353. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  1354. }
  1355. },
  1356. "alert": function(type, title, text, width, height){
  1357. _form.alert(type, title, text, width, height);
  1358. },
  1359. "notice": function(content, type, target, where, offset, option){
  1360. _form.notice(content, type, target, where, offset, option);
  1361. },
  1362. "addEvent": function(e, f){_form.addEvent(e, f);},
  1363. "openWindow": function(application, form){
  1364. if (arguments.length){
  1365. var app = (arguments.length>1) ? arguments[0] : null;
  1366. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  1367. _form.openWindow(formName, app);
  1368. }else{
  1369. _form.openWindow();
  1370. }
  1371. },
  1372. "openWork": function(id, completedId, title, options){
  1373. var op = options || {};
  1374. op.workId = id;
  1375. op.workCompletedId = completedId;
  1376. op.docTitle = title;
  1377. op.appId = "process.Work"+(op.workId || op.workCompletedId);
  1378. return layout.desktop.openApplication(this.event, "process.Work", op);
  1379. },
  1380. "openJob": function(id, choice, options){
  1381. var workData = null;
  1382. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  1383. if (json.data) workData = json.data;
  1384. }.bind(this), null, false);
  1385. if (workData){
  1386. var len = workData.workList.length + workData.workCompletedList.length;
  1387. if (len){
  1388. if (len>1 && choice){
  1389. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  1390. workData.workList.each(function(work){
  1391. var workNode = new Element("div", {
  1392. "styles": {
  1393. "background": "#ffffff",
  1394. "border-radius": "10px",
  1395. "clear": "both",
  1396. "margin-bottom": "10px",
  1397. "height": "40px",
  1398. "padding": "10px 10px"
  1399. }
  1400. }).inject(node);
  1401. 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>" +
  1402. "<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>"+
  1403. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  1404. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  1405. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  1406. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  1407. workNode.set("html", html);
  1408. var action = workNode.getElement(".MWFAction");
  1409. action.store("work", work);
  1410. action.addEvent("click", function(e){
  1411. var work = e.target.retrieve("work");
  1412. if (work) this.openWork(work.id, null, work.title, options);
  1413. dlg.close();
  1414. }.bind(this));
  1415. }.bind(this));
  1416. workData.workCompletedList.each(function(work){
  1417. var workNode = new Element("div", {
  1418. "styles": {
  1419. "background": "#ffffff",
  1420. "border-radius": "10px",
  1421. "clear": "both",
  1422. "margin-bottom": "10px",
  1423. "height": "40px",
  1424. "padding": "10px 10px"
  1425. }
  1426. }).inject(node);
  1427. 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>" +
  1428. "<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>"+
  1429. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  1430. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  1431. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  1432. workNode.set("html", html);
  1433. var action = workNode.getElement(".MWFAction");
  1434. action.store("work", work);
  1435. action.addEvent("click", function(e){
  1436. var work = e.target.retrieve("work");
  1437. if (work) this.openWork(null, work.id, work.title, options);
  1438. dlg.close();
  1439. }.bind(this));
  1440. }.bind(this));
  1441. var height = node.getSize().y+20;
  1442. if (height>600) height = 600;
  1443. var dlg = o2.DL.open({
  1444. "title": o2.LP.widget.choiceWork,
  1445. "style" : "user",
  1446. "isResize": false,
  1447. "content": node,
  1448. "buttonList": [
  1449. {
  1450. "type" : "cancel",
  1451. "text": o2.LP.widget.close,
  1452. "action": function(){dlg.close();}
  1453. }
  1454. ]
  1455. });
  1456. }else{
  1457. if (workData.workList.length){
  1458. var work = workData.workList[0];
  1459. return this.openWork(work.id, null, work.title, options);
  1460. }else{
  1461. var work = workData.workCompletedList[0];
  1462. return this.openWork(null, work.id, work.title, options);
  1463. }
  1464. }
  1465. }
  1466. }
  1467. // var op = options || {};
  1468. // op.workId = id;
  1469. // op.workCompletedId = completedId;
  1470. // op.docTitle = title;
  1471. // op.appId = "process.Work"+(op.workId || op.workCompletedId);
  1472. // layout.desktop.openApplication(this.event, "process.Work", op);
  1473. },
  1474. "openDocument": function(id, title, options){
  1475. var op = options || {};
  1476. op.documentId = id;
  1477. op.docTitle = title;
  1478. layout.desktop.openApplication(this.event, "cms.Document", op);
  1479. },
  1480. "openPortal": function(name, page, par){
  1481. var action = MWF.Actions.get("x_portal_assemble_surface");
  1482. action.getApplication(name, function(json){
  1483. if (json.data){
  1484. if (page){
  1485. action.getPageByName(page, json.data.id, function(pageJson){
  1486. layout.desktop.openApplication(null, "portal.Portal", {
  1487. "portalId": json.data.id,
  1488. "pageId": (pageJson.data) ? pageJson.data.id : "",
  1489. "parameters": par,
  1490. "appId": "portal.Portal"+json.data.id
  1491. })
  1492. });
  1493. }else{
  1494. layout.desktop.openApplication(null, "portal.Portal", {
  1495. "portalId": json.data.id,
  1496. "parameters": par,
  1497. "appId": "portal.Portal"+json.data.id
  1498. })
  1499. }
  1500. }
  1501. });
  1502. },
  1503. "openCMS": function(name){
  1504. var action = MWF.Actions.get("x_cms_assemble_control");
  1505. action.getColumn(name, function(json){
  1506. if (json.data){
  1507. layout.desktop.openApplication(null, "cms.Module", {
  1508. "columnId": json.data.id,
  1509. "appId": "cms.Module"+json.data.id
  1510. });
  1511. }
  1512. });
  1513. },
  1514. "openProcess": function(name){
  1515. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1516. action.getApplication(name, function(json){
  1517. if (json.data){
  1518. layout.desktop.openApplication(null, "process.Application", {
  1519. "id": json.data.id,
  1520. "appId": "process.Application"+json.data.id
  1521. });
  1522. }
  1523. });
  1524. },
  1525. "openApplication":function(name, options){
  1526. layout.desktop.openApplication(null, name, options);
  1527. },
  1528. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
  1529. var column = columnOrOptions;
  1530. var onAfterPublish, onPostPublish;
  1531. if (typeOf(columnOrOptions) == "object") {
  1532. column = columnOrOptions.column;
  1533. category = columnOrOptions.category;
  1534. data = columnOrOptions.data;
  1535. identity = columnOrOptions.identity;
  1536. callback = columnOrOptions.callback;
  1537. target = columnOrOptions.target;
  1538. latest = columnOrOptions.latest;
  1539. selectColumnEnable = columnOrOptions.selectColumnEnable;
  1540. ignoreTitle = columnOrOptions.ignoreTitle;
  1541. onAfterPublish = columnOrOptions.onAfterPublish;
  1542. onPostPublish = columnOrOptions.onPostPublish;
  1543. }
  1544. if (target) {
  1545. if (layout.app && layout.app.inBrowser) {
  1546. layout.app.content.empty();
  1547. layout.app = null;
  1548. }
  1549. }
  1550. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  1551. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  1552. "documentData": data,
  1553. "identity": identity,
  1554. "ignoreTitle": ignoreTitle === true,
  1555. "ignoreDrafted": latest === false,
  1556. "selectColumnEnable": !category || selectColumnEnable === true,
  1557. "restrictToColumn": !!category && selectColumnEnable !== true,
  1558. "categoryFlag": category, //category id or name
  1559. "columnFlag": column, //column id or name,
  1560. "onStarted": function (documentId, data) {
  1561. if (callback) callback();
  1562. },
  1563. "onPostPublish": function () {
  1564. if(onPostPublish)onPostPublish();
  1565. },
  1566. "onAfterPublish": function () {
  1567. if(onAfterPublish)onAfterPublish();
  1568. }
  1569. });
  1570. starter.load();
  1571. })
  1572. },
  1573. "startProcess": function(app, process, data, identity, callback, target, latest){
  1574. if (arguments.length>2){
  1575. for (var i=2; i<arguments.length; i++){
  1576. if (typeOf(arguments[i])=="boolean"){
  1577. target = arguments[i];
  1578. break;
  1579. }
  1580. }
  1581. }
  1582. if (target){
  1583. if (layout.app && layout.app.inBrowser){
  1584. //layout.app.content.empty();
  1585. layout.app.$openWithSelf = true;
  1586. }
  1587. }
  1588. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function(json){
  1589. if (json.data){
  1590. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  1591. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  1592. "workData": data,
  1593. "identity": identity,
  1594. "latest": latest,
  1595. "onStarted": function(data, title, processName){
  1596. var currentTask = [];
  1597. data.each(function(work){
  1598. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  1599. }.bind(this));
  1600. if (currentTask.length==1){
  1601. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  1602. layout.desktop.openApplication(null, "process.Work", options);
  1603. }else{}
  1604. if (callback) callback(data);
  1605. }.bind(this)
  1606. });
  1607. starter.load();
  1608. }.bind(this));
  1609. }
  1610. });
  1611. }
  1612. };
  1613. this.form.currentRouteName = _form.json.currentRouteName;
  1614. this.form.opinion = _form.json.opinion;
  1615. this.target = ev.target;
  1616. this.event = ev.event;
  1617. this.status = ev.status;
  1618. this.session = layout.desktop.session;
  1619. this.Actions = o2.Actions;
  1620. this.query = function(option){
  1621. // options = {
  1622. // "name": "statementName",
  1623. // "data": "json data",
  1624. // "firstResult": 1,
  1625. // "maxResults": 100,
  1626. // "success": function(){},
  1627. // "error": function(){},
  1628. // "async": true or false, default is true
  1629. // }
  1630. if (option){
  1631. var json = (option.data) || {};
  1632. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  1633. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  1634. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  1635. }
  1636. }
  1637. this.Table = MWF.xScript.createTable();
  1638. };
  1639. MWF.xScript.createTable = function(){
  1640. return function(name){
  1641. this.name = name;
  1642. this.action = o2.Actions.get("x_query_assemble_surface");
  1643. this.listRowNext = function(id, count, success, error, async){
  1644. this.action.listRowNext(this.name, id, count, success, error, async);
  1645. };
  1646. this.listRowPrev = function(id, count, success, error, async){
  1647. this.action.listRowPrev(this.name, id, count, success, error, async);
  1648. };
  1649. this.listRowPrev = function(id, count, success, error, async){
  1650. this.action.listRowPrev(this.name, id, count, success, error, async);
  1651. };
  1652. this.listRowSelectWhere = function(where, success, error, async){
  1653. this.action.listRowSelectWhere(this.name, where, success, error, async);
  1654. };
  1655. this.listRowCountWhere = function(where, success, error, async){
  1656. this.action.listRowCountWhere(this.name, where, success, error, async);
  1657. };
  1658. this.deleteRow = function(id, success, error, async){
  1659. this.action.deleteRow(this.name, id, success, error, async);
  1660. };
  1661. this.deleteAllRow = function(success, error, async){
  1662. this.action.deleteAllRow(this.name, success, error, async);
  1663. };
  1664. this.getRow = function(id, success, error, async){
  1665. this.action.getRow(this.name, id, success, error, async);
  1666. };
  1667. this.insertRow = function(data, success, error, async){
  1668. this.action.insertRow(this.name, data, success, error, async);
  1669. };
  1670. this.updateRow = function(id, data, success, error, async){
  1671. this.action.updateRow(this.name, id, data, success, error, async);
  1672. };
  1673. }
  1674. };
  1675. MWF.xScript.JSONData = function(data, callback, key, parent, _form){
  1676. var getter = function(data, callback, k, _self){
  1677. return function(){
  1678. // if (data[k]){
  1679. // return (["array","object"].indexOf(typeOf(data[k]))===-1) ? data[k] : new MWF.xScript.JSONData(data[k], callback, k, _self, _form);
  1680. // }else{
  1681. // var p = {"getKey": function(){return k;}, "getParent": function(){return _self;}};
  1682. // while (p && !_forms[p.getKey()]) p = p.getParent();
  1683. // if (p) if (p.getKey()) if (_forms[p.getKey()]) return _forms[p.getKey()].getValue();
  1684. // }
  1685. return (["array","object"].indexOf(typeOf(data[k]))===-1) ? data[k] : new MWF.xScript.JSONData(data[k], callback, k, _self, _form);
  1686. };
  1687. };
  1688. var setter = function(data, callback, k, _self){
  1689. return function(v){
  1690. data[k] = v;
  1691. //debugger;v
  1692. //this.add(k, v, true);
  1693. if (callback) callback(data, k, _self);
  1694. }
  1695. };
  1696. var define = function(){
  1697. var o = {};
  1698. for (var k in data) o[k] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, k, this]),"set": setter.apply(this, [data, callback, k, this])};
  1699. o["length"] = {"get": function(){return Object.keys(data).length;}};
  1700. MWF.defineProperties(this, o);
  1701. var methods = {
  1702. "getKey": {"value": function(){ return key; }},
  1703. "getParent": {"value": function(){ return parent; }},
  1704. "toString": {"value": function() { return data.toString();}},
  1705. "setSection": {"value": function(newKey, newValue){
  1706. this.add(newKey, newValue, true);
  1707. try {
  1708. var path = [this.getKey()];
  1709. p = this.getParent();
  1710. while (p && p.getKey()){
  1711. path.unshift(p.getKey());
  1712. p = p.getParent();
  1713. }
  1714. if (path.length) _form.sectionListObj[path.join(".")] = newKey;
  1715. }catch(e){
  1716. debugger;
  1717. }
  1718. }},
  1719. "add": {"value": function(newKey, newValue, overwrite){
  1720. var flag = true;
  1721. var type = typeOf(data);
  1722. if (type==="array"){
  1723. if (arguments.length<2){
  1724. data.push(newKey);
  1725. newValue = newKey;
  1726. newKey = data.length-1;
  1727. }else{
  1728. if (!newKey && newKey!==0){
  1729. data.push(newValue);
  1730. newKey = data.length-1;
  1731. }else{
  1732. flag = false;
  1733. }
  1734. }
  1735. if (flag){
  1736. var o = {};
  1737. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1738. MWF.defineProperties(this, o);
  1739. }
  1740. this[newKey] = newValue;
  1741. }else if (type==="object"){
  1742. if (!this.hasOwnProperty(newKey)){
  1743. data[newKey] = newValue;
  1744. if (flag){
  1745. var o = {};
  1746. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1747. MWF.defineProperties(this, o);
  1748. }
  1749. this[newKey] = newValue;
  1750. }else{
  1751. if (overwrite) this[newKey] = newValue;
  1752. }
  1753. }
  1754. return this[newKey];
  1755. }},
  1756. "del": {"value": function(delKey){
  1757. if (!this.hasOwnProperty(delKey)) return null;
  1758. delete data[delKey];
  1759. delete this[delKey];
  1760. return this;
  1761. }}
  1762. };
  1763. MWF.defineProperties(this, methods);
  1764. //this.getKey = function(){ return key; };
  1765. //this.getParent = function(){ return parent; };
  1766. //this.toString = function() { return data.toString();};
  1767. //this.add = function(newKey, newValue, overwrite){
  1768. // var flag = true;
  1769. // var type = typeOf(data);
  1770. // if (!this.hasOwnProperty(newKey)){
  1771. // if (type=="array"){
  1772. // if (arguments.length<2){
  1773. // data.push(newKey);
  1774. // newValue = newKey;
  1775. // newKey = data.length-1;
  1776. // }else{
  1777. // debugger;
  1778. // if (!newKey && newKey!=0){
  1779. // data.push(newValue);
  1780. // newKey = data.length-1;
  1781. // }else{
  1782. // flag == false;
  1783. // }
  1784. // }
  1785. // }else{
  1786. // data[newKey] = newValue;
  1787. // }
  1788. // //var valueType = typeOf(newValue);
  1789. // //var newValueData = newValue;
  1790. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  1791. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  1792. // if (flag){
  1793. // var o = {};
  1794. // o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1795. // MWF.defineProperties(this, o);
  1796. // }
  1797. // this[newKey] = newValue;
  1798. // }else{
  1799. // if (overwrite) this[newKey] = newValue;
  1800. // }
  1801. //
  1802. // //var valueType = typeOf(newValue);
  1803. // //var newValueData = newValue;
  1804. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  1805. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  1806. // //
  1807. // //this[newKey] = newValueData;
  1808. //
  1809. // return this[newKey];
  1810. //};
  1811. //this.del = function(delKey){
  1812. // if (!this.hasOwnProperty(delKey)) return null;
  1813. // delete data[newKey];
  1814. // delete this[newKey];
  1815. // return this;
  1816. //};
  1817. };
  1818. var type = typeOf(data);
  1819. if (type==="object" || type==="array") define.apply(this);
  1820. };
  1821. //MWF.xScript.createDict = function(application){
  1822. // return function(name){
  1823. // var applicationId = application;
  1824. // this.name = name;
  1825. // //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  1826. // var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1827. //
  1828. // this.get = function(path, success, failure){
  1829. // debugger;
  1830. // var value = null;
  1831. // if (path){
  1832. // var arr = path.split(/\./g);
  1833. // var ar = arr.map(function(v){
  1834. // return encodeURIComponent(v);
  1835. // });
  1836. // //var p = path.replace(/\./g, "/");
  1837. // var p = ar.join("/");
  1838. // action.getDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  1839. // value = json.data;
  1840. // if (success) success(json.data);
  1841. // }, function(xhr, text, error){
  1842. // if (failure) failure(xhr, text, error);
  1843. // }, false);
  1844. // }else{
  1845. // action.getDictRoot(encodeURIComponent(this.name), applicationId, function(json){
  1846. // value = json.data;
  1847. // if (success) success(json.data);
  1848. // }, function(xhr, text, error){
  1849. // if (failure) failure(xhr, text, error);
  1850. // }, false);
  1851. // }
  1852. //
  1853. // return value;
  1854. // };
  1855. //
  1856. // this.set = function(path, value, success, failure){
  1857. // var p = path.replace(/\./g, "/");
  1858. // action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1859. // if (success) success(json.data);
  1860. // }, function(xhr, text, error){
  1861. // if (failure) failure(xhr, text, error);
  1862. // });
  1863. // };
  1864. // this.add = function(path, value, success, failure){
  1865. // var p = path.replace(/\./g, "/");
  1866. // action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1867. // if (success) success(json.data);
  1868. // }, function(xhr, text, error){
  1869. // if (failure) failure(xhr, text, error);
  1870. // });
  1871. // };
  1872. // this["delete"] = function(path, success, failure){
  1873. // var p = path.replace(/\./g, "/");
  1874. // action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  1875. // if (success) success(json.data);
  1876. // }, function(xhr, text, error){
  1877. // if (failure) failure(xhr, text, error);
  1878. // });
  1879. // };
  1880. // this.destory = this["delete"];
  1881. // }
  1882. //};
  1883. // var dictLoaded = {};
  1884. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  1885. MWF.xScript.addDictToCache = function ( options, path, json ) {
  1886. if( !path )path = "root";
  1887. if( path.indexOf("root") !== 0 )path = "root." + path ;
  1888. var type = options.appType || "process";
  1889. var enableAnonymous = options.enableAnonymous || false;
  1890. var appFlagList = [];
  1891. if( options.application )appFlagList.push( options.application );
  1892. if( options.appId )appFlagList.push( options.appId );
  1893. if( options.appName )appFlagList.push( options.appName );
  1894. if( options.appAlias )appFlagList.push( options.appAlias );
  1895. var dictFlagList = [];
  1896. if( options.id )dictFlagList.push( options.id );
  1897. if( options.name )dictFlagList.push( options.name );
  1898. if( options.alias )dictFlagList.push( options.alias );
  1899. var cache = {};
  1900. cache[path] = json;
  1901. for( var i=0; i<appFlagList.length; i++ ){
  1902. for( var j=0; j<dictFlagList.length; j++ ){
  1903. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  1904. if( !MWF.xScript.dictLoaded[k] ){
  1905. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  1906. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  1907. }else if( i===0 && j===0 ){
  1908. MWF.xScript.setDictToCache( k, path ,json );
  1909. var arr = path.split(/\./g);
  1910. var p;
  1911. var cache = MWF.xScript.dictLoaded[k];
  1912. for( var l=0 ; l<arr.length; l++ ){
  1913. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  1914. if( cache[ p ] )break;
  1915. }
  1916. if( p ){
  1917. var mathP = p+".";
  1918. Object.keys( cache ).each( function( path, idx){
  1919. if( path.indexOf( mathP ) === 0 )delete cache[path];
  1920. })
  1921. }
  1922. }
  1923. }
  1924. }
  1925. };
  1926. MWF.xScript.getMatchedDict = function(key, path){
  1927. if( !path )path = "root";
  1928. if( path.indexOf("root") !== 0 )path = "root." + path ;
  1929. var arr = path.split(/\./g);
  1930. if( MWF.xScript.dictLoaded[key] ){
  1931. var dicts = MWF.xScript.dictLoaded[key];
  1932. var list = Array.clone(arr);
  1933. var p;
  1934. var dict;
  1935. for( var i=0 ; i<arr.length; i++ ){
  1936. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  1937. list.shift();
  1938. if( dicts[ p ] ){
  1939. dict = dicts[ p ];
  1940. break;
  1941. }
  1942. }
  1943. return {
  1944. dict : dict,
  1945. unmatchedPathList : list
  1946. }
  1947. }
  1948. return {
  1949. dict : null,
  1950. unmatchedPathList : list
  1951. }
  1952. };
  1953. MWF.xScript.insertDictToCache = function(key, path, json){
  1954. if( MWF.xScript.dictLoaded[key] ){
  1955. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  1956. var dict = matchedDict.dict;
  1957. var list = matchedDict.unmatchedPathList;
  1958. if( !dict ){
  1959. MWF.xScript.dictLoaded[key][path] = json;
  1960. }else{
  1961. for( var j=0; j<list.length-1; j++ ){
  1962. if( !dict[ list[j] ] ){
  1963. dict[ list[j] ] = {};
  1964. }
  1965. dict = dict[ list[j] ];
  1966. }
  1967. var lastPath = list[list.length-1];
  1968. if( !dict[lastPath] ){
  1969. dict[lastPath] = json;
  1970. }else if( typeOf( dict[lastPath] ) === "array" ){
  1971. dict[lastPath].push( json );
  1972. }
  1973. }
  1974. }else{
  1975. MWF.xScript.dictLoaded[key] = {};
  1976. MWF.xScript.dictLoaded[key][path] = json;
  1977. }
  1978. };
  1979. MWF.xScript.setDictToCache = function(key, path, json){
  1980. if( MWF.xScript.dictLoaded[key] ){
  1981. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  1982. var dict = matchedDict.dict;
  1983. var list = matchedDict.unmatchedPathList;
  1984. if( !dict ){
  1985. MWF.xScript.dictLoaded[key][path] = json;
  1986. }else{
  1987. for( var j=0; j<list.length-1; j++ ){
  1988. if( !dict[ list[j] ] ){
  1989. dict[ list[j] ] = {};
  1990. }
  1991. dict = dict[ list[j] ];
  1992. }
  1993. dict[list[list.length-1]] = json;
  1994. }
  1995. }else{
  1996. MWF.xScript.dictLoaded[key] = {};
  1997. MWF.xScript.dictLoaded[key][path] = json;
  1998. }
  1999. };
  2000. MWF.xScript.getDictFromCache = function( key, path ){
  2001. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2002. var dict = matchedDict.dict;
  2003. var list = matchedDict.unmatchedPathList;
  2004. if( dict ){
  2005. for( var j=0; j<list.length; j++ ){
  2006. dict = dict[ list[j] ];
  2007. if( !dict )return null;
  2008. }
  2009. return dict;
  2010. }
  2011. return null;
  2012. };
  2013. MWF.xScript.deleteDictToCache = function(key, path){
  2014. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  2015. var dict = matchedDict.dict;
  2016. var list = matchedDict.unmatchedPathList;
  2017. if( dict){
  2018. for( var j=0; j<list.length-1; j++ ){
  2019. dict = dict[ list[j] ];
  2020. if( !dict )return;
  2021. }
  2022. delete dict[list[list.length-1]];
  2023. }
  2024. };
  2025. MWF.xScript.createDict = function(application){
  2026. //optionsOrName : {
  2027. // type : "", //默认为process, 可以为 process cms
  2028. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  2029. // name : "", // 数据字典名称/别名/id
  2030. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  2031. //}
  2032. //或者name: "" // 数据字典名称/别名/id
  2033. return function(optionsOrName){
  2034. var options = optionsOrName;
  2035. if( typeOf( options ) == "string" ){
  2036. options = { name : options };
  2037. }
  2038. var name = this.name = options.name;
  2039. var type = ( options.type && options.application ) ? options.type : "process";
  2040. var applicationId = options.application || application;
  2041. var enableAnonymous = options.enableAnonymous || false;
  2042. var opt = {
  2043. "appType" : type,
  2044. "name" : name,
  2045. "appId" : applicationId,
  2046. "enableAnonymous" : enableAnonymous
  2047. };
  2048. var key = name+type+applicationId+enableAnonymous;
  2049. // if (!dictLoaded[key]) dictLoaded[key] = {};
  2050. // this.dictData = dictLoaded[key];
  2051. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  2052. if( type == "cms" ){
  2053. var action = MWF.Actions.get("x_cms_assemble_control");
  2054. }else{
  2055. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  2056. }
  2057. var encodePath = function( path ){
  2058. var arr = path.split(/\./g);
  2059. var ar = arr.map(function(v){
  2060. return encodeURIComponent(v);
  2061. });
  2062. return ar.join("/");
  2063. };
  2064. this.get = function(path, success, failure, async, refresh){
  2065. var value = null;
  2066. if (!refresh ){
  2067. var data = MWF.xScript.getDictFromCache( key, path );
  2068. if( data ){
  2069. if (success && o2.typeOf(success)=="function") success( data );
  2070. return data;
  2071. }
  2072. }
  2073. if (success===true) async=true;
  2074. if (failure===true) async=true;
  2075. var cb = function(json){
  2076. value = json.data;
  2077. MWF.xScript.addDictToCache(opt, path, value);
  2078. if (success && o2.typeOf(success)=="function") value = success(json.data);
  2079. return value;
  2080. }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  2081. if (path){
  2082. var p = encodePath( path );
  2083. //var p = path.replace(/\./g, "/");
  2084. action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async);
  2085. }else{
  2086. action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async);
  2087. }
  2088. return (!!async) ? cb : value;
  2089. // if (path){
  2090. // var p = encodePath( path );
  2091. // //var p = path.replace(/\./g, "/");
  2092. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  2093. // value = json.data;
  2094. // // this.dictData[path] = value;
  2095. // MWF.xScript.addDictToCache(opt, path, value);
  2096. // if (success) success(json.data);
  2097. // }.bind(this), function(xhr, text, error){
  2098. // if (failure) failure(xhr, text, error);
  2099. // }, !!async);
  2100. // }else{
  2101. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  2102. // value = json.data;
  2103. // // this.dictData["root"] = value;
  2104. // MWF.xScript.addDictToCache(opt, path, value);
  2105. // if (success) success(json.data);
  2106. // }.bind(this), function(xhr, text, error){
  2107. // if (failure) failure(xhr, text, error);
  2108. // }, !!async);
  2109. // }
  2110. //return value;
  2111. };
  2112. this.set = function(path, value, success, failure){
  2113. var p = encodePath( path );
  2114. //var p = path.replace(/\./g, "/");
  2115. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  2116. MWF.xScript.setDictToCache(key, path, value);
  2117. if (success) return success(json.data);
  2118. }, function(xhr, text, error){
  2119. if (failure) return failure(xhr, text, error);
  2120. }, false, false);
  2121. };
  2122. this.add = function(path, value, success, failure){
  2123. var p = encodePath( path );
  2124. //var p = path.replace(/\./g, "/");
  2125. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  2126. MWF.xScript.insertDictToCache(key, path, value);
  2127. if (success) return success(json.data);
  2128. }, function(xhr, text, error){
  2129. if (failure) return failure(xhr, text, error);
  2130. }, false, false);
  2131. };
  2132. this["delete"] = function(path, success, failure){
  2133. var p = encodePath( path );
  2134. //var p = path.replace(/\./g, "/");
  2135. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  2136. MWF.xScript.deleteDictToCache(key, path);
  2137. if (success) return success(json.data);
  2138. }, function(xhr, text, error){
  2139. if (failure) return failure(xhr, text, error);
  2140. }, false, false);
  2141. };
  2142. this.destory = this["delete"];
  2143. }
  2144. };