Main.js 45 KB

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