PageEnvironment.js 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  262. listPersonWithUnit: function(name, nested){
  263. getOrgActions();
  264. var data = {"unitList": getNameFlag(name)};
  265. var v = null;
  266. if (nested){
  267. orgActions.listPersonWithUnitNested(data, function(json){v = json.data;}, null, false);
  268. }else{
  269. orgActions.listPersonWithUnitDirect(data, function(json){v = json.data;}, null, false);
  270. }
  271. return v;
  272. },
  273. //根据属性查询人员--返回人员的对象数组
  274. //name string 属性名
  275. //value string 属性值
  276. listPersonWithAttribute: function(name, value){
  277. getOrgActions();
  278. var data = {"name": name, "attribute": value};
  279. var v = null;
  280. orgActions.listPersonWithAttribute(data, function(json){v = json.data;}, null, false);
  281. return v;
  282. },
  283. //根据属性查询人员--返回人员的全称数组
  284. //name string 属性名
  285. //value string 属性值
  286. listPersonNameWithAttribute: function(name, value){
  287. getOrgActions();
  288. var data = {"name": name, "attribute": value};
  289. var v = null;
  290. orgActions.listPersonWithAttributeValue(data, function(json){v = json.data.personList;}, null, false);
  291. return v;
  292. },
  293. //人员属性************
  294. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  295. appendPersonAttribute: function(person, attr, values, success, failure){
  296. getOrgActions();
  297. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  298. var data = {"attributeList":values,"name":attr,"person":personFlag};
  299. orgActions.appendPersonAttribute(data, function(json){
  300. if (json.data.value){
  301. if (success) success();
  302. }else{
  303. if (failure) failure(null, "", "append values failed");
  304. }
  305. }, function(xhr, text, error){
  306. if (failure) failure(xhr, text, error);
  307. }, false);
  308. },
  309. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  310. setPersonAttribute: function(person, attr, values, success, failure){
  311. getOrgActions();
  312. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  313. var data = {"attributeList":values,"name":attr,"person":personFlag};
  314. orgActions.setPersonAttribute(data, function(json){
  315. if (json.data.value){
  316. if (success) success();
  317. }else{
  318. if (failure) failure(null, "", "append values failed");
  319. }
  320. }, function(xhr, text, error){
  321. if (failure) failure(xhr, text, error);
  322. }, false);
  323. },
  324. //获取人员属性值
  325. getPersonAttribute: function(person, attr){
  326. getOrgActions();
  327. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  328. var data = {"name":attr,"person":personFlag};
  329. var v = null;
  330. orgActions.getPersonAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  331. return v;
  332. },
  333. //列出人员所有属性的名称
  334. listPersonAttributeName: function(name){
  335. getOrgActions();
  336. var data = {"personList":getNameFlag(name)};
  337. var v = null;
  338. orgActions.listPersonAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  339. return v;
  340. },
  341. //列出人员的所有属性
  342. listPersonAllAttribute: function(name){
  343. getOrgActions();
  344. var data = {"personList":getNameFlag(name)};
  345. var v = null;
  346. orgActions.listPersonAllAttribute(data, function(json){v = json.data;}, null, false);
  347. return v;
  348. },
  349. //身份**********
  350. //获取身份
  351. getIdentity: function(name){
  352. getOrgActions();
  353. var data = {"identityList":getNameFlag(name)};
  354. var v = null;
  355. orgActions.listIdentity(data, function(json){v = json.data;}, null, false);
  356. return (v && v.length===1) ? v[0] : v;
  357. },
  358. //列出人员的身份
  359. listIdentityWithPerson: function(name){
  360. getOrgActions();
  361. var data = {"personList":getNameFlag(name)};
  362. var v = null;
  363. orgActions.listIdentityWithPerson(data, function(json){v = json.data;}, null, false);
  364. return v;
  365. },
  366. //查询组织成员身份--返回身份的对象数组
  367. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  368. listIdentityWithUnit: function(name, nested){
  369. getOrgActions();
  370. var data = {"unitList": getNameFlag(name)};
  371. var v = null;
  372. if (nested){
  373. orgActions.listIdentityWithUnitNested(data, function(json){v = json.data;}, null, false);
  374. }else{
  375. orgActions.listIdentityWithUnitDirect(data, function(json){v = json.data;}, null, false);
  376. }
  377. return v;
  378. },
  379. //组织**********
  380. //获取组织
  381. getUnit: function(name){
  382. getOrgActions();
  383. var data = {"unitList":getNameFlag(name)};
  384. var v = null;
  385. orgActions.listUnit(data, function(json){v = json.data;}, null, false);
  386. return (v && v.length===1) ? v[0] : v;
  387. },
  388. //查询组织的下级--返回组织的对象数组
  389. //nested 布尔 true嵌套下级;false直接下级;默认false;
  390. listSubUnit: function(name, nested){
  391. getOrgActions();
  392. var data = {"unitList": getNameFlag(name)};
  393. var v = null;
  394. if (nested){
  395. orgActions.listUnitSubNested(data, function(json){v = json.data;}, null, false);
  396. }else{
  397. orgActions.listUnitSubDirect(data, function(json){v = json.data;}, null, false);
  398. }
  399. return v;
  400. },
  401. //查询组织的上级--返回组织的对象数组
  402. //nested 布尔 true嵌套上级;false直接上级;默认false;
  403. listSupUnit: function(name, nested){
  404. getOrgActions();
  405. var data = {"unitList": getNameFlag(name)};
  406. var v = null;
  407. if (nested){
  408. orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  409. }else{
  410. orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  411. }
  412. return v;
  413. },
  414. //根据个人身份获取组织
  415. //flag 数字 表示获取第几层的组织
  416. // 字符串 表示获取指定类型的组织
  417. // 空 表示获取直接所在的组织
  418. getUnitByIdentity: function(name, flag){
  419. getOrgActions();
  420. var getUnitMethod = "current";
  421. var v;
  422. if (flag){
  423. if (typeOf(flag)==="string") getUnitMethod = "type";
  424. if (typeOf(flag)==="number") getUnitMethod = "level";
  425. }
  426. switch (getUnitMethod){
  427. case "current":
  428. var data = {"identityList":getNameFlag(name)};
  429. orgActions.listUnitWithIdentity(data, function(json){ v = json.data; v=(v&&v.length===1) ? v[0] : v }, null, false);
  430. break;
  431. case "type":
  432. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  433. orgActions.getUnitWithIdentityAndType(data, function(json){ v = json.data; }, null, false);
  434. break;
  435. case "level":
  436. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  437. orgActions.getUnitWithIdentityAndLevel(data, function(json){ v = json.data; }, null, false);
  438. break;
  439. }
  440. return v;
  441. },
  442. //列出身份所在组织的所有上级组织
  443. listAllSupUnitWithIdentity: function(name){
  444. getOrgActions();
  445. var data = {"identityList":getNameFlag(name)};
  446. var v = null;
  447. orgActions.listUnitSupNestedWithIdentity(data, function(json){v = json.data;}, null, false);
  448. return v;
  449. },
  450. //获取人员所在的所有组织
  451. listUnitWithPerson: function(name){
  452. getOrgActions();
  453. var data = {"personList":getNameFlag(name)};
  454. var v = null;
  455. orgActions.listUnitWithPerson(data, function(json){v = json.data;}, null, false);
  456. return v;
  457. },
  458. //列出身份所在组织的所有上级组织
  459. listAllSupUnitWithPerson: function(name){
  460. getOrgActions();
  461. var data = {"personList":getNameFlag(name)};
  462. var v = null;
  463. orgActions.listUnitSupNestedWithPerson(data, function(json){v = json.data;}, null, false);
  464. return v;
  465. },
  466. //根据组织属性,获取所有符合的组织
  467. listUnitWithAttribute: function(name, attribute){
  468. getOrgActions();
  469. var data = {"name":name,"attribute":attribute};
  470. var v = null;
  471. orgActions.listUnitWithAttribute(data, function(json){v = json.data;}, null, false);
  472. return v;
  473. },
  474. //根据组织职务,获取所有符合的组织
  475. listUnitWithDuty: function(name, id){
  476. getOrgActions();
  477. var data = {"name":"","identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  478. var v = null;
  479. orgActions.listUnitWithDuty(data, function(json){v = json.data;}, null, false);
  480. return v;
  481. },
  482. //列出顶层组织
  483. listTopUnit: function(){
  484. var action = MWF.Actions.get("x_organization_assemble_control");
  485. var v = null;
  486. action.listTopUnit(function(json){
  487. v = json.data;
  488. }, null, false);
  489. return v;
  490. },
  491. //组织职务***********
  492. //获取指定的组织职务的身份
  493. getDuty: function(duty, id){
  494. getOrgActions();
  495. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  496. var v = null;
  497. orgActions.getDuty(data, function(json){v = json.data;}, null, false);
  498. return v;
  499. },
  500. //获取身份的所有职务名称
  501. listDutyNameWithIdentity: function(name){
  502. getOrgActions();
  503. var data = {"identityList":getNameFlag(name)};
  504. var v = null;
  505. orgActions.listDutyNameWithIdentity(data, function(json){v = json.data.nameList;}, null, false);
  506. return v;
  507. },
  508. //获取组织的所有职务名称
  509. listDutyNameWithUnit: function(name){
  510. getOrgActions();
  511. var data = {"unitList":getNameFlag(name)};
  512. var v = null;
  513. orgActions.listDutyNameWithUnit(data, function(json){v = json.data.nameList;}, null, false);
  514. return v;
  515. },
  516. //获取组织的所有职务
  517. listUnitAllDuty: function(name){
  518. getOrgActions();
  519. var data = {"unitList":getNameFlag(name)};
  520. var v = null;
  521. orgActions.listUnitAllDuty(data, function(json){v = json.data;}, null, false);
  522. return v;
  523. },
  524. //组织属性**************
  525. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  526. appendUnitAttribute: function(unit, attr, values, success, failure){
  527. getOrgActions();
  528. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  529. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  530. orgActions.appendUnitAttribute(data, function(json){
  531. if (json.data.value){
  532. if (success) success();
  533. }else{
  534. if (failure) failure(null, "", "append values failed");
  535. }
  536. }, function(xhr, text, error){
  537. if (failure) failure(xhr, text, error);
  538. }, false);
  539. },
  540. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  541. setUnitAttribute: function(unit, attr, values, success, failure){
  542. getOrgActions();
  543. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  544. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  545. orgActions.setUnitAttribute(data, function(json){
  546. if (json.data.value){
  547. if (success) success();
  548. }else{
  549. if (failure) failure(null, "", "append values failed");
  550. }
  551. }, function(xhr, text, error){
  552. if (failure) failure(xhr, text, error);
  553. }, false);
  554. },
  555. //获取组织属性值
  556. getUnitAttribute: function(unit, attr){
  557. getOrgActions();
  558. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  559. var data = {"name":attr,"unit":unitFlag};
  560. var v = null;
  561. orgActions.getUnitAttribute(data, function(json){v = json.data.attributeList;}, null, false);
  562. return v;
  563. },
  564. //列出组织所有属性的名称
  565. listUnitAttributeName: function(name){
  566. getOrgActions();
  567. var data = {"unitList":getNameFlag(name)};
  568. var v = null;
  569. orgActions.listUnitAttributeName(data, function(json){v = json.data.nameList;}, null, false);
  570. return v;
  571. },
  572. //列出组织的所有属性
  573. listUnitAllAttribute: function(name){
  574. getOrgActions();
  575. var data = {"unitList":getNameFlag(name)};
  576. var v = null;
  577. orgActions.listUnitAllAttribute(data, function(json){v = json.data;}, null, false);
  578. return v;
  579. }
  580. };
  581. this.Action = (function(){
  582. var actions = [];
  583. return function(root, json){
  584. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  585. action.getActions = function(callback){
  586. if (!this.actions) this.actions = {};
  587. Object.merge(this.actions, json);
  588. if (callback) callback();
  589. };
  590. this.invoke = function(option){
  591. action.invoke(option)
  592. }
  593. }
  594. })();
  595. this.service = {
  596. "jaxwsClient": {},
  597. "jaxrsClient":{}
  598. };
  599. var lookupAction = null;
  600. var getLookupAction = function(callback){
  601. if (!lookupAction){
  602. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  603. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  604. lookupAction.getActions = function(actionCallback){
  605. this.actions = {
  606. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  607. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  608. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  609. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  610. };
  611. if (actionCallback) actionCallback();
  612. }
  613. if (callback) callback();
  614. });
  615. }else{
  616. if (callback) callback();
  617. }
  618. };
  619. this.view = {
  620. "lookup": function(view, callback, async){
  621. var filterList = {"filterList": (view.filter || null)};
  622. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function(json){
  623. var data = {
  624. "grid": json.data.grid || json.data.groupGrid,
  625. "groupGrid": json.data.groupGrid
  626. };
  627. if (callback) callback(data);
  628. }, null, async);
  629. },
  630. "lookupV1": function(view, callback){
  631. getLookupAction(function(){
  632. lookupAction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
  633. var data = {
  634. "grid": json.data.grid,
  635. "groupGrid": json.data.groupGrid
  636. };
  637. if (callback) callback(data);
  638. }.bind(this)});
  639. }.bind(this));
  640. },
  641. "select": function(view, callback, options){
  642. if (view.view){
  643. var viewJson = {
  644. "application": view.application || _form.json.application,
  645. "viewName": view.view || "",
  646. "isTitle": (view.isTitle===false) ? "no" : "yes",
  647. "select": (view.isMulti===false) ? "single" : "multi",
  648. "filter": view.filter
  649. };
  650. if (!options) options = {};
  651. options.width = view.width;
  652. options.height = view.height;
  653. options.title = view.caption;
  654. var width = options.width || "700";
  655. var height = options.height || "400";
  656. if (layout.mobile){
  657. var size = document.body.getSize();
  658. width = size.x;
  659. height = size.y;
  660. options.style = "viewmobile";
  661. }
  662. width = width.toInt();
  663. height = height.toInt();
  664. var size = _form.app.content.getSize();
  665. var x = (size.x-width)/2;
  666. var y = (size.y-height)/2;
  667. if (x<0) x = 0;
  668. if (y<0) y = 0;
  669. if (layout.mobile){
  670. x = 20;
  671. y = 0;
  672. }
  673. var _self = this;
  674. MWF.require("MWF.xDesktop.Dialog", function(){
  675. var dlg = new MWF.xDesktop.Dialog({
  676. "title": options.title || "select view",
  677. "style": options.style || "view",
  678. "top": y,
  679. "left": x-20,
  680. "fromTop":y,
  681. "fromLeft": x-20,
  682. "width": width,
  683. "height": height,
  684. "html": "<div style='height: 100%;'></div>",
  685. "maskNode": _form.app.content,
  686. "container": _form.app.content,
  687. "buttonList": [
  688. {
  689. "text": MWF.LP.process.button.ok,
  690. "action": function(){
  691. //if (callback) callback(_self.view.selectedItems);
  692. if (callback) callback(_self.view.getData());
  693. this.close();
  694. }
  695. },
  696. {
  697. "text": MWF.LP.process.button.cancel,
  698. "action": function(){this.close();}
  699. }
  700. ]
  701. });
  702. dlg.show();
  703. if (layout.mobile){
  704. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  705. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  706. if (backAction) backAction.addEvent("click", function(e){
  707. dlg.close();
  708. }.bind(this));
  709. if (okAction) okAction.addEvent("click", function(e){
  710. //if (callback) callback(this.view.selectedItems);
  711. if (callback) callback(this.view.getData());
  712. dlg.close();
  713. }.bind(this));
  714. }
  715. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  716. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, {"style": "select"});
  717. }.bind(this));
  718. }.bind(this));
  719. }
  720. }
  721. };
  722. //include 引用脚本
  723. //optionsOrName : {
  724. // type : "", 默认为portal, 可以为 portal process cms
  725. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  726. // name : "" // 脚本名称/别名/id
  727. //}
  728. //或者name: "" // 脚本名称/别名/id
  729. // if( !window.includedScripts ){
  730. // var includedScripts = window.includedScripts = [];
  731. // }else{
  732. // var includedScripts = window.includedScripts;
  733. // }
  734. var includedScripts = [];
  735. this.include = function( optionsOrName , callback ){
  736. var options = optionsOrName;
  737. if( typeOf( options ) == "string" ){
  738. options = { name : options };
  739. }
  740. var name = options.name;
  741. var type = ( options.type && options.application ) ? options.type : "portal";
  742. var application = options.application || _form.json.application;
  743. var key = type +"-" + application + "-" + name;
  744. if (includedScripts.indexOf( key )> -1){
  745. if (callback) callback.apply(this);
  746. return;
  747. }
  748. //if (includedScripts.indexOf( name )> -1){
  749. // if (callback) callback.apply(this);
  750. // return;
  751. //}
  752. var scriptAction;
  753. switch ( type ){
  754. case "portal" :
  755. if( this.scriptActionPortal ){
  756. scriptAction = this.scriptActionPortal;
  757. }else{
  758. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  759. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  760. }
  761. break;
  762. case "process" :
  763. if( this.scriptActionProcess ){
  764. scriptAction = this.scriptActionProcess;
  765. }else{
  766. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  767. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  768. }
  769. break;
  770. case "cms" :
  771. if( this.scriptActionCMS ){
  772. scriptAction = this.scriptActionCMS;
  773. }else{
  774. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  775. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  776. }
  777. break;
  778. }
  779. scriptAction.getScriptByName( application, name, includedScripts, function(json){
  780. if (json.data){
  781. includedScripts.push( key );
  782. includedScripts = includedScripts.concat(json.data.importedList);
  783. MWF.Macro.exec(json.data.text, this);
  784. if (callback) callback.apply(this);
  785. }else{
  786. if (callback) callback.apply(this);
  787. }
  788. }.bind(this), null, false);
  789. };
  790. //var includedScripts = [];
  791. //this.include = function(name, callback){
  792. // if (includedScripts.indexOf(name)==-1){
  793. // if (!this.scriptAction){
  794. // MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  795. // this.scriptAction = new MWF.xScript.Actions.PortalScriptActions();
  796. // }
  797. // this.scriptAction.getScriptByName(_form.json.application, name, includedScripts, function(json){
  798. // if (json.data){
  799. // includedScripts = includedScripts.concat(json.data.importedList);
  800. // MWF.Macro.exec(json.data.text, this);
  801. // if (callback) callback.apply(this);
  802. // }else{
  803. // if (callback) callback.apply(this);
  804. // }
  805. // }.bind(this), null, false);
  806. // }else{
  807. // if (callback) callback.apply(this);
  808. // }
  809. //}.bind(this);
  810. this.define = function(name, fun, overwrite){
  811. var over = true;
  812. if (overwrite===false) over = false;
  813. var o = {};
  814. o[name] = {"value": fun, "configurable": over};
  815. MWF.defineProperties(this, o);
  816. }.bind(this);
  817. //仅前台对象-----------------------------------------
  818. //form
  819. this.page = this.form = {
  820. "getInfor": function(){return ev.pageInfor;},
  821. "infor": ev.pageInfor,
  822. "getApp": function(){return _form.app;},
  823. "app": _form.app,
  824. "node": function(){return _form.node;},
  825. //"readonly": _form.options.readonly,
  826. "get": function(name){return (_form.all) ? _form.all[name] : null;},
  827. "getWidgetModule": function(widget, moduleName){
  828. if( !_form.widgetModules || !_form.widgetModules[widget] )return null;
  829. var module = _form.widgetModules[widget][moduleName];
  830. return module || null;
  831. },
  832. "getField": function(name){return _forms[name];},
  833. "getAction": function(){return _form.workAction},
  834. "getDesktop": function(){return _form.app.desktop},
  835. "getData": function(){return new MWF.xScript.JSONData(_form.getData());},
  836. //"save": function(callback){_form.saveWork(callback);},
  837. "close": function(){_form.closeWork();},
  838. "print": function(application, form){
  839. _form.printWork(application, form);
  840. },
  841. "confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
  842. // var p = MWF.getCenter({"x": width, "y": height});
  843. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  844. // _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  845. if ((arguments.length<=1) || o2.typeOf(arguments[1])==="string"){
  846. var p = MWF.getCenter({"x": width, "y": height});
  847. e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  848. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  849. }else{
  850. e = (arguments.length>1) ? arguments[1] : null;
  851. title = (arguments.length>2) ? arguments[2] : null;
  852. text = (arguments.length>3) ? arguments[3] : null;
  853. width = (arguments.length>4) ? arguments[4] : null;
  854. height = (arguments.length>5) ? arguments[5] : null;
  855. ok = (arguments.length>6) ? arguments[6] : null;
  856. cancel = (arguments.length>7) ? arguments[7] : null;
  857. callback = (arguments.length>8) ? arguments[8] : null;
  858. mask = (arguments.length>9) ? arguments[9] : null;
  859. style = (arguments.length>10) ? arguments[10] : null;
  860. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  861. }
  862. },
  863. "notice": function(content, type, target, where, offset, option){
  864. _form.notice(content, type, target, where, offset, option);
  865. },
  866. "addEvent": function(e, f){_form.addEvent(e, f);},
  867. "openWindow": function(form, app){
  868. _form.openWindow(form, app);
  869. },
  870. "toPage": function(name, par){
  871. _form.app.toPage(name, par);
  872. },
  873. "toPortal": function(portal, page, par){
  874. _form.app.toPortal(portal, page, par);
  875. },
  876. "openWork": function(id, completedId, title, options){
  877. var op = options || {};
  878. op.workId = id;
  879. op.workCompletedId = completedId;
  880. op.docTitle = title;
  881. op.appId = "process.Work"+(op.workId || op.workCompletedId);
  882. return layout.desktop.openApplication(this.event, "process.Work", op);
  883. },
  884. "openJob": function(id, choice, options){
  885. var workData = null;
  886. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  887. if (json.data) workData = json.data;
  888. }.bind(this), null, false);
  889. if (workData){
  890. var len = workData.workList.length + workData.workCompletedList.length;
  891. if (len){
  892. if (len>1 && choice){
  893. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  894. workData.workList.each(function(work){
  895. var workNode = new Element("div", {
  896. "styles": {
  897. "background": "#ffffff",
  898. "border-radius": "10px",
  899. "clear": "both",
  900. "margin-bottom": "10px",
  901. "height": "40px",
  902. "padding": "10px 10px"
  903. }
  904. }).inject(node);
  905. 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>" +
  906. "<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>"+
  907. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  908. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  909. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  910. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  911. workNode.set("html", html);
  912. var action = workNode.getElement(".MWFAction");
  913. action.store("work", work);
  914. action.addEvent("click", function(e){
  915. var work = e.target.retrieve("work");
  916. if (work) this.openWork(work.id, null, work.title, options);
  917. dlg.close();
  918. }.bind(this));
  919. }.bind(this));
  920. workData.workCompletedList.each(function(work){
  921. var workNode = new Element("div", {
  922. "styles": {
  923. "background": "#ffffff",
  924. "border-radius": "10px",
  925. "clear": "both",
  926. "margin-bottom": "10px",
  927. "height": "40px",
  928. "padding": "10px 10px"
  929. }
  930. }).inject(node);
  931. 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>" +
  932. "<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>"+
  933. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  934. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  935. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  936. workNode.set("html", html);
  937. var action = workNode.getElement(".MWFAction");
  938. action.store("work", work);
  939. action.addEvent("click", function(e){
  940. var work = e.target.retrieve("work");
  941. if (work) this.openWork(null, work.id, work.title, options);
  942. dlg.close();
  943. }.bind(this));
  944. }.bind(this));
  945. var height = node.getSize().y+20;
  946. if (height>600) height = 600;
  947. var dlg = o2.DL.open({
  948. "title": o2.LP.widget.choiceWork,
  949. "style" : "user",
  950. "isResize": false,
  951. "content": node,
  952. "buttonList": [
  953. {
  954. "type" : "cancel",
  955. "text": o2.LP.widget.close,
  956. "action": function(){dlg.close();}
  957. }
  958. ]
  959. });
  960. }else{
  961. if (workData.workList.length){
  962. var work = workData.workList[0];
  963. return this.openWork(work.id, null, work.title, options);
  964. }else{
  965. var work = workData.workCompletedList[0];
  966. return this.openWork(null, work.id, work.title, options);
  967. }
  968. }
  969. }
  970. }
  971. },
  972. "openDocument": function(id, title, options){
  973. var op = options || {};
  974. op.documentId = id;
  975. op.docTitle = title || "";
  976. layout.desktop.openApplication(this.event, "cms.Document", op);
  977. },
  978. "openPortal": function(name, page, par){
  979. var action = MWF.Actions.get("x_portal_assemble_surface");
  980. action.getApplication(name, function(json){
  981. if (json.data){
  982. if (page){
  983. action.getPageByName(page, json.data.id, function(pageJson){
  984. layout.desktop.openApplication(null, "portal.Portal", {
  985. "portalId": json.data.id,
  986. "pageId": (pageJson.data) ? pageJson.data.id : "",
  987. "parameters": par,
  988. "appId": "portal.Portal"+json.data.id
  989. })
  990. });
  991. }else{
  992. layout.desktop.openApplication(null, "portal.Portal", {
  993. "portalId": json.data.id,
  994. "parameters": par,
  995. "appId": "portal.Portal"+json.data.id
  996. })
  997. }
  998. }
  999. });
  1000. },
  1001. "openCMS": function(name){
  1002. var action = MWF.Actions.get("x_cms_assemble_control");
  1003. action.getColumn(name, function(json){
  1004. if (json.data){
  1005. layout.desktop.openApplication(null, "cms.Module", {
  1006. "columnId": json.data.id,
  1007. "appId": "cms.Module"+json.data.id
  1008. });
  1009. }
  1010. });
  1011. },
  1012. "openProcess": function(name){
  1013. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1014. action.getApplication(name, function(json){
  1015. if (json.data){
  1016. layout.desktop.openApplication(null, "process.Application", {
  1017. "id": json.data.id,
  1018. "appId": "process.Application"+json.data.id
  1019. });
  1020. }
  1021. });
  1022. },
  1023. "openApplication":function(name, options){
  1024. layout.desktop.openApplication(null, name, options);
  1025. },
  1026. "createDocument" : function(columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle){
  1027. var column = columnOrOptions;
  1028. if( typeOf( columnOrOptions ) == "object" ){
  1029. column = columnOrOptions.column;
  1030. category = columnOrOptions.category;
  1031. data = columnOrOptions.data;
  1032. identity = columnOrOptions.identity;
  1033. callback = columnOrOptions.callback;
  1034. target = columnOrOptions.target;
  1035. latest = columnOrOptions.latest;
  1036. selectColumnEnable = columnOrOptions.selectColumnEnable;
  1037. ignoreTitle = columnOrOptions.ignoreTitle;
  1038. }
  1039. if (target){
  1040. if (layout.app && layout.app.inBrowser){
  1041. layout.app.content.empty();
  1042. layout.app = null;
  1043. }
  1044. }
  1045. MWF.xDesktop.requireApp("cms.Index", "Newer", function(){
  1046. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  1047. "documentData": data,
  1048. "identity": identity,
  1049. "ignoreTitle" : ignoreTitle === true,
  1050. "ignoreDrafted" : latest === false,
  1051. "selectColumnEnable" : !category || selectColumnEnable === true,
  1052. "restrictToColumn" : !!category && selectColumnEnable !== true,
  1053. "categoryFlag" : category, //category id or name
  1054. "columnFlag" : column, //column id or name,
  1055. "onStarted" : function( documentId, data ){
  1056. if(callback)callback();
  1057. },
  1058. "onPostLoad" : function(){
  1059. },
  1060. "onPostPublish" : function(){
  1061. }
  1062. });
  1063. starter.load();
  1064. })
  1065. },
  1066. "startProcess": function(app, process, data, identity, callback, target, latest){
  1067. debugger;
  1068. if (arguments.length>2){
  1069. for (var i=2; i<arguments.length; i++){
  1070. if (typeOf(arguments[i])=="boolean"){
  1071. target = arguments[i];
  1072. break;
  1073. }
  1074. }
  1075. }
  1076. if (target){
  1077. if (layout.app && layout.app.inBrowser){
  1078. //layout.app.content.empty();
  1079. layout.app.$openWithSelf = true;
  1080. }
  1081. }
  1082. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function(json){
  1083. if (json.data){
  1084. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  1085. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  1086. "workData": data,
  1087. "identity": identity,
  1088. "latest": latest,
  1089. "onStarted": function(data, title, processName){
  1090. var currentTask = [];
  1091. data.each(function(work){
  1092. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  1093. }.bind(this));
  1094. if (currentTask.length==1){
  1095. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  1096. layout.desktop.openApplication(null, "process.Work", options);
  1097. }else{}
  1098. if (callback) callback(data);
  1099. }.bind(this)
  1100. });
  1101. starter.load();
  1102. }.bind(this));
  1103. }
  1104. });
  1105. },
  1106. "parameters": _form.options.parameters,
  1107. "getWidgetPrameters" : function(){
  1108. if( !this.target )return null;
  1109. if( !this.target.widget )return null;
  1110. if( !this.widgetParameters )return null;
  1111. var pageId = this.target.widget.json.id;
  1112. return this.widgetParameters[pageId];
  1113. }.bind(this)
  1114. //"app": _form.app
  1115. };
  1116. this.form.currentRouteName = _form.json.currentRouteName;
  1117. this.form.opinion = _form.json.opinion;
  1118. this.target = ev.target;
  1119. this.event = ev.event;
  1120. this.status = ev.status;
  1121. this.session = layout.desktop.session;
  1122. this.Actions = o2.Actions;
  1123. this.query = function(option){
  1124. // options = {
  1125. // "name": "statementName",
  1126. // "data": "json data",
  1127. // "firstResult": 1,
  1128. // "maxResults": 100,
  1129. // "success": function(){},
  1130. // "error": function(){},
  1131. // "async": true or false, default is true
  1132. // }
  1133. if (option){
  1134. var json = (option.data) || {};
  1135. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  1136. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  1137. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  1138. }
  1139. };
  1140. this.Table = MWF.xScript.createTable();
  1141. };