Main.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. MWF.require("MWF.widget.Mask", null, false);
  2. MWF.require("MWF.xDesktop.UserData", null, false);
  3. MWF.xDesktop.requireApp("process.TaskCenter", "TaskList", null, false);
  4. MWF.xDesktop.requireApp("process.TaskCenter", "TaskCompletedList", null, false);
  5. MWF.xDesktop.requireApp("process.TaskCenter", "ReadList", null, false);
  6. MWF.xDesktop.requireApp("process.TaskCenter", "ReadCompletedList", null, false);
  7. MWF.xDesktop.requireApp("process.TaskCenter", "ReviewList", null, false);
  8. MWF.xApplication.process.TaskCenter.options.multitask = false;
  9. MWF.xApplication.process.TaskCenter.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "process.TaskCenter",
  15. "icon": "icon.png",
  16. "width": "1280",
  17. "height": "700",
  18. "title": MWF.xApplication.process.TaskCenter.LP.title,
  19. "filterMap": {
  20. "applicationList": "applicationList",
  21. "processList": "processList",
  22. "creatorUnitList": "creatorUnitList",
  23. "creatorCompanyList": "creatorCompanyList",
  24. "creatorDepartmentList": "creatorDepartmentList",
  25. "activityNameList": "activityNameList",
  26. "completedTimeMonthList": "completedTimeMonthList",
  27. "key": "key"
  28. }
  29. },
  30. onQueryLoad: function () {
  31. this.lp = MWF.xApplication.process.TaskCenter.LP;
  32. },
  33. loadApplication: function (callback) {
  34. this.appIcons = {};
  35. this.tabs = [];
  36. this.tabShadows = [];
  37. this.startApplications = [];
  38. this.appStartableData = null;
  39. this.loadTitle();
  40. this.loadTab();
  41. this.loadFilterAction();
  42. this.loadContent();
  43. this.currentTab = "";
  44. this.openTab();
  45. if (callback) callback();
  46. },
  47. loadTitle: function () {
  48. this.loadTitleBar();
  49. if (!layout.mobile) this.loadTitleUserNode();
  50. this.loadStartProcessActionNode();
  51. if (!layout.mobile) this.loadTitleTextNode();
  52. this.loadSearchNode();
  53. },
  54. loadTitleBar: function () {
  55. this.taskTitleBar = new Element("div", {
  56. "styles": this.css.taskTitleBar
  57. }).inject(this.content);
  58. },
  59. loadTitleUserNode: function () {
  60. this.taskTitleUserNode = new Element("div", {
  61. "styles": this.css.taskTitleUserNode
  62. }).inject(this.taskTitleBar);
  63. this.taskTitleUserIconNode = new Element("div", {
  64. "styles": this.css.taskTitleUserIconNode
  65. }).inject(this.taskTitleUserNode);
  66. this.taskTitleUserTextNode = new Element("div", {
  67. "styles": this.css.taskTitleUserTextNode,
  68. "text": this.desktop.session.user.name
  69. }).inject(this.taskTitleUserNode);
  70. },
  71. loadStartProcessActionNode: function () {
  72. this.startProcessAction = new Element("div", {
  73. "styles": this.css.startProcessAction
  74. }).inject(this.taskTitleBar);
  75. this.startProcessAction.addEvents({
  76. "click": function (e) {
  77. this.showStartProcessArea(e);
  78. }.bind(this)
  79. });
  80. },
  81. loadTitleTextNode: function () {
  82. this.taskTitleTextNode = new Element("div", {
  83. "styles": this.css.taskTitleTextNode,
  84. "text": this.lp.title
  85. }).inject(this.taskTitleBar);
  86. },
  87. loadSearchNode: function () {
  88. this.searchBarAreaNode = new Element("div", {
  89. "styles": this.css.searchBarAreaNode
  90. }).inject(this.taskTitleBar);
  91. if (layout.mobile) this.searchBarAreaNode.setStyle("margin-left", "10px");
  92. if (layout.mobile) this.searchBarAreaNode.setStyle("margin-right", "20px");
  93. this.searchBarNode = new Element("div", {
  94. "styles": this.css.searchBarNode
  95. }).inject(this.searchBarAreaNode);
  96. this.searchBarActionNode = new Element("div", {
  97. "styles": this.css.searchBarActionNode
  98. }).inject(this.searchBarNode);
  99. this.searchBarInputBoxNode = new Element("div", {
  100. "styles": this.css.searchBarInputBoxNode
  101. }).inject(this.searchBarNode);
  102. this.searchBarInputNode = new Element("input", {
  103. "type": "text",
  104. "value": this.lp.searchKey,
  105. "styles": this.css.searchBarInputNode
  106. }).inject(this.searchBarInputBoxNode);
  107. var _self = this;
  108. this.searchBarActionNode.addEvent("click", function () {
  109. this.searchTask();
  110. }.bind(this));
  111. this.searchBarInputNode.addEvents({
  112. "focus": function () {
  113. if (this.value === _self.lp.searchKey) this.set("value", "");
  114. },
  115. "blur": function () {
  116. if (!this.value) this.set("value", _self.lp.searchKey);
  117. },
  118. "keydown": function (e) {
  119. if (e.code === 13) {
  120. this.searchTask();
  121. e.preventDefault();
  122. }
  123. }.bind(this),
  124. "selectstart": function (e) {
  125. e.preventDefault();
  126. }
  127. });
  128. },
  129. loadTab: function () {
  130. this.tabAreaNode = new Element("div", {
  131. "styles": this.css.tabAreaNode
  132. }).inject(this.content);
  133. this.createTabItem(this.lp.task, "task.png", "task", function () {
  134. this.showTask();
  135. }.bind(this));
  136. this.createTabItem(this.lp.done, "done.png", "taskCompleted", function () {
  137. this.showDone();
  138. }.bind(this));
  139. this.createTabItem(this.lp.read, "read.png", "read", function () {
  140. this.showRead();
  141. }.bind(this));
  142. this.createTabItem(this.lp.readed, "readed.png", "readCompleted", function () {
  143. this.showReaded();
  144. }.bind(this));
  145. //this.createTabItem(this.lp.review, "review.png", "review", function(){this.showReview();}.bind(this));
  146. this.getWorkCounts();
  147. },
  148. // createTabItem: function (text, icon, countKey, action) {
  149. // if (COMMON.Browser.Platform.isMobile){
  150. // this.createTabItem_mobile(text, icon, countKey, action);
  151. // }else{
  152. // this.createTabItem_pc(text, icon, countKey, action);
  153. // }
  154. // },
  155. // createTabItem_mobile: function(text, icon, countKey, action){
  156. // var tab = new Element("div", {
  157. // "styles": this.css.tabItemNode
  158. // }).inject(this.tabAreaNode);
  159. //
  160. // var tabItem = new Element("div", {
  161. // "styles": this.css.tabItemAreaNode
  162. // }).inject(tab);
  163. //
  164. // var tabContent = new Element("div", {
  165. // "styles": this.css.tabItemContentNode_mobile
  166. // }).inject(tabItem);
  167. //
  168. // var tabText = new Element("div", {
  169. // "styles": this.css.tabItemTextNode_mobile,
  170. // "text": text
  171. // }).inject(tabContent);
  172. //
  173. // this[countKey+"CountNode"] = new Element("div", {
  174. // "styles": this.css.tabItemCountNode
  175. // }).inject(tabContent);
  176. //
  177. // tab.addEvent("click", function(){action();}.bind(this));
  178. //
  179. // this.tabs.push(tab);
  180. // },
  181. createTabItem: function(text, icon, countKey, action){
  182. var tab = new Element("div", {
  183. "styles": this.css.tabItemNode
  184. }).inject(this.tabAreaNode);
  185. if (!layout.mobile){
  186. var tabIcon = new Element("div", {
  187. "styles": this.css.tabItemIconNode
  188. }).inject(tab);
  189. tabIcon.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/tab/"+icon+")");
  190. }
  191. var tabText = new Element("div", {
  192. "styles": this.css.tabItemTextNode,
  193. "text": text
  194. }).inject(tab);
  195. this[countKey+"CountNode"] = new Element("div", {
  196. "styles": this.css.tabItemCountNode
  197. }).inject(tab);
  198. tab.addEvent("click", function(){action();}.bind(this));
  199. this.tabs.push(tab);
  200. },
  201. loadFilterAction: function(){
  202. // this.flterAction = new Element("div", {
  203. // "styles": this.css.tabItemNode
  204. // }).inject(this.tabAreaNode);
  205. //
  206. // var tabIcon = new Element("div", {
  207. // "styles": this.css.tabItemIconNode
  208. // }).inject(tab);
  209. // tabIcon.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/tab/"+icon+")");
  210. // var tabText = new Element("div", {
  211. // "styles": this.css.tabItemTextNode,
  212. // "text": text
  213. // }).inject(tab);
  214. //
  215. // this[countKey+"CountNode"] = new Element("div", {
  216. // "styles": this.css.tabItemCountNode
  217. // }).inject(tab);
  218. //
  219. // tab.addEvent("click", function(){action();}.bind(this));
  220. },
  221. getWorkCounts: function () {
  222. debugger;
  223. this.getAction(function () {
  224. this.action.getCount(function (json) {
  225. debugger;
  226. this.counts = json.data;
  227. this["taskCountNode"].set("text", "( " + ((this.counts.task > 100) ? "99" : this.counts.task) + " )");
  228. this["taskCompletedCountNode"].set("text", "( " + ((this.counts.taskCompleted > 100) ? "99" : this.counts.taskCompleted) + " )");
  229. this["readCountNode"].set("text", "( " + ((this.counts.read > 100) ? "99" : this.counts.read) + " )");
  230. this["readCompletedCountNode"].set("text", "( " + ((this.counts.readCompleted > 100) ? "99" : this.counts.readCompleted) + " )");
  231. //this["reviewCountNode"].set("text", "[ "+((this.counts.review>100) ? "99" : this.counts.review)+" ]");
  232. }.bind(this), null, this.desktop.session.user.distinguishedName);
  233. }.bind(this));
  234. },
  235. loadContent: function(){
  236. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  237. this.contentListAreaNode = new Element("div", {"styles": this.css.contentListAreaNode}).inject(this.contentNode);
  238. this.setContentNodeHeight();
  239. this.addEvent("resize", this.setContentNodeHeight.bind(this));
  240. },
  241. setContentNodeHeight: function(){
  242. var size = this.content.getSize();
  243. var titleSize = this.taskTitleBar.getSize();
  244. var tabSize = this.tabAreaNode.getSize();
  245. var y = size.y-titleSize.y-tabSize.y-1;
  246. this.contentNode.setStyle("height", ""+y+"px");
  247. var x = 0;
  248. if (this.taskList) x = x + size.x;
  249. if (this.taskCompletedList) x = x + size.x;
  250. if (this.readList) x = x + size.x;
  251. if (this.readCompletedList) x = x + size.x;
  252. this.contentListAreaNode.setStyle("width", ""+x+"px");
  253. },
  254. openTab: function () {
  255. var tab = "task";
  256. if (this.status) tab = this.status.navi;
  257. switch (tab) {
  258. case "task":
  259. this.showTask();
  260. break;
  261. case "done":
  262. this.showDone();
  263. break;
  264. case "read":
  265. this.showRead();
  266. break;
  267. case "readed":
  268. this.showReaded();
  269. break;
  270. case "review":
  271. this.showReview();
  272. break;
  273. default:
  274. this.showTask();
  275. break;
  276. }
  277. },
  278. showTask: function () {
  279. if (this.currentTab !== "task") {
  280. this.showTab(0);
  281. this.currentTab = "task";
  282. if (!this.taskList) {
  283. this.createTaskList();
  284. this.taskList.show();
  285. } else {
  286. this.taskList.show();
  287. if (this.taskList) this.taskList.refresh();
  288. }
  289. } else {
  290. if (this.taskList) this.taskList.refresh();
  291. }
  292. //this.searchBarAreaNode.setStyle("display", "none");
  293. },
  294. showTab: function (idx) {
  295. this.tabs.each(function (node, i) {
  296. if (i === idx) {
  297. node.getLast().setStyles(this.css.tabItemTextNode_current);
  298. if (!layout.mobile){
  299. node.getFirst().getNext().setStyles(this.css.tabItemTextNode_current);
  300. var icon = node.getFirst().getStyle("background-image");
  301. node.getFirst().setStyle("background-image", icon.replace(".png", "_cur.png"));
  302. }else{
  303. node.getFirst().setStyles(this.css.tabItemTextNode_current);
  304. }
  305. } else {
  306. node.getLast().setStyles(this.css.tabItemCountNode);
  307. if (!layout.mobile){
  308. node.getFirst().getNext().setStyles(this.css.tabItemTextNode);
  309. var icon = node.getFirst().getStyle("background-image");
  310. node.getFirst().setStyle("background-image", icon.replace("_cur.png", ".png"));
  311. }else{
  312. node.getFirst().setStyles(this.css.tabItemTextNode);
  313. }
  314. }
  315. }.bind(this));
  316. },
  317. createTaskList: function () {
  318. if (!this.contentNode) this.loadContent();
  319. this.taskList = new MWF.xApplication.process.TaskCenter.TaskList(this.contentListAreaNode, this);
  320. },
  321. //@todo 起草 搜索 筛选 。。。
  322. showStartProcessArea: function(){
  323. if (layout.mobile){
  324. this.showStartProcessArea_mobile();
  325. }else{
  326. this.showStartProcessArea_pc();
  327. }
  328. },
  329. showStartProcessArea_mobile: function(){
  330. if (!this.startProcessAreaNode) {
  331. this.createStartProcessArea_mobile();
  332. }
  333. this.startProcessAreaNode.setStyle("display", "block");
  334. //document.body.setStyle("-webkit-overflow-scrolling", "auto");
  335. var morph = new Fx.Morph(this.startProcessAreaNode, {
  336. "duration": 200,
  337. "transition": Fx.Transitions.Expo.easeOut
  338. });
  339. morph.start({"left": "0px"});
  340. },
  341. showStartProcessArea_pc: function () {
  342. if (!this.startProcessAreaNode) {
  343. this.createStartProcessArea();
  344. }
  345. this.content.mask({
  346. "destroyOnHide": true,
  347. "id": "process_taskcenter_startProcessMask",
  348. "style": this.css.maskNode
  349. });
  350. var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  351. if (maskNode){
  352. maskNode.addEvent("click", function (e) {
  353. this.closeStartProcessArea(e);
  354. }.bind(this));
  355. }
  356. //if (this.allApplicationStarter) this.allApplicationStarter.loadChild();
  357. this.startProcessAreaNode.fade("in");
  358. //this.startProcessTween.start("left", "-400px", "0px");
  359. },
  360. createStartProcessArea_mobile: function(){
  361. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode_mobile}).inject(this.content);
  362. var size = this.content.getSize();
  363. this.startProcessAreaNode.setStyles({
  364. "width": ""+size.x+"px",
  365. "height": ""+size.y+"px",
  366. "top": "0px",
  367. "left": ""+size.x+"px"
  368. });
  369. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode_mobile}).inject(this.startProcessAreaNode);
  370. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode_mobile, "text": this.lp.back}).inject(this.startProcessTopNode);
  371. this.startProcessCloseNode.addEvent("click", function (e) {
  372. this.closeStartProcessArea(e);
  373. }.bind(this));
  374. this.startProcessListNode = new Element("div", {"styles": this.css.startProcessListNode_mobile}).inject(this.startProcessAreaNode);
  375. var h = size.y-this.startProcessTopNode.getSize().y;
  376. this.startProcessListNode.setStyle("height", ""+h+"px");
  377. //this.createStartProcessScrollNode();
  378. this.getAction(function () {
  379. this.action.listApplicationStartable(function (appjson) {
  380. this.app = this;
  381. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  382. this.top5Data = json;
  383. if (this.top5Data && this.top5Data.length){
  384. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.lp.startTop5}).inject(this.startProcessListNode);
  385. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  386. this.top5Data.sort(function(p1, p2){
  387. return 0-(p1.count-p2.count);
  388. });
  389. this.top5Data.each(function(process, i){
  390. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  391. }.bind(this));
  392. }
  393. appjson.data.each(function (app) {
  394. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.startProcessListNode);
  395. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  396. app.processList.each(function(process){
  397. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  398. }.bind(this));
  399. }.bind(this));
  400. }.bind(this));
  401. // this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  402. // this.allApplicationStarter.selected();
  403. // json.data.each(function (app) {
  404. // new MWF.xApplication.process.TaskCenter.Application(app, this);
  405. // }.bind(this));
  406. }.bind(this));
  407. }.bind(this));
  408. },
  409. createStartProcessArea: function () {
  410. this.createStartProcessAreaNode();
  411. this.createStartProcessScrollNode();
  412. this.listApplications();
  413. this.setResizeStartProcessAreaHeight();
  414. this.addEvent("resize", this.setResizeStartProcessAreaHeight.bind(this));
  415. //this.startProcessTween = new Fx.Tween(this.startProcessAreaNode, {
  416. // "duration": "200",
  417. // "transition": Fx.Transitions.Quad.easeOut
  418. //});
  419. },
  420. createStartProcessAreaNode: function () {
  421. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode}).inject(this.content);
  422. },
  423. createStartProcessCloseNode: function () {
  424. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode}).inject(this.startProcessRightListNode);
  425. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode}).inject(this.startProcessTopNode);
  426. this.startProcessCloseNode.addEvent("click", function (e) {
  427. this.closeStartProcessArea(e);
  428. }.bind(this));
  429. },
  430. createStartProcessSearchNode: function(){
  431. this.startProcessSearchNode = new Element("div", {"styles": this.css.startProcessSearchNode}).inject(this.startProcessRightListNode);
  432. this.startProcessSearchIconNode = new Element("div", {"styles": this.css.startProcessSearchIconNode}).inject(this.startProcessSearchNode);
  433. this.startProcessSearchAreaNode = new Element("div", {"styles": this.css.startProcessSearchAreaNode}).inject(this.startProcessSearchNode);
  434. this.startProcessSearchInputNode = new Element("input", {"styles": this.css.startProcessSearchInputNode}).inject(this.startProcessSearchAreaNode);
  435. this.startProcessSearchInputNode.set("value", this.lp.searchProcess);
  436. this.startProcessSearchInputNode.addEvents({
  437. "focus": function(){ if (this.startProcessSearchInputNode.get("value")===this.lp.searchProcess) this.startProcessSearchInputNode.set("value", ""); }.bind(this),
  438. "blur": function(){if (!this.startProcessSearchInputNode.get("value")) this.startProcessSearchInputNode.set("value", this.lp.searchProcess);}.bind(this),
  439. "keydown": function(e){ if (e.code===13) this.searchStartProcess(); }.bind(this)
  440. });
  441. this.startProcessSearchIconNode.addEvent("click", function(){ this.searchStartProcess(); }.bind(this));
  442. },
  443. searchStartProcess: function(){
  444. var key = this.startProcessSearchInputNode.get("value");
  445. if (key && key!==this.lp.searchProcess){
  446. if (this.appStartableData){
  447. this.startApplications.each(function(app){ app.unselected(); });
  448. if (this.searchProcessSearchchildNode) this.searchProcessSearchchildNode.destroy();
  449. var text = this.lp.searchProcessResault.replace("{key}", key);
  450. this.searchProcessSearchchildNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.startProcessProcessAreaNode);
  451. this.searchProcessSearchchildNode.setStyle("display", "block");
  452. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": text}).inject(this.searchProcessSearchchildNode);
  453. var proListNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.searchProcessSearchchildNode);
  454. this.appStartableData.each(function (app) {
  455. app.processList.each(function(pro){
  456. if (pro.name.indexOf(key)!==-1){
  457. var data = Object.clone(pro);
  458. data.applicationName = app.name;
  459. new MWF.xApplication.process.TaskCenter.Process(data, {"app": this}, {"name": app}, proListNode);
  460. }
  461. }.bind(this));
  462. }.bind(this));
  463. }
  464. }
  465. },
  466. createStartProcessScrollNode: function () {
  467. this.startProcessApplicationListNode = new Element("div", {"styles": this.css.startProcessApplicationListNode}).inject(this.startProcessAreaNode);
  468. this.startProcessRightListNode = new Element("div", {"styles": this.css.startProcessRightListNode}).inject(this.startProcessAreaNode);
  469. this.createStartProcessCloseNode();
  470. this.createStartProcessSearchNode();
  471. this.startProcessApplicationScrollNode = new Element("div", {"styles": this.css.startProcessApplicationScrollNode}).inject(this.startProcessApplicationListNode);
  472. this.startProcessApplicationAreaNode = new Element("div", {"styles": this.css.startProcessApplicationAreaNode}).inject(this.startProcessApplicationScrollNode);
  473. this.startProcessProcessListNode = new Element("div", {"styles": this.css.startProcessProcessListNode}).inject(this.startProcessRightListNode);
  474. this.startProcessProcessScrollNode = new Element("div", {"styles": this.css.startProcessProcessScrollNode}).inject(this.startProcessProcessListNode);
  475. this.startProcessProcessAreaNode = new Element("div", {"styles": this.css.startProcessProcessAreaNode}).inject(this.startProcessProcessScrollNode);
  476. MWF.require("MWF.widget.ScrollBar", function () {
  477. new MWF.widget.ScrollBar(this.startProcessApplicationScrollNode, {
  478. "distance": 100,
  479. "friction": 4
  480. });
  481. new MWF.widget.ScrollBar(this.startProcessProcessScrollNode, {
  482. "distance": 100,
  483. "friction": 4
  484. });
  485. }.bind(this));
  486. //this.startProcessContentNode = new Element("div", {"styles": this.css.startProcessContentNode}).inject(this.startProcessScrollNode);
  487. },
  488. closeStartProcessArea: function () {
  489. //if (this.startProcessAreaNode) this.startProcessTween.start("left", "0px", "-400px");
  490. if (layout.mobile){
  491. var size = this.startProcessAreaNode.getSize();
  492. var morph = new Fx.Morph(this.startProcessAreaNode, {
  493. "duration": 200,
  494. "transition": Fx.Transitions.Expo.easeOut,
  495. "onComplete": function(){
  496. this.startProcessAreaNode.setStyle("display", "none");
  497. }.bind(this)
  498. });
  499. morph.start({"left": ""+size.x+"px"});
  500. }else{
  501. this.content.unmask();
  502. if (this.startProcessAreaNode) this.startProcessAreaNode.fade("out");
  503. }
  504. },
  505. setResizeStartProcessAreaHeight: function () {
  506. if (this.startProcessAreaNode) {
  507. var size = this.content.getSize();
  508. var nodeSize = this.startProcessAreaNode.getSize();
  509. var x = (size.x-nodeSize.x)/2;
  510. var y = (size.y-nodeSize.y)/2;
  511. this.startProcessAreaNode.setStyle("top", "" + y + "px");
  512. this.startProcessAreaNode.setStyle("left", "" + x + "px");
  513. var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  514. if (maskNode){
  515. maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  516. maskNode.position({
  517. "relativeTo": this.content,
  518. "position": "topLeft",
  519. "edge": "topLeft"
  520. });
  521. }
  522. if (this.startProcessProcessListNode){
  523. var topSize = this.startProcessTopNode.getSize();
  524. var searchSize = this.startProcessSearchNode.getSize();
  525. var h = nodeSize.y-topSize.y-searchSize.y;
  526. this.startProcessProcessListNode.setStyle("height", ""+h+"px");
  527. }
  528. }
  529. },
  530. listApplications: function () {
  531. this.getAction(function () {
  532. this.action.listApplicationStartable(function (json) {
  533. this.appStartableData = json.data;
  534. this.startProcessSearchNode.setStyle("display", "block");
  535. this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  536. this.allApplicationStarter.selected();
  537. json.data.each(function (app) {
  538. new MWF.xApplication.process.TaskCenter.Application(app, this);
  539. }.bind(this));
  540. }.bind(this));
  541. }.bind(this));
  542. },
  543. getAction: function (callback) {
  544. if (!this.action) {
  545. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  546. if (callback) callback();
  547. // MWF.xDesktop.requireApp("process.TaskCenter", "Actions.RestActions", function () {
  548. // this.action = new MWF.xApplication.process.TaskCenter.Actions.RestActions();
  549. // if (callback) callback();
  550. // }.bind(this));
  551. } else {
  552. if (callback) callback();
  553. }
  554. },
  555. refreshAll: function () {
  556. this.getWorkCounts();
  557. if (this.taskList) if (this.currentTab === "task") this.taskList.refresh();
  558. //if (this.taskCompletedList) if (this.currentTab == "done") this.taskCompletedList.refresh();
  559. //if (this.readList) if (this.currentTab == "read") this.readList.refresh();
  560. //if (this.readedList) if (this.currentTab == "readed") this.readedList.refresh();
  561. //if (this.reviewList) if (this.currentTab == "review") this.reviewList.refresh();
  562. },
  563. createTaskCompletedList: function (filterData) {
  564. if (!this.contentNode) this.loadContent();
  565. this.taskCompletedList = new MWF.xApplication.process.TaskCenter.TaskCompletedList(this.contentListAreaNode, this, filterData);
  566. //if (filterData) this.taskCompletedList.filterData = filterData;
  567. },
  568. showDone: function () {
  569. if (this.currentTab !== "done") {
  570. this.showTab(1);
  571. this.currentTab = "done";
  572. if (!this.taskCompletedList) {
  573. this.createTaskCompletedList((this.status) ? this.status.filter : null);
  574. this.taskCompletedList.show();
  575. } else {
  576. this.taskCompletedList.show();
  577. if (this.taskCompletedList) this.taskCompletedList.refresh();
  578. }
  579. } else {
  580. if (this.taskCompletedList) this.taskCompletedList.refresh();
  581. }
  582. this.searchBarAreaNode.setStyle("display", "block");
  583. this.searchBarInputNode.set("value", this.lp.searchKey);
  584. },
  585. createReadList: function (filterData) {
  586. if (!this.contentNode) this.loadContent();
  587. this.readList = new MWF.xApplication.process.TaskCenter.ReadList(this.contentListAreaNode, this, filterData);
  588. //if (filterData) this.taskCompletedList.filterData = filterData;
  589. },
  590. showRead: function () {
  591. if (this.currentTab !== "read") {
  592. this.showTab(2);
  593. this.currentTab = "read";
  594. if (!this.readList) {
  595. this.createReadList((this.status) ? this.status.filter : null);
  596. this.readList.show();
  597. } else {
  598. this.readList.show();
  599. if (this.readList) this.readList.refresh();
  600. }
  601. } else {
  602. if (this.readList) this.readList.refresh();
  603. }
  604. this.searchBarAreaNode.setStyle("display", "block");
  605. this.searchBarInputNode.set("value", this.lp.searchKey);
  606. },
  607. createReadedList: function (filterData) {
  608. if (!this.contentNode) this.loadContent();
  609. this.readedList = new MWF.xApplication.process.TaskCenter.ReadCompletedList(this.contentListAreaNode, this, filterData);
  610. //if (filterData) this.taskCompletedList.filterData = filterData;
  611. },
  612. showReaded: function () {
  613. if (this.currentTab !== "readed") {
  614. this.showTab(3);
  615. this.currentTab = "readed";
  616. if (!this.readedList) {
  617. this.createReadedList((this.status) ? this.status.filter : null);
  618. this.readedList.show();
  619. } else {
  620. this.readedList.show();
  621. if (this.readedList) this.readedList.refresh();
  622. }
  623. } else {
  624. if (this.readedList) this.readedList.refresh();
  625. }
  626. this.searchBarAreaNode.setStyle("display", "block");
  627. this.searchBarInputNode.set("value", this.lp.searchKey);
  628. },
  629. createReviewList: function (filterData) {
  630. if (!this.contentNode) this.loadContent();
  631. this.reviewList = new MWF.xApplication.process.TaskCenter.ReviewList(this.contentListAreaNode, this, filterData);
  632. //if (filterData) this.taskCompletedList.filterData = filterData;
  633. },
  634. showReview: function () {
  635. if (this.currentTab !== "review") {
  636. this.showTab(4);
  637. this.currentTab = "review";
  638. if (!this.reviewList) {
  639. this.createReviewList((this.status) ? this.status.filter : null);
  640. this.reviewList.show();
  641. } else {
  642. this.reviewList.show();
  643. if (this.reviewList) this.reviewList.refresh();
  644. }
  645. } else {
  646. if (this.reviewList) this.reviewList.refresh();
  647. }
  648. this.searchBarAreaNode.setStyle("display", "block");
  649. },
  650. recordStatus: function(){
  651. var tab = this.currentTab || "task";
  652. var filter = null;
  653. if (tab==="done"){
  654. filter = this.taskCompletedList.filterData;
  655. }
  656. if (tab==="read"){
  657. filter = this.readList.filterData;
  658. }
  659. if (tab==="readed"){
  660. filter = this.readedList.filterData;
  661. }
  662. if (tab==="review"){
  663. filter = this.reviewList.filterData;
  664. }
  665. return {"navi": this.currentTab || "task", "filter": filter};
  666. },
  667. searchTask: function(){
  668. var keyWord = this.searchBarInputNode.get("value");
  669. if (keyWord && (keyWord!==this.lp.searchKey)){
  670. var tab = this.currentTab || "task";
  671. switch (tab){
  672. case "task":
  673. if (!this.taskList.filterData) this.taskList.filterData = {};
  674. this.taskList.filterData.key = keyWord;
  675. this.taskList.refilter();
  676. break;
  677. case "done":
  678. if (!this.taskCompletedList.filterData) this.taskCompletedList.filterData = {};
  679. this.taskCompletedList.filterData.key = keyWord;
  680. this.taskCompletedList.refilter();
  681. break;
  682. case "read":
  683. if (!this.readList.filterData) this.readList.filterData = {};
  684. this.readList.filterData.key = keyWord;
  685. this.readList.refilter();
  686. break;
  687. case "readed":
  688. if (!this.readedList.filterData) this.readedList.filterData = {};
  689. this.readedList.filterData.key = keyWord;
  690. this.readedList.refilter();
  691. break;
  692. case "review":
  693. if (!this.reviewList.filterData) this.reviewList.filterData = {};
  694. this.reviewList.filterData.key = keyWord;
  695. this.reviewList.refilter();
  696. break;
  697. }
  698. }
  699. }
  700. });
  701. MWF.xApplication.process.TaskCenter.Application = new Class({
  702. initialize: function(data, app){
  703. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  704. this.data = data;
  705. this.app = app;
  706. this.container = this.app.startProcessApplicationAreaNode;
  707. this.processContainer = this.app.startProcessProcessAreaNode;
  708. this.css = this.app.css;
  709. this.isLoaded = false;
  710. this.load();
  711. },
  712. load: function(){
  713. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  714. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  715. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  716. if (this.data.icon){
  717. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  718. }else{
  719. this.iconNode.set("src", "/x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  720. }
  721. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  722. this.textNode.set("text", this.data.name);
  723. this.textNode.set("title", this.data.name);
  724. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  725. //this.loadChild();
  726. this.node.addEvent("click", function(){
  727. this.selected();
  728. }.bind(this));
  729. this.app.startApplications.push(this);
  730. },
  731. unselected: function(){
  732. this.childNode.setStyle("display", "none");
  733. this.node.setStyles(this.css.applicationNode);
  734. },
  735. selected: function(){
  736. this.app.startApplications.each(function(app){
  737. app.unselected();
  738. });
  739. if (this.app.searchProcessSearchchildNode) this.app.searchProcessSearchchildNode.destroy();
  740. if (this.app.startProcessSearchInputNode) this.app.startProcessSearchInputNode.set("value", this.app.lp.searchProcess);
  741. this.childNode.setStyle("display", "block");
  742. this.node.setStyles(this.css.applicationNode_selected);
  743. if (!this.isLoaded){
  744. this.loadChild();
  745. this.isLoaded = true;
  746. }
  747. },
  748. loadChild: function(){
  749. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startProcess}).inject(this.childNode);
  750. var childNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  751. this.data.processList.each(function(process){
  752. new MWF.xApplication.process.TaskCenter.Process(process, this, this.data, childNode);
  753. }.bind(this));
  754. }
  755. });
  756. MWF.xApplication.process.TaskCenter.AllApplication = new Class({
  757. Extends: MWF.xApplication.process.TaskCenter.Application,
  758. initialize: function(data, app){
  759. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  760. this.data = data;
  761. this.app = app;
  762. this.container = this.app.startProcessApplicationAreaNode;
  763. this.processContainer = this.app.startProcessProcessAreaNode;
  764. this.css = this.app.css;
  765. this.isLoaded = false;
  766. this.load();
  767. },
  768. load: function(){
  769. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  770. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  771. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  772. this.iconNode.set("src", "/x_component_process_TaskCenter/$Main/default/icon/appAppliction.png");
  773. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  774. this.textNode.set("text", this.app.lp.all);
  775. this.textNode.set("title", this.app.lp.all);
  776. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  777. //this.loadChild();
  778. this.node.addEvent("click", function(){
  779. this.selected();
  780. }.bind(this));
  781. this.app.startApplications.push(this);
  782. },
  783. unselected: function(){
  784. this.childNode.empty();
  785. this.isLoaded = false;
  786. this.childNode.setStyle("display", "none");
  787. this.node.setStyles(this.css.applicationNode);
  788. },
  789. loadChild: function(){
  790. //this.loadSearch();
  791. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  792. this.top5Data = json;
  793. if (this.top5Data && this.top5Data.length){
  794. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  795. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  796. this.top5Data.sort(function(p1, p2){
  797. return 0-(p1.count-p2.count);
  798. });
  799. this.top5Data.each(function(process, i){
  800. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  801. }.bind(this));
  802. }
  803. this.data.each(function (app) {
  804. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  805. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  806. app.processList.each(function(process){
  807. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  808. }.bind(this));
  809. }.bind(this));
  810. }.bind(this));
  811. }
  812. });
  813. MWF.xApplication.process.TaskCenter.Process = new Class({
  814. initialize: function(data, application, applicationData, container){
  815. this.data = data;
  816. this.application = application;
  817. this.applicationData = applicationData;
  818. this.app = this.application.app;
  819. this.container = container;
  820. this.css = this.app.css;
  821. this.load();
  822. },
  823. load: function(){
  824. this.node = new Element("div.processItem", {"styles": this.css.startProcessNode}).inject(this.container);
  825. this.iconNode = new Element("div", {"styles": this.css.processIconNode}).inject(this.node);
  826. if (this.data.icon){
  827. this.iconNode.setStyle("background-image", "url("+this.data.icon+")");
  828. }else{
  829. this.iconNode.setStyle("background-image", "url(/x_component_process_ProcessManager/$Explorer/default/processIcon/process.png)");
  830. }
  831. this.actionNode = new Element("div", {"styles": this.css.processActionNode, "text": this.app.lp.start}).inject(this.node);
  832. this.textNode = new Element("div", {"styles": this.css.processTextNode}).inject(this.node);
  833. this.textNode.set({
  834. "text": this.data.name+((this.data.applicationName) ? " -- ("+this.data.applicationName+")" : ""),
  835. "title": this.data.name+"-"+this.data.description
  836. });
  837. //var _self = this;
  838. this.actionNode.addEvents({
  839. "mouseover": function(){this.actionNode.setStyles(this.css.processActionNode_over);}.bind(this),
  840. "mouseout": function(){this.actionNode.setStyles(this.css.processActionNode);}.bind(this),
  841. "click": function(e){
  842. this.startProcess(e);
  843. }.bind(this)
  844. });
  845. this.node.addEvents({
  846. "mouseover": function(){
  847. this.node.setStyles(this.css.startProcessNode_over);
  848. this.actionNode.setStyle("display", "block");
  849. }.bind(this),
  850. "mouseout": function(){
  851. this.node.setStyles(this.css.startProcessNode_out);
  852. //this.actionNode.setStyle("display", "none");
  853. }.bind(this)
  854. });
  855. },
  856. startProcess: function(){
  857. debugger;
  858. this.app.closeStartProcessArea();
  859. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  860. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(this.data, this.app, {
  861. "onStarted": function(data, title, processName){
  862. this.afterStartProcess(data, title, processName);
  863. }.bind(this)
  864. });
  865. starter.load();
  866. }.bind(this));
  867. },
  868. recordProcessData: function(){
  869. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  870. if (!json || !json.length) json = [];
  871. var recordProcess = null;
  872. this.data.lastStartTime = new Date();
  873. var earlyProcessIdx = 0;
  874. var flag = true;
  875. for (var i=0; i<json.length; i++){
  876. var process = json[i];
  877. if (process.id === this.data.id) recordProcess = process;
  878. if (flag){
  879. if (!process.lastStartTime){
  880. earlyProcessIdx = i;
  881. flag = false;
  882. }else{
  883. if (new Date(process.lastStartTime)<new Date(json[earlyProcessIdx].lastStartTime)){
  884. earlyProcessIdx = i;
  885. }
  886. }
  887. }
  888. }
  889. if (recordProcess) {
  890. recordProcess.lastStartTime = new Date();
  891. recordProcess.count = (recordProcess.count || 0)+1;
  892. recordProcess.applicationName = this.applicationData.name;
  893. }else{
  894. if (json.length<10){
  895. this.data.count = 1;
  896. this.data.applicationName = this.applicationData.name;
  897. json.push(this.data);
  898. }else{
  899. json.splice(earlyProcessIdx, 1);
  900. this.data.count = 1;
  901. this.data.applicationName = this.applicationData.name;
  902. json.push(this.data);
  903. }
  904. }
  905. MWF.UD.putData("taskCenter_startTop", json);
  906. }.bind(this));
  907. },
  908. afterStartProcess: function(data, title, processName){
  909. this.recordProcessData();
  910. var workInfors = [];
  911. var currentTask = [];
  912. data.each(function(work){
  913. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  914. workInfors.push(this.getStartWorkInforObj(work));
  915. }.bind(this));
  916. if (currentTask.length===1){
  917. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  918. this.app.desktop.openApplication(null, "process.Work", options);
  919. this.createStartWorkResault(workInfors, title, processName, false);
  920. }else{
  921. this.createStartWorkResault(workInfors, title, processName, true);
  922. }
  923. },
  924. getStartWorkInforObj: function(work){
  925. var users = [];
  926. var currentTask = "";
  927. work.taskList.each(function(task, idx){
  928. users.push(task.person+"("+task.department + ")");
  929. if (work.currentTaskIndex===idx) currentTask = task.id;
  930. }.bind(this));
  931. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  932. },
  933. createStartWorkResault: function(workInfors, title, processName, isopen){
  934. var content = "";
  935. workInfors.each(function(infor){
  936. var users = [];
  937. infor.users.each(function(uname){
  938. users.push(MWF.name.cn(uname));
  939. });
  940. content += "<div><b>"+this.app.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.app.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  941. if (infor.currentTask && isopen){
  942. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  943. }else{
  944. content += "</div>";
  945. }
  946. }.bind(this));
  947. var msg = {
  948. "subject": this.app.lp.processStarted,
  949. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  950. };
  951. var tooltip = layout.desktop.message.addTooltip(msg);
  952. var item = layout.desktop.message.addMessage(msg);
  953. this.setStartWorkResaultAction(tooltip);
  954. this.setStartWorkResaultAction(item);
  955. },
  956. setStartWorkResaultAction: function(item){
  957. var node = item.node.getElements("span");
  958. node.setStyles(this.app.css.dealStartedWorkAction);
  959. var _self = this;
  960. node.addEvent("click", function(e){
  961. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  962. _self.app.desktop.openApplication(e, "process.Work", options);
  963. });
  964. }
  965. });