Main.js 81 KB

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