ProcessStarter.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. MWF.require("MWF.widget.Mask", null, false);
  2. MWF.xApplication.process = MWF.xApplication.process || {};
  3. MWF.xApplication.process.TaskCenter = MWF.xApplication.process.TaskCenter || {};
  4. MWF.xDesktop.requireApp("process.TaskCenter", "lp.zh-cn", null, false);
  5. MWF.xApplication.process.TaskCenter.ProcessStarter = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "workData" : null,
  11. "identity": null,
  12. "latest": false
  13. },
  14. initialize: function(data, app, options){
  15. this.setOptions(options);
  16. this.path = "../x_component_process_TaskCenter/$ProcessStarter/";
  17. this.cssPath = "../x_component_process_TaskCenter/$ProcessStarter/"+this.options.style+"/css.wcss";
  18. this._loadCss();
  19. MWF.xDesktop.requireApp("process.TaskCenter", "$ProcessStarter."+MWF.language, null, false);
  20. this.lp = MWF.xApplication.process.TaskCenter.ProcessStarter.lp;
  21. this.data = data;
  22. this.app = app;
  23. },
  24. load: function(){
  25. this.getOrgAction(function(){
  26. if (this.app.desktop.session.user.distinguishedName){
  27. this.orgAction.getPerson(function(json){
  28. this.identitys = json.data.woIdentityList || [];
  29. if (this.identitys.length){
  30. if (this.options.identity){
  31. this.identitys = this.identitys.filter(function(id){
  32. var dn = (typeOf(this.options.identity)==="string") ? this.options.identity : this.options.identity.distinguishedName;
  33. return id.distinguishedName===dn;
  34. }.bind(this));
  35. }
  36. if (this.identitys.length){
  37. if (this.identitys.length==1){
  38. var data = {
  39. "title": this.data.name+"-"+this.lp.unnamed,
  40. "identity": this.identitys[0].distinguishedName,
  41. "latest": this.options.latest
  42. };
  43. if( this.options.workData ){
  44. data.data = this.options.workData;
  45. if (data.data.title || data.data.subject) data.title = data.data.title || data.data.subject;
  46. }
  47. this.mask = new MWF.widget.Mask({"style": "desktop"});
  48. this.mask.loadNode(this.app.content);
  49. this.getWorkAction(function(){
  50. this.workAction.startWork(function(json){
  51. debugger;
  52. this.mask.hide();
  53. //this.markNode.destroy();
  54. //this.areaNode.destroy();
  55. this.fireEvent("started", [json.data, data.title, this.data.name]);
  56. if (this.app.refreshAll) this.app.refreshAll();
  57. //this.app.notice(this.lp.processStarted, "success");
  58. // this.app.processConfig();
  59. }.bind(this), null, this.data.id, data);
  60. }.bind(this));
  61. }else{
  62. this.createMarkNode();
  63. this.createAreaNode();
  64. this.createStartNode();
  65. this.areaNode.inject(this.markNode, "after");
  66. this.areaNode.fade("in");
  67. //$("form_startSubject").focus();
  68. this.setStartNodeSize();
  69. this.setStartNodeSizeFun = this.setStartNodeSize.bind(this);
  70. this.app.addEvent("resize", this.setStartNodeSizeFun);
  71. this.fireEvent("selectId");
  72. }
  73. }
  74. }else{
  75. var t = this.lp.noIdentitys.replace("{name}", this.app.desktop.session.user.name);
  76. this.app.notice(t, "error");
  77. }
  78. }.bind(this), null, this.app.desktop.session.user.distinguishedName)
  79. }
  80. }.bind(this));
  81. },
  82. createMarkNode: function(){
  83. this.markNode = new Element("div#mark", {
  84. "styles": this.css.markNode,
  85. "events": {
  86. "mouseover": function(e){e.stopPropagation();},
  87. "mouseout": function(e){e.stopPropagation();}
  88. }
  89. }).inject(this.app.content);
  90. },
  91. createAreaNode: function(){
  92. this.areaNode = new Element("div#area", {
  93. "styles": this.css.areaNode
  94. });
  95. },
  96. createStartNode: function(){
  97. this.createNode = new Element("div", {
  98. "styles": this.css.createNode
  99. }).inject(this.areaNode);
  100. this.createNewNode = new Element("div", {
  101. "styles": this.css.createNewNode
  102. }).inject(this.createNode);
  103. this.createCloseNode = new Element("div", {
  104. "styles": this.css.createCloseNode
  105. }).inject(this.createNode);
  106. this.createCloseNode.addEvent("click", function(e){
  107. this.cancelStartProcess(e);
  108. }.bind(this));
  109. this.formNode = new Element("div", {
  110. "styles": this.css.formNode
  111. }).inject(this.createNode);
  112. var html = "<table width=\"100%\" height=\"90%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\">" +
  113. "<tr><td colSpan=\"2\" style=\"height: 50px; line-height: 50px; text-align: center; font-size: 24px; font-weight: bold\">" +
  114. this.lp.start+" - "+this.data.name+"</td></tr>" +
  115. "<tr><td colSpan=\"2\" style=\"height: 40px; color: #0044cc; line-height: 40px; text-align: center; font-size: 18px; font-weight: bold\">" +
  116. this.lp.selectStartIdentity+"</td></tr>" +
  117. "<tr><td colSpan=\"2\" id=\"form_startIdentity\"></td></tr>" +
  118. "</table>";
  119. this.formNode.set("html", html);
  120. this.identityArea = this.formNode.getElementById("form_startIdentity");
  121. // MWF.xDesktop.requireApp("Organization", "PersonExplorer", function(){
  122. // var o = {
  123. // "data": this.app.desktop.session.user,
  124. // "explorer":{
  125. // "app": {
  126. // "lp":this.lp
  127. // },
  128. // "actions": this.orgAction
  129. // }
  130. // };
  131. var _self = this;
  132. this.identitys.each(function(item){
  133. //if (item.woUnit){
  134. var id = new MWF.xApplication.process.TaskCenter.ProcessStarter.Identity(this.identityArea, item, this, this.css);
  135. id.node.store("identity", id);
  136. id.node.addEvents({
  137. "mouseover": function(){
  138. this.setStyles(_self.css.identityNode_over);
  139. this.getFirst().getLast().setStyles(_self.css.identityInforNameTextNode_over);
  140. this.getFirst().getNext().getFirst().setStyles(_self.css.identityTitleNode_over);
  141. this.getFirst().getNext().getNext().getFirst().setStyles(_self.css.identityTitleNode_over);
  142. //this.getFirst().getNext().getNext().getNext().getFirst().setStyles(_self.css.identityTitleNode_over);
  143. },
  144. "mouseout": function(){
  145. this.setStyles((layout.mobile) ? _self.css.identityNode_mobile : _self.css.identityNode);
  146. this.getFirst().getLast().setStyles(_self.css.identityInforNameTextNode);
  147. this.getFirst().getNext().getFirst().setStyles(_self.css.identityTitleNode);
  148. this.getFirst().getNext().getNext().getFirst().setStyles(_self.css.identityTitleNode);
  149. //this.getFirst().getNext().getNext().getNext().getFirst().setStyles(_self.css.identityTitleNode);
  150. },
  151. "click": function(){
  152. var identity = this.retrieve("identity");
  153. if (identity){
  154. _self.okStartProcess(identity.data.distinguishedName);
  155. }
  156. }
  157. });
  158. // if (id.data.major){
  159. // id.node.setStyles(this.css.identityNode_over);
  160. // id.node.getFirst().getLast().setStyles(this.css.identityInforNameTextNode_over);
  161. // id.node.getFirst().getNext().getFirst().setStyles(this.css.identityTitleNode_over);
  162. // id.node.getFirst().getNext().getNext().getFirst().setStyles(this.css.identityTitleNode_over);
  163. // }
  164. }.bind(this));
  165. if (layout.mobile){
  166. this.areaNode.setStyles(this.css.areaNode_mobile);
  167. this.createNode.setStyles(this.css.createNode_mobile);
  168. }
  169. },
  170. getOrgAction: function(callback){
  171. if (!this.orgAction){
  172. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  173. if (callback) callback();
  174. // MWF.xDesktop.requireApp("Selector", "Actions.RestActions", function(){
  175. // this.orgAction = new MWF.xApplication.Selector.Actions.RestActions();
  176. // if (callback) callback();
  177. // }.bind(this));
  178. }else{
  179. if (callback) callback();
  180. }
  181. },
  182. setStartNodeSize: function(){
  183. if (!layout.mobile){
  184. var size = this.app.content.getSize();
  185. var allSize = this.app.content.getSize();
  186. this.markNode.setStyles({
  187. "width": ""+allSize.x+"px",
  188. "height": ""+allSize.y+"px"
  189. });
  190. this.areaNode.setStyles({
  191. "width": ""+size.x+"px",
  192. "height": ""+size.y+"px"
  193. });
  194. var hY = size.y*0.7;
  195. var mY = size.y*0.3/2;
  196. this.createNode.setStyles({
  197. "height": ""+hY+"px",
  198. "margin-top": ""+mY+"px"
  199. });
  200. var count = this.identitys.length;
  201. if (count>2) count=2;
  202. var w = count*294;
  203. this.formNode.setStyles({
  204. "width": ""+w+"px"
  205. });
  206. w = w + 60;
  207. this.createNode.setStyles({
  208. "width": ""+w+"px"
  209. });
  210. }
  211. },
  212. cancelStartProcess: function(e){
  213. this.markNode.destroy();
  214. this.areaNode.destroy();
  215. },
  216. okStartProcess: function(identity){
  217. var data = {
  218. "title": this.data.name+"-"+this.lp.unnamed,
  219. //"identity": this.identityArea.get("value")
  220. "identity": identity
  221. };
  222. if( this.options.workData ){
  223. data.data = this.options.workData
  224. }
  225. if (!data.identity){
  226. this.departmentSelArea.setStyle("border-color", "red");
  227. if (this.app && this.app.notice) this.app.notice(this.lp.selectStartId, "error");
  228. }else{
  229. this.mask = new MWF.widget.Mask({"style": "desktop"});
  230. this.mask.loadNode(this.areaNode);
  231. this.getWorkAction(function(){
  232. this.workAction.startWork(function(json){
  233. this.mask.hide();
  234. this.markNode.destroy();
  235. this.areaNode.destroy();
  236. this.fireEvent("started", [json.data, data.title, this.data.name]);
  237. if (this.app && this.app.refreshAll) this.app.refreshAll();
  238. //if (this.app && this.app.notice) this.app.notice(this.lp.processStarted, "success");
  239. // this.app.processConfig();
  240. }.bind(this), null, this.data.id, data);
  241. }.bind(this));
  242. }
  243. },
  244. getWorkAction: function(callback){
  245. if (!this.workAction){
  246. this.workAction = MWF.Actions.get("x_processplatform_assemble_surface");
  247. if (callback) callback();
  248. // MWF.xDesktop.requireApp("process.TaskCenter", "Actions.RestActions", function(){
  249. // this.workAction = new MWF.xApplication.process.TaskCenter.Actions.RestActions();
  250. // if (callback) callback();
  251. // }.bind(this));
  252. }else{
  253. if (callback) callback();
  254. }
  255. }
  256. });
  257. MWF.xApplication.process.TaskCenter.ProcessStarter.Identity = new Class({
  258. initialize: function(container, data, starter, style){
  259. this.container = $(container);
  260. this.data = data;
  261. this.starter = starter;
  262. this.action = this.starter.orgAction;
  263. this.style = style;
  264. //this.item = item;
  265. this.load();
  266. },
  267. load: function(){
  268. this.node = new Element("div", {
  269. "styles": (layout.mobile) ? this.style.identityNode_mobile : this.style.identityNode
  270. }).inject(this.container);
  271. var nameNode = new Element("div", {
  272. "styles": this.style.identityInforNameNode
  273. }).inject(this.node);
  274. var url = this.action.getPersonIcon(this.starter.app.desktop.session.user.id);
  275. var img = "<img width='50' height='50' border='0' src='"+url+"'></img>";
  276. // if (this.item.data.icon){
  277. // img = "<img width='50' height='50' border='0' src='data:image/png;base64,"+this.item.data.icon+"'></img>"
  278. // }else{
  279. // if (this.item.data.genderType=="f"){
  280. // img = "<img width='50' height='50' border='0' src='"+"../x_component_Organization/$PersonExplorer/default/icon/female.png'></img>";
  281. // }else{
  282. // img = "<img width='50' height='50' border='0' src='"+"../x_component_Organization/$PersonExplorer/default/icon/man.png'></img>";
  283. // }
  284. // }
  285. var picNode = new Element("div", {
  286. "styles": this.style.identityInforPicNode,
  287. "html": img
  288. }).inject(nameNode);
  289. var nameTextNode = new Element("div", {
  290. "styles": this.style.identityInforNameTextNode,
  291. "text": this.data.name
  292. }).inject(nameNode);
  293. var unitNode = new Element("div", {"styles": this.style.identityDepartmentNode}).inject(this.node);
  294. var unitTitleNode = new Element("div", {
  295. "styles": this.style.identityTitleNode,
  296. "text": MWF.xApplication.process.TaskCenter.LP.unit
  297. }).inject(unitNode);
  298. this.unitTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(unitNode);
  299. if (this.data.woUnit) this.unitTextNode.set({"text": this.data.woUnit.levelName, "title": this.data.woUnit.levelName});
  300. // var companyNode = new Element("div", {"styles": this.style.identityCompanyNode}).inject(this.node);
  301. // var companyTitleNode = new Element("div", {
  302. // "styles": this.style.identityTitleNode,
  303. // "text": this.item.explorer.app.lp.company
  304. // }).inject(companyNode);
  305. // this.companyTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(companyNode);
  306. var dutyNode = new Element("div", {"styles": this.style.identityDutyNode}).inject(this.node);
  307. var dutyTitleNode = new Element("div", {
  308. "styles": this.style.identityTitleNode,
  309. "text": MWF.xApplication.process.TaskCenter.LP.duty
  310. }).inject(dutyNode);
  311. this.dutyTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(dutyNode);
  312. var dutyTextList = [];
  313. var dutyTitleList = [];
  314. this.data.woUnitDutyList.each(function(duty){
  315. dutyTextList.push(duty.name);
  316. if (duty.woUnit) dutyTitleList.push(duty.name+"("+duty.woUnit.levelName+")");
  317. }.bind(this));
  318. this.dutyTextNode.set({"text": dutyTextList.join(", "), "title": dutyTitleList.join(", ")});
  319. // this.item.explorer.actions.getDepartment(function(json){
  320. // this.department = json.data;
  321. // this.departmentTextNode.set({"text": this.department.name, "title": this.department.name});
  322. //
  323. // this.item.explorer.actions.getCompany(function(json){
  324. // this.company = json.data;
  325. // this.companyTextNode.set({"text": this.company.name, "title": this.company.name});
  326. // }.bind(this), null, this.department.company);
  327. //
  328. // }.bind(this), null, this.data.department);
  329. //
  330. //
  331. // this.item.explorer.actions.listCompanyDutyByIdentity(function(json){
  332. // json.data.each(function(duty){
  333. // var text = this.dutyTextNode.get("text");
  334. // if (text){
  335. // text = text+", "+duty.name;
  336. // }else{
  337. // text = duty.name;
  338. // }
  339. // this.dutyTextNode.set({"text": text, "title": text});
  340. // }.bind(this));
  341. // }.bind(this), null, this.data.id);
  342. // this.item.explorer.actions.listDepartmentDutyByIdentity(function(json){
  343. // json.data.each(function(duty){
  344. // var text = this.dutyTextNode.get("text");
  345. // if (text){
  346. // text = text+", "+duty.name;
  347. // }else{
  348. // text = duty.name;
  349. // }
  350. // this.dutyTextNode.set({"text": text, "title": text});
  351. // }.bind(this));
  352. // }.bind(this), null, this.data.id);
  353. }
  354. });
  355. // MWF.xApplication.process.TaskCenter.ProcessStarter.DepartmentSel = new Class({
  356. // initialize: function(data, starter, container, idArea){
  357. // this.data = data;
  358. // this.starter = starter;
  359. // this.container = container;
  360. // this.idArea = idArea;
  361. // this.css = this.starter.css;
  362. // this.isSelected = false;
  363. // this.load();
  364. // },
  365. // load: function(){
  366. //
  367. // this.node = new Element("div", {"styles": this.css.departSelNode}).inject(this.container);
  368. // this.starter.orgAction.getDepartmentByIdentity(function(department){
  369. // this.node.set("text", department.data.name);
  370. // }.bind(this), null, this.data.name);
  371. //
  372. // this.node.addEvents({
  373. // "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.departSelNode_over);}.bind(this),
  374. // "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.departSelNode_out);}.bind(this),
  375. // "click": function(){
  376. // this.selected();
  377. // }.bind(this),
  378. // });
  379. // },
  380. // selected: function(){
  381. // if (!this.isSelected){
  382. // if (this.starter.currentDepartment) this.starter.currentDepartment.unSelected();
  383. // this.node.setStyles(this.css.departSelNode_selected);
  384. // this.isSelected = true;
  385. // this.starter.currentDepartment = this;
  386. //
  387. // this.idArea.set({
  388. // "text": this.data.display,
  389. // "value": this.data.name
  390. // });
  391. // }
  392. // },
  393. // unSelected: function(){
  394. // if (this.isSelected){
  395. // if (this.starter.currentDepartment) this.starter.currentDepartment = null;;
  396. // this.node.setStyles(this.css.departSelNode);
  397. // this.isSelected = false;
  398. // }
  399. // }
  400. //
  401. // });