ProcessStarter.js 18 KB

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