Main.js 67 KB

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