Environment.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  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){
  237. getOrgActions();
  238. var data = {"groupList": getNameFlag(name)};
  239. var v = null;
  240. orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  241. return (v && v.length===1) ? v[0] : v;
  242. },
  243. //查询下级群组--返回群组的对象数组
  244. //nested 布尔 true嵌套下级;false直接下级;默认false;
  245. listSubGroup: function(name, nested){
  246. getOrgActions();
  247. var data = {"groupList": getNameFlag(name)};
  248. var v = null;
  249. if (nested){
  250. orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  251. }else{
  252. orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  253. }
  254. return v;
  255. },
  256. //查询上级群组--返回群组的对象数组
  257. //nested 布尔 true嵌套上级;false直接上级;默认false;
  258. listSupGroup:function(name, nested){
  259. getOrgActions();
  260. var data = {"groupList": getNameFlag(name)};
  261. var v = null;
  262. if (nested){
  263. orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  264. }else{
  265. orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  266. }
  267. return v;
  268. },
  269. //人员所在群组(嵌套)--返回群组的对象数组
  270. listGroupWithPerson:function(name){
  271. getOrgActions();
  272. var data = {"personList": getNameFlag(name)};
  273. var v = null;
  274. orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  275. return v;
  276. },
  277. //群组是否拥有角色--返回true, false
  278. groupHasRole: function(name, role){
  279. getOrgActions();
  280. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  281. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  282. var v = false;
  283. orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  284. return v;
  285. },
  286. //角色***************
  287. //获取角色--返回角色的对象数组
  288. getRole: function(name){
  289. getOrgActions();
  290. var data = {"roleList": getNameFlag(name)};
  291. var v = null;
  292. orgActions.listRole(data, function(json){v = json.data;}, null, false);
  293. return (v && v.length===1) ? v[0] : v;
  294. },
  295. //人员所有角色(嵌套)--返回角色的对象数组
  296. listRoleWithPerson:function(name){
  297. getOrgActions();
  298. var data = {"personList": getNameFlag(name)};
  299. var v = null;
  300. orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  301. return v;
  302. },
  303. //人员***************
  304. //人员是否拥有角色--返回true, false
  305. personHasRole: function(name, role){
  306. getOrgActions();
  307. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  308. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  309. var v = false;
  310. orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  311. return v;
  312. },
  313. //获取人员--返回人员的对象数组
  314. getPerson: function(name){
  315. getOrgActions();
  316. var data = {"personList": getNameFlag(name)};
  317. var v = null;
  318. orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  319. return (v && v.length===1) ? v[0] : v;;
  320. },
  321. //查询下级人员--返回人员的对象数组
  322. //nested 布尔 true嵌套下级;false直接下级;默认false;
  323. listSubPerson: function(name, nested){
  324. getOrgActions();
  325. var data = {"personList": getNameFlag(name)};
  326. var v = null;
  327. if (nested){
  328. orgActions.listPersonSubNested(data, function(json){v = json.data;}, null, false);
  329. }else{
  330. orgActions.listPersonSubDirect(data, function(json){v = json.data;}, null, false);
  331. }
  332. return v;
  333. },
  334. //查询上级人员--返回人员的对象数组
  335. //nested 布尔 true嵌套上级;false直接上级;默认false;
  336. listSupPerson: function(name, nested){
  337. getOrgActions();
  338. var data = {"personList": getNameFlag(name)};
  339. var v = null;
  340. if (nested){
  341. orgActions.listPersonSupNested(data, function(json){v = json.data;}, null, false);
  342. }else{
  343. orgActions.listPersonSupDirect(data, function(json){v = json.data;}, null, false);
  344. }
  345. return v;
  346. },
  347. //获取群组的所有人员--返回人员的对象数组
  348. listPersonWithGroup: function(name){
  349. getOrgActions();
  350. var data = {"groupList": getNameFlag(name)};
  351. var v = null;
  352. orgActions.listPersonWithGroup(data, function(json){v = json.data;}, null, false);
  353. return v;
  354. },
  355. //获取角色的所有人员--返回人员的对象数组
  356. listPersonWithRole: function(name){
  357. getOrgActions();
  358. var data = {"roleList": getNameFlag(name)};
  359. var v = null;
  360. orgActions.listPersonWithRole(data, function(json){v = json.data;}, null, false);
  361. return v;
  362. },
  363. //获取身份的所有人员--返回人员的对象数组
  364. listPersonWithIdentity: function(name){
  365. getOrgActions();
  366. var data = {"identityList": getNameFlag(name)};
  367. var v = null;
  368. orgActions.listPersonWithIdentity(data, function(json){v = json.data;}, null, false);
  369. return v;
  370. },
  371. //获取身份的所有人员--返回人员的对象数组或人员对象
  372. getPersonWithIdentity: function(name){
  373. getOrgActions();
  374. var data = {"identityList": getNameFlag(name)};
  375. var v = null;
  376. orgActions.listPersonWithIdentity(data, function(json){v = json.data;}, null, false);
  377. return (v && v.length===1) ? v[0] : v;
  378. },
  379. //查询组织成员的人员--返回人员的对象数组
  380. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  381. listPersonWithUnit: function(name, nested){
  382. getOrgActions();
  383. var data = {"unitList": getNameFlag(name)};
  384. var v = null;
  385. if (nested){
  386. orgActions.listPersonWithUnitNested(data, function(json){v = json.data;}, null, false);
  387. }else{
  388. orgActions.listPersonWithUnitDirect(data, function(json){v = json.data;}, null, false);
  389. }
  390. return v;
  391. },
  392. //根据属性查询人员--返回人员的对象数组
  393. //name string 属性名
  394. //value string 属性值
  395. listPersonWithAttribute: function(name, value){
  396. getOrgActions();
  397. var data = {"name": name, "attribute": value};
  398. var v = null;
  399. orgActions.listPersonWithAttribute(data, function(json){v = json.data;}, null, false);
  400. return v;
  401. },
  402. //根据属性查询人员--返回人员的全称数组
  403. //name string 属性名
  404. //value string 属性值
  405. listPersonNameWithAttribute: function(name, value){
  406. getOrgActions();
  407. var data = {"name": name, "attribute": value};
  408. var v = null;
  409. orgActions.listPersonWithAttributeValue(data, function(json){v = json.data.personList;}, null, false);
  410. return v;
  411. },
  412. //人员属性************
  413. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  414. appendPersonAttribute: function(person, attr, values, success, failure){
  415. getOrgActions();
  416. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  417. var data = {"attributeList":values,"name":attr,"person":personFlag};
  418. orgActions.appendPersonAttribute(data, function(json){
  419. if (json.data.value){
  420. if (success) success();
  421. }else{
  422. if (failure) failure(null, "", "append values failed");
  423. }
  424. }, function(xhr, text, error){
  425. if (failure) failure(xhr, text, error);
  426. }, false);
  427. },
  428. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  429. setPersonAttribute: function(person, attr, values, success, failure){
  430. getOrgActions();
  431. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  432. var data = {"attributeList":values,"name":attr,"person":personFlag};
  433. orgActions.setPersonAttribute(data, function(json){
  434. if (json.data.value){
  435. if (success) success();
  436. }else{
  437. if (failure) failure(null, "", "append values failed");
  438. }
  439. }, function(xhr, text, error){
  440. if (failure) failure(xhr, text, error);
  441. }, false);
  442. },
  443. //获取人员属性值
  444. getPersonAttribute: function(person, attr){
  445. getOrgActions();
  446. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  447. var data = {"name":attr,"person":personFlag};
  448. var v = null;
  449. orgActions.getPersonAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  450. return v;
  451. },
  452. //列出人员所有属性的名称
  453. listPersonAttributeName: function(name){
  454. getOrgActions();
  455. var data = {"personList":getNameFlag(name)};
  456. var v = null;
  457. orgActions.listPersonAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  458. return v;
  459. },
  460. //列出人员的所有属性
  461. listPersonAllAttribute: function(name){
  462. getOrgActions();
  463. var data = {"personList":getNameFlag(name)};
  464. var v = null;
  465. orgActions.listPersonAllAttribute(data, function(json){v = json.data;}, null, false);
  466. return v;
  467. },
  468. //身份**********
  469. //获取身份
  470. getIdentity: function(name){
  471. getOrgActions();
  472. var data = {"identityList":getNameFlag(name)};
  473. var v = null;
  474. orgActions.listIdentity(data, function(json){v = json.data;}, null, false);
  475. return (v && v.length===1) ? v[0] : v;
  476. },
  477. //列出人员的身份
  478. listIdentityWithPerson: function(name){
  479. getOrgActions();
  480. var data = {"personList":getNameFlag(name)};
  481. var v = null;
  482. orgActions.listIdentityWithPerson(data, function(json){v = json.data;}, null, false);
  483. return v;
  484. },
  485. //查询组织成员身份--返回身份的对象数组
  486. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  487. listIdentityWithUnit: function(name, nested){
  488. getOrgActions();
  489. var data = {"unitList": getNameFlag(name)};
  490. var v = null;
  491. if (nested){
  492. orgActions.listIdentityWithUnitNested(data, function(json){v = json.data;}, null, false);
  493. }else{
  494. orgActions.listIdentityWithUnitDirect(data, function(json){v = json.data;}, null, false);
  495. }
  496. return v;
  497. },
  498. //组织**********
  499. //获取组织
  500. getUnit: function(name){
  501. getOrgActions();
  502. var data = {"unitList":getNameFlag(name)};
  503. var v = null;
  504. orgActions.listUnit(data, function(json){v = json.data;}, null, false);
  505. return (v && v.length===1) ? v[0] : v;
  506. },
  507. //查询组织的下级--返回组织的对象数组
  508. //nested 布尔 true嵌套下级;false直接下级;默认false;
  509. listSubUnit: function(name, nested){
  510. getOrgActions();
  511. var data = {"unitList": getNameFlag(name)};
  512. var v = null;
  513. if (nested){
  514. orgActions.listUnitSubNested(data, function(json){v = json.data;}, null, false);
  515. }else{
  516. orgActions.listUnitSubDirect(data, function(json){v = json.data;}, null, false);
  517. }
  518. return v;
  519. },
  520. //查询组织的上级--返回组织的对象数组
  521. //nested 布尔 true嵌套上级;false直接上级;默认false;
  522. listSupUnit: function(name, nested){
  523. getOrgActions();
  524. var data = {"unitList": getNameFlag(name)};
  525. var v = null;
  526. if (nested){
  527. orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  528. }else{
  529. orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  530. }
  531. return v;
  532. },
  533. //根据个人身份获取组织
  534. //flag 数字 表示获取第几层的组织
  535. // 字符串 表示获取指定类型的组织
  536. // 空 表示获取直接所在的组织
  537. getUnitByIdentity: function(name, flag){
  538. getOrgActions();
  539. var getUnitMethod = "current";
  540. var v;
  541. if (flag){
  542. if (typeOf(flag)==="string") getUnitMethod = "type";
  543. if (typeOf(flag)==="number") getUnitMethod = "level";
  544. }
  545. switch (getUnitMethod){
  546. case "current":
  547. var data = {"identityList":getNameFlag(name)};
  548. orgActions.listUnitWithIdentity(data, function(json){ v = json.data; v=(v&&v.length===1) ? v[0] : v }, null, false);
  549. break;
  550. case "type":
  551. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  552. orgActions.getUnitWithIdentityAndType(data, function(json){ v = json.data; }, null, false);
  553. break;
  554. case "level":
  555. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  556. orgActions.getUnitWithIdentityAndLevel(data, function(json){ v = json.data; }, null, false);
  557. break;
  558. }
  559. return v;
  560. },
  561. //列出身份所在组织的所有上级组织
  562. listAllSupUnitWithIdentity: function(name){
  563. getOrgActions();
  564. var data = {"identityList":getNameFlag(name)};
  565. var v = null;
  566. orgActions.listUnitSupNestedWithIdentity(data, function(json){v = json.data;}, null, false);
  567. return v;
  568. },
  569. //获取人员所在的所有组织
  570. listUnitWithPerson: function(name){
  571. getOrgActions();
  572. var data = {"personList":getNameFlag(name)};
  573. var v = null;
  574. orgActions.listUnitWithPerson(data, function(json){v = json.data;}, null, false);
  575. return v;
  576. },
  577. //列出人员所在组织的所有上级组织
  578. listAllSupUnitWithPerson: function(name){
  579. getOrgActions();
  580. var data = {"personList":getNameFlag(name)};
  581. var v = null;
  582. orgActions.listUnitSupNestedWithPerson(data, function(json){v = json.data;}, null, false);
  583. return v;
  584. },
  585. //根据组织属性,获取所有符合的组织
  586. listUnitWithAttribute: function(name, attribute){
  587. getOrgActions();
  588. var data = {"name":name,"attribute":attribute};
  589. var v = null;
  590. orgActions.listUnitWithAttribute(data, function(json){v = json.data;}, null, false);
  591. return v;
  592. },
  593. //根据组织职务,获取所有符合的组织
  594. listUnitWithDuty: function(name, id){
  595. getOrgActions();
  596. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  597. var v = null;
  598. orgActions.listUnitWithDuty(data, function(json){v = json.data;}, null, false);
  599. return v;
  600. },
  601. //组织职务***********
  602. //获取指定的组织职务的身份
  603. getDuty: function(duty, id){
  604. getOrgActions();
  605. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  606. var v = null;
  607. orgActions.getDuty(data, function(json){v = json.data;}, null, false);
  608. return v;
  609. },
  610. //获取身份的所有职务名称
  611. listDutyNameWithIdentity: function(name){
  612. getOrgActions();
  613. var data = {"identityList":getNameFlag(name)};
  614. var v = null;
  615. orgActions.listDutyNameWithIdentity(data, function(json){v = json.data.nameList;}, null, false);
  616. return v;
  617. },
  618. //获取组织的所有职务名称
  619. listDutyNameWithUnit: function(name){
  620. getOrgActions();
  621. var data = {"unitList":getNameFlag(name)};
  622. var v = null;
  623. orgActions.listDutyNameWithUnit(data, function(json){v = json.data.nameList;}, null, false);
  624. return v;
  625. },
  626. //获取组织的所有职务
  627. listUnitAllDuty: function(name){
  628. getOrgActions();
  629. var data = {"unitList":getNameFlag(name)};
  630. var v = null;
  631. orgActions.listUnitAllDuty(data, function(json){v = json.data;}, null, false);
  632. return v;
  633. },
  634. //列出顶层组织
  635. listTopUnit: function(){
  636. var action = MWF.Actions.get("x_organization_assemble_control");
  637. var v = null;
  638. action.listTopUnit(function(json){
  639. v = json.data;
  640. }, null, false);
  641. return v;
  642. },
  643. //组织属性**************
  644. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  645. appendUnitAttribute: function(unit, attr, values, success, failure){
  646. getOrgActions();
  647. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  648. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  649. orgActions.appendUnitAttribute(data, function(json){
  650. if (json.data.value){
  651. if (success) success();
  652. }else{
  653. if (failure) failure(null, "", "append values failed");
  654. }
  655. }, function(xhr, text, error){
  656. if (failure) failure(xhr, text, error);
  657. }, false);
  658. },
  659. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  660. setUnitAttribute: function(unit, attr, values, success, failure){
  661. getOrgActions();
  662. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  663. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  664. orgActions.setUnitAttribute(data, function(json){
  665. if (json.data.value){
  666. if (success) success();
  667. }else{
  668. if (failure) failure(null, "", "append values failed");
  669. }
  670. }, function(xhr, text, error){
  671. if (failure) failure(xhr, text, error);
  672. }, false);
  673. },
  674. //获取组织属性值
  675. getUnitAttribute: function(unit, attr){
  676. getOrgActions();
  677. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  678. var data = {"name":attr,"unit":unitFlag};
  679. var v = null;
  680. orgActions.getUnitAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  681. return v;
  682. },
  683. //列出组织所有属性的名称
  684. listUnitAttributeName: function(name){
  685. getOrgActions();
  686. var data = {"unitList":getNameFlag(name)};
  687. var v = null;
  688. orgActions.listUnitAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  689. return v;
  690. },
  691. //列出组织的所有属性
  692. listUnitAllAttribute: function(name){
  693. getOrgActions();
  694. var data = {"unitList":getNameFlag(name)};
  695. var v = null;
  696. orgActions.listUnitAllAttribute(data, function(json){v = json.data;}, null, false);
  697. return v;
  698. }
  699. };
  700. this.Action = (function(){
  701. var actions = [];
  702. return function(root, json){
  703. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  704. action.getActions = function(callback){
  705. if (!this.actions) this.actions = {};
  706. Object.merge(this.actions, json);
  707. if (callback) callback();
  708. };
  709. this.invoke = function(option){
  710. action.invoke(option)
  711. }
  712. }
  713. })();
  714. this.service = {
  715. "jaxwsClient":{},
  716. "jaxrsClient":{}
  717. };
  718. var lookupAction = null;
  719. var getLookupAction = function(callback){
  720. if (!lookupAction){
  721. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  722. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  723. lookupAction.getActions = function(actionCallback){
  724. this.actions = {
  725. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  726. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  727. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  728. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  729. };
  730. if (actionCallback) actionCallback();
  731. };
  732. if (callback) callback();
  733. });
  734. }else{
  735. if (callback) callback();
  736. }
  737. };
  738. this.view = {
  739. "lookup": function(view, callback, async){
  740. var filterList = {"filterList": (view.filter || null)};
  741. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function(json){
  742. var data = {
  743. "grid": json.data.grid || json.data.groupGrid,
  744. "groupGrid": json.data.groupGrid
  745. };
  746. if (callback) callback(data);
  747. }, null, async);
  748. },
  749. "lookupV1": function(view, callback){
  750. getLookupAction(function(){
  751. lookupAction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
  752. var data = {
  753. "grid": json.data.grid,
  754. "groupGrid": json.data.groupGrid
  755. };
  756. if (callback) callback(data);
  757. }.bind(this)});
  758. }.bind(this));
  759. },
  760. "select": function(view, callback, options){
  761. if (view.view){
  762. var viewJson = {
  763. "application": view.application || _form.json.application,
  764. "viewName": view.view || "",
  765. "isTitle": (view.isTitle===false) ? "no" : "yes",
  766. "select": (view.isMulti===false) ? "single" : "multi",
  767. "filter": view.filter
  768. };
  769. if (!options) options = {};
  770. options.width = view.width;
  771. options.height = view.height;
  772. options.title = view.caption;
  773. var width = options.width || "700";
  774. var height = options.height || "400";
  775. if (layout.mobile){
  776. var size = document.body.getSize();
  777. width = size.x;
  778. height = size.y;
  779. options.style = "viewmobile";
  780. }
  781. width = width.toInt();
  782. height = height.toInt();
  783. var size = _form.app.content.getSize();
  784. var x = (size.x-width)/2;
  785. var y = (size.y-height)/2;
  786. if (x<0) x = 0;
  787. if (y<0) y = 0;
  788. if (layout.mobile){
  789. x = 20;
  790. y = 0;
  791. }
  792. var _self = this;
  793. MWF.require("MWF.xDesktop.Dialog", function(){
  794. var dlg = new MWF.xDesktop.Dialog({
  795. "title": options.title || "select view",
  796. "style": options.style || "view",
  797. "top": y,
  798. "left": x-20,
  799. "fromTop":y,
  800. "fromLeft": x-20,
  801. "width": width,
  802. "height": height,
  803. "html": "<div style='height: 100%;'></div>",
  804. "maskNode": _form.app.content,
  805. "container": _form.app.content,
  806. "buttonList": [
  807. {
  808. "text": MWF.LP.process.button.ok,
  809. "action": function(){
  810. //if (callback) callback(_self.view.selectedItems);
  811. if (callback) callback(_self.view.getData());
  812. this.close();
  813. }
  814. },
  815. {
  816. "text": MWF.LP.process.button.cancel,
  817. "action": function(){this.close();}
  818. }
  819. ]
  820. });
  821. dlg.show();
  822. if (layout.mobile){
  823. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  824. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  825. if (backAction) backAction.addEvent("click", function(e){
  826. dlg.close();
  827. }.bind(this));
  828. if (okAction) okAction.addEvent("click", function(e){
  829. //if (callback) callback(this.view.selectedItems);
  830. if (callback) callback(this.view.getData());
  831. dlg.close();
  832. }.bind(this));
  833. }
  834. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  835. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, {"style": "select"}, _form.app, _form.Macro);
  836. }.bind(this));
  837. }.bind(this));
  838. }
  839. }
  840. };
  841. //include 引用脚本
  842. //optionsOrName : {
  843. // type : "", 默认为process, 可以为 portal process cms
  844. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  845. // name : "" // 脚本名称/别名/id
  846. //}
  847. //或者name: "" // 脚本名称/别名/id
  848. // if( !window.includedScripts ){
  849. // var includedScripts = window.includedScripts = [];
  850. // }else{
  851. // var includedScripts = window.includedScripts;
  852. // }
  853. var includedScripts = [];
  854. var _includeSingle = function( optionsOrName , callback, async){
  855. var options = optionsOrName;
  856. if( typeOf( options ) == "string" ){
  857. options = { name : options };
  858. }
  859. var name = options.name;
  860. var type = ( options.type && options.application ) ? options.type : "process";
  861. var application = options.application || _form.json.application;
  862. var key = type +"-" + application + "-" + name;
  863. if (includedScripts.indexOf( key )> -1){
  864. if (callback) callback.apply(this);
  865. return;
  866. }
  867. //if (includedScripts.indexOf( name )> -1){
  868. // if (callback) callback.apply(this);
  869. // return;
  870. //}
  871. var scriptAction;
  872. switch ( type ){
  873. case "portal" :
  874. if( this.scriptActionPortal ){
  875. scriptAction = this.scriptActionPortal;
  876. }else{
  877. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  878. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  879. }
  880. break;
  881. case "process" :
  882. if( this.scriptActionProcess ){
  883. scriptAction = this.scriptActionProcess;
  884. }else{
  885. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  886. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  887. }
  888. break;
  889. case "cms" :
  890. if( this.scriptActionCMS ){
  891. scriptAction = this.scriptActionCMS;
  892. }else{
  893. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  894. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  895. }
  896. break;
  897. }
  898. debugger;
  899. scriptAction.getScriptByName( application, name, includedScripts, function(json){
  900. if (json.data){
  901. includedScripts.push( key );
  902. includedScripts = includedScripts.concat(json.data.importedList);
  903. MWF.Macro.exec(json.data.text, this);
  904. if (callback) callback.apply(this);
  905. }else{
  906. if (callback) callback.apply(this);
  907. }
  908. }.bind(this), null, !!async);
  909. }
  910. this.include = function( optionsOrName , callback, async){
  911. if (o2.typeOf(optionsOrName)=="array"){
  912. if (!!async){
  913. var count = optionsOrName.length;
  914. var loaded = 0;
  915. optionsOrName.each(function(option){
  916. _includeSingle.apply(this, [option, function(){
  917. loaded++;
  918. if (loaded>=count) if (callback) callback.apply(this);;
  919. }.bind(this), true]);
  920. }.bind(this));
  921. }else{
  922. optionsOrName.each(function(option){
  923. _includeSingle.apply(this, [option]);
  924. if (callback) callback.apply(this);
  925. }.bind(this));
  926. }
  927. }else{
  928. _includeSingle.apply(this, [optionsOrName , callback, async])
  929. }
  930. };
  931. this.define = function(name, fun, overwrite){
  932. var over = true;
  933. if (overwrite===false) over = false;
  934. var o = {};
  935. o[name] = {"value": fun, "configurable": over};
  936. MWF.defineProperties(this, o);
  937. }.bind(this);
  938. //如果前端事件有异步调用,想要在异步调用结束后继续运行页面加载,
  939. //可在调用前执行 var resolve = this.wait();
  940. //在异步调用结束后 执行 resolve.cb();
  941. //目前只有表单的queryload事件支持此方法。
  942. this.wait = function(){
  943. resolve = {};
  944. var setResolve = function(callback){
  945. resolve.cb = callback;
  946. }.bind(this);
  947. this.target.event_resolve = setResolve;
  948. return resolve;
  949. }
  950. //和this.wait配合使用,
  951. //如果没有异步,则resolve.cb方法不存在,
  952. //所以在回调中中使用this.goon();使表单继续加载
  953. this.goon = function(){
  954. this.target.event_resolve = null;
  955. }
  956. //仅前台对象-----------------------------------------
  957. //form
  958. this.page = this.form = {
  959. "getInfor": function(){return ev.formInfor;},
  960. "infor": ev.formInfor,
  961. "getApp": function(){return _form.app;},
  962. "app": _form.app,
  963. "node": function(){return _form.node;},
  964. "readonly": _form.options.readonly,
  965. "get": function(name){return (_form.all) ? _form.all[name] : null;},
  966. "getField": function(name){return _forms[name];},
  967. "getAction": function(){return _form.workAction},
  968. "getDesktop": function(){return _form.app.desktop},
  969. "getData": function(){return new MWF.xScript.JSONData(_form.getData());},
  970. "save": function(callback, silent){_form.saveWork(callback, silent); },
  971. "close": function(){_form.closeWork();},
  972. "verify": function(){
  973. return !(!_form.formCustomValidation("", "") || !_form.formValidation("", ""));
  974. },
  975. "process": function(option){
  976. var op = _form.getOpinion();
  977. var mds = op.medias;
  978. if (option){
  979. _form.submitWork(option.routeName, option.opinion, mds, option.callback,
  980. option.processor, null, option.appendTaskIdentityList, option.processorOrgList, option.callbackBeforeSave );
  981. }else{
  982. _form.processWork();
  983. }
  984. },
  985. "reset": function(option){
  986. if (!option){
  987. if (_form.businessData.control["allowReset"]) _form.resetWork();
  988. }else{
  989. _form.resetWorkToPeson(option.names, option.opinion, option.keep, option.success, option.failure);
  990. }
  991. },
  992. "retract": function(option){
  993. if (!option){
  994. if (_form.businessData.control["allowAddSplit"]) _form.addSplit();
  995. }else{
  996. _form.doRetractWork(option.success, option.failure);
  997. }
  998. },
  999. "addSplit": function(option){
  1000. if (!option){
  1001. if (_form.businessData.control["allowRetract"]) _form.retractWork();
  1002. }else{
  1003. _form.addSplitWork(option.value, option.success, option.failure);
  1004. }
  1005. },
  1006. "rollback": function(option){
  1007. if (!option){
  1008. if (_form.businessData.control["allowRollback"]) _form.rollback();
  1009. }else{
  1010. _form.doRollbackActionInvoke(option.log, option.flow, option.success, option.failure);
  1011. }
  1012. },
  1013. "print": function(application, form){
  1014. if (arguments.length){
  1015. var app = (arguments.length>1) ? arguments[0] : null;
  1016. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  1017. _form.printWork(app, formName);
  1018. }else{
  1019. _form.printWork();
  1020. }
  1021. },
  1022. "deleteWork": function(option){
  1023. if (!option){
  1024. if (_form.businessData.control["allowDelete"]) _form.deleteWork();
  1025. }else{
  1026. _form.doDeleteWork(option.success, option.failure);
  1027. }
  1028. },
  1029. "confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
  1030. if ((arguments.length<=1) || o2.typeOf(arguments[1])==="string"){
  1031. var p = MWF.getCenter({"x": width, "y": height});
  1032. e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  1033. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  1034. }else{
  1035. e = (arguments.length>1) ? arguments[1] : null;
  1036. title = (arguments.length>2) ? arguments[2] : null;
  1037. text = (arguments.length>3) ? arguments[3] : null;
  1038. width = (arguments.length>4) ? arguments[4] : null;
  1039. height = (arguments.length>5) ? arguments[5] : null;
  1040. ok = (arguments.length>6) ? arguments[6] : null;
  1041. cancel = (arguments.length>7) ? arguments[7] : null;
  1042. callback = (arguments.length>8) ? arguments[8] : null;
  1043. mask = (arguments.length>9) ? arguments[9] : null;
  1044. style = (arguments.length>10) ? arguments[10] : null;
  1045. // var p = MWF.getCenter({"x": width, "y": height});
  1046. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  1047. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  1048. }
  1049. },
  1050. "alert": function(type, title, text, width, height){
  1051. _form.alert(type, title, text, width, height);
  1052. },
  1053. "notice": function(content, type, target, where, offset, option){
  1054. _form.notice(content, type, target, where, offset, option);
  1055. },
  1056. "addEvent": function(e, f){_form.addEvent(e, f);},
  1057. "openWindow": function(application, form){
  1058. if (arguments.length){
  1059. var app = (arguments.length>1) ? arguments[0] : null;
  1060. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  1061. _form.openWindow(formName, app);
  1062. }else{
  1063. _form.openWindow();
  1064. }
  1065. },
  1066. "openWork": function(id, completedId, title, options){
  1067. var op = options || {};
  1068. op.workId = id;
  1069. op.workCompletedId = completedId;
  1070. op.docTitle = title;
  1071. op.appId = "process.Work"+(op.workId || op.workCompletedId);
  1072. return layout.desktop.openApplication(this.event, "process.Work", op);
  1073. },
  1074. "openJob": function(id, choice, options){
  1075. var workData = null;
  1076. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  1077. if (json.data) workData = json.data;
  1078. }.bind(this), null, false);
  1079. if (workData){
  1080. var len = workData.workList.length + workData.workCompletedList.length;
  1081. if (len){
  1082. if (len>1 && choice){
  1083. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  1084. workData.workList.each(function(work){
  1085. var workNode = new Element("div", {
  1086. "styles": {
  1087. "background": "#ffffff",
  1088. "border-radius": "10px",
  1089. "clear": "both",
  1090. "margin-bottom": "10px",
  1091. "height": "40px",
  1092. "padding": "10px 10px"
  1093. }
  1094. }).inject(node);
  1095. 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>" +
  1096. "<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>"+
  1097. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  1098. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  1099. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  1100. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  1101. workNode.set("html", html);
  1102. var action = workNode.getElement(".MWFAction");
  1103. action.store("work", work);
  1104. action.addEvent("click", function(e){
  1105. var work = e.target.retrieve("work");
  1106. if (work) this.openWork(work.id, null, work.title, options);
  1107. dlg.close();
  1108. }.bind(this));
  1109. }.bind(this));
  1110. workData.workCompletedList.each(function(work){
  1111. var workNode = new Element("div", {
  1112. "styles": {
  1113. "background": "#ffffff",
  1114. "border-radius": "10px",
  1115. "clear": "both",
  1116. "margin-bottom": "10px",
  1117. "height": "40px",
  1118. "padding": "10px 10px"
  1119. }
  1120. }).inject(node);
  1121. 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>" +
  1122. "<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>"+
  1123. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  1124. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  1125. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  1126. workNode.set("html", html);
  1127. var action = workNode.getElement(".MWFAction");
  1128. action.store("work", work);
  1129. action.addEvent("click", function(e){
  1130. var work = e.target.retrieve("work");
  1131. if (work) this.openWork(null, work.id, work.title, options);
  1132. dlg.close();
  1133. }.bind(this));
  1134. }.bind(this));
  1135. var height = node.getSize().y+20;
  1136. if (height>600) height = 600;
  1137. var dlg = o2.DL.open({
  1138. "title": o2.LP.widget.choiceWork,
  1139. "style" : "user",
  1140. "isResize": false,
  1141. "content": node,
  1142. "buttonList": [
  1143. {
  1144. "type" : "cancel",
  1145. "text": o2.LP.widget.close,
  1146. "action": function(){dlg.close();}
  1147. }
  1148. ]
  1149. });
  1150. }else{
  1151. if (workData.workList.length){
  1152. var work = workData.workList[0];
  1153. return this.openWork(work.id, null, work.title, options);
  1154. }else{
  1155. var work = workData.workCompletedList[0];
  1156. return this.openWork(null, work.id, work.title, options);
  1157. }
  1158. }
  1159. }
  1160. }
  1161. // var op = options || {};
  1162. // op.workId = id;
  1163. // op.workCompletedId = completedId;
  1164. // op.docTitle = title;
  1165. // op.appId = "process.Work"+(op.workId || op.workCompletedId);
  1166. // layout.desktop.openApplication(this.event, "process.Work", op);
  1167. },
  1168. "openDocument": function(id, title, options){
  1169. var op = options || {};
  1170. op.documentId = id;
  1171. op.docTitle = title;
  1172. layout.desktop.openApplication(this.event, "cms.Document", op);
  1173. },
  1174. "openPortal": function(name, page, par){
  1175. var action = MWF.Actions.get("x_portal_assemble_surface");
  1176. action.getApplication(name, function(json){
  1177. if (json.data){
  1178. if (page){
  1179. action.getPageByName(page, json.data.id, function(pageJson){
  1180. layout.desktop.openApplication(null, "portal.Portal", {
  1181. "portalId": json.data.id,
  1182. "pageId": (pageJson.data) ? pageJson.data.id : "",
  1183. "parameters": par,
  1184. "appId": "portal.Portal"+json.data.id
  1185. })
  1186. });
  1187. }else{
  1188. layout.desktop.openApplication(null, "portal.Portal", {
  1189. "portalId": json.data.id,
  1190. "parameters": par,
  1191. "appId": "portal.Portal"+json.data.id
  1192. })
  1193. }
  1194. }
  1195. });
  1196. },
  1197. "openCMS": function(name){
  1198. var action = MWF.Actions.get("x_cms_assemble_control");
  1199. action.getColumn(name, function(json){
  1200. if (json.data){
  1201. layout.desktop.openApplication(null, "cms.Module", {
  1202. "columnId": json.data.id,
  1203. "appId": "cms.Module"+json.data.id
  1204. });
  1205. }
  1206. });
  1207. },
  1208. "openProcess": function(name){
  1209. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1210. action.getApplication(name, function(json){
  1211. if (json.data){
  1212. layout.desktop.openApplication(null, "process.Application", {
  1213. "id": json.data.id,
  1214. "appId": "process.Application"+json.data.id
  1215. });
  1216. }
  1217. });
  1218. },
  1219. "openApplication":function(name, options){
  1220. layout.desktop.openApplication(null, name, options);
  1221. },
  1222. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
  1223. var column = columnOrOptions;
  1224. var onAfterPublish, onPostPublish;
  1225. if (typeOf(columnOrOptions) == "object") {
  1226. column = columnOrOptions.column;
  1227. category = columnOrOptions.category;
  1228. data = columnOrOptions.data;
  1229. identity = columnOrOptions.identity;
  1230. callback = columnOrOptions.callback;
  1231. target = columnOrOptions.target;
  1232. latest = columnOrOptions.latest;
  1233. selectColumnEnable = columnOrOptions.selectColumnEnable;
  1234. ignoreTitle = columnOrOptions.ignoreTitle;
  1235. onAfterPublish = columnOrOptions.onAfterPublish;
  1236. onPostPublish = columnOrOptions.onPostPublish;
  1237. }
  1238. if (target) {
  1239. if (layout.app && layout.app.inBrowser) {
  1240. layout.app.content.empty();
  1241. layout.app = null;
  1242. }
  1243. }
  1244. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  1245. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  1246. "documentData": data,
  1247. "identity": identity,
  1248. "ignoreTitle": ignoreTitle === true,
  1249. "ignoreDrafted": latest === false,
  1250. "selectColumnEnable": !category || selectColumnEnable === true,
  1251. "restrictToColumn": !!category && selectColumnEnable !== true,
  1252. "categoryFlag": category, //category id or name
  1253. "columnFlag": column, //column id or name,
  1254. "onStarted": function (documentId, data) {
  1255. if (callback) callback();
  1256. },
  1257. "onPostPublish": function () {
  1258. if(onPostPublish)onPostPublish();
  1259. },
  1260. "onAfterPublish": function () {
  1261. if(onAfterPublish)onAfterPublish();
  1262. }
  1263. });
  1264. starter.load();
  1265. })
  1266. },
  1267. "startProcess": function(app, process, data, identity, callback, target, latest){
  1268. if (arguments.length>2){
  1269. for (var i=2; i<arguments.length; i++){
  1270. if (typeOf(arguments[i])=="boolean"){
  1271. target = arguments[i];
  1272. break;
  1273. }
  1274. }
  1275. }
  1276. if (target){
  1277. if (layout.app && layout.app.inBrowser){
  1278. //layout.app.content.empty();
  1279. layout.app.$openWithSelf = true;
  1280. }
  1281. }
  1282. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function(json){
  1283. if (json.data){
  1284. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  1285. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  1286. "workData": data,
  1287. "identity": identity,
  1288. "latest": latest,
  1289. "onStarted": function(data, title, processName){
  1290. var currentTask = [];
  1291. data.each(function(work){
  1292. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  1293. }.bind(this));
  1294. if (currentTask.length==1){
  1295. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  1296. layout.desktop.openApplication(null, "process.Work", options);
  1297. }else{}
  1298. if (callback) callback(data);
  1299. }.bind(this)
  1300. });
  1301. starter.load();
  1302. }.bind(this));
  1303. }
  1304. });
  1305. }
  1306. };
  1307. this.form.currentRouteName = _form.json.currentRouteName;
  1308. this.form.opinion = _form.json.opinion;
  1309. this.target = ev.target;
  1310. this.event = ev.event;
  1311. this.status = ev.status;
  1312. this.session = layout.desktop.session;
  1313. this.Actions = o2.Actions;
  1314. this.query = function(option){
  1315. // options = {
  1316. // "name": "statementName",
  1317. // "data": "json data",
  1318. // "firstResult": 1,
  1319. // "maxResults": 100,
  1320. // "success": function(){},
  1321. // "error": function(){},
  1322. // "async": true or false, default is true
  1323. // }
  1324. if (option){
  1325. var json = (option.data) || {};
  1326. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  1327. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  1328. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  1329. }
  1330. }
  1331. this.Table = MWF.xScript.createTable();
  1332. };
  1333. MWF.xScript.createTable = function(){
  1334. return function(name){
  1335. this.name = name;
  1336. this.action = o2.Actions.get("x_query_assemble_surface");
  1337. this.listRowNext = function(id, count, success, error, async){
  1338. this.action.listRowNext(this.name, id, count, success, error, async);
  1339. };
  1340. this.listRowPrev = function(id, count, success, error, async){
  1341. this.action.listRowPrev(this.name, id, count, success, error, async);
  1342. };
  1343. this.listRowPrev = function(id, count, success, error, async){
  1344. this.action.listRowPrev(this.name, id, count, success, error, async);
  1345. };
  1346. this.listRowSelectWhere = function(where, success, error, async){
  1347. this.action.listRowSelectWhere(this.name, where, success, error, async);
  1348. };
  1349. this.listRowCountWhere = function(where, success, error, async){
  1350. this.action.listRowCountWhere(this.name, where, success, error, async);
  1351. };
  1352. this.deleteRow = function(id, success, error, async){
  1353. this.action.deleteRow(this.name, id, success, error, async);
  1354. };
  1355. this.deleteAllRow = function(success, error, async){
  1356. this.action.deleteAllRow(this.name, success, error, async);
  1357. };
  1358. this.getRow = function(id, success, error, async){
  1359. this.action.getRow(this.name, id, success, error, async);
  1360. };
  1361. this.insertRow = function(data, success, error, async){
  1362. this.action.insertRow(this.name, data, success, error, async);
  1363. };
  1364. this.updateRow = function(id, data, success, error, async){
  1365. this.action.updateRow(this.name, id, data, success, error, async);
  1366. };
  1367. }
  1368. };
  1369. MWF.xScript.JSONData = function(data, callback, key, parent, _form){
  1370. var getter = function(data, callback, k, _self){
  1371. return function(){return (["array","object"].indexOf(typeOf(data[k]))===-1) ? data[k] : new MWF.xScript.JSONData(data[k], callback, k, _self, _form);};
  1372. };
  1373. var setter = function(data, callback, k, _self){
  1374. return function(v){
  1375. data[k] = v;
  1376. //debugger;
  1377. //this.add(k, v, true);
  1378. if (callback) callback(data, k, _self);
  1379. }
  1380. };
  1381. var define = function(){
  1382. var o = {};
  1383. 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])};
  1384. o["length"] = {"get": function(){return Object.keys(data).length;}};
  1385. MWF.defineProperties(this, o);
  1386. var methods = {
  1387. "getKey": {"value": function(){ return key; }},
  1388. "getParent": {"value": function(){ return parent; }},
  1389. "toString": {"value": function() { return data.toString();}},
  1390. "setSection": {"value": function(newKey, newValue){
  1391. this.add(newKey, newValue, true);
  1392. try {
  1393. var path = [this.getKey()];
  1394. p = this.getParent();
  1395. while (p && p.getKey()){
  1396. path.unshift(p.getKey());
  1397. p = p.getParent();
  1398. }
  1399. if (path.length) _form.sectionListObj[path.join(".")] = newKey;
  1400. }catch(e){
  1401. debugger;
  1402. }
  1403. }},
  1404. "add": {"value": function(newKey, newValue, overwrite){
  1405. var flag = true;
  1406. var type = typeOf(data);
  1407. if (type==="array"){
  1408. if (arguments.length<2){
  1409. data.push(newKey);
  1410. newValue = newKey;
  1411. newKey = data.length-1;
  1412. }else{
  1413. if (!newKey && newKey!==0){
  1414. data.push(newValue);
  1415. newKey = data.length-1;
  1416. }else{
  1417. flag = false;
  1418. }
  1419. }
  1420. if (flag){
  1421. var o = {};
  1422. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1423. MWF.defineProperties(this, o);
  1424. }
  1425. this[newKey] = newValue;
  1426. }else if (type==="object"){
  1427. if (!this.hasOwnProperty(newKey)){
  1428. data[newKey] = newValue;
  1429. if (flag){
  1430. var o = {};
  1431. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1432. MWF.defineProperties(this, o);
  1433. }
  1434. this[newKey] = newValue;
  1435. }else{
  1436. if (overwrite) this[newKey] = newValue;
  1437. }
  1438. }
  1439. return this[newKey];
  1440. }},
  1441. "del": {"value": function(delKey){
  1442. if (!this.hasOwnProperty(delKey)) return null;
  1443. delete data[delKey];
  1444. delete this[delKey];
  1445. return this;
  1446. }}
  1447. };
  1448. MWF.defineProperties(this, methods);
  1449. //this.getKey = function(){ return key; };
  1450. //this.getParent = function(){ return parent; };
  1451. //this.toString = function() { return data.toString();};
  1452. //this.add = function(newKey, newValue, overwrite){
  1453. // var flag = true;
  1454. // var type = typeOf(data);
  1455. // if (!this.hasOwnProperty(newKey)){
  1456. // if (type=="array"){
  1457. // if (arguments.length<2){
  1458. // data.push(newKey);
  1459. // newValue = newKey;
  1460. // newKey = data.length-1;
  1461. // }else{
  1462. // debugger;
  1463. // if (!newKey && newKey!=0){
  1464. // data.push(newValue);
  1465. // newKey = data.length-1;
  1466. // }else{
  1467. // flag == false;
  1468. // }
  1469. // }
  1470. // }else{
  1471. // data[newKey] = newValue;
  1472. // }
  1473. // //var valueType = typeOf(newValue);
  1474. // //var newValueData = newValue;
  1475. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  1476. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  1477. // if (flag){
  1478. // var o = {};
  1479. // o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  1480. // MWF.defineProperties(this, o);
  1481. // }
  1482. // this[newKey] = newValue;
  1483. // }else{
  1484. // if (overwrite) this[newKey] = newValue;
  1485. // }
  1486. //
  1487. // //var valueType = typeOf(newValue);
  1488. // //var newValueData = newValue;
  1489. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  1490. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  1491. // //
  1492. // //this[newKey] = newValueData;
  1493. //
  1494. // return this[newKey];
  1495. //};
  1496. //this.del = function(delKey){
  1497. // if (!this.hasOwnProperty(delKey)) return null;
  1498. // delete data[newKey];
  1499. // delete this[newKey];
  1500. // return this;
  1501. //};
  1502. };
  1503. var type = typeOf(data);
  1504. if (type==="object" || type==="array") define.apply(this);
  1505. };
  1506. //MWF.xScript.createDict = function(application){
  1507. // return function(name){
  1508. // var applicationId = application;
  1509. // this.name = name;
  1510. // //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  1511. // var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1512. //
  1513. // this.get = function(path, success, failure){
  1514. // debugger;
  1515. // var value = null;
  1516. // if (path){
  1517. // var arr = path.split(/\./g);
  1518. // var ar = arr.map(function(v){
  1519. // return encodeURIComponent(v);
  1520. // });
  1521. // //var p = path.replace(/\./g, "/");
  1522. // var p = ar.join("/");
  1523. // action.getDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  1524. // value = json.data;
  1525. // if (success) success(json.data);
  1526. // }, function(xhr, text, error){
  1527. // if (failure) failure(xhr, text, error);
  1528. // }, false);
  1529. // }else{
  1530. // action.getDictRoot(encodeURIComponent(this.name), applicationId, function(json){
  1531. // value = json.data;
  1532. // if (success) success(json.data);
  1533. // }, function(xhr, text, error){
  1534. // if (failure) failure(xhr, text, error);
  1535. // }, false);
  1536. // }
  1537. //
  1538. // return value;
  1539. // };
  1540. //
  1541. // this.set = function(path, value, success, failure){
  1542. // var p = path.replace(/\./g, "/");
  1543. // action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1544. // if (success) success(json.data);
  1545. // }, function(xhr, text, error){
  1546. // if (failure) failure(xhr, text, error);
  1547. // });
  1548. // };
  1549. // this.add = function(path, value, success, failure){
  1550. // var p = path.replace(/\./g, "/");
  1551. // action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1552. // if (success) success(json.data);
  1553. // }, function(xhr, text, error){
  1554. // if (failure) failure(xhr, text, error);
  1555. // });
  1556. // };
  1557. // this["delete"] = function(path, success, failure){
  1558. // var p = path.replace(/\./g, "/");
  1559. // action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  1560. // if (success) success(json.data);
  1561. // }, function(xhr, text, error){
  1562. // if (failure) failure(xhr, text, error);
  1563. // });
  1564. // };
  1565. // this.destory = this["delete"];
  1566. // }
  1567. //};
  1568. var dictLoaded = {};
  1569. MWF.xScript.createDict = function(application){
  1570. //optionsOrName : {
  1571. // type : "", //默认为process, 可以为 process cms
  1572. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  1573. // name : "", // 数据字典名称/别名/id
  1574. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  1575. //}
  1576. //或者name: "" // 数据字典名称/别名/id
  1577. return function(optionsOrName){
  1578. var options = optionsOrName;
  1579. if( typeOf( options ) == "string" ){
  1580. options = { name : options };
  1581. }
  1582. var name = this.name = options.name;
  1583. var type = ( options.type && options.application ) ? options.type : "process";
  1584. var applicationId = options.application || application;
  1585. var enableAnonymous = options.enableAnonymous || false;
  1586. var key = name+type+applicationId+enableAnonymous
  1587. if (!dictLoaded[key]) dictLoaded[key] = {};
  1588. this.dictData = dictLoaded[key];
  1589. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  1590. if( type == "cms" ){
  1591. var action = MWF.Actions.get("x_cms_assemble_control");
  1592. }else{
  1593. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1594. }
  1595. var encodePath = function( path ){
  1596. var arr = path.split(/\./g);
  1597. var ar = arr.map(function(v){
  1598. return encodeURIComponent(v);
  1599. });
  1600. return ar.join("/");
  1601. };
  1602. this.get = function(path, success, failure, async){
  1603. var value = null;
  1604. if (path){
  1605. if (this.dictData[path]){
  1606. if (success) success(this.dictData[path]);
  1607. return this.dictData[path];
  1608. }
  1609. var p = encodePath( path );
  1610. //var p = path.replace(/\./g, "/");
  1611. action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  1612. value = json.data;
  1613. this.dictData[path] = value;
  1614. if (success) success(json.data);
  1615. }.bind(this), function(xhr, text, error){
  1616. if (failure) failure(xhr, text, error);
  1617. }, !!async, false);
  1618. }else{
  1619. if (this.dictData["root"]){
  1620. if (success) success(this.dictData["root"]);
  1621. return this.dictData["root"];
  1622. }
  1623. action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  1624. value = json.data;
  1625. this.dictData["root"] = value;
  1626. if (success) success(json.data);
  1627. }.bind(this), function(xhr, text, error){
  1628. if (failure) failure(xhr, text, error);
  1629. }, !!async);
  1630. }
  1631. return value;
  1632. };
  1633. this.set = function(path, value, success, failure){
  1634. var p = encodePath( path );
  1635. //var p = path.replace(/\./g, "/");
  1636. action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1637. if (success) success(json.data);
  1638. }, function(xhr, text, error){
  1639. if (failure) failure(xhr, text, error);
  1640. }, false, false);
  1641. };
  1642. this.add = function(path, value, success, failure){
  1643. var p = encodePath( path );
  1644. //var p = path.replace(/\./g, "/");
  1645. action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  1646. if (success) success(json.data);
  1647. }, function(xhr, text, error){
  1648. if (failure) failure(xhr, text, error);
  1649. }, false, false);
  1650. };
  1651. this["delete"] = function(path, success, failure){
  1652. var p = encodePath( path );
  1653. //var p = path.replace(/\./g, "/");
  1654. action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  1655. if (success) success(json.data);
  1656. }, function(xhr, text, error){
  1657. if (failure) failure(xhr, text, error);
  1658. }, false, false);
  1659. };
  1660. this.destory = this["delete"];
  1661. }
  1662. };