Main.js 67 KB

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