Main.js 64 KB

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