Main.js 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.xApplication.process.TaskCenter = MWF.xApplication.process.TaskCenter || {};
  3. MWF.require("MWF.widget.Mask", null, false);
  4. MWF.require("MWF.xDesktop.UserData", null, false);
  5. MWF.xDesktop.requireApp("process.TaskCenter", "TaskList", null, false);
  6. MWF.xDesktop.requireApp("process.TaskCenter", "TaskCompletedList", null, false);
  7. MWF.xDesktop.requireApp("process.TaskCenter", "ReadList", null, false);
  8. MWF.xDesktop.requireApp("process.TaskCenter", "ReadCompletedList", null, false);
  9. MWF.xDesktop.requireApp("process.TaskCenter", "ReviewList", null, false);
  10. if (MWF.xApplication.process.TaskCenter.options) MWF.xApplication.process.TaskCenter.options.multitask = false;
  11. MWF.xApplication.process.TaskCenter.Main = new Class({
  12. Extends: MWF.xApplication.Common.Main,
  13. Implements: [Options, Events],
  14. options: {
  15. "style": "default",
  16. "name": "process.TaskCenter",
  17. "icon": "icon.png",
  18. "width": "1280",
  19. "height": "700",
  20. "title": MWF.xApplication.process.TaskCenter.LP.title,
  21. "filterMap": {
  22. "applicationList": "applicationList",
  23. "processList": "processList",
  24. "creatorUnitList": "creatorUnitList",
  25. "creatorCompanyList": "creatorCompanyList",
  26. "creatorDepartmentList": "creatorDepartmentList",
  27. "activityNameList": "activityNameList",
  28. "completedTimeMonthList": "completedTimeMonthList",
  29. "key": "key"
  30. }
  31. },
  32. onQueryLoad: function () {
  33. this.lp = MWF.xApplication.process.TaskCenter.LP;
  34. },
  35. loadApplication: function (callback) {
  36. this.appIcons = {};
  37. this.tabs = [];
  38. this.tabShadows = [];
  39. this.appStartableData = null;
  40. this.loadTitle();
  41. this.loadTab();
  42. this.loadFilterAction();
  43. this.loadContent();
  44. this.currentTab = "";
  45. this.openTab();
  46. if (callback) callback();
  47. },
  48. loadTitle: function () {
  49. this.loadTitleBar();
  50. if (!layout.mobile) this.loadTitleUserNode();
  51. this.loadStartProcessActionNode();
  52. if (!layout.mobile) this.loadTitleTextNode();
  53. this.loadSearchNode();
  54. },
  55. loadTitleBar: function () {
  56. this.taskTitleBar = new Element("div", {
  57. "styles": this.css.taskTitleBar
  58. }).inject(this.content);
  59. },
  60. loadTitleUserNode: function () {
  61. this.taskTitleUserNode = new Element("div", {
  62. "styles": this.css.taskTitleUserNode
  63. }).inject(this.taskTitleBar);
  64. this.taskTitleUserIconNode = new Element("div", {
  65. "styles": this.css.taskTitleUserIconNode
  66. }).inject(this.taskTitleUserNode);
  67. this.taskTitleUserTextNode = new Element("div", {
  68. "styles": this.css.taskTitleUserTextNode,
  69. "text": this.desktop.session.user.name
  70. }).inject(this.taskTitleUserNode);
  71. },
  72. loadStartProcessActionNode: function () {
  73. this.startProcessAction = new Element("div", {
  74. "styles": this.css.startProcessAction
  75. }).inject(this.taskTitleBar);
  76. this.startProcessAction.addEvents({
  77. "click": function (e) {
  78. this.showStartProcessArea(e);
  79. }.bind(this)
  80. });
  81. },
  82. loadTitleTextNode: function () {
  83. this.taskTitleTextNode = new Element("div", {
  84. "styles": this.css.taskTitleTextNode,
  85. "text": this.lp.title
  86. }).inject(this.taskTitleBar);
  87. },
  88. loadSearchNode: function () {
  89. this.searchBarAreaNode = new Element("div", {
  90. "styles": this.css.searchBarAreaNode
  91. }).inject(this.taskTitleBar);
  92. if (layout.mobile) this.searchBarAreaNode.setStyle("margin-left", "10px");
  93. if (layout.mobile) this.searchBarAreaNode.setStyle("margin-right", "20px");
  94. this.searchBarNode = new Element("div", {
  95. "styles": this.css.searchBarNode
  96. }).inject(this.searchBarAreaNode);
  97. this.searchBarActionNode = new Element("div", {
  98. "styles": this.css.searchBarActionNode
  99. }).inject(this.searchBarNode);
  100. this.searchBarInputBoxNode = new Element("div", {
  101. "styles": this.css.searchBarInputBoxNode
  102. }).inject(this.searchBarNode);
  103. this.searchBarInputNode = new Element("input", {
  104. "type": "text",
  105. "value": this.lp.searchKey,
  106. "styles": this.css.searchBarInputNode
  107. }).inject(this.searchBarInputBoxNode);
  108. var _self = this;
  109. this.searchBarActionNode.addEvent("click", function () {
  110. this.searchTask();
  111. }.bind(this));
  112. this.searchBarInputNode.addEvents({
  113. "focus": function () {
  114. if (this.value === _self.lp.searchKey) this.set("value", "");
  115. },
  116. "blur": function () {
  117. if (!this.value) this.set("value", _self.lp.searchKey);
  118. },
  119. "keydown": function (e) {
  120. if (e.code === 13) {
  121. this.searchTask();
  122. e.preventDefault();
  123. }
  124. }.bind(this),
  125. "selectstart": function (e) {
  126. e.preventDefault();
  127. }
  128. });
  129. },
  130. loadTab: function () {
  131. this.tabAreaNode = new Element("div", {
  132. "styles": this.css.tabAreaNode
  133. }).inject(this.content);
  134. this.createTabItem(this.lp.task, "task.png", "task", function () {
  135. this.showTask();
  136. }.bind(this));
  137. this.createTabItem(this.lp.done, "done.png", "taskCompleted", function () {
  138. this.showDone();
  139. }.bind(this));
  140. this.createTabItem(this.lp.read, "read.png", "read", function () {
  141. this.showRead();
  142. }.bind(this));
  143. this.createTabItem(this.lp.readed, "readed.png", "readCompleted", function () {
  144. this.showReaded();
  145. }.bind(this));
  146. //this.createTabItem(this.lp.review, "review.png", "review", function(){this.showReview();}.bind(this));
  147. this.getWorkCounts();
  148. },
  149. // createTabItem: function (text, icon, countKey, action) {
  150. // if (COMMON.Browser.Platform.isMobile){
  151. // this.createTabItem_mobile(text, icon, countKey, action);
  152. // }else{
  153. // this.createTabItem_pc(text, icon, countKey, action);
  154. // }
  155. // },
  156. // createTabItem_mobile: function(text, icon, countKey, action){
  157. // var tab = new Element("div", {
  158. // "styles": this.css.tabItemNode
  159. // }).inject(this.tabAreaNode);
  160. //
  161. // var tabItem = new Element("div", {
  162. // "styles": this.css.tabItemAreaNode
  163. // }).inject(tab);
  164. //
  165. // var tabContent = new Element("div", {
  166. // "styles": this.css.tabItemContentNode_mobile
  167. // }).inject(tabItem);
  168. //
  169. // var tabText = new Element("div", {
  170. // "styles": this.css.tabItemTextNode_mobile,
  171. // "text": text
  172. // }).inject(tabContent);
  173. //
  174. // this[countKey+"CountNode"] = new Element("div", {
  175. // "styles": this.css.tabItemCountNode
  176. // }).inject(tabContent);
  177. //
  178. // tab.addEvent("click", function(){action();}.bind(this));
  179. //
  180. // this.tabs.push(tab);
  181. // },
  182. createTabItem: function(text, icon, countKey, action){
  183. var tab = new Element("div", {
  184. "styles": this.css.tabItemNode
  185. }).inject(this.tabAreaNode);
  186. if (!layout.mobile){
  187. var tabIcon = new Element("div", {
  188. "styles": this.css.tabItemIconNode
  189. }).inject(tab);
  190. tabIcon.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/tab/"+icon+")");
  191. }
  192. var tabText = new Element("div", {
  193. "styles": this.css.tabItemTextNode,
  194. "text": text
  195. }).inject(tab);
  196. this[countKey+"CountNode"] = new Element("div", {
  197. "styles": this.css.tabItemCountNode
  198. }).inject(tab);
  199. tab.addEvent("click", function(){action();}.bind(this));
  200. this.tabs.push(tab);
  201. },
  202. loadFilterAction: function(){
  203. // this.flterAction = new Element("div", {
  204. // "styles": this.css.tabItemNode
  205. // }).inject(this.tabAreaNode);
  206. //
  207. // var tabIcon = new Element("div", {
  208. // "styles": this.css.tabItemIconNode
  209. // }).inject(tab);
  210. // tabIcon.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/tab/"+icon+")");
  211. // var tabText = new Element("div", {
  212. // "styles": this.css.tabItemTextNode,
  213. // "text": text
  214. // }).inject(tab);
  215. //
  216. // this[countKey+"CountNode"] = new Element("div", {
  217. // "styles": this.css.tabItemCountNode
  218. // }).inject(tab);
  219. //
  220. // tab.addEvent("click", function(){action();}.bind(this));
  221. },
  222. getWorkCounts: function () {
  223. this.getAction(function () {
  224. this.action.getCount(function (json) {
  225. this.counts = json.data;
  226. this["taskCountNode"].set("text", "( " + ((this.counts.task > 100) ? "99" : this.counts.task) + " )");
  227. this["taskCompletedCountNode"].set("text", "( " + ((this.counts.taskCompleted > 100) ? "99" : this.counts.taskCompleted) + " )");
  228. this["readCountNode"].set("text", "( " + ((this.counts.read > 100) ? "99" : this.counts.read) + " )");
  229. this["readCompletedCountNode"].set("text", "( " + ((this.counts.readCompleted > 100) ? "99" : this.counts.readCompleted) + " )");
  230. //this["reviewCountNode"].set("text", "[ "+((this.counts.review>100) ? "99" : this.counts.review)+" ]");
  231. }.bind(this), null, this.desktop.session.user.distinguishedName);
  232. }.bind(this));
  233. },
  234. loadContent: function(){
  235. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  236. this.contentListAreaNode = new Element("div", {"styles": this.css.contentListAreaNode}).inject(this.contentNode);
  237. this.setContentNodeHeight();
  238. this.addEvent("resize", this.setContentNodeHeight.bind(this));
  239. },
  240. setContentNodeHeight: function(){
  241. var size = this.content.getSize();
  242. var titleSize = this.taskTitleBar.getSize();
  243. var tabSize = this.tabAreaNode.getSize();
  244. var y = size.y-titleSize.y-tabSize.y-1;
  245. this.contentNode.setStyle("height", ""+y+"px");
  246. var x = 0;
  247. if (this.taskList) x = x + size.x;
  248. if (this.taskCompletedList) x = x + size.x;
  249. if (this.readList) x = x + size.x;
  250. if (this.readCompletedList) x = x + size.x;
  251. this.contentListAreaNode.setStyle("width", ""+x+"px");
  252. },
  253. openTab: function () {
  254. var tab = "task";
  255. if (this.options.navi) tab = this.options.navi;
  256. if (this.status) tab = this.status.navi;
  257. switch (tab) {
  258. case "task":
  259. this.showTask();
  260. break;
  261. case "done":
  262. this.showDone();
  263. break;
  264. case "read":
  265. this.showRead();
  266. break;
  267. case "readed":
  268. this.showReaded();
  269. break;
  270. case "review":
  271. this.showReview();
  272. break;
  273. default:
  274. this.showTask();
  275. break;
  276. }
  277. },
  278. showTask: function () {
  279. if (this.currentTab !== "task") {
  280. this.showTab(0);
  281. this.currentTab = "task";
  282. if (!this.taskList) {
  283. this.createTaskList();
  284. this.taskList.show();
  285. } else {
  286. this.taskList.show();
  287. if (this.taskList) this.taskList.refresh();
  288. }
  289. } else {
  290. if (this.taskList) this.taskList.refresh();
  291. }
  292. //this.searchBarAreaNode.setStyle("display", "none");
  293. },
  294. showTab: function (idx) {
  295. this.tabs.each(function (node, i) {
  296. if (i === idx) {
  297. node.getLast().setStyles(this.css.tabItemTextNode_current);
  298. if (!layout.mobile){
  299. node.getFirst().getNext().setStyles(this.css.tabItemTextNode_current);
  300. var icon = node.getFirst().getStyle("background-image");
  301. node.getFirst().setStyle("background-image", icon.replace(".png", "_cur.png"));
  302. }else{
  303. node.getFirst().setStyles(this.css.tabItemTextNode_current);
  304. }
  305. } else {
  306. node.getLast().setStyles(this.css.tabItemCountNode);
  307. if (!layout.mobile){
  308. node.getFirst().getNext().setStyles(this.css.tabItemTextNode);
  309. var icon = node.getFirst().getStyle("background-image");
  310. node.getFirst().setStyle("background-image", icon.replace("_cur.png", ".png"));
  311. }else{
  312. node.getFirst().setStyles(this.css.tabItemTextNode);
  313. }
  314. }
  315. }.bind(this));
  316. },
  317. createTaskList: function () {
  318. if (!this.contentNode) this.loadContent();
  319. this.taskList = new MWF.xApplication.process.TaskCenter.TaskList(this.contentListAreaNode, this);
  320. },
  321. //@todo 起草 搜索 筛选 。。。
  322. showStartProcessArea: function(){
  323. if (!this.processStarter) this.processStarter = new MWF.xApplication.process.TaskCenter.Starter(this);
  324. this.processStarter.load();
  325. // if (layout.mobile){
  326. // this.showStartProcessArea_mobile();
  327. // }else{
  328. // this.showStartProcessArea_pc();
  329. // }
  330. },
  331. // showStartProcessArea_mobile: function(){
  332. // if (!this.startProcessAreaNode) {
  333. // this.createStartProcessArea_mobile();
  334. // }
  335. // this.startProcessAreaNode.setStyle("display", "block");
  336. // //document.body.setStyle("-webkit-overflow-scrolling", "auto");
  337. // var morph = new Fx.Morph(this.startProcessAreaNode, {
  338. // "duration": 200,
  339. // "transition": Fx.Transitions.Expo.easeOut
  340. // });
  341. // morph.start({"left": "0px"});
  342. // },
  343. // showStartProcessArea_pc: function () {
  344. // if (!this.startProcessAreaNode) {
  345. // this.createStartProcessArea();
  346. // }
  347. // this.content.mask({
  348. // "inject": this.content,
  349. // "destroyOnHide": true,
  350. // "id": "process_taskcenter_startProcessMask",
  351. // "style": this.css.maskNode
  352. // });
  353. //
  354. // //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  355. // var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  356. // if (maskNode){
  357. // if( this.inBrowser ){
  358. // maskNode.setStyles({"width":"100%","height":"100%"});
  359. // }
  360. // maskNode.addEvent("click", function (e) {
  361. // this.closeStartProcessArea(e);
  362. // }.bind(this));
  363. // }
  364. // //if (this.allApplicationStarter) this.allApplicationStarter.loadChild();
  365. // this.startProcessAreaNode.fade("in");
  366. // //this.startProcessTween.start("left", "-400px", "0px");
  367. // },
  368. // createStartProcessArea_mobile: function(){
  369. // this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode_mobile}).inject(this.content);
  370. // var size = this.content.getSize();
  371. // this.startProcessAreaNode.setStyles({
  372. // "width": ""+size.x+"px",
  373. // "height": ""+size.y+"px",
  374. // "top": "0px",
  375. // "left": ""+size.x+"px"
  376. // });
  377. //
  378. // this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode_mobile}).inject(this.startProcessAreaNode);
  379. // this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode_mobile, "text": this.lp.back}).inject(this.startProcessTopNode);
  380. // this.startProcessCloseNode.addEvent("click", function (e) {
  381. // this.closeStartProcessArea(e);
  382. // }.bind(this));
  383. //
  384. // this.startProcessListNode = new Element("div", {"styles": this.css.startProcessListNode_mobile}).inject(this.startProcessAreaNode);
  385. // var h = size.y-this.startProcessTopNode.getSize().y;
  386. // this.startProcessListNode.setStyle("height", ""+h+"px");
  387. //
  388. // //this.createStartProcessScrollNode();
  389. // this.getAction(function () {
  390. // this.action.listApplicationStartable(function (appjson) {
  391. // this.app = this;
  392. // MWF.UD.getDataJson("taskCenter_startTop", function(json){
  393. // this.top5Data = json;
  394. // if (this.top5Data && this.top5Data.length){
  395. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.lp.startTop5}).inject(this.startProcessListNode);
  396. // var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  397. //
  398. // this.top5Data.sort(function(p1, p2){
  399. // return 0-(p1.count-p2.count);
  400. // });
  401. // this.top5Data.each(function(process, i){
  402. // if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  403. // }.bind(this));
  404. // }
  405. // appjson.data.each(function (app) {
  406. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.startProcessListNode);
  407. // var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  408. // app.processList.each(function(process){
  409. // new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  410. // }.bind(this));
  411. // }.bind(this));
  412. // }.bind(this));
  413. //
  414. //
  415. // // this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  416. // // this.allApplicationStarter.selected();
  417. // // json.data.each(function (app) {
  418. // // new MWF.xApplication.process.TaskCenter.Application(app, this);
  419. // // }.bind(this));
  420. // }.bind(this));
  421. // }.bind(this));
  422. // },
  423. // createStartProcessArea: function () {
  424. // this.createStartProcessAreaNode();
  425. // this.createStartProcessScrollNode();
  426. //
  427. // this.listApplications();
  428. //
  429. // this.setResizeStartProcessAreaHeight();
  430. // this.addEvent("resize", this.setResizeStartProcessAreaHeight.bind(this));
  431. //
  432. // //this.startProcessTween = new Fx.Tween(this.startProcessAreaNode, {
  433. // // "duration": "200",
  434. // // "transition": Fx.Transitions.Quad.easeOut
  435. // //});
  436. // },
  437. // createStartProcessAreaNode: function () {
  438. // this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode}).inject(this.content);
  439. // },
  440. // createStartProcessCloseNode: function () {
  441. // this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode}).inject(this.startProcessRightListNode);
  442. // this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode}).inject(this.startProcessTopNode);
  443. // this.startProcessCloseNode.addEvent("click", function (e) {
  444. // this.closeStartProcessArea(e);
  445. // }.bind(this));
  446. // },
  447. // createStartProcessSearchNode: function(){
  448. // this.startProcessSearchNode = new Element("div", {"styles": this.css.startProcessSearchNode}).inject(this.startProcessRightListNode);
  449. // this.startProcessSearchIconNode = new Element("div", {"styles": this.css.startProcessSearchIconNode}).inject(this.startProcessSearchNode);
  450. // this.startProcessSearchAreaNode = new Element("div", {"styles": this.css.startProcessSearchAreaNode}).inject(this.startProcessSearchNode);
  451. // this.startProcessSearchInputNode = new Element("input", {"styles": this.css.startProcessSearchInputNode}).inject(this.startProcessSearchAreaNode);
  452. // this.startProcessSearchInputNode.set("value", this.lp.searchProcess);
  453. // this.startProcessSearchInputNode.addEvents({
  454. // "focus": function(){ if (this.startProcessSearchInputNode.get("value")===this.lp.searchProcess) this.startProcessSearchInputNode.set("value", ""); }.bind(this),
  455. // "blur": function(){if (!this.startProcessSearchInputNode.get("value")) this.startProcessSearchInputNode.set("value", this.lp.searchProcess);}.bind(this),
  456. // "keydown": function(e){ if (e.code===13) this.searchStartProcess(); }.bind(this)
  457. // });
  458. // this.startProcessSearchIconNode.addEvent("click", function(){ this.searchStartProcess(); }.bind(this));
  459. // },
  460. // searchStartProcess: function(){
  461. // var key = this.startProcessSearchInputNode.get("value");
  462. // if (key && key!==this.lp.searchProcess){
  463. // if (this.appStartableData){
  464. // this.startApplications.each(function(app){ app.unselected(); });
  465. // if (this.searchProcessSearchchildNode) this.searchProcessSearchchildNode.destroy();
  466. // var text = this.lp.searchProcessResault.replace("{key}", key);
  467. //
  468. // this.searchProcessSearchchildNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.startProcessProcessAreaNode);
  469. // this.searchProcessSearchchildNode.setStyle("display", "block");
  470. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": text}).inject(this.searchProcessSearchchildNode);
  471. // var proListNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.searchProcessSearchchildNode);
  472. //
  473. // this.appStartableData.each(function (app) {
  474. // app.processList.each(function(pro){
  475. // if (pro.name.indexOf(key)!==-1){
  476. // var data = Object.clone(pro);
  477. // data.applicationName = app.name;
  478. // new MWF.xApplication.process.TaskCenter.Process(data, {"app": this}, {"name": app}, proListNode);
  479. // }
  480. // }.bind(this));
  481. // }.bind(this));
  482. // }
  483. // }
  484. // },
  485. // createStartProcessScrollNode: function () {
  486. // this.startProcessApplicationListNode = new Element("div", {"styles": this.css.startProcessApplicationListNode}).inject(this.startProcessAreaNode);
  487. // this.startProcessRightListNode = new Element("div", {"styles": this.css.startProcessRightListNode}).inject(this.startProcessAreaNode);
  488. //
  489. // this.createStartProcessCloseNode();
  490. // this.createStartProcessSearchNode();
  491. //
  492. // this.startProcessApplicationScrollNode = new Element("div", {"styles": this.css.startProcessApplicationScrollNode}).inject(this.startProcessApplicationListNode);
  493. // this.startProcessApplicationAreaNode = new Element("div", {"styles": this.css.startProcessApplicationAreaNode}).inject(this.startProcessApplicationScrollNode);
  494. //
  495. // this.startProcessProcessListNode = new Element("div", {"styles": this.css.startProcessProcessListNode}).inject(this.startProcessRightListNode);
  496. // this.startProcessProcessScrollNode = new Element("div", {"styles": this.css.startProcessProcessScrollNode}).inject(this.startProcessProcessListNode);
  497. // this.startProcessProcessAreaNode = new Element("div", {"styles": this.css.startProcessProcessAreaNode}).inject(this.startProcessProcessScrollNode);
  498. //
  499. // MWF.require("MWF.widget.ScrollBar", function () {
  500. // new MWF.widget.ScrollBar(this.startProcessApplicationScrollNode, {
  501. // "distance": 100,
  502. // "friction": 4
  503. // });
  504. // new MWF.widget.ScrollBar(this.startProcessProcessScrollNode, {
  505. // "distance": 100,
  506. // "friction": 4
  507. // });
  508. // }.bind(this));
  509. //
  510. // //this.startProcessContentNode = new Element("div", {"styles": this.css.startProcessContentNode}).inject(this.startProcessScrollNode);
  511. // },
  512. // closeStartProcessArea: function () {
  513. // //if (this.startProcessAreaNode) this.startProcessTween.start("left", "0px", "-400px");
  514. // if (layout.mobile){
  515. // var size = this.startProcessAreaNode.getSize();
  516. // var morph = new Fx.Morph(this.startProcessAreaNode, {
  517. // "duration": 200,
  518. // "transition": Fx.Transitions.Expo.easeOut,
  519. // "onComplete": function(){
  520. // this.startProcessAreaNode.setStyle("display", "none");
  521. // }.bind(this)
  522. // });
  523. // morph.start({"left": ""+size.x+"px"});
  524. // }else{
  525. // this.content.unmask();
  526. // if (this.startProcessAreaNode) this.startProcessAreaNode.fade("out");
  527. // }
  528. //
  529. // },
  530. // setResizeStartProcessAreaHeight: function () {
  531. // if (this.startProcessAreaNode) {
  532. // var size = this.content.getSize();
  533. // var nodeSize = this.startProcessAreaNode.getSize();
  534. // var x = (size.x-nodeSize.x)/2;
  535. // var y = (size.y-nodeSize.y)/2;
  536. // this.startProcessAreaNode.setStyle("top", "" + y + "px");
  537. // this.startProcessAreaNode.setStyle("left", "" + x + "px");
  538. //
  539. // var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  540. // //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  541. // if (maskNode){
  542. // maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  543. // maskNode.position({
  544. // "relativeTo": this.content,
  545. // "position": "topLeft",
  546. // "edge": "topLeft"
  547. // });
  548. // }
  549. //
  550. // if (this.startProcessProcessListNode){
  551. // var topSize = this.startProcessTopNode.getSize();
  552. // var searchSize = this.startProcessSearchNode.getSize();
  553. // var h = nodeSize.y-topSize.y-searchSize.y;
  554. // this.startProcessProcessListNode.setStyle("height", ""+h+"px");
  555. // }
  556. //
  557. // }
  558. // },
  559. // listApplications: function () {
  560. // this.getAction(function () {
  561. // this.action.listApplicationStartable(function (json) {
  562. // this.appStartableData = json.data;
  563. // this.startProcessSearchNode.setStyle("display", "block");
  564. // this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  565. // this.allApplicationStarter.selected();
  566. // json.data.each(function (app) {
  567. // new MWF.xApplication.process.TaskCenter.Application(app, this);
  568. // }.bind(this));
  569. // }.bind(this));
  570. // }.bind(this));
  571. // },
  572. //
  573. getAction: function (callback) {
  574. if (!this.action) {
  575. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  576. if (callback) callback();
  577. // MWF.xDesktop.requireApp("process.TaskCenter", "Actions.RestActions", function () {
  578. // this.action = new MWF.xApplication.process.TaskCenter.Actions.RestActions();
  579. // if (callback) callback();
  580. // }.bind(this));
  581. } else {
  582. if (callback) callback();
  583. }
  584. },
  585. refreshAll: function () {
  586. this.getWorkCounts();
  587. if (this.taskList) if (this.currentTab === "task") this.taskList.refresh();
  588. //if (this.taskCompletedList) if (this.currentTab == "done") this.taskCompletedList.refresh();
  589. //if (this.readList) if (this.currentTab == "read") this.readList.refresh();
  590. //if (this.readedList) if (this.currentTab == "readed") this.readedList.refresh();
  591. //if (this.reviewList) if (this.currentTab == "review") this.reviewList.refresh();
  592. },
  593. createTaskCompletedList: function (filterData) {
  594. if (!this.contentNode) this.loadContent();
  595. this.taskCompletedList = new MWF.xApplication.process.TaskCenter.TaskCompletedList(this.contentListAreaNode, this, filterData);
  596. //if (filterData) this.taskCompletedList.filterData = filterData;
  597. },
  598. showDone: function () {
  599. if (this.currentTab !== "done") {
  600. this.showTab(1);
  601. this.currentTab = "done";
  602. if (!this.taskCompletedList) {
  603. this.createTaskCompletedList((this.status) ? this.status.filter : null);
  604. this.taskCompletedList.show();
  605. } else {
  606. this.taskCompletedList.show();
  607. if (this.taskCompletedList) this.taskCompletedList.refresh();
  608. }
  609. } else {
  610. if (this.taskCompletedList) this.taskCompletedList.refresh();
  611. }
  612. this.searchBarAreaNode.setStyle("display", "block");
  613. this.searchBarInputNode.set("value", this.lp.searchKey);
  614. },
  615. createReadList: function (filterData) {
  616. if (!this.contentNode) this.loadContent();
  617. this.readList = new MWF.xApplication.process.TaskCenter.ReadList(this.contentListAreaNode, this, filterData);
  618. //if (filterData) this.taskCompletedList.filterData = filterData;
  619. },
  620. showRead: function () {
  621. if (this.currentTab !== "read") {
  622. this.showTab(2);
  623. this.currentTab = "read";
  624. if (!this.readList) {
  625. this.createReadList((this.status) ? this.status.filter : null);
  626. this.readList.show();
  627. } else {
  628. this.readList.show();
  629. if (this.readList) this.readList.refresh();
  630. }
  631. } else {
  632. if (this.readList) this.readList.refresh();
  633. }
  634. this.searchBarAreaNode.setStyle("display", "block");
  635. this.searchBarInputNode.set("value", this.lp.searchKey);
  636. },
  637. createReadedList: function (filterData) {
  638. if (!this.contentNode) this.loadContent();
  639. this.readedList = new MWF.xApplication.process.TaskCenter.ReadCompletedList(this.contentListAreaNode, this, filterData);
  640. //if (filterData) this.taskCompletedList.filterData = filterData;
  641. },
  642. showReaded: function () {
  643. if (this.currentTab !== "readed") {
  644. this.showTab(3);
  645. this.currentTab = "readed";
  646. if (!this.readedList) {
  647. this.createReadedList((this.status) ? this.status.filter : null);
  648. this.readedList.show();
  649. } else {
  650. this.readedList.show();
  651. if (this.readedList) this.readedList.refresh();
  652. }
  653. } else {
  654. if (this.readedList) this.readedList.refresh();
  655. }
  656. this.searchBarAreaNode.setStyle("display", "block");
  657. this.searchBarInputNode.set("value", this.lp.searchKey);
  658. },
  659. createReviewList: function (filterData) {
  660. if (!this.contentNode) this.loadContent();
  661. this.reviewList = new MWF.xApplication.process.TaskCenter.ReviewList(this.contentListAreaNode, this, filterData);
  662. //if (filterData) this.taskCompletedList.filterData = filterData;
  663. },
  664. showReview: function () {
  665. if (this.currentTab !== "review") {
  666. this.showTab(4);
  667. this.currentTab = "review";
  668. if (!this.reviewList) {
  669. this.createReviewList((this.status) ? this.status.filter : null);
  670. this.reviewList.show();
  671. } else {
  672. this.reviewList.show();
  673. if (this.reviewList) this.reviewList.refresh();
  674. }
  675. } else {
  676. if (this.reviewList) this.reviewList.refresh();
  677. }
  678. this.searchBarAreaNode.setStyle("display", "block");
  679. },
  680. recordStatus: function(){
  681. var tab = this.currentTab || "task";
  682. var filter = null;
  683. if (tab==="done"){
  684. filter = this.taskCompletedList.filterData;
  685. }
  686. if (tab==="read"){
  687. filter = this.readList.filterData;
  688. }
  689. if (tab==="readed"){
  690. filter = this.readedList.filterData;
  691. }
  692. if (tab==="review"){
  693. filter = this.reviewList.filterData;
  694. }
  695. return {"navi": this.currentTab || "task", "filter": filter};
  696. },
  697. searchTask: function(){
  698. var keyWord = this.searchBarInputNode.get("value");
  699. if (keyWord && (keyWord!==this.lp.searchKey)){
  700. var tab = this.currentTab || "task";
  701. switch (tab){
  702. case "task":
  703. if (!this.taskList.filterData) this.taskList.filterData = {};
  704. this.taskList.filterData.key = keyWord;
  705. this.taskList.refilter();
  706. break;
  707. case "done":
  708. if (!this.taskCompletedList.filterData) this.taskCompletedList.filterData = {};
  709. this.taskCompletedList.filterData.key = keyWord;
  710. this.taskCompletedList.refilter();
  711. break;
  712. case "read":
  713. if (!this.readList.filterData) this.readList.filterData = {};
  714. this.readList.filterData.key = keyWord;
  715. this.readList.refilter();
  716. break;
  717. case "readed":
  718. if (!this.readedList.filterData) this.readedList.filterData = {};
  719. this.readedList.filterData.key = keyWord;
  720. this.readedList.refilter();
  721. break;
  722. case "review":
  723. if (!this.reviewList.filterData) this.reviewList.filterData = {};
  724. this.reviewList.filterData.key = keyWord;
  725. this.reviewList.refilter();
  726. break;
  727. }
  728. }
  729. }
  730. });
  731. MWF.xApplication.process.TaskCenter.Application = new Class({
  732. initialize: function(data, starter){
  733. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  734. this.data = data;
  735. this.starter = starter
  736. this.app = this.starter.app;
  737. this.container = this.starter.startProcessApplicationAreaNode;
  738. this.processContainer = this.starter.startProcessProcessAreaNode;
  739. this.css = this.app.css;
  740. this.isLoaded = false;
  741. this.load();
  742. },
  743. load: function(){
  744. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  745. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  746. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  747. if (this.data.icon){
  748. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  749. }else{
  750. this.iconNode.set("src", "/x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  751. }
  752. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  753. this.textNode.set("text", this.data.name);
  754. this.textNode.set("title", this.data.name);
  755. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  756. //this.loadChild();
  757. this.node.addEvent("click", function(){
  758. this.selected();
  759. }.bind(this));
  760. this.starter.startApplications.push(this);
  761. },
  762. unselected: function(){
  763. this.childNode.setStyle("display", "none");
  764. this.node.setStyles(this.css.applicationNode);
  765. },
  766. selected: function(){
  767. this.starter.startApplications.each(function(app){
  768. app.unselected();
  769. });
  770. if (this.starter.searchProcessSearchchildNode) this.starter.searchProcessSearchchildNode.destroy();
  771. if (this.starter.startProcessSearchInputNode) this.starter.startProcessSearchInputNode.set("value", this.app.lp.searchProcess);
  772. this.childNode.setStyle("display", "block");
  773. this.node.setStyles(this.css.applicationNode_selected);
  774. if (!this.isLoaded){
  775. this.loadChild();
  776. this.isLoaded = true;
  777. }
  778. },
  779. loadChild: function(){
  780. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startProcess}).inject(this.childNode);
  781. var childNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  782. this.data.processList.each(function(process){
  783. new MWF.xApplication.process.TaskCenter.Process(process, this, this.data, childNode);
  784. }.bind(this));
  785. }
  786. });
  787. MWF.xApplication.process.TaskCenter.AllApplication = new Class({
  788. Extends: MWF.xApplication.process.TaskCenter.Application,
  789. initialize: function(data, starter){
  790. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  791. this.data = data;
  792. this.starter = starter;
  793. this.app = this.starter.app;
  794. this.container = this.starter.startProcessApplicationAreaNode;
  795. this.processContainer = this.starter.startProcessProcessAreaNode;
  796. this.css = this.starter.css;
  797. this.isLoaded = false;
  798. this.load();
  799. },
  800. load: function(){
  801. this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  802. this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  803. this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  804. this.iconNode.set("src", "/x_component_process_TaskCenter/$Main/default/icon/appAppliction.png");
  805. this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  806. this.textNode.set("text", this.app.lp.all);
  807. this.textNode.set("title", this.app.lp.all);
  808. this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  809. //this.loadChild();
  810. this.node.addEvent("click", function(){
  811. this.selected();
  812. }.bind(this));
  813. this.starter.startApplications.push(this);
  814. },
  815. unselected: function(){
  816. this.childNode.empty();
  817. this.isLoaded = false;
  818. this.childNode.setStyle("display", "none");
  819. this.node.setStyles(this.css.applicationNode);
  820. },
  821. loadChild: function(){
  822. //this.loadSearch();
  823. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  824. this.top5Data = json;
  825. if (this.top5Data && this.top5Data.length){
  826. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  827. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  828. this.top5Data.sort(function(p1, p2){
  829. return 0-(p1.count-p2.count);
  830. });
  831. }
  832. var allowProcessIds = [];
  833. this.data.each(function (app) {
  834. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  835. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  836. app.processList.each(function(process){
  837. allowProcessIds.push(process.id);
  838. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  839. }.bind(this));
  840. }.bind(this));
  841. if (top5ChildNode){
  842. saveflag = false;
  843. this.top5Data.each(function(process, i){
  844. if (allowProcessIds.indexOf(process.id)!==-1){
  845. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  846. }else{
  847. saveflag = true;
  848. process.count=0;
  849. }
  850. }.bind(this));
  851. if (saveflag) MWF.UD.putData("taskCenter_startTop", this.top5Data);
  852. }
  853. }.bind(this));
  854. }
  855. });
  856. MWF.xApplication.process.TaskCenter.Process = new Class({
  857. initialize: function(data, application, applicationData, container){
  858. this.data = data;
  859. this.application = application;
  860. this.applicationData = applicationData;
  861. this.app = this.application.app;
  862. this.starter = this.application.starter
  863. this.container = container;
  864. this.css = this.app.css;
  865. this.load();
  866. },
  867. load: function(){
  868. this.node = new Element("div.processItem", {"styles": this.css.startProcessNode}).inject(this.container);
  869. this.iconNode = new Element("div", {"styles": this.css.processIconNode}).inject(this.node);
  870. if (this.data.icon){
  871. this.iconNode.setStyle("background-image", "url("+this.data.icon+")");
  872. }else{
  873. this.iconNode.setStyle("background-image", "url(/x_component_process_ProcessManager/$Explorer/default/processIcon/process.png)");
  874. }
  875. this.actionNode = new Element("div", {"styles": this.css.processActionNode, "text": this.app.lp.start}).inject(this.node);
  876. this.textNode = new Element("div", {"styles": this.css.processTextNode}).inject(this.node);
  877. this.textNode.set({
  878. "text": this.data.name+((this.data.applicationName) ? " -- ("+this.data.applicationName+")" : ""),
  879. "title": this.data.name+"-"+this.data.description
  880. });
  881. //var _self = this;
  882. this.actionNode.addEvents({
  883. "mouseover": function(){this.actionNode.setStyles(this.css.processActionNode_over);}.bind(this),
  884. "mouseout": function(){this.actionNode.setStyles(this.css.processActionNode);}.bind(this),
  885. "click": function(e){
  886. this.startProcess(e);
  887. }.bind(this)
  888. });
  889. this.node.addEvents({
  890. "mouseover": function(){
  891. this.node.setStyles(this.css.startProcessNode_over);
  892. this.actionNode.setStyle("display", "block");
  893. }.bind(this),
  894. "mouseout": function(){
  895. this.node.setStyles(this.css.startProcessNode_out);
  896. //this.actionNode.setStyle("display", "none");
  897. }.bind(this)
  898. });
  899. },
  900. startProcess: function(){
  901. this.starter.closeStartProcessArea();
  902. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  903. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(this.data, this.app, {
  904. "onStarted": function(data, title, processName){
  905. this.afterStartProcess(data, title, processName);
  906. }.bind(this)
  907. });
  908. starter.load();
  909. }.bind(this));
  910. },
  911. recordProcessData: function(){
  912. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  913. if (!json || !json.length) json = [];
  914. var recordProcess = null;
  915. this.data.lastStartTime = new Date();
  916. var earlyProcessIdx = 0;
  917. var flag = true;
  918. for (var i=0; i<json.length; i++){
  919. var process = json[i];
  920. if (process.id === this.data.id) recordProcess = process;
  921. if (flag){
  922. if (!process.lastStartTime){
  923. earlyProcessIdx = i;
  924. flag = false;
  925. }else{
  926. if (new Date(process.lastStartTime)<new Date(json[earlyProcessIdx].lastStartTime)){
  927. earlyProcessIdx = i;
  928. }
  929. }
  930. }
  931. }
  932. if (recordProcess) {
  933. recordProcess.lastStartTime = new Date();
  934. recordProcess.count = (recordProcess.count || 0)+1;
  935. recordProcess.applicationName = this.applicationData.name;
  936. }else{
  937. if (json.length<10){
  938. this.data.count = 1;
  939. this.data.applicationName = this.applicationData.name;
  940. json.push(this.data);
  941. }else{
  942. json.splice(earlyProcessIdx, 1);
  943. this.data.count = 1;
  944. this.data.applicationName = this.applicationData.name;
  945. json.push(this.data);
  946. }
  947. }
  948. MWF.UD.putData("taskCenter_startTop", json);
  949. }.bind(this));
  950. },
  951. afterStartProcess: function(data, title, processName){
  952. this.recordProcessData();
  953. var workInfors = [];
  954. var currentTask = [];
  955. data.each(function(work){
  956. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  957. workInfors.push(this.getStartWorkInforObj(work));
  958. }.bind(this));
  959. if (currentTask.length===1){
  960. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  961. this.app.desktop.openApplication(null, "process.Work", options);
  962. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
  963. }else{
  964. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
  965. }
  966. this.starter.fireEvent("startProcess");
  967. },
  968. getStartWorkInforObj: function(work){
  969. var users = [];
  970. var currentTask = "";
  971. work.taskList.each(function(task, idx){
  972. users.push(task.person+"("+task.department + ")");
  973. if (work.currentTaskIndex===idx) currentTask = task.id;
  974. }.bind(this));
  975. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  976. },
  977. createStartWorkResault: function(workInfors, title, processName, isopen){
  978. var content = "";
  979. workInfors.each(function(infor){
  980. var users = [];
  981. infor.users.each(function(uname){
  982. users.push(MWF.name.cn(uname));
  983. });
  984. 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>";
  985. if (infor.currentTask && isopen){
  986. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  987. }else{
  988. content += "</div>";
  989. }
  990. }.bind(this));
  991. var msg = {
  992. "subject": this.app.lp.processStarted,
  993. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  994. };
  995. var tooltip = layout.desktop.message.addTooltip(msg);
  996. var item = layout.desktop.message.addMessage(msg);
  997. this.setStartWorkResaultAction(tooltip);
  998. this.setStartWorkResaultAction(item);
  999. },
  1000. setStartWorkResaultAction: function(item){
  1001. var node = item.node.getElements("span");
  1002. node.setStyles(this.app.css.dealStartedWorkAction);
  1003. var _self = this;
  1004. node.addEvent("click", function(e){
  1005. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  1006. _self.app.desktop.openApplication(e, "process.Work", options);
  1007. });
  1008. }
  1009. });
  1010. MWF.xApplication.process.TaskCenter.Starter = new Class({
  1011. Implements: [Options, Events],
  1012. initialize: function(app, options){
  1013. this.setOptions(options);
  1014. this.app = app;
  1015. this.css = app.css;
  1016. this.lp = app.lp;
  1017. this.content = this.app.content;
  1018. this.startApplications = [];
  1019. },
  1020. load: function(){
  1021. if (layout.mobile){
  1022. this.showStartProcessArea_mobile();
  1023. }else{
  1024. this.showStartProcessArea_pc();
  1025. }
  1026. },
  1027. showStartProcessArea_pc: function () {
  1028. if (!this.startProcessAreaNode) {
  1029. this.createStartProcessArea();
  1030. }
  1031. this.content.mask({
  1032. "destroyOnHide": true,
  1033. "id": "process_taskcenter_startProcessMask",
  1034. "style": this.css.maskNode
  1035. });
  1036. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  1037. if (maskNode){
  1038. if( this.inBrowser ){
  1039. maskNode.setStyles({"width":"100%","height":"100%"});
  1040. }
  1041. maskNode.addEvent("click", function (e) {
  1042. this.closeStartProcessArea(e);
  1043. }.bind(this));
  1044. }
  1045. this.startProcessAreaNode.fade("in");
  1046. },
  1047. createStartProcessArea: function () {
  1048. this.createStartProcessAreaNode();
  1049. this.createStartProcessScrollNode();
  1050. this.listApplications();
  1051. this.setResizeStartProcessAreaHeight();
  1052. this.app.addEvent("resize", this.setResizeStartProcessAreaHeight.bind(this));
  1053. },
  1054. createStartProcessAreaNode: function () {
  1055. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode}).inject(this.content);
  1056. },
  1057. createStartProcessScrollNode: function () {
  1058. this.startProcessApplicationListNode = new Element("div", {"styles": this.css.startProcessApplicationListNode}).inject(this.startProcessAreaNode);
  1059. this.startProcessRightListNode = new Element("div", {"styles": this.css.startProcessRightListNode}).inject(this.startProcessAreaNode);
  1060. this.createStartProcessCloseNode();
  1061. this.createStartProcessSearchNode();
  1062. this.startProcessApplicationScrollNode = new Element("div", {"styles": this.css.startProcessApplicationScrollNode}).inject(this.startProcessApplicationListNode);
  1063. this.startProcessApplicationAreaNode = new Element("div", {"styles": this.css.startProcessApplicationAreaNode}).inject(this.startProcessApplicationScrollNode);
  1064. this.startProcessProcessListNode = new Element("div", {"styles": this.css.startProcessProcessListNode}).inject(this.startProcessRightListNode);
  1065. this.startProcessProcessScrollNode = new Element("div", {"styles": this.css.startProcessProcessScrollNode}).inject(this.startProcessProcessListNode);
  1066. this.startProcessProcessAreaNode = new Element("div", {"styles": this.css.startProcessProcessAreaNode}).inject(this.startProcessProcessScrollNode);
  1067. MWF.require("MWF.widget.ScrollBar", function () {
  1068. new MWF.widget.ScrollBar(this.startProcessApplicationScrollNode, {
  1069. "distance": 100,
  1070. "friction": 4
  1071. });
  1072. new MWF.widget.ScrollBar(this.startProcessProcessScrollNode, {
  1073. "distance": 100,
  1074. "friction": 4
  1075. });
  1076. }.bind(this));
  1077. },
  1078. createStartProcessCloseNode: function () {
  1079. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode}).inject(this.startProcessRightListNode);
  1080. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode}).inject(this.startProcessTopNode);
  1081. this.startProcessCloseNode.addEvent("click", function (e) {
  1082. this.closeStartProcessArea(e);
  1083. }.bind(this));
  1084. },
  1085. createStartProcessSearchNode: function(){
  1086. this.startProcessSearchNode = new Element("div", {"styles": this.css.startProcessSearchNode}).inject(this.startProcessRightListNode);
  1087. this.startProcessSearchIconNode = new Element("div", {"styles": this.css.startProcessSearchIconNode}).inject(this.startProcessSearchNode);
  1088. this.startProcessSearchAreaNode = new Element("div", {"styles": this.css.startProcessSearchAreaNode}).inject(this.startProcessSearchNode);
  1089. this.startProcessSearchInputNode = new Element("input", {"styles": this.css.startProcessSearchInputNode}).inject(this.startProcessSearchAreaNode);
  1090. this.startProcessSearchInputNode.set("value", this.lp.searchProcess);
  1091. this.startProcessSearchInputNode.addEvents({
  1092. "focus": function(){ if (this.startProcessSearchInputNode.get("value")===this.lp.searchProcess) this.startProcessSearchInputNode.set("value", ""); }.bind(this),
  1093. "blur": function(){if (!this.startProcessSearchInputNode.get("value")) this.startProcessSearchInputNode.set("value", this.lp.searchProcess);}.bind(this),
  1094. "keydown": function(e){ if (e.code===13) this.searchStartProcess(); }.bind(this)
  1095. });
  1096. this.startProcessSearchIconNode.addEvent("click", function(){ this.searchStartProcess(); }.bind(this));
  1097. },
  1098. searchStartProcess: function(){
  1099. var key = this.startProcessSearchInputNode.get("value");
  1100. if (key && key!==this.lp.searchProcess){
  1101. if (this.appStartableData){
  1102. this.startApplications.each(function(app){ app.unselected(); });
  1103. if (this.searchProcessSearchchildNode) this.searchProcessSearchchildNode.destroy();
  1104. var text = this.lp.searchProcessResault.replace("{key}", key);
  1105. this.searchProcessSearchchildNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.startProcessProcessAreaNode);
  1106. this.searchProcessSearchchildNode.setStyle("display", "block");
  1107. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": text}).inject(this.searchProcessSearchchildNode);
  1108. var proListNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.searchProcessSearchchildNode);
  1109. this.appStartableData.each(function (app) {
  1110. app.processList.each(function(pro){
  1111. if (pro.name.indexOf(key)!==-1){
  1112. var data = Object.clone(pro);
  1113. data.applicationName = app.name;
  1114. new MWF.xApplication.process.TaskCenter.Process(data, {"app": this}, {"name": app}, proListNode);
  1115. }
  1116. }.bind(this));
  1117. }.bind(this));
  1118. }
  1119. }
  1120. },
  1121. listApplications: function () {
  1122. this.app.getAction(function () {
  1123. this.app.action.listApplicationStartable(function (json) {
  1124. this.appStartableData = json.data;
  1125. this.startProcessSearchNode.setStyle("display", "block");
  1126. this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  1127. this.allApplicationStarter.selected();
  1128. json.data.each(function (app) {
  1129. new MWF.xApplication.process.TaskCenter.Application(app, this);
  1130. }.bind(this));
  1131. }.bind(this));
  1132. }.bind(this));
  1133. },
  1134. setResizeStartProcessAreaHeight: function () {
  1135. if (this.startProcessAreaNode) {
  1136. var size = this.content.getSize();
  1137. var nodeSize = this.startProcessAreaNode.getSize();
  1138. var x = (size.x-nodeSize.x)/2;
  1139. var y = (size.y-nodeSize.y)/2;
  1140. this.startProcessAreaNode.setStyle("top", "" + y + "px");
  1141. this.startProcessAreaNode.setStyle("left", "" + x + "px");
  1142. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  1143. //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  1144. if (maskNode){
  1145. maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  1146. maskNode.position({
  1147. "relativeTo": this.content,
  1148. "position": "topLeft",
  1149. "edge": "topLeft"
  1150. });
  1151. }
  1152. if (this.startProcessProcessListNode){
  1153. var topSize = this.startProcessTopNode.getSize();
  1154. var searchSize = this.startProcessSearchNode.getSize();
  1155. var h = nodeSize.y-topSize.y-searchSize.y;
  1156. this.startProcessProcessListNode.setStyle("height", ""+h+"px");
  1157. }
  1158. }
  1159. },
  1160. showStartProcessArea_mobile: function(){
  1161. if (!this.startProcessAreaNode) {
  1162. this.createStartProcessArea_mobile();
  1163. }
  1164. this.startProcessAreaNode.setStyle("display", "block");
  1165. //document.body.setStyle("-webkit-overflow-scrolling", "auto");
  1166. var morph = new Fx.Morph(this.startProcessAreaNode, {
  1167. "duration": 200,
  1168. "transition": Fx.Transitions.Expo.easeOut
  1169. });
  1170. morph.start({"left": "0px"});
  1171. },
  1172. createStartProcessArea_mobile: function(){
  1173. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode_mobile}).inject(this.content);
  1174. var size = this.content.getSize();
  1175. this.startProcessAreaNode.setStyles({
  1176. "width": ""+size.x+"px",
  1177. "height": ""+size.y+"px",
  1178. "top": "0px",
  1179. "left": ""+size.x+"px"
  1180. });
  1181. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode_mobile}).inject(this.startProcessAreaNode);
  1182. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode_mobile, "text": this.lp.back}).inject(this.startProcessTopNode);
  1183. this.startProcessCloseNode.addEvent("click", function (e) {
  1184. this.closeStartProcessArea(e);
  1185. }.bind(this));
  1186. this.startProcessListNode = new Element("div", {"styles": this.css.startProcessListNode_mobile}).inject(this.startProcessAreaNode);
  1187. var h = size.y-this.startProcessTopNode.getSize().y;
  1188. this.startProcessListNode.setStyle("height", ""+h+"px");
  1189. this.app.getAction(function () {
  1190. this.app.action.listApplicationStartable(function (appjson) {
  1191. //this.app = this;
  1192. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  1193. this.top5Data = json;
  1194. if (this.top5Data && this.top5Data.length){
  1195. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.lp.startTop5}).inject(this.startProcessListNode);
  1196. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  1197. this.top5Data.sort(function(p1, p2){
  1198. return 0-(p1.count-p2.count);
  1199. });
  1200. this.top5Data.each(function(process, i){
  1201. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  1202. }.bind(this));
  1203. }
  1204. appjson.data.each(function (app) {
  1205. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.startProcessListNode);
  1206. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  1207. app.processList.each(function(process){
  1208. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  1209. }.bind(this));
  1210. }.bind(this));
  1211. }.bind(this));
  1212. }.bind(this));
  1213. }.bind(this));
  1214. },
  1215. // getAction: function (callback) {
  1216. // if (!this.action) {
  1217. // this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  1218. // if (callback) callback();
  1219. // } else {
  1220. // if (callback) callback();
  1221. // }
  1222. // },
  1223. closeStartProcessArea: function () {
  1224. if (layout.mobile){
  1225. var size = this.startProcessAreaNode.getSize();
  1226. var morph = new Fx.Morph(this.startProcessAreaNode, {
  1227. "duration": 200,
  1228. "transition": Fx.Transitions.Expo.easeOut,
  1229. "onComplete": function(){
  1230. this.startProcessAreaNode.setStyle("display", "none");
  1231. }.bind(this)
  1232. });
  1233. morph.start({"left": ""+size.x+"px"});
  1234. }else{
  1235. this.content.unmask();
  1236. if (this.startProcessAreaNode) this.startProcessAreaNode.fade("out");
  1237. }
  1238. }
  1239. });
  1240. // MWF.xApplication.process.TaskCenter.AllApplication = new Class({
  1241. // Extends: MWF.xApplication.process.TaskCenter.Application,
  1242. // initialize: function(data, app){
  1243. // this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  1244. // this.data = data;
  1245. // this.app = app;
  1246. // this.container = this.app.startProcessApplicationAreaNode;
  1247. // this.processContainer = this.app.startProcessProcessAreaNode;
  1248. // this.css = this.app.css;
  1249. // this.isLoaded = false;
  1250. //
  1251. // this.load();
  1252. // },
  1253. // load: function(){
  1254. // this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  1255. // this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  1256. // this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  1257. // this.iconNode.set("src", "/x_component_process_TaskCenter/$Main/default/icon/appAppliction.png");
  1258. //
  1259. // this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  1260. // this.textNode.set("text", this.app.lp.all);
  1261. // this.textNode.set("title", this.app.lp.all);
  1262. //
  1263. // this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  1264. // //this.loadChild();
  1265. // this.node.addEvent("click", function(){
  1266. // this.selected();
  1267. // }.bind(this));
  1268. // this.app.startApplications.push(this);
  1269. // },
  1270. // unselected: function(){
  1271. // this.childNode.empty();
  1272. // this.isLoaded = false;
  1273. // this.childNode.setStyle("display", "none");
  1274. // this.node.setStyles(this.css.applicationNode);
  1275. // },
  1276. // loadChild: function(){
  1277. // //this.loadSearch();
  1278. // MWF.UD.getDataJson("taskCenter_startTop", function(json){
  1279. // this.top5Data = json;
  1280. // if (this.top5Data && this.top5Data.length){
  1281. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  1282. // var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  1283. //
  1284. // this.top5Data.sort(function(p1, p2){
  1285. // return 0-(p1.count-p2.count);
  1286. // });
  1287. // }
  1288. //
  1289. // var allowProcessIds = [];
  1290. // this.data.each(function (app) {
  1291. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  1292. // var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  1293. // app.processList.each(function(process){
  1294. // allowProcessIds.push(process.id);
  1295. // new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  1296. // }.bind(this));
  1297. // }.bind(this));
  1298. //
  1299. // if (top5ChildNode){
  1300. // saveflag = false;
  1301. // this.top5Data.each(function(process, i){
  1302. // if (allowProcessIds.indexOf(process.id)!==-1){
  1303. // if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  1304. // }else{
  1305. // saveflag = true;
  1306. // process.count=0;
  1307. // }
  1308. // }.bind(this));
  1309. // if (saveflag) MWF.UD.putData("taskCenter_startTop", this.top5Data);
  1310. // }
  1311. //
  1312. // }.bind(this));
  1313. // }
  1314. // });