ViewEnvironment.js 79 KB

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