PageEnvironment.js 78 KB

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