test.js 46 KB

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