Main.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  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. this.getAction(function () {
  223. this.action.getCount(function (json) {
  224. this.counts = json.data;
  225. this["taskCountNode"].set("text", "( " + ((this.counts.task > 100) ? "99" : this.counts.task) + " )");
  226. this["taskCompletedCountNode"].set("text", "( " + ((this.counts.taskCompleted > 100) ? "99" : this.counts.taskCompleted) + " )");
  227. this["readCountNode"].set("text", "( " + ((this.counts.read > 100) ? "99" : this.counts.read) + " )");
  228. this["readCompletedCountNode"].set("text", "( " + ((this.counts.readCompleted > 100) ? "99" : this.counts.readCompleted) + " )");
  229. //this["reviewCountNode"].set("text", "[ "+((this.counts.review>100) ? "99" : this.counts.review)+" ]");
  230. }.bind(this), null, this.desktop.session.user.distinguishedName);
  231. }.bind(this));
  232. },
  233. loadContent: function(){
  234. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  235. this.contentListAreaNode = new Element("div", {"styles": this.css.contentListAreaNode}).inject(this.contentNode);
  236. this.setContentNodeHeight();
  237. this.addEvent("resize", this.setContentNodeHeight.bind(this));
  238. },
  239. setContentNodeHeight: function(){
  240. var size = this.content.getSize();
  241. var titleSize = this.taskTitleBar.getSize();
  242. var tabSize = this.tabAreaNode.getSize();
  243. var y = size.y-titleSize.y-tabSize.y-1;
  244. this.contentNode.setStyle("height", ""+y+"px");
  245. var x = 0;
  246. if (this.taskList) x = x + size.x;
  247. if (this.taskCompletedList) x = x + size.x;
  248. if (this.readList) x = x + size.x;
  249. if (this.readCompletedList) x = x + size.x;
  250. this.contentListAreaNode.setStyle("width", ""+x+"px");
  251. },
  252. openTab: function () {
  253. var tab = "task";
  254. if (this.options.navi) tab = this.options.navi;
  255. if (this.status) tab = this.status.navi;
  256. switch (tab) {
  257. case "task":
  258. this.showTask();
  259. break;
  260. case "done":
  261. this.showDone();
  262. break;
  263. case "read":
  264. this.showRead();
  265. break;
  266. case "readed":
  267. this.showReaded();
  268. break;
  269. case "review":
  270. this.showReview();
  271. break;
  272. default:
  273. this.showTask();
  274. break;
  275. }
  276. },
  277. showTask: function () {
  278. if (this.currentTab !== "task") {
  279. this.showTab(0);
  280. this.currentTab = "task";
  281. if (!this.taskList) {
  282. this.createTaskList();
  283. this.taskList.show();
  284. } else {
  285. this.taskList.show();
  286. if (this.taskList) this.taskList.refresh();
  287. }
  288. } else {
  289. if (this.taskList) this.taskList.refresh();
  290. }
  291. //this.searchBarAreaNode.setStyle("display", "none");
  292. },
  293. showTab: function (idx) {
  294. this.tabs.each(function (node, i) {
  295. if (i === idx) {
  296. node.getLast().setStyles(this.css.tabItemTextNode_current);
  297. if (!layout.mobile){
  298. node.getFirst().getNext().setStyles(this.css.tabItemTextNode_current);
  299. var icon = node.getFirst().getStyle("background-image");
  300. node.getFirst().setStyle("background-image", icon.replace(".png", "_cur.png"));
  301. }else{
  302. node.getFirst().setStyles(this.css.tabItemTextNode_current);
  303. }
  304. } else {
  305. node.getLast().setStyles(this.css.tabItemCountNode);
  306. if (!layout.mobile){
  307. node.getFirst().getNext().setStyles(this.css.tabItemTextNode);
  308. var icon = node.getFirst().getStyle("background-image");
  309. node.getFirst().setStyle("background-image", icon.replace("_cur.png", ".png"));
  310. }else{
  311. node.getFirst().setStyles(this.css.tabItemTextNode);
  312. }
  313. }
  314. }.bind(this));
  315. },
  316. createTaskList: function () {
  317. if (!this.contentNode) this.loadContent();
  318. this.taskList = new MWF.xApplication.process.TaskCenter.TaskList(this.contentListAreaNode, this);
  319. },
  320. //@todo 起草 搜索 筛选 。。。
  321. showStartProcessArea: function(){
  322. if (layout.mobile){
  323. this.showStartProcessArea_mobile();
  324. }else{
  325. this.showStartProcessArea_pc();
  326. }
  327. },
  328. showStartProcessArea_mobile: function(){
  329. if (!this.startProcessAreaNode) {
  330. this.createStartProcessArea_mobile();
  331. }
  332. this.startProcessAreaNode.setStyle("display", "block");
  333. //document.body.setStyle("-webkit-overflow-scrolling", "auto");
  334. var morph = new Fx.Morph(this.startProcessAreaNode, {
  335. "duration": 200,
  336. "transition": Fx.Transitions.Expo.easeOut
  337. });
  338. morph.start({"left": "0px"});
  339. },
  340. showStartProcessArea_pc: function () {
  341. if (!this.startProcessAreaNode) {
  342. this.createStartProcessArea();
  343. }
  344. this.content.mask({
  345. "destroyOnHide": true,
  346. "id": "process_taskcenter_startProcessMask",
  347. "style": this.css.maskNode
  348. });
  349. //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  350. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  351. if (maskNode){
  352. if( this.inBrowser ){
  353. maskNode.setStyles({"width":"100%","height":"100%"});
  354. }
  355. maskNode.addEvent("click", function (e) {
  356. this.closeStartProcessArea(e);
  357. }.bind(this));
  358. }
  359. //if (this.allApplicationStarter) this.allApplicationStarter.loadChild();
  360. this.startProcessAreaNode.fade("in");
  361. //this.startProcessTween.start("left", "-400px", "0px");
  362. },
  363. createStartProcessArea_mobile: function(){
  364. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode_mobile}).inject(this.content);
  365. var size = this.content.getSize();
  366. this.startProcessAreaNode.setStyles({
  367. "width": ""+size.x+"px",
  368. "height": ""+size.y+"px",
  369. "top": "0px",
  370. "left": ""+size.x+"px"
  371. });
  372. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode_mobile}).inject(this.startProcessAreaNode);
  373. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode_mobile, "text": this.lp.back}).inject(this.startProcessTopNode);
  374. this.startProcessCloseNode.addEvent("click", function (e) {
  375. this.closeStartProcessArea(e);
  376. }.bind(this));
  377. this.startProcessListNode = new Element("div", {"styles": this.css.startProcessListNode_mobile}).inject(this.startProcessAreaNode);
  378. var h = size.y-this.startProcessTopNode.getSize().y;
  379. this.startProcessListNode.setStyle("height", ""+h+"px");
  380. //this.createStartProcessScrollNode();
  381. this.getAction(function () {
  382. this.action.listApplicationStartable(function (appjson) {
  383. this.app = this;
  384. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  385. this.top5Data = json;
  386. if (this.top5Data && this.top5Data.length){
  387. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.lp.startTop5}).inject(this.startProcessListNode);
  388. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  389. this.top5Data.sort(function(p1, p2){
  390. return 0-(p1.count-p2.count);
  391. });
  392. this.top5Data.each(function(process, i){
  393. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  394. }.bind(this));
  395. }
  396. appjson.data.each(function (app) {
  397. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.startProcessListNode);
  398. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  399. app.processList.each(function(process){
  400. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  401. }.bind(this));
  402. }.bind(this));
  403. }.bind(this));
  404. // this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  405. // this.allApplicationStarter.selected();
  406. // json.data.each(function (app) {
  407. // new MWF.xApplication.process.TaskCenter.Application(app, this);
  408. // }.bind(this));
  409. }.bind(this));
  410. }.bind(this));
  411. },
  412. createStartProcessArea: function () {
  413. this.createStartProcessAreaNode();
  414. this.createStartProcessScrollNode();
  415. this.listApplications();
  416. this.setResizeStartProcessAreaHeight();
  417. this.addEvent("resize", this.setResizeStartProcessAreaHeight.bind(this));
  418. //this.startProcessTween = new Fx.Tween(this.startProcessAreaNode, {
  419. // "duration": "200",
  420. // "transition": Fx.Transitions.Quad.easeOut
  421. //});
  422. },
  423. createStartProcessAreaNode: function () {
  424. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode}).inject(this.content);
  425. },
  426. createStartProcessCloseNode: function () {
  427. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode}).inject(this.startProcessRightListNode);
  428. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode}).inject(this.startProcessTopNode);
  429. this.startProcessCloseNode.addEvent("click", function (e) {
  430. this.closeStartProcessArea(e);
  431. }.bind(this));
  432. },
  433. createStartProcessSearchNode: function(){
  434. this.startProcessSearchNode = new Element("div", {"styles": this.css.startProcessSearchNode}).inject(this.startProcessRightListNode);
  435. this.startProcessSearchIconNode = new Element("div", {"styles": this.css.startProcessSearchIconNode}).inject(this.startProcessSearchNode);
  436. this.startProcessSearchAreaNode = new Element("div", {"styles": this.css.startProcessSearchAreaNode}).inject(this.startProcessSearchNode);
  437. this.startProcessSearchInputNode = new Element("input", {"styles": this.css.startProcessSearchInputNode}).inject(this.startProcessSearchAreaNode);
  438. this.startProcessSearchInputNode.set("value", this.lp.searchProcess);
  439. this.startProcessSearchInputNode.addEvents({
  440. "focus": function(){ if (this.startProcessSearchInputNode.get("value")===this.lp.searchProcess) this.startProcessSearchInputNode.set("value", ""); }.bind(this),
  441. "blur": function(){if (!this.startProcessSearchInputNode.get("value")) this.startProcessSearchInputNode.set("value", this.lp.searchProcess);}.bind(this),
  442. "keydown": function(e){ if (e.code===13) this.searchStartProcess(); }.bind(this)
  443. });
  444. this.startProcessSearchIconNode.addEvent("click", function(){ this.searchStartProcess(); }.bind(this));
  445. },
  446. searchStartProcess: function(){
  447. var key = this.startProcessSearchInputNode.get("value");
  448. if (key && key!==this.lp.searchProcess){
  449. if (this.appStartableData){
  450. this.startApplications.each(function(app){ app.unselected(); });
  451. if (this.searchProcessSearchchildNode) this.searchProcessSearchchildNode.destroy();
  452. var text = this.lp.searchProcessResault.replace("{key}", key);
  453. this.searchProcessSearchchildNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.startProcessProcessAreaNode);
  454. this.searchProcessSearchchildNode.setStyle("display", "block");
  455. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": text}).inject(this.searchProcessSearchchildNode);
  456. var proListNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.searchProcessSearchchildNode);
  457. this.appStartableData.each(function (app) {
  458. app.processList.each(function(pro){
  459. if (pro.name.indexOf(key)!==-1){
  460. var data = Object.clone(pro);
  461. data.applicationName = app.name;
  462. new MWF.xApplication.process.TaskCenter.Process(data, {"app": this}, {"name": app}, proListNode);
  463. }
  464. }.bind(this));
  465. }.bind(this));
  466. }
  467. }
  468. },
  469. createStartProcessScrollNode: function () {
  470. this.startProcessApplicationListNode = new Element("div", {"styles": this.css.startProcessApplicationListNode}).inject(this.startProcessAreaNode);
  471. this.startProcessRightListNode = new Element("div", {"styles": this.css.startProcessRightListNode}).inject(this.startProcessAreaNode);
  472. this.createStartProcessCloseNode();
  473. this.createStartProcessSearchNode();
  474. this.startProcessApplicationScrollNode = new Element("div", {"styles": this.css.startProcessApplicationScrollNode}).inject(this.startProcessApplicationListNode);
  475. this.startProcessApplicationAreaNode = new Element("div", {"styles": this.css.startProcessApplicationAreaNode}).inject(this.startProcessApplicationScrollNode);
  476. this.startProcessProcessListNode = new Element("div", {"styles": this.css.startProcessProcessListNode}).inject(this.startProcessRightListNode);
  477. this.startProcessProcessScrollNode = new Element("div", {"styles": this.css.startProcessProcessScrollNode}).inject(this.startProcessProcessListNode);
  478. this.startProcessProcessAreaNode = new Element("div", {"styles": this.css.startProcessProcessAreaNode}).inject(this.startProcessProcessScrollNode);
  479. MWF.require("MWF.widget.ScrollBar", function () {
  480. new MWF.widget.ScrollBar(this.startProcessApplicationScrollNode, {
  481. "distance": 100,
  482. "friction": 4
  483. });
  484. new MWF.widget.ScrollBar(this.startProcessProcessScrollNode, {
  485. "distance": 100,
  486. "friction": 4
  487. });
  488. }.bind(this));
  489. //this.startProcessContentNode = new Element("div", {"styles": this.css.startProcessContentNode}).inject(this.startProcessScrollNode);
  490. },
  491. closeStartProcessArea: function () {
  492. //if (this.startProcessAreaNode) this.startProcessTween.start("left", "0px", "-400px");
  493. if (layout.mobile){
  494. var size = this.startProcessAreaNode.getSize();
  495. var morph = new Fx.Morph(this.startProcessAreaNode, {
  496. "duration": 200,
  497. "transition": Fx.Transitions.Expo.easeOut,
  498. "onComplete": function(){
  499. this.startProcessAreaNode.setStyle("display", "none");
  500. }.bind(this)
  501. });
  502. morph.start({"left": ""+size.x+"px"});
  503. }else{
  504. this.content.unmask();
  505. if (this.startProcessAreaNode) this.startProcessAreaNode.fade("out");
  506. }
  507. },
  508. setResizeStartProcessAreaHeight: function () {
  509. if (this.startProcessAreaNode) {
  510. var size = this.content.getSize();
  511. var nodeSize = this.startProcessAreaNode.getSize();
  512. var x = (size.x-nodeSize.x)/2;
  513. var y = (size.y-nodeSize.y)/2;
  514. this.startProcessAreaNode.setStyle("top", "" + y + "px");
  515. this.startProcessAreaNode.setStyle("left", "" + x + "px");
  516. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  517. //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  518. if (maskNode){
  519. maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  520. maskNode.position({
  521. "relativeTo": this.content,
  522. "position": "topLeft",
  523. "edge": "topLeft"
  524. });
  525. }
  526. if (this.startProcessProcessListNode){
  527. var topSize = this.startProcessTopNode.getSize();
  528. var searchSize = this.startProcessSearchNode.getSize();
  529. var h = nodeSize.y-topSize.y-searchSize.y;
  530. this.startProcessProcessListNode.setStyle("height", ""+h+"px");
  531. }
  532. }
  533. },
  534. listApplications: function () {
  535. this.getAction(function () {
  536. this.action.listApplicationStartable(function (json) {
  537. this.appStartableData = json.data;
  538. this.startProcessSearchNode.setStyle("display", "block");
  539. this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  540. this.allApplicationStarter.selected();
  541. json.data.each(function (app) {
  542. new MWF.xApplication.process.TaskCenter.Application(app, this);
  543. }.bind(this));
  544. }.bind(this));
  545. }.bind(this));
  546. },
  547. getAction: function (callback) {
  548. if (!this.action) {
  549. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  550. if (callback) callback();
  551. // MWF.xDesktop.requireApp("process.TaskCenter", "Actions.RestActions", function () {
  552. // this.action = new MWF.xApplication.process.TaskCenter.Actions.RestActions();
  553. // if (callback) callback();
  554. // }.bind(this));
  555. } else {
  556. if (callback) callback();
  557. }
  558. },
  559. refreshAll: function () {
  560. this.getWorkCounts();
  561. if (this.taskList) if (this.currentTab === "task") this.taskList.refresh();
  562. //if (this.taskCompletedList) if (this.currentTab == "done") this.taskCompletedList.refresh();
  563. //if (this.readList) if (this.currentTab == "read") this.readList.refresh();
  564. //if (this.readedList) if (this.currentTab == "readed") this.readedList.refresh();
  565. //if (this.reviewList) if (this.currentTab == "review") this.reviewList.refresh();
  566. },
  567. createTaskCompletedList: function (filterData) {
  568. if (!this.contentNode) this.loadContent();
  569. this.taskCompletedList = new MWF.xApplication.process.TaskCenter.TaskCompletedList(this.contentListAreaNode, this, filterData);
  570. //if (filterData) this.taskCompletedList.filterData = filterData;
  571. },
  572. showDone: function () {
  573. if (this.currentTab !== "done") {
  574. this.showTab(1);
  575. this.currentTab = "done";
  576. if (!this.taskCompletedList) {
  577. this.createTaskCompletedList((this.status) ? this.status.filter : null);
  578. this.taskCompletedList.show();
  579. } else {
  580. this.taskCompletedList.show();
  581. if (this.taskCompletedList) this.taskCompletedList.refresh();
  582. }
  583. } else {
  584. if (this.taskCompletedList) this.taskCompletedList.refresh();
  585. }
  586. this.searchBarAreaNode.setStyle("display", "block");
  587. this.searchBarInputNode.set("value", this.lp.searchKey);
  588. },
  589. createReadList: function (filterData) {
  590. if (!this.contentNode) this.loadContent();
  591. this.readList = new MWF.xApplication.process.TaskCenter.ReadList(this.contentListAreaNode, this, filterData);
  592. //if (filterData) this.taskCompletedList.filterData = filterData;
  593. },
  594. showRead: function () {
  595. if (this.currentTab !== "read") {
  596. this.showTab(2);
  597. this.currentTab = "read";
  598. if (!this.readList) {
  599. this.createReadList((this.status) ? this.status.filter : null);
  600. this.readList.show();
  601. } else {
  602. this.readList.show();
  603. if (this.readList) this.readList.refresh();
  604. }
  605. } else {
  606. if (this.readList) this.readList.refresh();
  607. }
  608. this.searchBarAreaNode.setStyle("display", "block");
  609. this.searchBarInputNode.set("value", this.lp.searchKey);
  610. },
  611. createReadedList: function (filterData) {
  612. if (!this.contentNode) this.loadContent();
  613. this.readedList = new MWF.xApplication.process.TaskCenter.ReadCompletedList(this.contentListAreaNode, this, filterData);
  614. //if (filterData) this.taskCompletedList.filterData = filterData;
  615. },
  616. showReaded: function () {
  617. if (this.currentTab !== "readed") {
  618. this.showTab(3);
  619. this.currentTab = "readed";
  620. if (!this.readedList) {
  621. this.createReadedList((this.status) ? this.status.filter : null);
  622. this.readedList.show();
  623. } else {
  624. this.readedList.show();
  625. if (this.readedList) this.readedList.refresh();
  626. }
  627. } else {
  628. if (this.readedList) this.readedList.refresh();
  629. }
  630. this.searchBarAreaNode.setStyle("display", "block");
  631. this.searchBarInputNode.set("value", this.lp.searchKey);
  632. },
  633. createReviewList: function (filterData) {
  634. if (!this.contentNode) this.loadContent();
  635. this.reviewList = new MWF.xApplication.process.TaskCenter.ReviewList(this.contentListAreaNode, this, filterData);
  636. //if (filterData) this.taskCompletedList.filterData = filterData;
  637. },
  638. showReview: function () {
  639. if (this.currentTab !== "review") {
  640. this.showTab(4);
  641. this.currentTab = "review";
  642. if (!this.reviewList) {
  643. this.createReviewList((this.status) ? this.status.filter : null);
  644. this.reviewList.show();
  645. } else {
  646. this.reviewList.show();
  647. if (this.reviewList) this.reviewList.refresh();
  648. }
  649. } else {
  650. if (this.reviewList) this.reviewList.refresh();
  651. }
  652. this.searchBarAreaNode.setStyle("display", "block");
  653. },
  654. recordStatus: function(){
  655. var tab = this.currentTab || "task";
  656. var filter = null;
  657. if (tab==="done"){
  658. filter = this.taskCompletedList.filterData;
  659. }
  660. if (tab==="read"){
  661. filter = this.readList.filterData;
  662. }
  663. if (tab==="readed"){
  664. filter = this.readedList.filterData;
  665. }
  666. if (tab==="review"){
  667. filter = this.reviewList.filterData;
  668. }
  669. return {"navi": this.currentTab || "task", "filter": filter};
  670. },
  671. searchTask: function(){
  672. var keyWord = this.searchBarInputNode.get("value");
  673. if (keyWord && (keyWord!==this.lp.searchKey)){
  674. var tab = this.currentTab || "task";
  675. switch (tab){
  676. case "task":
  677. if (!this.taskList.filterData) this.taskList.filterData = {};
  678. this.taskList.filterData.key = keyWord;
  679. this.taskList.refilter();
  680. break;
  681. case "done":
  682. if (!this.taskCompletedList.filterData) this.taskCompletedList.filterData = {};
  683. this.taskCompletedList.filterData.key = keyWord;
  684. this.taskCompletedList.refilter();
  685. break;
  686. case "read":
  687. if (!this.readList.filterData) this.readList.filterData = {};
  688. this.readList.filterData.key = keyWord;
  689. this.readList.refilter();
  690. break;
  691. case "readed":
  692. if (!this.readedList.filterData) this.readedList.filterData = {};
  693. this.readedList.filterData.key = keyWord;
  694. this.readedList.refilter();
  695. break;
  696. case "review":
  697. if (!this.reviewList.filterData) this.reviewList.filterData = {};
  698. this.reviewList.filterData.key = keyWord;
  699. this.reviewList.refilter();
  700. break;
  701. }
  702. }
  703. }
  704. });
  705. MWF.xApplication.process.TaskCenter.Application = new Class({
  706. initialize: function(data, app){
  707. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  708. this.data = data;
  709. this.app = app;
  710. this.container = this.app.startProcessApplicationAreaNode;
  711. this.processContainer = this.app.startProcessProcessAreaNode;
  712. this.css = this.app.css;
  713. this.isLoaded = false;
  714. this.load();
  715. },
  716. load: function(){
  717. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  718. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  719. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  720. if (this.data.icon){
  721. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  722. }else{
  723. this.iconNode.set("src", "/x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  724. }
  725. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  726. this.textNode.set("text", this.data.name);
  727. this.textNode.set("title", this.data.name);
  728. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  729. //this.loadChild();
  730. this.node.addEvent("click", function(){
  731. this.selected();
  732. }.bind(this));
  733. this.app.startApplications.push(this);
  734. },
  735. unselected: function(){
  736. this.childNode.setStyle("display", "none");
  737. this.node.setStyles(this.css.applicationNode);
  738. },
  739. selected: function(){
  740. this.app.startApplications.each(function(app){
  741. app.unselected();
  742. });
  743. if (this.app.searchProcessSearchchildNode) this.app.searchProcessSearchchildNode.destroy();
  744. if (this.app.startProcessSearchInputNode) this.app.startProcessSearchInputNode.set("value", this.app.lp.searchProcess);
  745. this.childNode.setStyle("display", "block");
  746. this.node.setStyles(this.css.applicationNode_selected);
  747. if (!this.isLoaded){
  748. this.loadChild();
  749. this.isLoaded = true;
  750. }
  751. },
  752. loadChild: function(){
  753. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startProcess}).inject(this.childNode);
  754. var childNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  755. this.data.processList.each(function(process){
  756. new MWF.xApplication.process.TaskCenter.Process(process, this, this.data, childNode);
  757. }.bind(this));
  758. }
  759. });
  760. MWF.xApplication.process.TaskCenter.AllApplication = new Class({
  761. Extends: MWF.xApplication.process.TaskCenter.Application,
  762. initialize: function(data, app){
  763. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  764. this.data = data;
  765. this.app = app;
  766. this.container = this.app.startProcessApplicationAreaNode;
  767. this.processContainer = this.app.startProcessProcessAreaNode;
  768. this.css = this.app.css;
  769. this.isLoaded = false;
  770. this.load();
  771. },
  772. load: function(){
  773. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  774. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  775. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  776. this.iconNode.set("src", "/x_component_process_TaskCenter/$Main/default/icon/appAppliction.png");
  777. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  778. this.textNode.set("text", this.app.lp.all);
  779. this.textNode.set("title", this.app.lp.all);
  780. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  781. //this.loadChild();
  782. this.node.addEvent("click", function(){
  783. this.selected();
  784. }.bind(this));
  785. this.app.startApplications.push(this);
  786. },
  787. unselected: function(){
  788. this.childNode.empty();
  789. this.isLoaded = false;
  790. this.childNode.setStyle("display", "none");
  791. this.node.setStyles(this.css.applicationNode);
  792. },
  793. loadChild: function(){
  794. //this.loadSearch();
  795. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  796. this.top5Data = json;
  797. if (this.top5Data && this.top5Data.length){
  798. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  799. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  800. this.top5Data.sort(function(p1, p2){
  801. return 0-(p1.count-p2.count);
  802. });
  803. }
  804. var allowProcessIds = [];
  805. this.data.each(function (app) {
  806. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  807. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  808. app.processList.each(function(process){
  809. allowProcessIds.push(process.id);
  810. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  811. }.bind(this));
  812. }.bind(this));
  813. if (top5ChildNode){
  814. saveflag = false;
  815. this.top5Data.each(function(process, i){
  816. if (allowProcessIds.indexOf(process.id)!==-1){
  817. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  818. }else{
  819. saveflag = true;
  820. process.count=0;
  821. }
  822. }.bind(this));
  823. if (saveflag) MWF.UD.putData("taskCenter_startTop", this.top5Data);
  824. }
  825. }.bind(this));
  826. }
  827. });
  828. MWF.xApplication.process.TaskCenter.Process = new Class({
  829. initialize: function(data, application, applicationData, container){
  830. this.data = data;
  831. this.application = application;
  832. this.applicationData = applicationData;
  833. this.app = this.application.app;
  834. this.container = container;
  835. this.css = this.app.css;
  836. this.load();
  837. },
  838. load: function(){
  839. this.node = new Element("div.processItem", {"styles": this.css.startProcessNode}).inject(this.container);
  840. this.iconNode = new Element("div", {"styles": this.css.processIconNode}).inject(this.node);
  841. if (this.data.icon){
  842. this.iconNode.setStyle("background-image", "url("+this.data.icon+")");
  843. }else{
  844. this.iconNode.setStyle("background-image", "url(/x_component_process_ProcessManager/$Explorer/default/processIcon/process.png)");
  845. }
  846. this.actionNode = new Element("div", {"styles": this.css.processActionNode, "text": this.app.lp.start}).inject(this.node);
  847. this.textNode = new Element("div", {"styles": this.css.processTextNode}).inject(this.node);
  848. this.textNode.set({
  849. "text": this.data.name+((this.data.applicationName) ? " -- ("+this.data.applicationName+")" : ""),
  850. "title": this.data.name+"-"+this.data.description
  851. });
  852. //var _self = this;
  853. this.actionNode.addEvents({
  854. "mouseover": function(){this.actionNode.setStyles(this.css.processActionNode_over);}.bind(this),
  855. "mouseout": function(){this.actionNode.setStyles(this.css.processActionNode);}.bind(this),
  856. "click": function(e){
  857. this.startProcess(e);
  858. }.bind(this)
  859. });
  860. this.node.addEvents({
  861. "mouseover": function(){
  862. this.node.setStyles(this.css.startProcessNode_over);
  863. this.actionNode.setStyle("display", "block");
  864. }.bind(this),
  865. "mouseout": function(){
  866. this.node.setStyles(this.css.startProcessNode_out);
  867. //this.actionNode.setStyle("display", "none");
  868. }.bind(this)
  869. });
  870. },
  871. startProcess: function(){
  872. this.app.closeStartProcessArea();
  873. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  874. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(this.data, this.app, {
  875. "onStarted": function(data, title, processName){
  876. this.afterStartProcess(data, title, processName);
  877. }.bind(this)
  878. });
  879. starter.load();
  880. }.bind(this));
  881. },
  882. recordProcessData: function(){
  883. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  884. if (!json || !json.length) json = [];
  885. var recordProcess = null;
  886. this.data.lastStartTime = new Date();
  887. var earlyProcessIdx = 0;
  888. var flag = true;
  889. for (var i=0; i<json.length; i++){
  890. var process = json[i];
  891. if (process.id === this.data.id) recordProcess = process;
  892. if (flag){
  893. if (!process.lastStartTime){
  894. earlyProcessIdx = i;
  895. flag = false;
  896. }else{
  897. if (new Date(process.lastStartTime)<new Date(json[earlyProcessIdx].lastStartTime)){
  898. earlyProcessIdx = i;
  899. }
  900. }
  901. }
  902. }
  903. if (recordProcess) {
  904. recordProcess.lastStartTime = new Date();
  905. recordProcess.count = (recordProcess.count || 0)+1;
  906. recordProcess.applicationName = this.applicationData.name;
  907. }else{
  908. if (json.length<10){
  909. this.data.count = 1;
  910. this.data.applicationName = this.applicationData.name;
  911. json.push(this.data);
  912. }else{
  913. json.splice(earlyProcessIdx, 1);
  914. this.data.count = 1;
  915. this.data.applicationName = this.applicationData.name;
  916. json.push(this.data);
  917. }
  918. }
  919. MWF.UD.putData("taskCenter_startTop", json);
  920. }.bind(this));
  921. },
  922. afterStartProcess: function(data, title, processName){
  923. this.recordProcessData();
  924. var workInfors = [];
  925. var currentTask = [];
  926. data.each(function(work){
  927. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  928. workInfors.push(this.getStartWorkInforObj(work));
  929. }.bind(this));
  930. if (currentTask.length===1){
  931. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  932. this.app.desktop.openApplication(null, "process.Work", options);
  933. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
  934. }else{
  935. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
  936. }
  937. },
  938. getStartWorkInforObj: function(work){
  939. var users = [];
  940. var currentTask = "";
  941. work.taskList.each(function(task, idx){
  942. users.push(task.person+"("+task.department + ")");
  943. if (work.currentTaskIndex===idx) currentTask = task.id;
  944. }.bind(this));
  945. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  946. },
  947. createStartWorkResault: function(workInfors, title, processName, isopen){
  948. var content = "";
  949. workInfors.each(function(infor){
  950. var users = [];
  951. infor.users.each(function(uname){
  952. users.push(MWF.name.cn(uname));
  953. });
  954. 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>";
  955. if (infor.currentTask && isopen){
  956. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  957. }else{
  958. content += "</div>";
  959. }
  960. }.bind(this));
  961. var msg = {
  962. "subject": this.app.lp.processStarted,
  963. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  964. };
  965. var tooltip = layout.desktop.message.addTooltip(msg);
  966. var item = layout.desktop.message.addMessage(msg);
  967. this.setStartWorkResaultAction(tooltip);
  968. this.setStartWorkResaultAction(item);
  969. },
  970. setStartWorkResaultAction: function(item){
  971. var node = item.node.getElements("span");
  972. node.setStyles(this.app.css.dealStartedWorkAction);
  973. var _self = this;
  974. node.addEvent("click", function(e){
  975. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  976. _self.app.desktop.openApplication(e, "process.Work", options);
  977. });
  978. }
  979. });