Environment.js 74 KB

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