Main.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468
  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. if (this.top5Data && this.top5Data.length){
  870. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  871. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  872. this.top5Data.sort(function(p1, p2){
  873. return 0-(p1.count-p2.count);
  874. });
  875. }
  876. var allowProcessIds = [];
  877. this.data.each(function (app) {
  878. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  879. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  880. app.processList.each(function(process){
  881. allowProcessIds.push(process.id);
  882. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  883. }.bind(this));
  884. }.bind(this));
  885. if (top5ChildNode){
  886. saveflag = false;
  887. this.top5Data.each(function(process, i){
  888. if (allowProcessIds.indexOf(process.id)!==-1){
  889. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  890. }else{
  891. saveflag = true;
  892. process.count=0;
  893. }
  894. }.bind(this));
  895. if (saveflag) MWF.UD.putData("taskCenter_startTop", this.top5Data);
  896. }
  897. }.bind(this));
  898. }
  899. });
  900. MWF.xApplication.process.TaskCenter.Process = new Class({
  901. initialize: function(data, application, applicationData, container){
  902. this.data = data;
  903. this.application = application;
  904. this.applicationData = applicationData;
  905. this.app = this.application.app;
  906. if( this.application.starter ){
  907. this.starter = this.application.starter;
  908. }else if( this.application.app && this.application.app.starter ){
  909. this.starter = this.application.app.starter;
  910. }else if( this.application.app && this.application.app.processStarter ){
  911. this.starter = this.application.app.processStarter;
  912. }
  913. //this.starter = this.application.starter
  914. this.container = container;
  915. this.css = this.app.css;
  916. this.load();
  917. },
  918. load: function(){
  919. this.node = new Element("div.processItem", {"styles": this.css.startProcessNode}).inject(this.container);
  920. this.iconNode = new Element("div", {"styles": this.css.processIconNode}).inject(this.node);
  921. if (this.data.icon){
  922. this.iconNode.setStyle("background-image", "url("+this.data.icon+")");
  923. }else{
  924. this.iconNode.setStyle("background-image", "url(../x_component_process_ProcessManager/$Explorer/default/processIcon/process.png)");
  925. }
  926. this.actionNode = new Element("div", {"styles": this.css.processActionNode, "text": this.app.lp.start}).inject(this.node);
  927. this.textNode = new Element("div", {"styles": this.css.processTextNode}).inject(this.node);
  928. this.textNode.set({
  929. "text": this.data.name+((this.data.applicationName) ? " -- ("+this.data.applicationName+")" : ""),
  930. "title": this.data.name+"-"+this.data.description
  931. });
  932. //var _self = this;
  933. this.actionNode.addEvents({
  934. "mouseover": function(){this.actionNode.setStyles(this.css.processActionNode_over);}.bind(this),
  935. "mouseout": function(){this.actionNode.setStyles(this.css.processActionNode);}.bind(this),
  936. "click": function(e){
  937. this.startProcess(e);
  938. }.bind(this)
  939. });
  940. this.node.addEvents({
  941. "mouseover": function(){
  942. this.node.setStyles(this.css.startProcessNode_over);
  943. this.actionNode.setStyle("display", "block");
  944. }.bind(this),
  945. "mouseout": function(){
  946. this.node.setStyles(this.css.startProcessNode_out);
  947. //this.actionNode.setStyle("display", "none");
  948. }.bind(this)
  949. });
  950. },
  951. startProcess: function(){
  952. this.starter.closeStartProcessArea();
  953. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  954. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(this.data, this.app, {
  955. "onStarted": function(data, title, processName){
  956. this.afterStartProcess(data, title, processName);
  957. }.bind(this)
  958. });
  959. starter.load();
  960. }.bind(this));
  961. },
  962. recordProcessData: function(){
  963. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  964. if (!json || !json.length) json = [];
  965. var recordProcess = null;
  966. this.data.lastStartTime = new Date();
  967. var earlyProcessIdx = 0;
  968. var flag = true;
  969. for (var i=0; i<json.length; i++){
  970. var process = json[i];
  971. if (process.id === this.data.id) recordProcess = process;
  972. if (flag){
  973. if (!process.lastStartTime){
  974. earlyProcessIdx = i;
  975. flag = false;
  976. }else{
  977. if (new Date(process.lastStartTime)<new Date(json[earlyProcessIdx].lastStartTime)){
  978. earlyProcessIdx = i;
  979. }
  980. }
  981. }
  982. }
  983. if (recordProcess) {
  984. recordProcess.lastStartTime = new Date();
  985. recordProcess.count = (recordProcess.count || 0)+1;
  986. recordProcess.applicationName = this.applicationData.name;
  987. }else{
  988. if (json.length<10){
  989. this.data.count = 1;
  990. this.data.applicationName = this.applicationData.name;
  991. json.push(this.data);
  992. }else{
  993. json.splice(earlyProcessIdx, 1);
  994. this.data.count = 1;
  995. this.data.applicationName = this.applicationData.name;
  996. json.push(this.data);
  997. }
  998. }
  999. MWF.UD.putData("taskCenter_startTop", json);
  1000. }.bind(this));
  1001. },
  1002. afterStartProcess: function(data, title, processName){
  1003. this.recordProcessData();
  1004. //if (data[0].startMode==="draft"){
  1005. debugger;
  1006. if (data.work){
  1007. this.startProcessDraft(data, title, processName);
  1008. }else{
  1009. this.startProcessInstance(data, title, processName);
  1010. }
  1011. this.starter.fireEvent("startProcess");
  1012. },
  1013. startProcessDraft: function(data, title, processName){
  1014. var work = data.work;
  1015. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
  1016. this.app.desktop.openApplication(null, "process.Work", options);
  1017. // var msg = {
  1018. // "subject": this.app.lp.processStarted,
  1019. // "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"
  1020. // };
  1021. // var tooltip = layout.desktop.message.addTooltip(msg);
  1022. // var item = layout.desktop.message.addMessage(msg);
  1023. },
  1024. startProcessInstance: function(data, title, processName){
  1025. var workInfors = [];
  1026. var currentTask = [];
  1027. data.each(function(work){
  1028. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  1029. workInfors.push(this.getStartWorkInforObj(work));
  1030. }.bind(this));
  1031. if (currentTask.length===1){
  1032. var options = {"workId": currentTask[0], "appId": "process.Work"+currentTask[0]};
  1033. this.app.desktop.openApplication(null, "process.Work", options);
  1034. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
  1035. }else{
  1036. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
  1037. }
  1038. },
  1039. getStartWorkInforObj: function(work){
  1040. var users = [];
  1041. var currentTask = "";
  1042. work.taskList.each(function(task, idx){
  1043. users.push(task.person+"("+task.department + ")");
  1044. if (work.currentTaskIndex===idx) currentTask = task.id;
  1045. }.bind(this));
  1046. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  1047. },
  1048. createStartWorkResault: function(workInfors, title, processName, isopen){
  1049. var content = "";
  1050. workInfors.each(function(infor){
  1051. var users = [];
  1052. infor.users.each(function(uname){
  1053. users.push(MWF.name.cn(uname));
  1054. });
  1055. 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>";
  1056. if (infor.currentTask && isopen){
  1057. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  1058. }else{
  1059. content += "</div>";
  1060. }
  1061. }.bind(this));
  1062. var msg = {
  1063. "subject": this.app.lp.processStarted,
  1064. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  1065. };
  1066. var tooltip = layout.desktop.message.addTooltip(msg);
  1067. var item = layout.desktop.message.addMessage(msg);
  1068. this.setStartWorkResaultAction(tooltip);
  1069. this.setStartWorkResaultAction(item);
  1070. },
  1071. setStartWorkResaultAction: function(item){
  1072. var node = item.node.getElements("span");
  1073. node.setStyles(this.app.css.dealStartedWorkAction);
  1074. var _self = this;
  1075. node.addEvent("click", function(e){
  1076. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  1077. _self.app.desktop.openApplication(e, "process.Work", options);
  1078. });
  1079. }
  1080. });
  1081. MWF.xApplication.process.TaskCenter.Starter = new Class({
  1082. Implements: [Options, Events],
  1083. initialize: function(app, options){
  1084. this.setOptions(options);
  1085. this.app = app;
  1086. this.css = app.css;
  1087. this.lp = app.lp;
  1088. this.content = this.app.content;
  1089. this.startApplications = [];
  1090. },
  1091. load: function(){
  1092. if (layout.mobile){
  1093. this.showStartProcessArea_mobile();
  1094. }else{
  1095. this.showStartProcessArea_pc();
  1096. }
  1097. },
  1098. showStartProcessArea_pc: function () {
  1099. if (!this.startProcessAreaNode) {
  1100. this.createStartProcessArea();
  1101. }
  1102. this.content.mask({
  1103. "destroyOnHide": true,
  1104. "id": "process_taskcenter_startProcessMask",
  1105. "style": this.css.maskNode
  1106. });
  1107. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  1108. if (maskNode){
  1109. if( this.inBrowser ){
  1110. maskNode.setStyles({"width":"100%","height":"100%"});
  1111. }
  1112. maskNode.addEvent("click", function (e) {
  1113. this.closeStartProcessArea(e);
  1114. }.bind(this));
  1115. }
  1116. this.startProcessAreaNode.fade("in");
  1117. },
  1118. createStartProcessArea: function () {
  1119. this.createStartProcessAreaNode();
  1120. this.createStartProcessScrollNode();
  1121. this.listApplications();
  1122. this.setResizeStartProcessAreaHeight();
  1123. this.app.addEvent("resize", this.setResizeStartProcessAreaHeight.bind(this));
  1124. },
  1125. createStartProcessAreaNode: function () {
  1126. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode}).inject(this.content);
  1127. },
  1128. createStartProcessScrollNode: function () {
  1129. this.startProcessApplicationListNode = new Element("div", {"styles": this.css.startProcessApplicationListNode}).inject(this.startProcessAreaNode);
  1130. this.startProcessRightListNode = new Element("div", {"styles": this.css.startProcessRightListNode}).inject(this.startProcessAreaNode);
  1131. this.createStartProcessCloseNode();
  1132. this.createStartProcessSearchNode();
  1133. this.startProcessApplicationScrollNode = new Element("div", {"styles": this.css.startProcessApplicationScrollNode}).inject(this.startProcessApplicationListNode);
  1134. this.startProcessApplicationAreaNode = new Element("div", {"styles": this.css.startProcessApplicationAreaNode}).inject(this.startProcessApplicationScrollNode);
  1135. this.startProcessProcessListNode = new Element("div", {"styles": this.css.startProcessProcessListNode}).inject(this.startProcessRightListNode);
  1136. this.startProcessProcessScrollNode = new Element("div", {"styles": this.css.startProcessProcessScrollNode}).inject(this.startProcessProcessListNode);
  1137. this.startProcessProcessAreaNode = new Element("div", {"styles": this.css.startProcessProcessAreaNode}).inject(this.startProcessProcessScrollNode);
  1138. MWF.require("MWF.widget.ScrollBar", function () {
  1139. new MWF.widget.ScrollBar(this.startProcessApplicationScrollNode, {
  1140. "distance": 100,
  1141. "friction": 4
  1142. });
  1143. new MWF.widget.ScrollBar(this.startProcessProcessScrollNode, {
  1144. "distance": 100,
  1145. "friction": 4
  1146. });
  1147. }.bind(this));
  1148. },
  1149. createStartProcessCloseNode: function () {
  1150. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode}).inject(this.startProcessRightListNode);
  1151. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode}).inject(this.startProcessTopNode);
  1152. this.startProcessCloseNode.addEvent("click", function (e) {
  1153. this.closeStartProcessArea(e);
  1154. }.bind(this));
  1155. },
  1156. createStartProcessSearchNode: function(){
  1157. this.startProcessSearchNode = new Element("div", {"styles": this.css.startProcessSearchNode}).inject(this.startProcessRightListNode);
  1158. this.startProcessSearchIconNode = new Element("div", {"styles": this.css.startProcessSearchIconNode}).inject(this.startProcessSearchNode);
  1159. this.startProcessSearchAreaNode = new Element("div", {"styles": this.css.startProcessSearchAreaNode}).inject(this.startProcessSearchNode);
  1160. this.startProcessSearchInputNode = new Element("input", {"styles": this.css.startProcessSearchInputNode}).inject(this.startProcessSearchAreaNode);
  1161. this.startProcessSearchInputNode.set("value", this.lp.searchProcess);
  1162. this.startProcessSearchInputNode.addEvents({
  1163. "focus": function(){ if (this.startProcessSearchInputNode.get("value")===this.lp.searchProcess) this.startProcessSearchInputNode.set("value", ""); }.bind(this),
  1164. "blur": function(){if (!this.startProcessSearchInputNode.get("value")) this.startProcessSearchInputNode.set("value", this.lp.searchProcess);}.bind(this),
  1165. "keydown": function(e){ if (e.code===13) this.searchStartProcess(); }.bind(this)
  1166. });
  1167. this.startProcessSearchIconNode.addEvent("click", function(){ this.searchStartProcess(); }.bind(this));
  1168. },
  1169. searchStartProcess: function(){
  1170. var key = this.startProcessSearchInputNode.get("value");
  1171. if (key && key!==this.lp.searchProcess){
  1172. if (this.appStartableData){
  1173. this.startApplications.each(function(app){ app.unselected(); });
  1174. if (this.searchProcessSearchchildNode) this.searchProcessSearchchildNode.destroy();
  1175. var text = this.lp.searchProcessResault.replace("{key}", key);
  1176. this.searchProcessSearchchildNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.startProcessProcessAreaNode);
  1177. this.searchProcessSearchchildNode.setStyle("display", "block");
  1178. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": text}).inject(this.searchProcessSearchchildNode);
  1179. var proListNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.searchProcessSearchchildNode);
  1180. this.appStartableData.each(function (app) {
  1181. app.processList.each(function(pro){
  1182. if (pro.name.indexOf(key)!==-1){
  1183. var data = Object.clone(pro);
  1184. data.applicationName = app.name;
  1185. new MWF.xApplication.process.TaskCenter.Process(data, {"app": this.app, "starter": this}, {"name": app}, proListNode);
  1186. }
  1187. }.bind(this));
  1188. }.bind(this));
  1189. }
  1190. }
  1191. },
  1192. listApplications: function () {
  1193. this.app.getAction(function () {
  1194. this.app.action.listApplicationStartable(function (json) {
  1195. this.appStartableData = json.data;
  1196. this.startProcessSearchNode.setStyle("display", "block");
  1197. this.allApplicationStarter = new MWF.xApplication.process.TaskCenter.AllApplication(json.data, this);
  1198. this.allApplicationStarter.selected();
  1199. json.data.each(function (app) {
  1200. new MWF.xApplication.process.TaskCenter.Application(app, this);
  1201. }.bind(this));
  1202. }.bind(this));
  1203. }.bind(this));
  1204. },
  1205. setResizeStartProcessAreaHeight: function () {
  1206. if (this.startProcessAreaNode) {
  1207. var size = this.content.getSize();
  1208. var nodeSize = this.startProcessAreaNode.getSize();
  1209. var x = (size.x-nodeSize.x)/2;
  1210. var y = (size.y-nodeSize.y)/2;
  1211. this.startProcessAreaNode.setStyle("top", "" + y + "px");
  1212. this.startProcessAreaNode.setStyle("left", "" + x + "px");
  1213. var maskNode = this.content.getParent().getElement("#process_taskcenter_startProcessMask");
  1214. //var maskNode = this.window.node.getElement("#process_taskcenter_startProcessMask");
  1215. if (maskNode){
  1216. maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  1217. maskNode.position({
  1218. "relativeTo": this.content,
  1219. "position": "topLeft",
  1220. "edge": "topLeft"
  1221. });
  1222. }
  1223. if (this.startProcessProcessListNode){
  1224. var topSize = this.startProcessTopNode.getSize();
  1225. var searchSize = this.startProcessSearchNode.getSize();
  1226. var h = nodeSize.y-topSize.y-searchSize.y;
  1227. this.startProcessProcessListNode.setStyle("height", ""+h+"px");
  1228. }
  1229. }
  1230. },
  1231. showStartProcessArea_mobile: function(){
  1232. if (!this.startProcessAreaNode) {
  1233. this.createStartProcessArea_mobile();
  1234. }
  1235. this.startProcessAreaNode.setStyle("display", "block");
  1236. //document.body.setStyle("-webkit-overflow-scrolling", "auto");
  1237. var morph = new Fx.Morph(this.startProcessAreaNode, {
  1238. "duration": 200,
  1239. "transition": Fx.Transitions.Expo.easeOut
  1240. });
  1241. morph.start({"left": "0px"});
  1242. },
  1243. createStartProcessArea_mobile: function(){
  1244. this.startProcessAreaNode = new Element("div", {"styles": this.css.startProcessAreaNode_mobile}).inject(this.content);
  1245. var size = this.content.getSize();
  1246. this.startProcessAreaNode.setStyles({
  1247. "width": ""+size.x+"px",
  1248. "height": ""+size.y+"px",
  1249. "top": "0px",
  1250. "left": ""+size.x+"px"
  1251. });
  1252. this.startProcessTopNode = new Element("div", {"styles": this.css.startProcessTopNode_mobile}).inject(this.startProcessAreaNode);
  1253. this.startProcessCloseNode = new Element("div", {"styles": this.css.startProcessCloseNode_mobile, "text": this.lp.back}).inject(this.startProcessTopNode);
  1254. this.startProcessCloseNode.addEvent("click", function (e) {
  1255. this.closeStartProcessArea(e);
  1256. }.bind(this));
  1257. this.startProcessListNode = new Element("div", {"styles": this.css.startProcessListNode_mobile}).inject(this.startProcessAreaNode);
  1258. var h = size.y-this.startProcessTopNode.getSize().y;
  1259. this.startProcessListNode.setStyle("height", ""+h+"px");
  1260. this.app.getAction(function () {
  1261. this.app.action.listApplicationStartable(function (appjson) {
  1262. //this.app = this;
  1263. MWF.UD.getDataJson("taskCenter_startTop", function(json){
  1264. this.top5Data = json;
  1265. if (this.top5Data && this.top5Data.length){
  1266. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.lp.startTop5}).inject(this.startProcessListNode);
  1267. var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  1268. this.top5Data.sort(function(p1, p2){
  1269. return 0-(p1.count-p2.count);
  1270. });
  1271. this.top5Data.each(function(process, i){
  1272. if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  1273. }.bind(this));
  1274. }
  1275. appjson.data.each(function (app) {
  1276. new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.startProcessListNode);
  1277. var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.startProcessListNode);
  1278. app.processList.each(function(process){
  1279. new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  1280. }.bind(this));
  1281. }.bind(this));
  1282. }.bind(this));
  1283. }.bind(this));
  1284. }.bind(this));
  1285. },
  1286. // getAction: function (callback) {
  1287. // if (!this.action) {
  1288. // this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  1289. // if (callback) callback();
  1290. // } else {
  1291. // if (callback) callback();
  1292. // }
  1293. // },
  1294. closeStartProcessArea: function () {
  1295. if (layout.mobile){
  1296. var size = this.startProcessAreaNode.getSize();
  1297. var morph = new Fx.Morph(this.startProcessAreaNode, {
  1298. "duration": 200,
  1299. "transition": Fx.Transitions.Expo.easeOut,
  1300. "onComplete": function(){
  1301. this.startProcessAreaNode.setStyle("display", "none");
  1302. }.bind(this)
  1303. });
  1304. morph.start({"left": ""+size.x+"px"});
  1305. }else{
  1306. this.content.unmask();
  1307. if (this.startProcessAreaNode) this.startProcessAreaNode.fade("out");
  1308. }
  1309. }
  1310. });
  1311. // MWF.xApplication.process.TaskCenter.AllApplication = new Class({
  1312. // Extends: MWF.xApplication.process.TaskCenter.Application,
  1313. // initialize: function(data, app){
  1314. // this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  1315. // this.data = data;
  1316. // this.app = app;
  1317. // this.container = this.app.startProcessApplicationAreaNode;
  1318. // this.processContainer = this.app.startProcessProcessAreaNode;
  1319. // this.css = this.app.css;
  1320. // this.isLoaded = false;
  1321. //
  1322. // this.load();
  1323. // },
  1324. // load: function(){
  1325. // this.node = new Element("div", {"styles": this.css.applicationNode}).inject(this.container);
  1326. // this.iconAreaNode = new Element("div", {"styles": this.css.applicationIconAreaNode}).inject(this.node);
  1327. // this.iconNode = new Element("img", {"styles": this.css.applicationIconNode}).inject(this.iconAreaNode);
  1328. // this.iconNode.set("src", "../x_component_process_TaskCenter/$Main/default/icon/appAppliction.png");
  1329. //
  1330. // this.textNode = new Element("div", {"styles": this.css.applicationTextNode}).inject(this.node);
  1331. // this.textNode.set("text", this.app.lp.all);
  1332. // this.textNode.set("title", this.app.lp.all);
  1333. //
  1334. // this.childNode = new Element("div", {"styles": this.css.applicationChildNode}).inject(this.processContainer);
  1335. // //this.loadChild();
  1336. // this.node.addEvent("click", function(){
  1337. // this.selected();
  1338. // }.bind(this));
  1339. // this.app.startApplications.push(this);
  1340. // },
  1341. // unselected: function(){
  1342. // this.childNode.empty();
  1343. // this.isLoaded = false;
  1344. // this.childNode.setStyle("display", "none");
  1345. // this.node.setStyles(this.css.applicationNode);
  1346. // },
  1347. // loadChild: function(){
  1348. // //this.loadSearch();
  1349. // MWF.UD.getDataJson("taskCenter_startTop", function(json){
  1350. // this.top5Data = json;
  1351. // if (this.top5Data && this.top5Data.length){
  1352. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": this.app.lp.startTop5}).inject(this.childNode);
  1353. // var top5ChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  1354. //
  1355. // this.top5Data.sort(function(p1, p2){
  1356. // return 0-(p1.count-p2.count);
  1357. // });
  1358. // }
  1359. //
  1360. // var allowProcessIds = [];
  1361. // this.data.each(function (app) {
  1362. // new Element("div", {"styles": this.css.applicationChildTitleNode, "text": app.name}).inject(this.childNode);
  1363. // var appChildNode = new Element("div", {"styles": this.css.applicationChildChildNode}).inject(this.childNode);
  1364. // app.processList.each(function(process){
  1365. // allowProcessIds.push(process.id);
  1366. // new MWF.xApplication.process.TaskCenter.Process(process, this, app, appChildNode);
  1367. // }.bind(this));
  1368. // }.bind(this));
  1369. //
  1370. // if (top5ChildNode){
  1371. // saveflag = false;
  1372. // this.top5Data.each(function(process, i){
  1373. // if (allowProcessIds.indexOf(process.id)!==-1){
  1374. // if (i<5) new MWF.xApplication.process.TaskCenter.Process(process, this, {"name": process.applicationName}, top5ChildNode);
  1375. // }else{
  1376. // saveflag = true;
  1377. // process.count=0;
  1378. // }
  1379. // }.bind(this));
  1380. // if (saveflag) MWF.UD.putData("taskCenter_startTop", this.top5Data);
  1381. // }
  1382. //
  1383. // }.bind(this));
  1384. // }
  1385. // });