List.js 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298
  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. 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. if (json.count<=this.items.length){
  70. this.isItemsLoaded = true;
  71. }
  72. json.data.each(function(task){
  73. this.items.push(this._createItem(task));
  74. }.bind(this));
  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 barSize = this.actionBarNode.getSize();
  387. var y = size.y - barSize.y;
  388. this.listScrollAreaNode.setStyle("height", ""+y+"px");
  389. if (this.listAreaNode){
  390. // var count = (size.x/402).toInt();
  391. // var x = 402 * count;
  392. // var m = (size.x-x)/2;
  393. // this.listAreaNode.setStyles({
  394. // "width": ""+x+"px",
  395. // "margin-left": ""+m+"px"
  396. // });
  397. //
  398. // if (this.actionBarNode) this.actionBarNode.setStyles({
  399. // "width": ""+x+"px",
  400. // "margin-left": ""+m+"px"
  401. // });
  402. // var hCount = (y/102).toInt()+1;
  403. // this.pageCount = count*hCount;
  404. this.pageCount = 50;
  405. debugger;
  406. if (this.items.length<this.pageCount){
  407. this.listItemNext(this.pageCount-this.items.length);
  408. }
  409. //this.listAreaNode
  410. }
  411. },
  412. resetListAreaHeight_pc: function(){
  413. debugger;
  414. var contentSize = this.app.contentNode.getSize();
  415. this.contentNode.setStyle("width", ""+contentSize.x+"px");
  416. var size = this.contentNode.getSize();
  417. var barSize = this.actionBarNode.getSize();
  418. var y = size.y - barSize.y;
  419. this.listScrollAreaNode.setStyle("height", ""+y+"px");
  420. if (this.listAreaNode){
  421. var count = (size.x/350).toInt();
  422. var x = 350 * count;
  423. var m = (size.x-x)/2;
  424. this.listAreaNode.setStyles({
  425. "width": ""+x+"px",
  426. "margin-left": ""+m+"px"
  427. });
  428. if (this.actionBarNode) this.actionBarNode.setStyles({
  429. "width": ""+x+"px",
  430. "margin-left": ""+m+"px"
  431. });
  432. var hCount = (y/182).toInt()+1;
  433. this.pageCount = count*hCount;
  434. if (this.items.length<this.pageCount){
  435. this.listItemNext(this.pageCount-this.items.length);
  436. }
  437. //this.listAreaNode
  438. }
  439. },
  440. show: function(){
  441. debugger;
  442. //if (!this.app.contentScroll){
  443. // this.app.contentScroll = new Fx.Scroll(this.app.contentNode, {"wheelStops": false});
  444. //}
  445. //this.app.contentScroll.toElement(this.contentNode, "x");
  446. if (this.app.currentList) this.app.currentList.hide();
  447. this.app.currentList = this;
  448. this.contentNode.setStyle("display", "block");
  449. //this.refresh();
  450. },
  451. hide: function(){
  452. this.contentNode.setStyle("display", "none");
  453. },
  454. _getCurrentPageData: function(callback, count){
  455. this.app.getAction(function(){
  456. var id;
  457. if (this.filterApplication){
  458. id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  459. this.app.action.listTaskNextByApp(function(json){
  460. if (callback) callback(json);
  461. }, null, id, count || this.pageCount, this.filterApplication);
  462. }else{
  463. id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  464. this.app.action.listTaskNext(function(json){
  465. if (callback) callback(json);
  466. }, null, id, count || this.pageCount);
  467. }
  468. }.bind(this));
  469. },
  470. _getApplicationCount: function(callback){
  471. this.app.getAction(function(){
  472. this.app.action.listTaskApplication(function(json){
  473. if (callback) callback(json);
  474. }.bind(this));
  475. }.bind(this));
  476. },
  477. _createItem: function(task){
  478. return new MWF.xApplication.process.TaskCenter.TaskList.Item(task, this)
  479. },
  480. showDatch: function(){
  481. if (!this.datchActionNode){
  482. this.datchActionNode = new Element("div", {"styles": this.css.datchActionNode, "text": this.app.lp.datch}).inject(this.app.content);
  483. this.datchActionNode.position({
  484. relativeTo: this.actionBarNode,
  485. position: "centerbottom",
  486. edge: "centerbottom"
  487. });
  488. this.datchActionNode.addEvent("click", function(e){
  489. this.datchProcess();
  490. }.bind(this));
  491. }
  492. },
  493. hideDatch: function(){
  494. if (this.datchActionNode){
  495. this.datchActionNode.destroy();
  496. this.datchActionNode = null;
  497. }
  498. },
  499. datchProcess: function(){
  500. var width = "580";
  501. var height = "260";
  502. size = this.app.content.getSize();
  503. var x = (size.x-width)/2;
  504. var y = (size.y-height)/2;
  505. if (x<0) x = 0;
  506. if (y<0) y = 0;
  507. var _self = this;
  508. MWF.require("MWF.xDesktop.Dialog", function() {
  509. var dlg = new MWF.xDesktop.Dialog({
  510. "title": this.app.lp.datch,
  511. "style": "datch",
  512. "top": y - 20,
  513. "left": x,
  514. "fromTop": y - 20,
  515. "fromLeft": x,
  516. "width": width,
  517. "height": height,
  518. "html": "",
  519. "maskNode": this.app.content,
  520. "container": this.app.content,
  521. // "buttonList": [
  522. // {
  523. // "text": MWF.LP.process.button.ok,
  524. // "action": function(){
  525. // //if (callback) callback(_self.view.selectedItems);
  526. // if (callback) callback(_self.view.getData());
  527. // this.close();
  528. // }
  529. // },
  530. // {
  531. // "text": MWF.LP.process.button.cancel,
  532. // "action": function(){this.close();}
  533. // }
  534. // ]
  535. });
  536. dlg.show();
  537. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  538. new MWF.xApplication.process.Work.Processor(dlg.content, this.selectedTask[0].data, {
  539. "style": "task",
  540. "onCancel": function(){
  541. dlg.close();
  542. delete this;
  543. },
  544. "onSubmit": function(routeName, opinion){
  545. _self.submitDatchTask(routeName, opinion, this);
  546. dlg.close();
  547. delete this;
  548. }
  549. })
  550. }.bind(this));
  551. }.bind(this));
  552. },
  553. submitDatchTask: function(routeName, opinion, processor){
  554. this.hideDatch();
  555. this.selectedTask.each(function(item){
  556. item.submitTask(routeName, opinion, processor, true);
  557. }.bind(this));
  558. this.selectedTask = [];
  559. }
  560. });
  561. MWF.xApplication.process.TaskCenter.List.Item = new Class({
  562. initialize: function(data, list){
  563. this.data = data;
  564. this.list = list;
  565. this.container = this.list.listAreaNode;
  566. this.load();
  567. },
  568. load: function(){
  569. this.node = new Element("div", {"styles": this.list.css.itemNode}).inject(this.container);
  570. if (layout.mobile){
  571. this.node.setStyles(this.list.css.itemNode_mobile);
  572. }
  573. this.mainContentNode = new Element("div", {"styles": this.list.css.itemMainContentAreaNode}).inject(this.node);
  574. this.timeContentNode = new Element("div", {"styles": this.list.css.itemTimeContentAreaNode}).inject(this.node);
  575. this.leftContentNode = new Element("div", {"styles": this.list.css.itemMainLeftContentAreaNode}).inject(this.mainContentNode);
  576. this.applicationIconAreaNode = new Element("div", {"styles": this.list.css.itemApplicationIconAreaNode, "title": this.data.applicationName}).inject(this.leftContentNode);
  577. this.timeIconNode = new Element("div", {"styles": this.list.css.itemTimeIconNode}).inject(this.leftContentNode);
  578. this.applicationIconNode = new Element("div", {"styles": this.list.css.itemApplicationIconNode}).inject(this.applicationIconAreaNode);
  579. this.actionContentNode = new Element("div", {"styles": this.list.css.itemMainActionContentAreaNode}).inject(this.mainContentNode);
  580. this.rightContentNode = new Element("div", {"styles": this.list.css.itemMainRightContentAreaNode}).inject(this.mainContentNode);
  581. this.applicationTitleNode = new Element("div", {"styles": this.list.css.itemApplicationTitleNode}).inject(this.rightContentNode);
  582. this.titleNode = new Element("div", {"styles": this.list.css.itemTitleNode}).inject(this.rightContentNode);
  583. this.activityNode = new Element("div", {"styles": this.list.css.itemActivityNode}).inject(this.rightContentNode);
  584. // this.contentNode = new Element("div", {"styles": this.list.css.itemContentNode}).inject(this.rightContentNode);
  585. // this.inforNode = new Element("div", {"styles": this.list.css.itemInforNode}).inject(this.contentNode);
  586. this.newIconNode = new Element("div", {"styles": this.list.css.itemNewIconNode}).inject(this.node);
  587. this.setContent();
  588. this.setNewIcon();
  589. this.setEvent();
  590. this.setTimeIcon();
  591. this.node.fade("in");
  592. },
  593. setTimeIcon: function(){
  594. //this.data.expireTime = "2017-08-31 19:00";
  595. if (this.data.completed){
  596. this.newIconNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/time/pic_ok.png)");
  597. return true;
  598. }
  599. this.timeIconNode.empty();
  600. if (this.data.expireTime){
  601. var d1 = Date.parse(this.data.expireTime);
  602. var d2 = Date.parse(this.data.createTime);
  603. var now = new Date();
  604. var time1 = d2.diff(now, "second");
  605. var time2 = now.diff(d1, "second");
  606. var time3 = d2.diff(d1, "second");
  607. var n = time1/time3;
  608. var img = "";
  609. var text = this.list.app.lp.expire1;
  610. text = text.replace(/{time}/g, this.data.expireTime);
  611. if (n<0.5){
  612. img = "1.png";
  613. }else if (n<0.75){
  614. img = "2.png";
  615. }else if (n<1){
  616. text = this.list.app.lp.expire2.replace(/{time}/g, this.data.expireTime);
  617. img = "3.png";
  618. this.newIconNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/time/pic_jichao.png)");
  619. }else if (n<2){
  620. text = this.list.app.lp.expire3.replace(/{time}/g, this.data.expireTime);
  621. img = "4.png";
  622. this.newIconNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/time/pic_yichao.png)");
  623. }else{
  624. text = this.list.app.lp.expire3.replace(/{time}/g, this.data.expireTime);
  625. img = "5.png";
  626. this.newIconNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/time/pic_yanchao.png)");
  627. }
  628. this.timeIconNode.setStyle("background-image", "url("+this.list.app.path+this.list.app.options.style+"/time/"+img+")");
  629. this.timeIconNode.set("title", text);
  630. }
  631. },
  632. setEvent: function(){
  633. this.node.addEvents({
  634. "mouseover": function(){this.showAction();}.bind(this),
  635. "mouseout": function(){this.hideAction();}.bind(this)
  636. });
  637. if (this.editNode){
  638. this.editNode.addEvent("click", function(e){
  639. this.editTask();
  640. }.bind(this));
  641. }
  642. if (this.closeNode){
  643. this.closeNode.addEvent("click", function(e){
  644. this.closeEditTask();
  645. }.bind(this));
  646. }
  647. if (this.rightContentNode){
  648. this.rightContentNode.addEvent("click", function(e){
  649. this.openTask(e);
  650. }.bind(this));
  651. }
  652. if (this.applicationIconNode){
  653. this.applicationIconNode.addEvent("click", function(e){
  654. this.selectTask(e);
  655. }.bind(this));
  656. }
  657. },
  658. selectTask: function(){
  659. if (!this.list.selectedTask) this.list.selectedTask = [];
  660. if (!this.selectedStatus){
  661. this.list.selectedTask.push(this);
  662. this.mainContentNodeBorder = this.mainContentNode.getStyle("border");
  663. debugger;
  664. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode_selected);
  665. this.selectedStatus = true;
  666. }else{
  667. this.list.selectedTask.erase(this);
  668. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  669. this.mainContentNode.setStyle("border", this.mainContentNodeBorder);
  670. this.selectedStatus = false;
  671. }
  672. if (this.checkProcess()){
  673. this.list.showDatch();
  674. }else{
  675. this.list.hideDatch();
  676. }
  677. },
  678. checkProcess: function(){
  679. var flag = true;
  680. var activity = "";
  681. if (this.list.selectedTask.length){
  682. for (var i=0; i<this.list.selectedTask.length; i++){
  683. var item = this.list.selectedTask[i];
  684. if (!item.data.allowRapid) return false;
  685. if (!activity){
  686. activity = item.data.activity;
  687. }else{
  688. if ((activity != item.data.activity) || (!item.data.allowRapid)) return false;
  689. }
  690. }
  691. }else{
  692. return false;
  693. }
  694. return true;
  695. },
  696. showAction: function(){
  697. // if (this.editNode) this.editNode.fade("in");
  698. // if (this.closeNode) this.closeNode.fade("in");
  699. },
  700. hideAction: function(){
  701. // if (this.editNode) this.editNode.fade("out");
  702. // if (this.closeNode) this.closeNode.fade("out");
  703. },
  704. openTask: function(e){
  705. // this._getJobByTask(function(data){
  706. var options = {"workId": this.data.work, "appId": this.data.work};
  707. this.list.app.desktop.openApplication(e, "process.Work", options);
  708. // }.bind(this));
  709. },
  710. closeEditTask: function(callback){
  711. this.closeNode.setStyle("display", "none");
  712. this.flowInforLeftNode.destroy();
  713. this.flowInforRightNode.destroy();
  714. this.flowInforContentNode.destroy();
  715. this.flowInforScrollNode.destroy();
  716. this.flowInforNode.destroy();
  717. this.processNode.destroy();
  718. this.flowInforScrollFx = null;
  719. this.flowInforLeftNode = null;
  720. this.flowInforRightNode = null;
  721. this.flowInforScrollNode = null;
  722. this.flowInforContentNode = null;
  723. delete this.flowInforScrollFx;
  724. delete this.flowInforLeftNode;
  725. delete this.flowInforRightNode;
  726. delete this.flowInforScrollNode;
  727. delete this.flowInforContentNode;
  728. delete this.flowInforNode;
  729. delete this.processNode;
  730. var p = this.node.getPosition(this.list.app.content);
  731. this.list.css.itemNode_edit_from.top = ""+ p.y+"px";
  732. this.list.css.itemNode_edit_from.left = ""+ p.x+"px";
  733. var morph = new Fx.Morph(this.mainContentNode, {
  734. "duration": 200,
  735. "transition": Fx.Transitions.Expo.easeIn,
  736. "onComplete": function(){
  737. this.nodeClone.destroy();
  738. this.nodeClone = null;
  739. this.list.app.content.unmask();
  740. document.body.setStyle("-webkit-overflow-scrolling", "touch");
  741. this.mainContentNode.setStyles(this.list.css.itemMainContentAreaNode);
  742. this.mainContentNode.setStyle("opacity", 1);
  743. this.list.app.removeEvent("resize", this.resizeEditNodeFun);
  744. this.editNode.setStyle("display", "block");
  745. if (callback) callback();
  746. }.bind(this)
  747. });
  748. morph.start(this.list.css.itemNode_edit_from);
  749. },
  750. editTask: function(){
  751. if (layout.mobile){
  752. this.editTask_mobile();
  753. }else{
  754. this.editTask_pc();
  755. }
  756. },
  757. editTask_mobile: function(){
  758. if (!this.nodeClone){
  759. this._getJobByTask(function(data){
  760. this.nodeClone = this.mainContentNode.clone(false);
  761. this.nodeClone.inject(this.mainContentNode, "after");
  762. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from_mobile);
  763. this.mainContentNode.position({
  764. relativeTo: this.nodeClone,
  765. position: "topleft",
  766. edge: "topleft"
  767. });
  768. this.showEditNode(data);
  769. }.bind(this));
  770. }
  771. },
  772. editTask_pc: function(){
  773. this.list.app.content.mask({
  774. "destroyOnHide": true,
  775. "id": "mask_"+this.data.id,
  776. "style": this.list.css.maskNode
  777. });
  778. this._getJobByTask(function(data){
  779. this.nodeClone = this.mainContentNode.clone(false);
  780. this.nodeClone.inject(this.mainContentNode, "after");
  781. this.mainContentNode.setStyles(this.list.css.itemNode_edit_from);
  782. this.mainContentNode.position({
  783. relativeTo: this.nodeClone,
  784. position: "topleft",
  785. edge: "topleft"
  786. });
  787. // this.nodeClone = this.node.clone(false);
  788. // this.nodeClone.inject(this.node, "after");
  789. // this.node.setStyles(this.list.css.itemNode_edit_from);
  790. // this.node.position({
  791. // relativeTo: this.nodeClone,
  792. // position: "topleft",
  793. // edge: "topleft"
  794. // });
  795. this.showEditNode(data);
  796. }.bind(this));
  797. },
  798. setEditTaskNodes: function(data){
  799. this.flowInforNode = new Element("div", {"styles": this.list.css.flowInforNode}).inject(this.mainContentNode);
  800. this.processNode = new Element("div", {"styles": this.list.css.processNode}).inject(this.mainContentNode);
  801. this.setFlowInfor(data);
  802. this.setProcessor();
  803. },
  804. setFlowChart: function(data){
  805. var idx = 0;
  806. data.workLogList.each(function(worklog){
  807. if (!worklog.taskCompletedList) worklog.taskCompletedList = [];
  808. if (!worklog.taskList) worklog.taskList = [];
  809. if (worklog.taskCompletedList.length || worklog.taskList.length){
  810. this.createFlowInforWorklogNode(worklog.fromActivityName, worklog.taskCompletedList, worklog.taskList || [], idx, worklog.fromActivityToken == data.task.activityToken);
  811. idx++;
  812. }
  813. }.bind(this));
  814. return idx;
  815. },
  816. setFlowInfor: function(data){
  817. this.flowInforLeftNode = new Element("div", {"styles": this.list.css.flowInforLeftNode}).inject(this.flowInforNode);
  818. this.flowInforRightNode = new Element("div", {"styles": this.list.css.flowInforRightNode}).inject(this.flowInforNode);
  819. this.flowInforScrollNode = new Element("div", {"styles": this.list.css.flowInforScrollNode}).inject(this.flowInforNode);
  820. this.flowInforContentNode = new Element("div", {"styles": this.list.css.flowInforContentNode}).inject(this.flowInforScrollNode);
  821. var idx = this.setFlowChart(data);
  822. var x = (idx*40)+((idx-1)*16);
  823. this.flowInforContentNode.setStyle("width", ""+x+"px");
  824. this.setFlowInforScroll();
  825. },
  826. toFlowInforLeft: function(){
  827. var size = this.flowInforScrollNode.getSize();
  828. var scrollSize = this.flowInforScrollNode.getScrollSize();
  829. var scroll = this.flowInforScrollNode.getScroll();
  830. if (scroll.x>0){
  831. var scrollX = scroll.x-size.x;
  832. if (scrollX<0) scrollX = 0;
  833. if (scrollX>0){
  834. // this.flowInforLeftNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/processor/left.png)");
  835. }else{
  836. this.flowInforLeftNode.setStyle("background-image", "");
  837. }
  838. if (scrollX+size.x<scrollSize.x){
  839. this.flowInforRightNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/processor/right.png)");
  840. }else{
  841. // this.flowInforRightNode.setStyle("background-image", "");
  842. }
  843. this.flowInforScrollFx.start(scrollX);
  844. }
  845. },
  846. toFlowInforRight: function(){
  847. var size = this.flowInforScrollNode.getSize();
  848. var scrollSize = this.flowInforScrollNode.getScrollSize();
  849. var scroll = this.flowInforScrollNode.getScroll();
  850. if (scroll.x+size.x<scrollSize.x){
  851. var scrollX = scroll.x+size.x;
  852. if (scrollX>scrollSize.x) scrollX = scrollSize.x;
  853. if (scrollX>0){
  854. this.flowInforLeftNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/processor/left.png)");
  855. }else{
  856. //this.flowInforLeftNode.setStyle("background-image", "");
  857. }
  858. if (scrollX+size.x<scrollSize.x){
  859. //this.flowInforRightNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/processor/right.png)");
  860. }else{
  861. this.flowInforRightNode.setStyle("background-image", "");
  862. }
  863. this.flowInforScrollFx.start(scrollX);
  864. }
  865. },
  866. setFlowInforScroll: function(){
  867. var size = this.flowInforScrollNode.getSize();
  868. var scrollSize = this.flowInforScrollNode.getScrollSize();
  869. var scroll = this.flowInforScrollNode.getScroll();
  870. if (scrollSize.x>size.x){
  871. if (!this.flowInforScrollFx) this.flowInforScrollFx = new Fx.Scroll(this.flowInforScrollNode, {"wheelStops": false});
  872. this.flowInforScrollFx.toRight();
  873. this.flowInforLeftNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/processor/left.png)");
  874. this.flowInforLeftNode.addEvent("click", function(){this.toFlowInforLeft();}.bind(this));
  875. this.flowInforRightNode.addEvent("click", function(){this.toFlowInforRight();}.bind(this));
  876. }
  877. },
  878. createFlowInforWorklogNode: function(activityName, taskCompleteList, taskList, idx, isCurrent){
  879. if (idx!=0) var logLineNode = new Element("div", {"styles": this.list.css.logLineNode}).inject(this.flowInforContentNode);
  880. var logActivityNode = new Element("div", {"styles": this.list.css.logActivityNode}).inject(this.flowInforContentNode);
  881. var logActivityIconNode = new Element("div", {"styles": this.list.css.logActivityIconNode}).inject(logActivityNode);
  882. var logActivityTextNode = new Element("div", {"styles": this.list.css.logActivityTextNode, "text": activityName}).inject(logActivityNode);
  883. var iconName = "user";
  884. var iconSuffix = "";
  885. if ((taskCompleteList.length+taskList.length)>1) iconName = "users";
  886. if (isCurrent) iconSuffix = "_red";
  887. var inforNode = new Element("div", {"styles": this.list.css.logInforNode});
  888. taskCompleteList.each(function(route){
  889. var routeNode = new Element("div", {"styles": this.list.css.logRouteNode}).inject(inforNode);
  890. routeNode.set("text", route.person.substring(0, route.person.indexOf("@"))+": ");
  891. var opinionNode = new Element("div", {"styles": this.list.css.logOpinionNode}).inject(inforNode);
  892. if (!route.opinion) route.opinion = "";
  893. opinionNode.set("text", "["+route.routeName+"] "+route.opinion);
  894. var timeNode = new Element("div", {"styles": this.list.css.logTimeNode}).inject(inforNode);
  895. timeNode.set("text", route.completedTime);
  896. if (this.list.app.desktop.session.user.distinguishedName === route.person) if (!iconSuffix) iconSuffix = "_yellow";
  897. }.bind(this));
  898. taskList.each(function(task){
  899. var taskTextNode = new Element("div", {"styles": this.list.css.taskTextNode}).inject(inforNode);
  900. taskTextNode.set("text", task.person.substring(0, task.person.indexOf("@"))+" "+this.list.app.lp.processing);
  901. }.bind(this));
  902. var icon = "url("+"/x_component_process_TaskCenter/$Main/default/processor/"+iconName+iconSuffix+".png)";
  903. logActivityIconNode.setStyle("background-image", icon);
  904. if (taskList.length){
  905. var countNode = new Element("div", {"styles": this.list.css.logTaskCountNode}).inject(logActivityNode);
  906. var text = (taskList.length>99) ? "99+" : taskList.length;
  907. countNode.set("text", text);
  908. }
  909. new mBox.Tooltip({
  910. content: inforNode,
  911. setStyles: {content: {padding: 10, lineHeight: 20}},
  912. attach: logActivityNode,
  913. transition: 'flyin',
  914. offset: {
  915. x: this.list.app.contentNode.getScroll().x,
  916. y: this.list.listScrollAreaNode.getScroll().y
  917. }
  918. });
  919. },
  920. setProcessor: function(){
  921. var _self = this;
  922. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  923. new MWF.xApplication.process.Work.Processor(this.processNode, this.data, {
  924. "style": "task",
  925. "onCancel": function(){
  926. _self.closeEditTask();
  927. delete this;
  928. },
  929. "onSubmit": function(routeName, opinion){
  930. _self.submitTask(routeName, opinion, this);
  931. delete this;
  932. }
  933. })
  934. }.bind(this));
  935. },
  936. addMessage: function(data){
  937. var content = "";
  938. if (data.length){
  939. data.each(function(work){
  940. var users = [];
  941. work.taskList.each(function(task){
  942. users.push(task.person+"("+task.department+")");
  943. }.bind(this));
  944. 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>"
  945. }.bind(this));
  946. }else{
  947. content += this.list.app.lp.workCompleted;
  948. }
  949. //
  950. //
  951. //data.taskList.each(function(list){
  952. // content += "<div><b>"+this.list.app.lp.nextActivity+"<font style=\"color: #ea621f\">"+list.activityName+"</font>, "+this.list.app.lp.nextUser+"<font style=\"color: #ea621f\">"+list.personList.join(", ")+"</font></b></div>"
  953. //}.bind(this));
  954. var msg = {
  955. "subject": this.list.app.lp.taskProcessed,
  956. "content": "<div>"+this.list.app.lp.taskProcessedMessage+"“"+this.data.title+"”</div>"+content
  957. };
  958. layout.desktop.message.addTooltip(msg);
  959. layout.desktop.message.addMessage(msg);
  960. },
  961. submitTask: function(routeName, opinion, processor, flag){
  962. if (!opinion) opinion = routeName;
  963. this.data.routeName = routeName;
  964. this.data.opinion = opinion;
  965. this.list.app.action.processTask(function(json){
  966. // this.list.app.notice(this.list.app.lp.taskProcessed, "success");
  967. if (processor) processor.destroy();
  968. if (!flag){
  969. this.closeEditTask(function(){
  970. this.node.destroy();
  971. this.list.refresh();
  972. this.addMessage(json.data);
  973. delete this;
  974. }.bind(this));
  975. }else{
  976. this.node.destroy();
  977. this.list.refresh();
  978. this.addMessage(json.data);
  979. delete this;
  980. }
  981. }.bind(this), null, this.data.id, this.data);
  982. },
  983. resizeEditNode: function(){
  984. var p = this.getEditNodePosition();
  985. var size = this.list.app.content.getSize();
  986. var maskNode = this.list.app.window.node.getElement("#mask_"+this.data.id);
  987. if (maskNode) maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
  988. this.mainContentNode.setStyles({"top": ""+ p.y+"px", "left": ""+ p.x +"px"});
  989. },
  990. getEditNodePosition: function(){
  991. var size = this.list.app.content.getSize();
  992. var p = this.node.getPosition(this.list.app.content);
  993. var top = p.y;
  994. var left = p.x;
  995. var w = this.list.css.itemNode_edit.width.toInt();
  996. var h = this.list.css.itemNode_edit.height.toInt();
  997. if (top+h>size.y){
  998. top = size.y-h;
  999. if (top<0) top=0;
  1000. }
  1001. if (left+w>size.x){
  1002. left = size.x-w;
  1003. if (left<0) left=0;
  1004. }
  1005. // var top = size.y/2-230;
  1006. // var left = size.x/2-260;
  1007. // if (top<0) top = 0;
  1008. return {"x": left, "y": top};
  1009. },
  1010. showEditNode: function(data, callback){
  1011. if (layout.mobile){
  1012. this.showEditNode_mobile(data, callback);
  1013. }else{
  1014. this.showEditNode_pc(data, callback);
  1015. }
  1016. },
  1017. showEditNode_mobile: function(data, callback){
  1018. var p = this.list.app.tabAreaNode.getPosition(this.list.app.content);
  1019. var contentSize = this.list.app.contentNode.getSize();
  1020. var tabSize = this.list.app.tabAreaNode.getSize();
  1021. var y = contentSize.y+tabSize.y;
  1022. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  1023. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  1024. this.list.css.itemNode_edit.width = ""+ contentSize.x+"px";
  1025. this.list.css.itemNode_edit.height = ""+ y+"px";
  1026. document.body.setStyle("-webkit-overflow-scrolling", "auto");
  1027. this.editNode.setStyle("display", "none");
  1028. var morph = new Fx.Morph(this.mainContentNode, {
  1029. "duration": 200,
  1030. "transition": Fx.Transitions.Expo.easeOut,
  1031. "onComplete": function(){
  1032. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  1033. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  1034. this.setEditTaskNodes(data);
  1035. this.closeNode.setStyle("display", "block");
  1036. if (callback) callback();
  1037. }.bind(this)
  1038. });
  1039. morph.start(this.list.css.itemNode_edit);
  1040. },
  1041. showEditNode_pc: function(data, callback){
  1042. var p = this.getEditNodePosition();
  1043. this.list.css.itemNode_edit.top = ""+ p.y+"px";
  1044. this.list.css.itemNode_edit.left = ""+ p.x+"px";
  1045. this.editNode.setStyle("display", "none");
  1046. var morph = new Fx.Morph(this.mainContentNode, {
  1047. "duration": 200,
  1048. "transition": Fx.Transitions.Expo.easeOut,
  1049. "onComplete": function(){
  1050. this.resizeEditNodeFun = this.resizeEditNode.bind(this);
  1051. this.list.app.addEvent("resize", this.resizeEditNodeFun);
  1052. this.setEditTaskNodes(data);
  1053. this.closeNode.setStyle("display", "block");
  1054. if (callback) callback();
  1055. }.bind(this)
  1056. });
  1057. morph.start(this.list.css.itemNode_edit);
  1058. },
  1059. _getJobByTask: function(callback){
  1060. this.list.app.action.getSimpleJobByTask(function(json){
  1061. if (callback) callback(json.data);
  1062. }.bind(this), null, this.data.id);
  1063. },
  1064. setContent: function(){
  1065. this.applicationTitleNode.set("text", this.data.applicationName);
  1066. this.titleNode.set("html", "<font style=\"color: #333;\">["+this.data.processName+"]&nbsp;&nbsp;</font>"+this.data.title);
  1067. this.titleNode.set("title", this.data.title);
  1068. this.activityNode.set("text", "( "+(this.data.activityName || this.list.app.lp.completed)+" )");
  1069. this.timeContentNode.set("text", this.list.app.lp.list_comedate+": "+this.data.startTime);
  1070. this.loadActions();
  1071. this.loadApplicationIcon();
  1072. //this.setTimeIconNode();
  1073. },
  1074. loadActions: function(){
  1075. if (this.data.allowRapid){
  1076. this.editNode = new Element("div", {"styles": this.list.css.titleActionEditNode}).inject(this.actionContentNode);
  1077. this.closeNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.actionContentNode);
  1078. }
  1079. },
  1080. loadApplicationIcon: function(){
  1081. this.getApplicationIcon(function(icon){
  1082. debugger;
  1083. if (icon.icon){
  1084. //this.mainContentNode.setStyle("border-top", "4px solid "+icon.iconHue);
  1085. this.applicationIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon.icon+")");
  1086. }else{
  1087. this.mainContentNode.setStyle("border-top", "4px solid #4e82bd");
  1088. this.applicationIconNode.setStyle("background-image", "url("+"/x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
  1089. }
  1090. }.bind(this));
  1091. },
  1092. getApplicationIcon: function(callback){
  1093. var icon = this.list.app.appIcons[this.data.application];
  1094. if (!icon) {
  1095. this.list.app.action.getApplicationIcon(function (json) {
  1096. if (json.data){
  1097. if (json.data){
  1098. this.list.app.appIcons[this.data.application] = json.data;
  1099. if (callback) callback(json.data);
  1100. }
  1101. }else{
  1102. this.invalidItem = true;
  1103. if (callback) callback({
  1104. "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",
  1105. "iconHue": "#4e82bd"
  1106. });
  1107. }
  1108. }.bind(this), function(){
  1109. this.invalidItem = true;
  1110. if (callback) callback({
  1111. "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",
  1112. "iconHue": "#f44336"
  1113. });
  1114. }.bind(this), this.data.application);
  1115. }else{
  1116. if (callback) callback(icon);
  1117. }
  1118. },
  1119. setNewIcon: function(){
  1120. var start = new Date().parse(this.data.startTime);
  1121. var now = new Date();
  1122. if (now.getTime()-start.getTime()<86400000){
  1123. this.newIconNode.setStyle("background-image", "url("+"/x_component_process_TaskCenter/$Main/default/time/new.png)");
  1124. }
  1125. },
  1126. setTimeIconNode: function(){
  1127. var colors = ["#FF0000", "#00d400", "#f6ff0c"];
  1128. var idx = (Math.random()*3).toInt();
  1129. var color = colors[idx];
  1130. this.timeIconNode.setStyle("background-color", color);
  1131. //timeIconNode
  1132. }
  1133. //load: function(){
  1134. // this.node = this.table.insertRow(this.table.rows.length || 0);
  1135. // this.node.setStyles(this.list.css.itemLine);
  1136. //
  1137. // this.appNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.applicationName}).inject(this.node);
  1138. // this.titleNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.title}).inject(this.node);
  1139. // this.processNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.processName}).inject(this.node);
  1140. // this.activityNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.activityName}).inject(this.node);
  1141. // this.dateNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.updateTime}).inject(this.node);
  1142. //
  1143. //
  1144. // //this.titleNode = this.node.insertCell(this.node.cells.length || 0);
  1145. // //this.titleNode.setStyles(this.list.css.itemCell);
  1146. // //this.titleNode.set("text", this.data.title);
  1147. //}
  1148. });