Main.js 67 KB

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