List.js 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. MWF.xApplication.process.TaskCenter.List = new Class({
  2. initialize: function(container, app, filterData){
  3. this.container = $(container);
  4. this.app = app;
  5. this.css = this.app.css;
  6. this.currentPageData = [];
  7. this.nextPageData = [];
  8. this.prevPageData = [];
  9. this.initData();
  10. this.filterData = null;
  11. if (filterData) this.filterData = filterData;
  12. this.load();
  13. },
  14. initData: function(){
  15. this.count = 0;
  16. this.isCountShow = false;
  17. this.currentPage = 1;
  18. this.pageCount = 20;
  19. this.pages = 0;
  20. this.items = [];
  21. this.isItemsLoaded = false;
  22. this.isItemLoadding = false;
  23. this.loadItemQueue = 0;
  24. this.filterApplication = "";
  25. this.currentFilterNode = null;
  26. this.filterListNode = null;
  27. },
  28. load: function(){
  29. this.mask = new MWF.widget.Mask({"style": "desktop"});
  30. this.mask.loadNode(this.app.content);
  31. this.contentNode = new Element("div", {"styles": this.css.listContentNode}).inject(this.container);
  32. this.createActionBarNode();
  33. this.createListAreaNode();
  34. this.resetListAreaHeight();
  35. this.app.addEvent("resize", this.resetListAreaHeight.bind(this));
  36. //this.setAppContentSize();
  37. // this.listItemNext();
  38. },
  39. refresh: function(){
  40. this.mask = new MWF.widget.Mask({"style": "desktop"});
  41. this.mask.loadNode(this.app.content);
  42. this.initData();
  43. this.filterData = null;
  44. if (this.applicationFilterAreaNode) this.applicationFilterAreaNode.empty();
  45. this.createAppFilterNodes();
  46. this.listAreaNode.empty();
  47. this.resetListAreaHeight();
  48. this.app.getWorkCounts();
  49. },
  50. refilter: function(){
  51. this.mask = new MWF.widget.Mask({"style": "desktop"});
  52. this.mask.loadNode(this.app.content);
  53. this.initData();
  54. this.applicationFilterAreaNode.empty();
  55. this.createAppFilterNodes();
  56. this.listAreaNode.empty();
  57. this.resetListAreaHeight();
  58. },
  59. listItemNext: function(count){
  60. if (!this.isItemsLoaded){
  61. if (!this.isItemLoadding){
  62. this.isItemLoadding = true;
  63. this._getCurrentPageData(function(json){
  64. this.count = json.count;
  65. if (!this.isCountShow){
  66. this.currentFilterNode.getFirst("span").set("text", "("+this.count+")");
  67. this.isCountShow = true;
  68. }
  69. json.data.each(function(task){
  70. this.items.push(this._createItem(task));
  71. }.bind(this));
  72. if (json.count<=this.items.length){
  73. this.isItemsLoaded = true;
  74. }
  75. this.isItemLoadding = false;
  76. if (this.loadItemQueue>0){
  77. this.loadItemQueue--;
  78. this.listItemNext();
  79. }
  80. this.mask.hide();
  81. }.bind(this), count);
  82. }else{
  83. this.loadItemQueue++;
  84. }
  85. }
  86. },
  87. createActionBarNode: function(){
  88. this.actionBarNode = new Element("div", {"styles": this.css.actionBarNode}).inject(this.contentNode);
  89. this.isFilterOpen = false;
  90. this.filterActionNode = new Element("div", {
  91. "styles": this.css.filterActionNode,
  92. "text": this.app.lp.filter
  93. }).inject(this.actionBarNode);
  94. this.filterActionNode.addEvents({
  95. "click": function (e){this.showOrHideFilter();e.stopPropagation();}.bind(this)
  96. });
  97. this.applicationFilterAreaNode = new Element("div", {"styles": this.css.applicationFilterAreaNode}).inject(this.actionBarNode);
  98. this.createAppFilterNodes();
  99. },
  100. showOrHideFilter: function(){
  101. if (!this.isFilterOpen){
  102. if (!this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.showFilter();
  103. }else{
  104. if (this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.hideFilter();
  105. }
  106. },
  107. showFilter: function(){
  108. this.filterActionNode.setStyles(this.css.filterActionNode_check);
  109. if (!this.filterAreaNode) this.createFilterAreaNode();
  110. this.filterAreaTipNode.setStyle("display", "block");
  111. this.filterAreaNode.setStyle("display", "block");
  112. this.resizeFilterAreaNode();
  113. var size = this.app.content.getSize();
  114. var toStyle = {
  115. "width": (!layout.mobile) ? "460px" : ""+size.x+"px",
  116. "height": (!layout.mobile) ? "500px" : ""+size.y+"px"
  117. };
  118. this.isFilterOpen = true;
  119. this.filterAreaMorph.start(toStyle).chain(function(){
  120. this.createFilterAreaTitle();
  121. this.createFilterAreaContent();
  122. this.hideFilterFun = this.hideFilter.bind(this);
  123. $(document.body).addEvent("click", this.hideFilterFun);
  124. }.bind(this));
  125. },
  126. hideFilter: function(){
  127. if (this.filterAreaNode){
  128. var toStyle = {
  129. "width": "460px",
  130. "height": "0px"
  131. };
  132. this.filterAreaNode.empty();
  133. this.isFilterOpen = false;
  134. this.filterAreaMorph.start(toStyle).chain(function(){
  135. this.filterAreaNode.eliminate("input");
  136. this.filterAreaNode.setStyle("display", "none");
  137. this.filterAreaTipNode.setStyle("display", "none");
  138. this.filterActionNode.setStyles(this.css.filterActionNode);
  139. }.bind(this));
  140. $(document.body).removeEvent("click", this.hideFilterFun);
  141. }
  142. },
  143. createFilterAreaContent: function(){
  144. var contentListNode = new Element("div", {"styles": this.css.applicationFilterAreaContentListNode}).inject(this.filterAreaNode);
  145. var contentScrollNode = new Element("div", {"styles": this.css.applicationFilterAreaContentScrollNode}).inject(contentListNode);
  146. var contentNode = new Element("div", {"styles": {"overflow": "hidden", "padding-bottom": "20px"}}).inject(contentScrollNode);
  147. MWF.require("MWF.widget.ScrollBar", function(){
  148. new MWF.widget.ScrollBar(contentScrollNode, {
  149. "style":"default", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}
  150. });
  151. }.bind(this));
  152. var _self = this;
  153. this.app.getAction(function(){
  154. this._getFilterCount(function(json){
  155. var obj = json.data;
  156. Object.each(obj, function(v, key){
  157. var categoryNode = new Element("div", {"styles": this.css.applicationFilterCategoryNode}).inject(contentNode);
  158. categoryNode.set("text", this.app.lp[key]);
  159. var itemAreaNode = new Element("div", {"styles": this.css.applicationFilterItemAreaNode}).inject(contentNode);
  160. // for (var x=0; x<10; x++){
  161. v.each(function(item){
  162. var itemNode = new Element("div", {"styles": this.css.applicationFilterItemNode}).inject(itemAreaNode);
  163. //itemNode.set("text", item.name+"("+item.count+")");
  164. itemNode.set("text", item.name);
  165. itemNode.store("value", item.value);
  166. itemNode.store("textname", item.name);
  167. itemNode.store("key", key);
  168. itemNode.addEvent("click", function(){
  169. if (this.hasClass("applicationFilterItemNode_over")){
  170. _self.unSelectedFilterItem(this);
  171. }else{
  172. _self.selectedFilterItem(this);
  173. }
  174. });
  175. if (this.filterData){
  176. if (this.filterData[key]){
  177. if (item.value === this.filterData[key].value){
  178. this.selectedFilterItem(itemNode);
  179. }
  180. }
  181. }
  182. }.bind(this));
  183. // }
  184. }.bind(this));
  185. }.bind(this));
  186. }.bind(this));
  187. },
  188. _getFilterCount: function(callback){
  189. this.app.action.listTaskCompletedFilterCount(function(json){
  190. if (callback) callback(json);
  191. });
  192. },
  193. unSelectedFilterItem: function(item){
  194. if (item.hasClass("applicationFilterItemNode_over")){
  195. // var value = item.retrieve("value");
  196. // var name = item.retrieve("textname");
  197. var key = item.retrieve("key");
  198. item.setStyles(this.css.applicationFilterItemNode);
  199. item.removeClass("applicationFilterItemNode_over");
  200. item.addClass("applicationFilterItemNode");
  201. if (!this.filterData) this.filterData = {};
  202. this.filterData[key] = null;
  203. delete this.filterData[key];
  204. item.getParent().eliminate("current");
  205. }
  206. },
  207. selectedFilterItem: function(item){
  208. if (!item.hasClass("applicationFilterItemNode_over")){
  209. var current = item.getParent().retrieve("current");
  210. if (current) this.unSelectedFilterItem(current);
  211. var value = item.retrieve("value");
  212. var key = item.retrieve("key");
  213. var name = item.retrieve("textname");
  214. item.setStyles(this.css.applicationFilterItemNode_over);
  215. item.removeClass("applicationFilterItemNode");
  216. item.addClass("applicationFilterItemNode_over");
  217. if (!this.filterData) this.filterData = {};
  218. this.filterData[key] = {"value": value, "name": name};
  219. item.getParent().store("current", item);
  220. }
  221. },
  222. createFilterAreaTitle: function(){
  223. var titleNode = new Element("div", {"styles": this.app.css.filterAreaTitleNode}).inject(this.filterAreaNode);
  224. var okNode = new Element("div", {"styles": this.app.css.filterAreaTitleActionOkNode, "text": this.app.lp.ok}).inject(titleNode);
  225. var clearNode = new Element("div", {"styles": this.app.css.filterAreaTitleActionClearNode, "text": this.app.lp.clear}).inject(titleNode);
  226. clearNode.addEvent("click", function(){
  227. this.filterAreaNode.getElements(".filterItem").each(function(el){
  228. this.unSelectedFilterItem(el);
  229. }.bind(this));
  230. var input = this.filterAreaNode.retrieve("input");
  231. input.set("value", "");
  232. this.filterData = null;
  233. this.hideFilter();
  234. this.refilter();
  235. }.bind(this));
  236. okNode.addEvent("click", function(){
  237. var input = this.filterAreaNode.retrieve("input");
  238. if (!this.filterData) this.filterData = {};
  239. var key = input.get("value");
  240. if (key && key!==this.app.lp.searchKey){
  241. this.filterData.key = key;
  242. }else{
  243. this.filterData.key = "";
  244. delete this.filterData.key
  245. }
  246. this.hideFilter();
  247. this.refilter();
  248. }.bind(this));
  249. var searchNode = new Element("div", {"styles": this.app.css.filterAreaTitleSearchNode}).inject(titleNode);
  250. var searchIconNode = new Element("div", {"styles": this.app.css.filterAreaTitleSearchIconNode}).inject(searchNode);
  251. var searchInputAreaNode = new Element("div", {"styles": this.app.css.filterAreaTitleSearchInputAreaNode}).inject(searchNode);
  252. var searchInputNode = new Element("input", {"styles": this.app.css.filterAreaTitleSearchInputNode, "value": this.app.lp.searchKey}).inject(searchInputAreaNode);
  253. if (this.filterData){
  254. if (this.filterData.key) searchInputNode.set("value", this.filterData.key);
  255. }
  256. this.filterAreaNode.store("input", searchInputNode);
  257. var key = this.app.lp.searchKey;
  258. searchInputNode.addEvents({
  259. "blur": function(){if (!this.get("value")) this.set("value", key)},
  260. "focus": function(){if (this.get("value")===key) this.set("value", "")}
  261. });
  262. },
  263. createFilterAreaNode: function(){
  264. this.filterAreaNode = new Element("div", {"styles": this.app.css.filterAreaNode}).inject(this.container);
  265. this.filterAreaNode.addEvent("click", function(e){e.stopPropagation();});
  266. this.filterAreaTipNode = new Element("div", {"styles": this.app.css.filterAreaTipNode}).inject(this.container);
  267. //var size = this.filterActionNode.getSize();
  268. this.filterAreaNode.setStyles({
  269. "width": (!layout.mobile) ? "460px" : ""+this.app.content.getSize().x+"px",
  270. "height": "0px"
  271. });
  272. this.filterAreaNode.position({
  273. relativeTo: this.filterActionNode,
  274. position: 'bottomRight',
  275. edge: 'upperRight',
  276. offset: {x:10, y: 7}
  277. });
  278. this.filterAreaTipNode.position({
  279. relativeTo: this.filterAreaNode,
  280. position: 'topRight',
  281. edge: 'bottomRight',
  282. offset: {x:-26, y: 1}
  283. });
  284. this.app.addEvent("resize", function(){
  285. this.resizeFilterAreaNode();
  286. }.bind(this));
  287. this.filterAreaMorph = new Fx.Morph(this.filterAreaNode, {
  288. duration: '100',
  289. transition: Fx.Transitions.Sine.easeInOut
  290. });
  291. },
  292. resizeFilterAreaNode: function(){
  293. if (this.filterAreaNode){
  294. this.filterAreaNode.position({
  295. relativeTo: this.filterActionNode,
  296. position: 'bottomRight',
  297. edge: 'upperRight',
  298. offset: {x:10, y: 7}
  299. });
  300. if (this.filterAreaTipNode){
  301. this.filterAreaTipNode.position({
  302. relativeTo: this.filterAreaNode,
  303. position: 'topRight',
  304. edge: 'bottomRight',
  305. offset: {x:-26, y: 1}
  306. });
  307. }
  308. }
  309. },
  310. createAppFilterNodes: function(){
  311. var allApp = {"name": this.app.lp.all, "application": "", "count": 0};
  312. this.allAppFilterNode = this.createAppFilterNode(allApp, "appFilterNode_current");
  313. this.currentFilterNode = this.allAppFilterNode;
  314. this._getApplicationCount(function(json){
  315. json.data.each(function(app){
  316. this.createAppFilterNode(app);
  317. }.bind(this));
  318. }.bind(this));
  319. },
  320. createAppFilterNode: function(app, style){
  321. style = style || "appFilterNode";
  322. var node = new Element("div", {"styles": this.app.css[style]}).inject(this.applicationFilterAreaNode);
  323. var text = (app.count) ? app.name+"<span>("+app.count+")</span>" : app.name+"<span></span>";
  324. node.set({"html": text, "id": app.value});
  325. var _self = this;
  326. node.addEvent("click", function(e){
  327. _self.filterByApplication(this);
  328. });
  329. return node;
  330. },
  331. filterByApplication: function(node){
  332. var id = node.get("id");
  333. if (!id){
  334. this.refresh();
  335. }else{
  336. if (this.currentFilterNode) this.currentFilterNode.setStyles(this.app.css.appFilterNode);
  337. this.initData();
  338. this.filterApplication = id;
  339. this.listAreaNode.empty();
  340. this.resetListAreaHeight();
  341. this.currentFilterNode = node;
  342. this.currentFilterNode.setStyles(this.app.css.appFilterNode_current);
  343. }
  344. },
  345. createListAreaNode: function(){
  346. this.listScrollAreaNode = new Element("div", {"styles": this.css.listScrollAreaNode}).inject(this.contentNode);
  347. this.listAreaNode = new Element("div", {"styles": this.css.listAreaNode}).inject(this.listScrollAreaNode);
  348. var _self = this;
  349. MWF.require("MWF.widget.ScrollBar", function(){
  350. new MWF.widget.ScrollBar(this.listScrollAreaNode, {
  351. "style":"xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  352. "onScroll": function(y, x){
  353. //new Element("div", {"text": "sss-"+y}).inject(_self.listScrollAreaNode, "before");
  354. // _self.app.taskTitleTextNode.set("text", "start");
  355. // _self.app.taskTitleTextNode.set("text", y);
  356. // if (!detail){
  357. var scrollSize = _self.listScrollAreaNode.getScrollSize();
  358. var clientSize = _self.listScrollAreaNode.getSize();
  359. var scrollHeight = scrollSize.y-clientSize.y;
  360. if (y+200>scrollHeight) {
  361. if (!_self.isElementLoaded) _self.listItemNext();
  362. }
  363. // }else{
  364. // _self.app.taskTitleTextNode.set("text", y);
  365. // }
  366. }
  367. });
  368. }.bind(this));
  369. },
  370. // setAppContentSize: function(){
  371. // var size = this.app.contentNode.getSize();
  372. // var x = this.container.getSize().x+size.x;
  373. // this.container.setStyle("width", ""+x+"px");
  374. // },
  375. resetListAreaHeight: function(){
  376. if (layout.mobile){
  377. this.resetListAreaHeight_mobile();
  378. }else{
  379. this.resetListAreaHeight_pc();
  380. }
  381. },
  382. resetListAreaHeight_mobile: function(){
  383. var contentSize = this.app.contentNode.getSize();
  384. this.contentNode.setStyle("width", ""+contentSize.x+"px");
  385. var size = this.contentNode.getSize();
  386. var y = size.y;
  387. if (this.actionBarNode){
  388. var barSize = this.actionBarNode.getSize();
  389. y = size.y - barSize.y;
  390. }
  391. this.listScrollAreaNode.setStyle("height", ""+y+"px");
  392. if (this.listAreaNode){
  393. // var count = (size.x/402).toInt();
  394. // var x = 402 * count;
  395. // var m = (size.x-x)/2;
  396. // this.listAreaNode.setStyles({
  397. // "width": ""+x+"px",
  398. // "margin-left": ""+m+"px"
  399. // });
  400. //
  401. // if (this.actionBarNode) this.actionBarNode.setStyles({
  402. // "width": ""+x+"px",
  403. // "margin-left": ""+m+"px"
  404. // });
  405. // var hCount = (y/102).toInt()+1;
  406. // this.pageCount = count*hCount;
  407. this.pageCount = 50;
  408. if (this.items.length<this.pageCount){
  409. this.listItemNext(this.pageCount-this.items.length);
  410. }
  411. //this.listAreaNode
  412. }
  413. },
  414. resetListAreaHeight_pc: function(){
  415. var contentSize = this.app.contentNode.getSize();
  416. this.contentNode.setStyle("width", ""+contentSize.x+"px");
  417. var size = this.contentNode.getSize();
  418. var y = size.y;
  419. if (this.actionBarNode){
  420. var barSize = this.actionBarNode.getSize();
  421. y = size.y - barSize.y;
  422. }
  423. // var barSize = this.actionBarNode.getSize();
  424. // var y = size.y - barSize.y;
  425. this.listScrollAreaNode.setStyle("height", ""+y+"px");
  426. if (this.listAreaNode){
  427. var count = (size.x/350).toInt();
  428. var x = 350 * count;
  429. var m = (size.x-x)/2;
  430. this.listAreaNode.setStyles({
  431. "width": ""+x+"px",
  432. "margin-left": ""+m+"px"
  433. });
  434. if (this.actionBarNode) this.actionBarNode.setStyles({
  435. "width": ""+x+"px",
  436. "margin-left": ""+m+"px"
  437. });
  438. var hCount = (y/182).toInt()+1;
  439. this.pageCount = count*hCount;
  440. if (this.items.length<this.pageCount){
  441. this.listItemNext(this.pageCount-this.items.length);
  442. }
  443. //this.listAreaNode
  444. }
  445. },
  446. show: function(){
  447. //if (!this.app.contentScroll){
  448. // this.app.contentScroll = new Fx.Scroll(this.app.contentNode, {"wheelStops": false});
  449. //}
  450. //this.app.contentScroll.toElement(this.contentNode, "x");
  451. if (this.app.currentList) this.app.currentList.hide();
  452. this.app.currentList = this;
  453. this.contentNode.setStyle("display", "block");
  454. //this.refresh();
  455. },
  456. hide: function(){
  457. this.contentNode.setStyle("display", "none");
  458. },
  459. _getCurrentPageData: function(callback, count){
  460. this.app.getAction(function(){
  461. var id;
  462. if (this.filterApplication){
  463. id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  464. this.app.action.listTaskNextByApp(function(json){
  465. if (callback) callback(json);
  466. }, null, id, count || this.pageCount, this.filterApplication);
  467. }else{
  468. id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  469. this.app.action.listTaskNext(function(json){
  470. if (callback) callback(json);
  471. }, null, id, count || this.pageCount);
  472. }
  473. }.bind(this));
  474. },
  475. _getApplicationCount: function(callback){
  476. this.app.getAction(function(){
  477. this.app.action.listTaskApplication(function(json){
  478. if (callback) callback(json);
  479. }.bind(this));
  480. }.bind(this));
  481. },
  482. _createItem: function(task){
  483. return new MWF.xApplication.process.TaskCenter.TaskList.Item(task, this)
  484. },
  485. showDatch: function(){
  486. if (!this.datchActionNode){
  487. this.datchActionNode = new Element("div", {"styles": this.css.datchActionNode, "text": this.app.lp.datch}).inject(this.app.content);
  488. this.datchActionNode.position({
  489. relativeTo: this.actionBarNode,
  490. position: "centerbottom",
  491. edge: "centerbottom"
  492. });
  493. this.datchActionNode.addEvent("click", function(e){
  494. this.datchProcess();
  495. }.bind(this));
  496. }
  497. },
  498. hideDatch: function(){
  499. if (this.datchActionNode){
  500. this.datchActionNode.destroy();
  501. this.datchActionNode = null;
  502. }
  503. },
  504. datchProcess: function(){
  505. var width = "580";
  506. var height = "260";
  507. size = this.app.content.getSize();
  508. var x = (size.x-width)/2;
  509. var y = (size.y-height)/2;
  510. if (x<0) x = 0;
  511. if (y<0) y = 0;
  512. var _self = this;
  513. MWF.require("MWF.xDesktop.Dialog", function() {
  514. var dlg = new MWF.xDesktop.Dialog({
  515. "title": this.app.lp.datch,
  516. "style": "datch",
  517. "top": y - 20,
  518. "left": x,
  519. "fromTop": y - 20,
  520. "fromLeft": x,
  521. "width": width,
  522. "height": height,
  523. "html": "",
  524. "maskNode": this.app.content,
  525. "container": this.app.content,
  526. // "buttonList": [
  527. // {
  528. // "text": MWF.LP.process.button.ok,
  529. // "action": function(){
  530. // //if (callback) callback(_self.view.selectedItems);
  531. // if (callback) callback(_self.view.getData());
  532. // this.close();
  533. // }
  534. // },
  535. // {
  536. // "text": MWF.LP.process.button.cancel,
  537. // "action": function(){this.close();}
  538. // }
  539. // ]
  540. });
  541. dlg.show();
  542. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  543. new MWF.xApplication.process.Work.Processor(dlg.content, this.selectedTask[0].data, {
  544. "style": "task",
  545. "onCancel": function(){
  546. dlg.close();
  547. delete this;
  548. },
  549. "onSubmit": function(routeName, opinion, medias){
  550. _self.submitDatchTask(routeName, opinion, medias, this);
  551. dlg.close();
  552. delete this;
  553. }
  554. })
  555. }.bind(this));
  556. }.bind(this));
  557. },
  558. submitDatchTask: function(routeName, opinion, medias, processor){
  559. this.hideDatch();
  560. this.selectedTask.each(function(item){
  561. item.submitTask(routeName, opinion, medias, processor, true);
  562. }.bind(this));
  563. this.selectedTask = [];
  564. }
  565. });
  566. MWF.xApplication.process.TaskCenter.List.Item = new Class({
  567. initialize: function(data, list){
  568. this.data = data;
  569. this.list = list;
  570. this.container = this.list.listAreaNode;
  571. this.load();
  572. },
  573. load: function(){
  574. this.node = new Element("div", {"styles": this.list.css.itemNode}).inject(this.container);
  575. if (layout.mobile){
  576. this.node.setStyles(this.list.css.itemNode_mobile);
  577. }
  578. this.mainContentNode = new Element("div", {"styles": this.list.css.itemMainContentAreaNode}).inject(this.node);
  579. this.timeContentNode = new Element("div", {"styles": this.list.css.itemTimeContentAreaNode}).inject(this.node);
  580. this.leftContentNode = new Element("div", {"styles": this.list.css.itemMainLeftContentAreaNode}).inject(this.mainContentNode);
  581. this.applicationIconAreaNode = new Element("div", {"styles": this.list.css.itemApplicationIconAreaNode, "title": this.data.applicationName}).inject(this.leftContentNode);
  582. this.timeIconNode = new Element("div", {"styles": this.list.css.itemTimeIconNode}).inject(this.leftContentNode);
  583. this.applicationIconNode = new Element("div", {"styles": this.list.css.itemApplicationIconNode}).inject(this.applicationIconAreaNode);
  584. this.actionContentNode = new Element("div", {"styles": this.list.css.itemMainActionContentAreaNode}).inject(this.mainContentNode);
  585. this.rightContentNode = new Element("div", {"styles": this.list.css.itemMainRightContentAreaNode}).inject(this.mainContentNode);
  586. this.applicationTitleNode = new Element("div", {"styles": this.list.css.itemApplicationTitleNode}).inject(this.rightContentNode);
  587. this.titleNode = new Element("div", {"styles": this.list.css.itemTitleNode}).inject(this.rightContentNode);
  588. this.activityNode = new Element("div", {"styles": this.list.css.itemActivityNode}).inject(this.rightContentNode);
  589. // this.contentNode = new Element("div", {"styles": this.list.css.itemContentNode}).inject(this.rightContentNode);
  590. // this.inforNode = new Element("div", {"styles": this.list.css.itemInforNode}).inject(this.contentNode);
  591. this.newIconNode = new Element("div", {"styles": this.list.css.itemNewIconNode}).inject(this.node);
  592. this.getApplicationIcon(function(icon){
  593. var pic = "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  594. if (icon.icon){
  595. pic = "data:image/png;base64,"+icon.icon;
  596. }
  597. this.applicationIconNode.makeLnk({
  598. "par": this._getLnkPar(pic)
  599. });
  600. }.bind(this));
  601. this.setContent();
  602. this.setNewIcon();
  603. this.setEvent();
  604. this.setTimeIcon();
  605. this.node.fade("in");
  606. },
  607. _getLnkPar: function(icon){
  608. return {
  609. "icon": icon,
  610. "title": "["+this.data.processName+"]"+(this.data.title || this.list.app.lp.unnamed),
  611. "par": (this.data.workCompleted) ? "process.Work#{\"workCompletedId\":\""+this.data.workCompleted+"\"}" : "process.Work#{\"workId\":\""+this.data.work+"\"}"
  612. };
  613. },
  614. setTimeIcon: function(){
  615. //this.data.expireTime = "2017-08-31 19:00";
  616. if (this.data.completed){
  617. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/pic_ok.png)");
  618. return true;
  619. }
  620. this.timeIconNode.empty();
  621. if (this.data.expireTime){
  622. var d1 = Date.parse(this.data.expireTime);
  623. var d2 = Date.parse(this.data.createTime);
  624. var now = new Date();
  625. var time1 = d2.diff(now, "second");
  626. var time2 = now.diff(d1, "second");
  627. var time3 = d2.diff(d1, "second");
  628. var n = time1/time3;
  629. var img = "";
  630. var text = this.list.app.lp.expire1;
  631. text = text.replace(/{time}/g, this.data.expireTime);
  632. if (n<0.5){
  633. img = "1.png";
  634. }else if (n<0.75){
  635. img = "2.png";
  636. }else if (n<1){
  637. text = this.list.app.lp.expire2.replace(/{time}/g, this.data.expireTime);
  638. img = "3.png";
  639. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/pic_jichao.png)");
  640. }else if (n<2){
  641. text = this.list.app.lp.expire3.replace(/{time}/g, this.data.expireTime);
  642. img = "4.png";
  643. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/pic_yichao.png)");
  644. }else{
  645. text = this.list.app.lp.expire3.replace(/{time}/g, this.data.expireTime);
  646. img = "5.png";
  647. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/pic_yanchao.png)");
  648. }
  649. this.timeIconNode.setStyle("background-image", "url("+this.list.app.path+this.list.app.options.style+"/time/"+img+")");
  650. this.timeIconNode.set("title", text);
  651. }
  652. },
  653. setEvent: function(){
  654. this.node.addEvents({
  655. "mouseover": function(){this.showAction();}.bind(this),
  656. "mouseout": function(){this.hideAction();}.bind(this)
  657. });
  658. if (this.editNode){
  659. this.editNode.addEvent("click", function(e){
  660. this.editTask();
  661. }.bind(this));
  662. }
  663. if (this.closeNode){
  664. this.closeNode.addEvent("click", function(e){
  665. this.closeEditTask();
  666. }.bind(this));
  667. }
  668. if (this.rightContentNode){
  669. this.rightContentNode.addEvent("click", function(e){
  670. this.openTask(e);
  671. }.bind(this));
  672. }
  673. if (this.applicationIconNode){
  674. this.applicationIconNode.addEvent("click", function(e){
  675. this.selectTask(e);
  676. }.bind(this));
  677. }
  678. },
  679. selectTask: function(){
  680. if (!this.list.selectedTask) this.list.selectedTask = [];
  681. if (!this.selectedStatus){
  682. this.list.selectedTask.push(this);
  683. this.mainContentNodeBorder = this.mainContentNode.getStyle("border");
  684. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode_selected);
  685. this.selectedStatus = true;
  686. }else{
  687. this.list.selectedTask.erase(this);
  688. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  689. this.mainContentNode.setStyle("border", this.mainContentNodeBorder);
  690. this.selectedStatus = false;
  691. }
  692. if (this.checkProcess()){
  693. this.list.showDatch();
  694. }else{
  695. this.list.hideDatch();
  696. }
  697. },
  698. checkProcess: function(){
  699. var flag = true;
  700. var activity = "";
  701. if (this.list.selectedTask.length){
  702. for (var i=0; i<this.list.selectedTask.length; i++){
  703. var item = this.list.selectedTask[i];
  704. if (!item.data.allowRapid) return false;
  705. if (!activity){
  706. activity = item.data.activity;
  707. }else{
  708. if ((activity != item.data.activity) || (!item.data.allowRapid)) return false;
  709. }
  710. }
  711. }else{
  712. return false;
  713. }
  714. return true;
  715. },
  716. showAction: function(){
  717. // if (this.editNode) this.editNode.fade("in");
  718. // if (this.closeNode) this.closeNode.fade("in");
  719. },
  720. hideAction: function(){
  721. // if (this.editNode) this.editNode.fade("out");
  722. // if (this.closeNode) this.closeNode.fade("out");
  723. },
  724. openTask: function(e){
  725. // this._getJobByTask(function(data){
  726. // 判断是否是钉钉环境 是否是独立窗口
  727. if (layout.inBrowser && (o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  728. var url = "../x_desktop/work.html?workid=" + this.data.work;
  729. window.location = o2.filterUrl(url);
  730. } else {
  731. var options = {"workId": this.data.work, "appId": "process.Work"+this.data.work};
  732. this.list.app.desktop.openApplication(e, "process.Work", options);
  733. }
  734. // }.bind(this));
  735. },
  736. closeEditTask: function(callback){
  737. this.closeNode.setStyle("display", "none");
  738. this.flowInforLeftNode.destroy();
  739. this.flowInforRightNode.destroy();
  740. this.flowInforContentNode.destroy();
  741. this.flowInforScrollNode.destroy();
  742. this.flowInforNode.destroy();
  743. this.processNode.destroy();
  744. this.flowInforScrollFx = null;
  745. this.flowInforLeftNode = null;
  746. this.flowInforRightNode = null;
  747. this.flowInforScrollNode = null;
  748. this.flowInforContentNode = null;
  749. delete this.flowInforScrollFx;
  750. delete this.flowInforLeftNode;
  751. delete this.flowInforRightNode;
  752. delete this.flowInforScrollNode;
  753. delete this.flowInforContentNode;
  754. delete this.flowInforNode;
  755. delete this.processNode;
  756. var p = this.node.getPosition(this.list.app.content);
  757. this.list.css.itemNode_edit_from.top = ""+ p.y+"px";
  758. this.list.css.itemNode_edit_from.left = ""+ p.x+"px";
  759. var morph = new Fx.Morph(this.mainContentNode, {
  760. "duration": 200,
  761. "transition": Fx.Transitions.Expo.easeIn,
  762. "onComplete": function(){
  763. this.nodeClone.destroy();
  764. this.nodeClone = null;
  765. this.list.app.content.unmask();
  766. document.body.setStyle("-webkit-overflow-scrolling", "touch");
  767. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  768. this.mainContentNode.setStyle("opacity", 1);
  769. this.list.app.removeEvent("resize", this.resizeEditNodeFun);
  770. this.editNode.setStyle("display", "block");
  771. if (callback) callback();
  772. }.bind(this)
  773. });
  774. morph.start(this.list.css.itemNode_edit_from);
  775. },
  776. editTask: function(){
  777. if (layout.mobile){
  778. this.editTask_mobile();
  779. }else{
  780. this.editTask_pc();
  781. }
  782. },
  783. editTask_mobile: function(){
  784. if (!this.nodeClone){
  785. this._getJobByTask(function(data){
  786. this.nodeClone = this.mainContentNode.clone(false);
  787. this.nodeClone.inject(this.mainContentNode, "after");
  788. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from_mobile);
  789. this.mainContentNode.position({
  790. relativeTo: this.nodeClone,
  791. position: "topleft",
  792. edge: "topleft"
  793. });
  794. this.showEditNode(data);
  795. }.bind(this));
  796. }
  797. },
  798. editTask_pc: function(){
  799. this.list.app.content.mask({
  800. "destroyOnHide": true,
  801. "id": "mask_"+this.data.id,
  802. "style": this.list.css.maskNode
  803. });
  804. this._getJobByTask(function(data){
  805. this.nodeClone = this.mainContentNode.clone(false);
  806. this.nodeClone.inject(this.mainContentNode, "after");
  807. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from);
  808. this.mainContentNode.position({
  809. relativeTo: this.nodeClone,
  810. position: "topleft",
  811. edge: "topleft"
  812. });
  813. this.showEditNode(data);
  814. }.bind(this));
  815. },
  816. setEditTaskNodes: function(data){
  817. this.flowInforNode = new Element("div", {"styles": this.list.css.flowInforNode}).inject(this.mainContentNode);
  818. this.processNode = new Element("div", {"styles": this.list.css.processNode}).inject(this.mainContentNode);
  819. this.setFlowInfor(data);
  820. this.setProcessor();
  821. },
  822. setFlowChart: function(data){
  823. var idx = 0;
  824. data.workLogList.each(function(worklog){
  825. if (!worklog.taskCompletedList) worklog.taskCompletedList = [];
  826. if (!worklog.taskList) worklog.taskList = [];
  827. if (worklog.taskCompletedList.length || worklog.taskList.length){
  828. this.createFlowInforWorklogNode(worklog.fromActivityName, worklog.taskCompletedList, worklog.taskList || [], idx, worklog.fromActivityToken == data.task.activityToken);
  829. idx++;
  830. }
  831. }.bind(this));
  832. return idx;
  833. },
  834. setFlowInfor: function(data){
  835. this.flowInforLeftNode = new Element("div", {"styles": this.list.css.flowInforLeftNode}).inject(this.flowInforNode);
  836. this.flowInforRightNode = new Element("div", {"styles": this.list.css.flowInforRightNode}).inject(this.flowInforNode);
  837. this.flowInforScrollNode = new Element("div", {"styles": this.list.css.flowInforScrollNode}).inject(this.flowInforNode);
  838. this.flowInforContentNode = new Element("div", {"styles": this.list.css.flowInforContentNode}).inject(this.flowInforScrollNode);
  839. var idx = this.setFlowChart(data);
  840. var x = (idx*40)+((idx-1)*16);
  841. this.flowInforContentNode.setStyle("width", ""+x+"px");
  842. this.setFlowInforScroll();
  843. },
  844. toFlowInforLeft: function(){
  845. var size = this.flowInforScrollNode.getSize();
  846. var scrollSize = this.flowInforScrollNode.getScrollSize();
  847. var scroll = this.flowInforScrollNode.getScroll();
  848. if (scroll.x>0){
  849. var scrollX = scroll.x-size.x;
  850. if (scrollX<0) scrollX = 0;
  851. if (scrollX>0){
  852. // this.flowInforLeftNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/left.png)");
  853. }else{
  854. this.flowInforLeftNode.setStyle("background-image", "");
  855. }
  856. if (scrollX+size.x<scrollSize.x){
  857. this.flowInforRightNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/right.png)");
  858. }else{
  859. // this.flowInforRightNode.setStyle("background-image", "");
  860. }
  861. this.flowInforScrollFx.start(scrollX);
  862. }
  863. },
  864. toFlowInforRight: function(){
  865. var size = this.flowInforScrollNode.getSize();
  866. var scrollSize = this.flowInforScrollNode.getScrollSize();
  867. var scroll = this.flowInforScrollNode.getScroll();
  868. if (scroll.x+size.x<scrollSize.x){
  869. var scrollX = scroll.x+size.x;
  870. if (scrollX>scrollSize.x) scrollX = scrollSize.x;
  871. if (scrollX>0){
  872. this.flowInforLeftNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/left.png)");
  873. }else{
  874. //this.flowInforLeftNode.setStyle("background-image", "");
  875. }
  876. if (scrollX+size.x<scrollSize.x){
  877. //this.flowInforRightNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/right.png)");
  878. }else{
  879. this.flowInforRightNode.setStyle("background-image", "");
  880. }
  881. this.flowInforScrollFx.start(scrollX);
  882. }
  883. },
  884. setFlowInforScroll: function(){
  885. var size = this.flowInforScrollNode.getSize();
  886. var scrollSize = this.flowInforScrollNode.getScrollSize();
  887. var scroll = this.flowInforScrollNode.getScroll();
  888. if (scrollSize.x>size.x){
  889. if (!this.flowInforScrollFx) this.flowInforScrollFx = new Fx.Scroll(this.flowInforScrollNode, {"wheelStops": false});
  890. this.flowInforScrollFx.toRight();
  891. this.flowInforLeftNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/left.png)");
  892. this.flowInforLeftNode.addEvent("click", function(){this.toFlowInforLeft();}.bind(this));
  893. this.flowInforRightNode.addEvent("click", function(){this.toFlowInforRight();}.bind(this));
  894. }
  895. },
  896. createFlowInforWorklogNode: function(activityName, taskCompleteList, taskList, idx, isCurrent){
  897. if (idx!=0) var logLineNode = new Element("div", {"styles": this.list.css.logLineNode}).inject(this.flowInforContentNode);
  898. var logActivityNode = new Element("div", {"styles": this.list.css.logActivityNode}).inject(this.flowInforContentNode);
  899. var logActivityIconNode = new Element("div", {"styles": this.list.css.logActivityIconNode}).inject(logActivityNode);
  900. var logActivityTextNode = new Element("div", {"styles": this.list.css.logActivityTextNode, "text": activityName}).inject(logActivityNode);
  901. var iconName = "user";
  902. var iconSuffix = "";
  903. if ((taskCompleteList.length+taskList.length)>1) iconName = "users";
  904. if (isCurrent) iconSuffix = "_red";
  905. var inforNode = new Element("div", {"styles": this.list.css.logInforNode});
  906. taskCompleteList.each(function(route){
  907. var routeNode = new Element("div", {"styles": this.list.css.logRouteNode}).inject(inforNode);
  908. routeNode.set("text", route.person.substring(0, route.person.indexOf("@"))+": ");
  909. var opinionNode = new Element("div", {"styles": this.list.css.logOpinionNode}).inject(inforNode);
  910. if (!route.opinion) route.opinion = "";
  911. opinionNode.set("text", "["+route.routeName+"] "+route.opinion);
  912. var timeNode = new Element("div", {"styles": this.list.css.logTimeNode}).inject(inforNode);
  913. timeNode.set("text", route.completedTime);
  914. if (this.list.app.desktop.session.user.distinguishedName === route.person) if (!iconSuffix) iconSuffix = "_yellow";
  915. }.bind(this));
  916. taskList.each(function(task){
  917. var taskTextNode = new Element("div", {"styles": this.list.css.taskTextNode}).inject(inforNode);
  918. taskTextNode.set("text", task.person.substring(0, task.person.indexOf("@"))+" "+this.list.app.lp.processing);
  919. }.bind(this));
  920. var icon = "url("+"../x_component_process_TaskCenter/$Main/default/processor/"+iconName+iconSuffix+".png)";
  921. logActivityIconNode.setStyle("background-image", icon);
  922. if (taskList.length){
  923. var countNode = new Element("div", {"styles": this.list.css.logTaskCountNode}).inject(logActivityNode);
  924. //var text = (taskList.length>99) ? "99+" : taskList.length;
  925. var text = taskList.length;
  926. countNode.set("text", text);
  927. }
  928. // new mBox.Tooltip({
  929. // content: inforNode,
  930. // setStyles: {content: {padding: 10, lineHeight: 20}},
  931. // attach: logActivityNode,
  932. // transition: 'flyin',
  933. // offset: {
  934. // x: this.list.app.contentNode.getScroll().x,
  935. // y: this.list.listScrollAreaNode.getScroll().y
  936. // }
  937. // });
  938. this.tooltip = new MWF.xApplication.process.TaskCenter.List.Item.Tooltip(this.list.app.content, logActivityNode, this.list.app, {}, {
  939. axis : "y",
  940. hiddenDelay : 300,
  941. displayDelay : 300
  942. });
  943. this.tooltip.inforNode = inforNode;
  944. },
  945. setProcessor: function(){
  946. var _self = this;
  947. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  948. new MWF.xApplication.process.Work.Processor(this.processNode, this.data, {
  949. "style": "task",
  950. "mediaNode": this.mainContentNode,
  951. "onCancel": function(){
  952. _self.closeEditTask();
  953. delete this;
  954. },
  955. "onSubmit": function(routeName, opinion, medias){
  956. _self.submitTask(routeName, opinion, medias, this);
  957. delete this;
  958. }
  959. })
  960. }.bind(this));
  961. },
  962. addMessage: function(data){
  963. if (layout.desktop.message){
  964. var content = "";
  965. if (data.length){
  966. data.each(function(work){
  967. var users = [];
  968. work.taskList.each(function(task){
  969. users.push(task.person+"("+task.department+")");
  970. }.bind(this));
  971. content += "<div><b>"+this.list.app.lp.nextActivity+"<font style=\"color: #ea621f\">"+work.fromActivityName+"</font>, "+this.list.app.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>"
  972. }.bind(this));
  973. }else{
  974. content += this.list.app.lp.workCompleted;
  975. }
  976. var msg = {
  977. "subject": this.list.app.lp.taskProcessed,
  978. "content": "<div>"+this.list.app.lp.taskProcessedMessage+"“"+this.data.title+"”</div>"+content
  979. };
  980. layout.desktop.message.addTooltip(msg);
  981. layout.desktop.message.addMessage(msg);
  982. }
  983. },
  984. submitTask: function(routeName, opinion, medias, processor, flag){
  985. if (!opinion) opinion = routeName;
  986. this.data.routeName = routeName;
  987. this.data.opinion = opinion;
  988. var mediaIds = [];
  989. if (medias.length){
  990. medias.each(function(file){
  991. var formData = new FormData();
  992. formData.append("file", file);
  993. //formData.append("fileName", (new MWF.UUID()).toString()+".wav");
  994. formData.append("site", "$mediaOpinion");
  995. this.list.app.action.uploadAttachment(this.data.work, formData, file, function(json){
  996. mediaIds.push(json.data.id);
  997. }.bind(this), null, false);
  998. }.bind(this));
  999. }
  1000. if (mediaIds.length) this.data.mediaOpinion = mediaIds.join(",");
  1001. this.list.app.action.processTask(function(json){
  1002. // this.list.app.notice(this.list.app.lp.taskProcessed, "success");
  1003. if (processor) processor.destroy();
  1004. if (!flag){
  1005. this.closeEditTask(function(){
  1006. this.node.destroy();
  1007. this.list.refresh();
  1008. this.addMessage(json.data);
  1009. delete this;
  1010. }.bind(this));
  1011. }else{
  1012. this.node.destroy();
  1013. this.list.refresh();
  1014. this.addMessage(json.data);
  1015. delete this;
  1016. }
  1017. }.bind(this), null, this.data.id, this.data);
  1018. },
  1019. resizeEditNode: function(){
  1020. var p = this.getEditNodePosition();
  1021. var size = this.list.app.content.getSize();
  1022. var maskNode = this.list.app.window.node.getElement("#mask_"+this.data.id);
  1023. if (maskNode) maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  1024. this.mainContentNode.setStyles({"top": ""+ p.y+"px", "left": ""+ p.x +"px"});
  1025. },
  1026. getEditNodePosition: function(){
  1027. var size = this.list.app.content.getSize();
  1028. var p = this.node.getPosition(this.list.app.content);
  1029. var top = p.y;
  1030. var left = p.x;
  1031. var w = this.list.css.itemNode_edit.width.toInt();
  1032. var h = this.list.css.itemNode_edit.height.toInt();
  1033. if (top+h>size.y){
  1034. top = size.y-h;
  1035. if (top<0) top=0;
  1036. }
  1037. if (left+w>size.x){
  1038. left = size.x-w-30;
  1039. if (left<0) left=0;
  1040. }
  1041. // var top = size.y/2-230;
  1042. // var left = size.x/2-260;
  1043. // if (top<0) top = 0;
  1044. return {"x": left, "y": top};
  1045. },
  1046. showEditNode: function(data, callback){
  1047. if (layout.mobile){
  1048. this.showEditNode_mobile(data, callback);
  1049. }else{
  1050. this.showEditNode_pc(data, callback);
  1051. }
  1052. },
  1053. showEditNode_mobile: function(data, callback){
  1054. var p = this.list.app.tabAreaNode.getPosition(this.list.app.content);
  1055. var contentSize = this.list.app.contentNode.getSize();
  1056. var tabSize = this.list.app.tabAreaNode.getSize();
  1057. var y = contentSize.y+tabSize.y;
  1058. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  1059. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  1060. this.list.css.itemNode_edit.width = ""+ contentSize.x+"px";
  1061. this.list.css.itemNode_edit.height = ""+ y+"px";
  1062. document.body.setStyle("-webkit-overflow-scrolling", "auto");
  1063. this.editNode.setStyle("display", "none");
  1064. var morph = new Fx.Morph(this.mainContentNode, {
  1065. "duration": 200,
  1066. "transition": Fx.Transitions.Expo.easeOut,
  1067. "onComplete": function(){
  1068. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  1069. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  1070. this.setEditTaskNodes(data);
  1071. this.closeNode.setStyle("display", "block");
  1072. if (callback) callback();
  1073. }.bind(this)
  1074. });
  1075. morph.start(this.list.css.itemNode_edit);
  1076. },
  1077. showEditNode_pc: function(data, callback){
  1078. var p = this.getEditNodePosition();
  1079. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  1080. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  1081. this.editNode.setStyle("display", "none");
  1082. var morph = new Fx.Morph(this.mainContentNode, {
  1083. "duration": 200,
  1084. "transition": Fx.Transitions.Expo.easeOut,
  1085. "onComplete": function(){
  1086. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  1087. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  1088. this.setEditTaskNodes(data);
  1089. this.closeNode.setStyle("display", "block");
  1090. if (callback) callback();
  1091. }.bind(this)
  1092. });
  1093. morph.start(this.list.css.itemNode_edit);
  1094. },
  1095. _getJobByTask: function(callback){
  1096. this.list.app.action.getSimpleJobByTask(function(json){
  1097. if (callback) callback(json.data);
  1098. }.bind(this), null, this.data.id);
  1099. },
  1100. setContent: function(){
  1101. this.applicationTitleNode.set("text", this.data.applicationName);
  1102. this.titleNode.set("html", "<font style=\"color: #333;\">["+this.data.processName+"]&nbsp;&nbsp;</font>"+o2.txt(this.data.title || ""));
  1103. this.titleNode.set("title", this.data.title);
  1104. this.activityNode.set("text", "( "+(this.data.activityName || this.list.app.lp.completed)+" )");
  1105. this.timeContentNode.set("text", this.list.app.lp.list_comedate+": "+this.data.startTime);
  1106. this.loadActions();
  1107. this.loadApplicationIcon();
  1108. //this.setTimeIconNode();
  1109. },
  1110. loadActions: function(){
  1111. if (this.data.allowRapid){
  1112. this.editNode = new Element("div", {"styles": this.list.css.titleActionEditNode}).inject(this.actionContentNode);
  1113. this.closeNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.actionContentNode);
  1114. }
  1115. },
  1116. loadApplicationIcon: function(){
  1117. this.getApplicationIcon(function(icon){
  1118. if (icon.icon){
  1119. //this.mainContentNode.setStyle("border-top", "4px solid "+icon.iconHue);
  1120. this.applicationIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon.icon+")");
  1121. }else{
  1122. this.mainContentNode.setStyle("border-top", "4px solid #4e82bd");
  1123. this.applicationIconNode.setStyle("background-image", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
  1124. }
  1125. }.bind(this));
  1126. },
  1127. getApplicationIcon: function(callback){
  1128. var icon = this.list.app.appIcons[this.data.application];
  1129. if (!icon) {
  1130. this.list.app.action.getApplicationIcon(function (json) {
  1131. if (json.data){
  1132. if (json.data){
  1133. this.list.app.appIcons[this.data.application] = json.data;
  1134. if (callback) callback(json.data);
  1135. }
  1136. }else{
  1137. this.invalidItem = true;
  1138. if (callback) callback({
  1139. "icon": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEgElEQVR4Xu1aPXMTSRB9vUaGQqs6iCgi4Bfgq7I2lqWrSwgQMQHyPzAJIeguvOT4BxbBxYjgkquTrFiiCvkXYCKKCFMSFEjs9tWsrEKWvTtfuyvXrTbd6ZnuN69fz842IecP5Tx+rAFYMyDnCKxTYBUE4MrWta9UuLu49hWeHlJveJy1P6kzQAT7eWPzPgN1MFeI6FpckMx8DKIeAe2iP3mVNiipADALuvAIQAOgLbtd5SGAVtGfvkgDjMQB+Fz1ngXgPdlO64IimOGAnhe7/d90bePGJwbAuOY9AqMJwu0kHTwzF+MIhKbb6b9IYh1rAATdxxub+yRyPMOHgbbrT3Zt08IKgHGlvIUN7NvnuSlyPISPXbc3EDph9BgDMPplu4KAXiad67pRhFXD4Qelf1/3dG3FeCMARPDEzoHJgmnZMAU7JiBoAyBozw4OVr3zy0AKJlCAHd100ALgpL4frC7nZfzhYdGf7ugIoxYAo5r3Mmu1l4V8hglAu9TpP1C1UwZgXC03QLSvOvFKxzHvut1BS8UHDQC8t6kfclQ8VhnDOHK7/TsqQ5UAGFW9JhGeqUy4PIZu3AR/eG9iChtbcPDY7b5+LltYCkB40nMKb01U/9Kv93D5yVN8++N3fP/nb5kvp97b2IqJRFVwg+kdmSBKARhXt/dAzp9a3gOYBzC30wHBxvaUnwoskANQK7/RLXvLAeiAYGN7dpN46HYGP8dtXiwAJ5cZH3V2X+Tt1b/akSZxTIgKfj7Zl4d1bT0p+pPrcWkQC4Bp6ZMFch4IJjZKGyMpibEAjGpem4D7SgstDdIJSGesri8MvCp1+pGf6vEAVMsfTdR/7qRKYGKsqBRRj454njeHqAal7uB61PzxKVDzWBfx5fEyEOLmtw1+Prfb6UfGGfnCRACjgjEBIanghU9GACT9za8DQpLBh4eimLuCSAYkDYBwRAWEpINfA3BRGKCy+zonRh1xNkqB3IugQHic5zIoABjVyscE+kmHbotjZbQXgpf6QQj8qdQZRP6QXR+F43Y39x9DJkL4v/ocDoWw6g1BONXNIdMEm0sNG9szfjEO3W4/tj9BfiOU9yux2e/vwpFJNbC52LSxDY+/4E+uP71tfSkalsM8X4vP82pc9URnxi1Z/l+I94x3brev1Kki1YAfAOT819jsZGh+R5gVM2R3gMt+KDMgFBbR/uZs9nTLYlbBg3FYDCYVmfAt+qMFQHguEA0SG+iZVIU0gRCqTz4qqTZIzANI47bIFpzMWmQWQQBTe9VMEDsP4rpJf5CIRTsFFncqbJNzqLUyTWAcIuCGLu2tNGCZqieNki3TP0im1Bdq7/qTho7gnbeWFQNOsUG00IBEq2y6hyXGO4Cbqi0wMoATA+DHgWl7j4maSWtDqPIsApd3fciCTjQFzltsdl641ACchrU+iDxH0CoG31u2dE81BaJQn4FRqDNRXRylZMwIVR3UI+Z2MZi20wg6dQaoUDDsNV54TMuYylpxYxLXAFuHsrZfA5A14hdtvTUDLtqOZO1P7hnwH8CljF98DV13AAAAAElFTkSuQmCC",
  1140. "iconHue": "#4e82bd"
  1141. });
  1142. }
  1143. }.bind(this), function(){
  1144. this.invalidItem = true;
  1145. if (callback) callback({
  1146. "icon": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEgElEQVR4Xu1aPXMTSRB9vUaGQqs6iCgi4Bfgq7I2lqWrSwgQMQHyPzAJIeguvOT4BxbBxYjgkquTrFiiCvkXYCKKCFMSFEjs9tWsrEKWvTtfuyvXrTbd6ZnuN69fz842IecP5Tx+rAFYMyDnCKxTYBUE4MrWta9UuLu49hWeHlJveJy1P6kzQAT7eWPzPgN1MFeI6FpckMx8DKIeAe2iP3mVNiipADALuvAIQAOgLbtd5SGAVtGfvkgDjMQB+Fz1ngXgPdlO64IimOGAnhe7/d90bePGJwbAuOY9AqMJwu0kHTwzF+MIhKbb6b9IYh1rAATdxxub+yRyPMOHgbbrT3Zt08IKgHGlvIUN7NvnuSlyPISPXbc3EDph9BgDMPplu4KAXiad67pRhFXD4Qelf1/3dG3FeCMARPDEzoHJgmnZMAU7JiBoAyBozw4OVr3zy0AKJlCAHd100ALgpL4frC7nZfzhYdGf7ugIoxYAo5r3Mmu1l4V8hglAu9TpP1C1UwZgXC03QLSvOvFKxzHvut1BS8UHDQC8t6kfclQ8VhnDOHK7/TsqQ5UAGFW9JhGeqUy4PIZu3AR/eG9iChtbcPDY7b5+LltYCkB40nMKb01U/9Kv93D5yVN8++N3fP/nb5kvp97b2IqJRFVwg+kdmSBKARhXt/dAzp9a3gOYBzC30wHBxvaUnwoskANQK7/RLXvLAeiAYGN7dpN46HYGP8dtXiwAJ5cZH3V2X+Tt1b/akSZxTIgKfj7Zl4d1bT0p+pPrcWkQC4Bp6ZMFch4IJjZKGyMpibEAjGpem4D7SgstDdIJSGesri8MvCp1+pGf6vEAVMsfTdR/7qRKYGKsqBRRj454njeHqAal7uB61PzxKVDzWBfx5fEyEOLmtw1+Prfb6UfGGfnCRACjgjEBIanghU9GACT9za8DQpLBh4eimLuCSAYkDYBwRAWEpINfA3BRGKCy+zonRh1xNkqB3IugQHic5zIoABjVyscE+kmHbotjZbQXgpf6QQj8qdQZRP6QXR+F43Y39x9DJkL4v/ocDoWw6g1BONXNIdMEm0sNG9szfjEO3W4/tj9BfiOU9yux2e/vwpFJNbC52LSxDY+/4E+uP71tfSkalsM8X4vP82pc9URnxi1Z/l+I94x3brev1Kki1YAfAOT819jsZGh+R5gVM2R3gMt+KDMgFBbR/uZs9nTLYlbBg3FYDCYVmfAt+qMFQHguEA0SG+iZVIU0gRCqTz4qqTZIzANI47bIFpzMWmQWQQBTe9VMEDsP4rpJf5CIRTsFFncqbJNzqLUyTWAcIuCGLu2tNGCZqieNki3TP0im1Bdq7/qTho7gnbeWFQNOsUG00IBEq2y6hyXGO4Cbqi0wMoATA+DHgWl7j4maSWtDqPIsApd3fciCTjQFzltsdl641ACchrU+iDxH0CoG31u2dE81BaJQn4FRqDNRXRylZMwIVR3UI+Z2MZi20wg6dQaoUDDsNV54TMuYylpxYxLXAFuHsrZfA5A14hdtvTUDLtqOZO1P7hnwH8CljF98DV13AAAAAElFTkSuQmCC",
  1147. "iconHue": "#f44336"
  1148. });
  1149. }.bind(this), this.data.application);
  1150. }else{
  1151. if (callback) callback(icon);
  1152. }
  1153. },
  1154. setNewIcon: function(){
  1155. var start = new Date().parse(this.data.startTime);
  1156. var now = new Date();
  1157. if (now.getTime()-start.getTime()<86400000){
  1158. this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/new.png)");
  1159. }
  1160. },
  1161. setTimeIconNode: function(){
  1162. var colors = ["#FF0000", "#00d400", "#f6ff0c"];
  1163. var idx = (Math.random()*3).toInt();
  1164. var color = colors[idx];
  1165. this.timeIconNode.setStyle("background-color", color);
  1166. //timeIconNode
  1167. }
  1168. //load: function(){
  1169. // this.node = this.table.insertRow(this.table.rows.length || 0);
  1170. // this.node.setStyles(this.list.css.itemLine);
  1171. //
  1172. // this.appNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.applicationName}).inject(this.node);
  1173. // this.titleNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.title}).inject(this.node);
  1174. // this.processNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.processName}).inject(this.node);
  1175. // this.activityNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.activityName}).inject(this.node);
  1176. // this.dateNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.updateTime}).inject(this.node);
  1177. //
  1178. //
  1179. // //this.titleNode = this.node.insertCell(this.node.cells.length || 0);
  1180. // //this.titleNode.setStyles(this.list.css.itemCell);
  1181. // //this.titleNode.set("text", this.data.title);
  1182. //}
  1183. });
  1184. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  1185. MWF.xApplication.process.TaskCenter.List.Item.Tooltip = new Class({
  1186. Extends: MTooltips,
  1187. options:{
  1188. nodeStyles: {
  1189. "font-size" : "12px",
  1190. "position" : "absolute",
  1191. "max-width" : "500px",
  1192. "min-width" : "180px",
  1193. "z-index" : "1001",
  1194. "background-color" : "#fff",
  1195. "padding" : "10px",
  1196. "border-radius" : "8px",
  1197. "box-shadow": "0 0 18px 0 #999999",
  1198. "-webkit-user-select": "text",
  1199. "-moz-user-select": "text"
  1200. },
  1201. isFitToContainer : true,
  1202. overflow : "scroll"
  1203. },
  1204. _loadCustom : function( callback ){
  1205. if(callback)callback();
  1206. },
  1207. _customNode : function( node, contentNode ){
  1208. this.inforNode.inject(contentNode);
  1209. if( this.inforNode.getSize().y > 300 ){
  1210. this.inforNode.setStyle("padding-bottom", "15px");
  1211. }
  1212. this.fireEvent("customContent", [contentNode, node]);
  1213. }
  1214. });