MonthView.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. MWF.xApplication.Report.MonthView = new Class({
  2. Extends: MWF.widget.Common,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "date" : ""
  7. },
  8. initialize: function(node, app, options){
  9. this.setOptions(options);
  10. this.path = "../x_component_Report/$MonthView/";
  11. this.cssPath = "../x_component_Report/$MonthView/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.app = app;
  14. this.container = $(node);
  15. this.load();
  16. },
  17. load: function(){
  18. this.node = new Element("div.node", {"styles": this.css.node}).inject(this.container);
  19. //this.loadSideBar();
  20. this.resetNodeSize();
  21. this.app.addEvent("resize", this.resetNodeSize.bind(this));
  22. this.loadCalendar();
  23. },
  24. resetNodeSize: function(){
  25. var size = this.container.getSize();
  26. var y = size.y-60;
  27. if( this.app.inContainer ){
  28. this.node.setStyle("height", "100%");
  29. }else{
  30. this.node.setStyle("height", ""+y+"px");
  31. }
  32. this.node.setStyle("margin-top", "60px");
  33. var sideBarSize = this.app.sideBar ? this.app.sideBar.getSize() : { x : 0, y:0 };
  34. this.node.setStyle("width", ""+(size.x - sideBarSize.x)+"px");
  35. this.node.setStyle("margin-right", ""+sideBarSize.x+"px");
  36. },
  37. loadCalendar: function(){
  38. var date = "";
  39. if( this.options.date ){
  40. date = Date.parse( this.options.date )
  41. }
  42. this.calendar = new MWF.xApplication.Report.MonthView.Calendar(this, date );
  43. },
  44. hide: function(){
  45. var fx = new Fx.Morph(this.node, {
  46. "duration": "300",
  47. "transition": Fx.Transitions.Expo.easeOut
  48. });
  49. fx.start({
  50. "opacity": 0
  51. }).chain(function(){
  52. this.node.setStyle("display", "none");
  53. }.bind(this));
  54. },
  55. show: function(){
  56. this.node.setStyles(this.css.node);
  57. var fx = new Fx.Morph(this.node, {
  58. "duration": "800",
  59. "transition": Fx.Transitions.Expo.easeOut
  60. });
  61. this.app.fireAppEvent("resize");
  62. fx.start({
  63. "opacity": 1,
  64. "left": "0px"
  65. }).chain(function(){
  66. this.node.setStyles({
  67. "position": "static",
  68. "width": "auto"
  69. });
  70. }.bind(this));
  71. },
  72. reload: function(){
  73. if (this.calendar) this.calendar.reLoadCalendar();
  74. },
  75. recordStatus : function(){
  76. var date = "";
  77. if (this.calendar) date = this.calendar.date;
  78. return {
  79. date : date.toString()
  80. };
  81. },
  82. destroy: function(){
  83. if (this.calendar){
  84. this.calendar.destroy();
  85. }
  86. this.node.destroy();
  87. //MWF.release( this );
  88. }
  89. });
  90. MWF.xApplication.Report.MonthView.Calendar = new Class({
  91. Implements: [Events],
  92. initialize: function(view, date){
  93. this.view = view;
  94. this.css = this.view.css;
  95. this.container = this.view.node;
  96. this.app = this.view.app;
  97. this.date = date || new Date();
  98. this.today = new Date();
  99. this.days = {};
  100. this.load();
  101. },
  102. load: function(){
  103. this.titleNode = new Element("div", {"styles": this.css.calendarTitleNode}).inject(this.container);
  104. this.scrollNode = new Element("div.scrollNode", {
  105. "styles": this.app.inContainer ? this.css.scrollNode_inContainer : this.css.scrollNode
  106. }).inject(this.container);
  107. this.contentWarpNode = new Element("div", {
  108. "styles": this.css.contentWarpNode
  109. }).inject(this.scrollNode);
  110. this.contentContainerNode = new Element("div",{
  111. "styles" : this.css.contentContainerNode
  112. }).inject(this.contentWarpNode);
  113. this.bodyNode = new Element("div", {
  114. "styles": this.css.contentNode
  115. }).inject(this.contentContainerNode);
  116. //this.bodyNode = new Element("div", {"styles": this.css.calendarBodyNode}).inject(this.container);
  117. this.setTitleNode();
  118. this.setBodyNode();
  119. this.resetBodySize();
  120. this.app.addEvent("resize", this.resetBodySize.bind(this));
  121. },
  122. resetBodySize: function(){
  123. var size = this.container.getSize();
  124. var sizeY = this.app.inContainer ? 1060 : size.y;
  125. var titleSize = this.titleNode.getSize();
  126. var y = sizeY-titleSize.y;
  127. //this.bodyNode.setStyle("height", ""+y+"px");
  128. //var size = this.container.getSize();
  129. if( this.app.inContainer ){
  130. this.contentWarpNode.setStyle("height", ""+y+"px");
  131. }else{
  132. this.scrollNode.setStyle("height", ""+y+"px");
  133. }
  134. //this.scrollNode.setStyle("margin-top", "60px");
  135. if (this.contentWarpNode){
  136. this.contentWarpNode.setStyles({
  137. "width": (size.x - 40) +"px"
  138. });
  139. }
  140. //var tdy = (y-30)/6;
  141. //tdy = tdy-34;
  142. //var tds = this.calendarTable.getElements("td");
  143. //tds.each(function(td){
  144. // var yy = tdy;
  145. // var node = td.getLast("div");
  146. // if (node.childNodes.length>=4){
  147. // if (yy<92) yy = 69;
  148. // }
  149. // node.setStyle("height", ""+yy+"px");
  150. //}.bind(this));
  151. },
  152. setTitleNode: function(){
  153. this.prevMonthNode = new Element("div", {"styles": this.css.calendarPrevMonthNode}).inject(this.titleNode);
  154. var text = this.date.format(this.app.lp.dateFormatMonth);
  155. this.titleTextNode = new Element("div", {"styles": this.css.calendarTitleTextNode, "text": text}).inject(this.titleNode);
  156. this.nextMonthNode = new Element("div", {"styles": this.css.calendarNextMonthNode}).inject(this.titleNode);
  157. this.prevMonthNode.addEvents({
  158. "mouseover": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_over);}.bind(this),
  159. "mouseout": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode);}.bind(this),
  160. "mousedown": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_down);}.bind(this),
  161. "mouseup": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_over);}.bind(this),
  162. "click": function(){this.changeMonthPrev();}.bind(this)
  163. });
  164. this.nextMonthNode.addEvents({
  165. "mouseover": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_over);}.bind(this),
  166. "mouseout": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode);}.bind(this),
  167. "mousedown": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_down);}.bind(this),
  168. "mouseup": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_over);}.bind(this),
  169. "click": function(){this.changeMonthNext();}.bind(this)
  170. });
  171. this.titleTextNode.addEvents({
  172. "mouseover": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_over);}.bind(this),
  173. "mouseout": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode);}.bind(this),
  174. "mousedown": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_down);}.bind(this),
  175. "mouseup": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_over);}.bind(this),
  176. "click": function(){this.changeMonthSelect();}.bind(this)
  177. });
  178. this.filterNode = new Element("div", {
  179. styles : this.css.filterNode
  180. }).inject( this.titleNode );
  181. //this.loadFilter();
  182. this.loadStatusArea()
  183. },
  184. loadStatusArea : function(){
  185. var lp = this.app.lp.config;
  186. var area = new Element("div", {
  187. "styles" : this.css.statusArea
  188. }).inject( this.titleNode );
  189. var html =
  190. "<div class = 'statusStyle'>"+
  191. " <div class='statusIconStyle' style='background-color:"+ lp.waitColor +"'></div>" +
  192. " <div class = 'statusTextStyle'>"+lp.wait+"</div></div>" +
  193. "</div>"+
  194. "<div class = 'statusStyle'>"+
  195. " <div class='statusIconStyle' style='background-color:"+ lp.auditColor +"'></div>" +
  196. " <div class = 'statusTextStyle'>"+lp.audit+"</div></div>" +
  197. "</div>"+
  198. "<div class = 'statusStyle'>"+
  199. " <div class='statusIconStyle' style='background-color:"+ lp.progressColor +"'></div>" +
  200. " <div class = 'statusTextStyle'>"+lp.progress+"</div></div>" +
  201. "</div>"+
  202. "<div class = 'statusStyle'>"+
  203. " <div class='statusIconStyle' style='background-color:"+ lp.completedColor +"'></div>" +
  204. " <div class = 'statusTextStyle'>"+lp.completed+"</div></div>" +
  205. "</div>";
  206. area.set("html", html);
  207. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  208. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  209. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  210. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  211. },
  212. loadFilter: function(){
  213. this.filterData = {};
  214. if( this.filter ){
  215. this.filter.destroy();
  216. }
  217. this.filter = new MWF.xApplication.Report.ReportFileter( this.filterNode, this.app, {
  218. items : ["reportType","title","targetList","activityList","currentPersonList","reportStatus","reportObjType"],
  219. defaultResult : {},
  220. onSearch : function( condition ){
  221. this.filterData = condition;
  222. this.reLoadCalendar();
  223. }.bind(this)
  224. });
  225. },
  226. changeMonthPrev: function(){
  227. this.date.decrement("month", 1);
  228. var text = this.date.format(this.app.lp.dateFormatMonth);
  229. this.titleTextNode.set("text", text);
  230. this.reLoadCalendar();
  231. },
  232. changeMonthNext: function(){
  233. this.date.increment("month", 1);
  234. var text = this.date.format(this.app.lp.dateFormatMonth);
  235. this.titleTextNode.set("text", text);
  236. this.reLoadCalendar();
  237. },
  238. changeMonthSelect: function(){
  239. if (!this.monthSelector) this.createMonthSelector();
  240. this.monthSelector.show();
  241. },
  242. createMonthSelector: function(){
  243. this.monthSelector = new MWF.xApplication.Report.MonthView.Calendar.MonthSelector(this.date, this);
  244. },
  245. changeMonthTo: function(d){
  246. this.date = d;
  247. var text = this.date.format(this.app.lp.dateFormatMonth);
  248. this.titleTextNode.set("text", text);
  249. this.reLoadCalendar();
  250. },
  251. setBodyNode: function(){
  252. var html = "<tr><th>"+this.app.lp.weeks.Mon+"</th><th>"+this.app.lp.weeks.Tues+"</th><th>"+this.app.lp.weeks.Wed+"</th>" +
  253. "<th>"+this.app.lp.weeks.Thur+"</th><th>"+this.app.lp.weeks.Fri+"</th><th>"+this.app.lp.weeks.Sat+"</th><th>"+this.app.lp.weeks.Sun+"</th></tr>";
  254. html += "<tr><td valign='top'></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  255. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  256. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  257. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  258. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  259. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  260. this.calendarTable = new Element("table", {
  261. "styles": this.css.calendarTable,
  262. "height": "100%",
  263. "border": "0",
  264. "cellPadding": "0",
  265. "cellSpacing": "0",
  266. "html": html
  267. }).inject(this.bodyNode);
  268. this.calendarTableTitleTr = this.calendarTable.getElement("tr");
  269. this.calendarTableTitleTr.setStyles(this.css.calendarTableTitleTr);
  270. var ths = this.calendarTableTitleTr.getElements("th");
  271. ths.setStyles(this.css.calendarTableTh);
  272. //var tds = this.calendarTable.getElements("td");
  273. //tds.setStyles(this.css.calendarTableCell);
  274. this.loadCalendar();
  275. },
  276. reLoadCalendar: function(){
  277. Object.each(this.days, function(day){
  278. day.destroy();
  279. }.bind(this));
  280. this.loadCalendar();
  281. },
  282. loadCalendar: function(){
  283. var date = this.date.clone();
  284. date.set("date", 1);
  285. var week = date.getDay();
  286. var decrementDay = ((week-1)<0) ? 6 : week-1;
  287. date.decrement("day", decrementDay);
  288. this.loadData( date, function(){
  289. var tds = this.calendarTable.getElements("td");
  290. tds.each(function(td){
  291. this.loadDay(td, date, this.data[date.format("%Y-%m-%d")]);
  292. date.increment();
  293. }.bind(this));
  294. }.bind(this))
  295. },
  296. loadDay: function(td, date, data){
  297. var type = "thisMonth";
  298. var m = date.get("month");
  299. var y = date.get("year");
  300. var d = date.get("date");
  301. var mm = this.date.get("month");
  302. var yy = this.date.get("year");
  303. var mmm = this.today.get("month");
  304. var yyy = this.today.get("year");
  305. var ddd = this.today.get("date");
  306. if ((m==mmm) && (y==yyy) && (d==ddd)){
  307. type = "today";
  308. }else if ((m==mm) && (y==yy)){
  309. type = "thisMonth";
  310. }else{
  311. type = "otherMonth";
  312. }
  313. var key = date.format(this.app.lp.dateFormat);
  314. this.days[key] = new MWF.xApplication.Report.MonthView.Calendar.Day(td, date, this, type, data);
  315. },
  316. loadData : function(date, callback){
  317. var da = date.clone();
  318. this.data = {};
  319. var flag = 0;
  320. for( var i=0; i<3; i++ ){
  321. var m = this.app.common.addZero( (da.get("month")+1).toString(), 2);
  322. var y = da.get("year");
  323. this.app.restActions.listDayByYearMonth(y, m, function(json){
  324. flag++;
  325. json.data.each( function(d){
  326. this.data[d.date] = d.reports;
  327. }.bind(this));
  328. if(callback && flag==3)callback();
  329. }.bind(this), null, false );
  330. da.increment("month", 1);
  331. }
  332. },
  333. reload : function(){
  334. this.view.reload();
  335. },
  336. destroy: function(){
  337. Object.each(this.days, function(day){
  338. day.destroy();
  339. }.bind(this));
  340. this.container.empty();
  341. }
  342. });
  343. MWF.xApplication.Report.MonthView.Calendar.Day = new Class({
  344. Implements: [Events],
  345. initialize: function(td, date, calendar, type, data){
  346. this.container = td;
  347. this.calendar = calendar;
  348. this.view = this.calendar.view;
  349. this.css = this.calendar.css;
  350. this.app = this.calendar.app;
  351. this.date = date.clone();
  352. this.data = data || [];
  353. this.key = this.date.format(this.app.lp.dateFormat);
  354. this.type = type; //today, otherMonth, thisMonth
  355. this.reports = [];
  356. this.load();
  357. },
  358. load: function(){
  359. this.color = "#666";
  360. if( this.type == "thisMonth" ){
  361. }else if( this.type == "otherMonth" ){
  362. this.color = "#ccc";
  363. }
  364. this.day = this.date.getDate();
  365. this.month = this.date.getMonth();
  366. this.year = this.date.getYear();
  367. this.node = new Element("div", {
  368. "styles" : this.css["calendarTableCell_"+this.type]
  369. }).inject( this.container );
  370. this.titleNode = new Element("div", {"styles": this.css["dayTitle_"+this.type]}).inject(this.node);
  371. this.titleDayNode = new Element("div", {"styles": this.css["dayTitleDay_"+this.type], "text": this.day}).inject(this.titleNode);
  372. this.contentNode = new Element("div", {"styles": this.css.dayContentNode}).inject(this.node);
  373. this.loadReports();
  374. },
  375. loadReports: function(){
  376. var y = this.date.getFullYear();
  377. var m = this.date.getMonth()+1;
  378. var d = this.date.getDate();
  379. var reportCount = 0;
  380. this.firstStatus = "";
  381. this.lastStatus = "";
  382. //var filterData = this.calendar.filterData;
  383. //filterData.year = y;
  384. //filterData.month = m;
  385. //filterData.date = this.date.clone().format("%Y-%m-%d");
  386. var lp = this.app.lp.config;
  387. var length = this.data.length;
  388. this.data.each(function(report, i){
  389. reportCount++;
  390. if (reportCount==3){
  391. //this.contentNode.setStyle("height", "100px");
  392. }
  393. if( reportCount == 1 ){
  394. if( report.reportStatus == "审核中" && this.app.userName == report.currentPersonName ){
  395. this.firstStatus = "需要我审核"
  396. }else{
  397. this.firstStatus = report.reportStatus;
  398. }
  399. }
  400. if( reportCount == length ){
  401. if( report.reportStatus == "审核中" && this.app.userName == report.currentPersonName ){
  402. this.lastStatus = "需要我审核"
  403. }else{
  404. this.lastStatus = report.reportStatus;
  405. }
  406. }
  407. //if (reportCount<4)
  408. this.reports.push(new MWF.xApplication.Report.MonthView.Calendar.Day.Report(this, report, reportCount));
  409. }.bind(this));
  410. if (reportCount==0){
  411. var node = new Element("div", {
  412. "styles": {
  413. "line-height": "40px",
  414. "font-size": "14px",
  415. "text-align" : "center",
  416. "color" : this.color,
  417. "padding": "0px 10px"
  418. }
  419. }).inject(this.contentNode);
  420. node.set("text", this.app.lp.noReport);
  421. }else{
  422. this.titleNode.setStyle("cursor","pointer");
  423. this.titleInforNode = new Element("div", {"styles": this.css["dayTitleInfor_"+this.type]}).inject(this.titleNode);
  424. this.titleInforNode.addEvent("click", function(e){
  425. this.app.toDay(this.date);
  426. e.stopPropagation();
  427. }.bind(this));
  428. this.titleInforNode.set("text", ""+reportCount+this.app.lp.countReports+"");
  429. if (reportCount>3){
  430. this.node.addEvents( {
  431. "mouseenter" : function(){
  432. this.expend();
  433. }.bind(this),
  434. "mouseleave" : function(){
  435. this.collapseReady = true;
  436. this.collapse();
  437. }.bind(this)
  438. } )
  439. }else{
  440. this.titleInforNode.setStyle("color", this.type == "otherMonth" ? "#ccc" : "#999");
  441. }
  442. }
  443. if(this.firstStatus){
  444. switch (this.firstStatus){
  445. case "汇报者填写":
  446. this.titleNode.setStyles({ "border-left": "6px solid "+ lp.waitColor });
  447. break;
  448. case "审核中":
  449. this.titleNode.setStyles({ "border-left": "6px solid "+ lp.progressColor });
  450. break;
  451. case "需要我审核":
  452. this.titleNode.setStyles({ "border-left": "6px solid "+ lp.auditColor });
  453. break;
  454. case "已完成":
  455. this.titleNode.setStyles({ "border-left": "6px solid "+ lp.completedColor });
  456. break;
  457. }
  458. }
  459. if( this.lastStatus ){
  460. var heigth=0;
  461. if( reportCount >= 3 ){
  462. heigth = 10;
  463. }else{
  464. heigth = 100 - reportCount*30;
  465. }
  466. var bottomEmptyNode = new Element("div", {
  467. styles : {
  468. "height" : ""+heigth+"px"
  469. }
  470. }).inject( this.node );
  471. switch (this.lastStatus){
  472. case "汇报者填写":
  473. bottomEmptyNode.setStyles({ "border-left": "6px solid " + lp.waitColor });
  474. break;
  475. case "审核中":
  476. bottomEmptyNode.setStyles({ "border-left": "6px solid "+ lp.progressColor });
  477. break;
  478. case "需要我审核":
  479. bottomEmptyNode.setStyles({ "border-left": "6px solid "+ lp.auditColor });
  480. break;
  481. case "已完成":
  482. bottomEmptyNode.setStyles({ "border-left": "6px solid " + lp.completedColor });
  483. break;
  484. }
  485. }
  486. },
  487. expend : function(){
  488. this.oSize = this.node.getSize();
  489. this.container.setStyles({
  490. "position" : "relative"
  491. });
  492. this.tempNode = new Element("div",{
  493. styles : {
  494. width : (this.node.getSize().x ) + "px",
  495. height : "1px",
  496. margin : "7px"
  497. }
  498. }).inject(this.container);
  499. this.node.setStyles({
  500. "height" : this.node.getScrollSize().y + "px",
  501. "width" : (this.node.getSize().x ) + "px",
  502. "position" : "absolute",
  503. "top" : "0px",
  504. "left" : "0px",
  505. "box-shadow": "0 0 8px 0 rgba(0,0,0,0.25)"
  506. });
  507. var nodeCoordinate = this.node.getCoordinates();
  508. var contentNode = this.calendar.contentWarpNode;
  509. var contentCoordinate = contentNode.getCoordinates();
  510. if( nodeCoordinate.bottom > contentCoordinate.bottom ){
  511. this.contentHeight = contentCoordinate.height;
  512. contentNode.setStyle("height", ( nodeCoordinate.bottom - contentCoordinate.top )+"px" );
  513. }
  514. this.isCollapse = false;
  515. },
  516. collapse : function(){
  517. if( !this.collapseDisable && this.collapseReady){
  518. this.container.setStyles({
  519. "position" : "static"
  520. });
  521. if( this.tempNode )this.tempNode.destroy();
  522. this.node.setStyles({
  523. "height" : "140px",
  524. "width" : "auto",
  525. "position" : "static",
  526. "box-shadow": "none"
  527. });
  528. if( this.contentHeight ){
  529. var contentNode = this.calendar.contentWarpNode;
  530. contentNode .setStyle("height", ( this.contentHeight )+"px" );
  531. this.contentHeight = null;
  532. }
  533. this.isCollapse = true;
  534. }
  535. },
  536. destroy: function(){
  537. this.reports.each(function(report){
  538. report.destroy();
  539. }.bind(this));
  540. this.reports = [];
  541. this.titleNode.destroy();
  542. this.titleNode = null;
  543. this.titleDayNode = null;
  544. this.titleInforNode = null;
  545. delete this.calendar.days[this.key];
  546. this.container.empty();
  547. MWF.release(this);
  548. },
  549. reload: function(){
  550. this.view.reload();
  551. }
  552. });
  553. MWF.xApplication.Report.MonthView.Calendar.Day.Report = new Class({
  554. initialize: function(day, data, index){
  555. this.day = day;
  556. this.css = this.day.css;
  557. this.view = this.day.view;
  558. this.app = this.day.app;
  559. this.container = this.day.contentNode;
  560. this.data = data;
  561. this.index = index;
  562. this.load();
  563. },
  564. load: function(){
  565. var d = this.data;
  566. this.nodeStyles = (this.day.type == "today") ? this.css.reportNode_today : this.css.reportNode;
  567. this.node = new Element("div", {
  568. "styles": this.nodeStyles
  569. //"title" : d.title
  570. }).inject(this.container);
  571. //this.iconNode = new Element("div", {"styles": this.css.reportIconNode}).inject(this.node);
  572. //this.timeNode = new Element("div", {"styles": this.css.reportTimeNode}).inject(this.node);
  573. this.textNode = new Element("div", {"styles": this.css.reportTextNode}).inject(this.node);
  574. //var timeStr = Date.parse(this.data.dateString).format("%H:%M");
  575. //this.timeNode.set("text", timeStr);
  576. var text = d[ d.reportObjType == "UNIT" ? "targetUnit" : "targetPerson"].split("@")[0] +
  577. "(" + this.app.lp[d.reportObjType] + this.app.lp[d.reportType] +")";
  578. this.textNode.set("text", text);
  579. //this.node.set("title", this.data.subject);
  580. //
  581. //if (this.data.myWaitAccept){
  582. // this.iconNode.setStyle("background", "url(../x_component_Report/$MonthView/"+this.app.options.style+"/icon/invite.png) no-repeat center center");
  583. //}
  584. var lp = this.app.lp.config;
  585. var status;
  586. if( d.reportStatus == "审核中" && this.app.userName == d.currentPersonName ){
  587. status = "需要我审核"
  588. }else{
  589. status = d.reportStatus;
  590. }
  591. switch (status){
  592. case "汇报者填写":
  593. this.node.setStyles({ "border-left": "6px solid "+ lp.waitColor });
  594. break;
  595. case "审核中":
  596. this.node.setStyles({ "border-left": "6px solid "+ lp.progressColor });
  597. break;
  598. case "需要我审核":
  599. this.node.setStyles({ "border-left": "6px solid "+ lp.auditColor });
  600. break;
  601. case "已完成":
  602. this.node.setStyles({ "border-left": "6px solid "+ lp.completedColor });
  603. break;
  604. }
  605. this.node.addEvents({
  606. mouseenter : function(){
  607. this.day.collapseReady = false;
  608. this.node.setStyles( this.css.reportNode_over );
  609. }.bind(this),
  610. mouseleave : function(){
  611. this.node.setStyles( this.nodeStyles );
  612. }.bind(this),
  613. "click": function(){this.openReport();}.bind(this)
  614. });
  615. this.loadTooltip();
  616. },
  617. loadTooltip : function(){
  618. this.tooltip = new MWF.xApplication.Report.ReportTooltip(this.app.content, this.node, this.app, this.data, {
  619. axis : "x",
  620. hiddenDelay : 300,
  621. displayDelay : 300,
  622. onShow : function(){
  623. this.day.collapseDisable = true;
  624. }.bind(this),
  625. onQueryCreate : function(){
  626. this.day.collapseDisable = true;
  627. }.bind(this),
  628. onHide : function(){
  629. this.day.collapseDisable = false;
  630. this.day.collapse();
  631. }.bind(this)
  632. });
  633. },
  634. openReport: function(){
  635. this.app.common.openReport(this.data, this);
  636. },
  637. destroy: function(){
  638. if(this.tooltip)this.tooltip.destroy();
  639. this.node.destroy();
  640. MWF.release(this);
  641. },
  642. reload: function(){
  643. this.view.reload();
  644. }
  645. });
  646. MWF.xApplication.Report.MonthView.Calendar.MonthSelector = new Class({
  647. Implements: [Events],
  648. initialize: function(date, calendar){
  649. this.calendar = calendar;
  650. this.css = this.calendar.css;
  651. this.app = this.calendar.app;
  652. this.date = date;
  653. this.year = this.date.get("year");
  654. this.load();
  655. },
  656. load: function(){
  657. this.monthSelectNode = new Element("div", {"styles": this.css.calendarMonthSelectNode}).inject(this.calendar.container);
  658. this.monthSelectNode.position({
  659. relativeTo: this.calendar.titleTextNode,
  660. position: 'bottomCenter',
  661. edge: 'upperCenter'
  662. });
  663. this.monthSelectNode.addEvent("mousedown", function(e){e.stopPropagation();});
  664. this.monthSelectTitleNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleNode}).inject(this.monthSelectNode);
  665. this.monthSelectPrevYearNode = new Element("div", {"styles": this.css.calendarMonthSelectTitlePrevYearNode}).inject(this.monthSelectTitleNode);
  666. this.monthSelectNextYearNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleNextYearNode}).inject(this.monthSelectTitleNode);
  667. this.monthSelectTextNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleTextNode}).inject(this.monthSelectTitleNode);
  668. this.monthSelectTextNode.set("text", this.year);
  669. var html = "<tr><td></td><td></td><td></td></tr>";
  670. html += "<tr><td></td><td></td><td></td></tr>";
  671. html += "<tr><td></td><td></td><td></td></tr>";
  672. html += "<tr><td></td><td></td><td></td></tr>";
  673. this.monthSelectTable = new Element("table", {
  674. "styles": {"margin-top": "10px"},
  675. "height": "200px",
  676. "width": "90%",
  677. "align": "center",
  678. "border": "0",
  679. "cellPadding": "0",
  680. "cellSpacing": "0", //5
  681. "html": html
  682. }).inject(this.monthSelectNode);
  683. //this.loadMonth();
  684. this.monthSelectBottomNode = new Element("div", {"styles": this.css.calendarMonthSelectBottomNode, "text": this.app.lp.today}).inject(this.monthSelectNode);
  685. this.setEvent();
  686. },
  687. loadMonth: function(){
  688. this.monthSelectTextNode.set("text", this.year);
  689. var d = new Date();
  690. var todayY = d.get("year");
  691. var todayM = d.get("month");
  692. var thisY = this.date.get("year");
  693. var thisM = this.date.get("month");
  694. var _self = this;
  695. var tds = this.monthSelectTable.getElements("td");
  696. tds.each(function(td, idx){
  697. td.empty();
  698. td.removeEvents("mouseover");
  699. td.removeEvents("mouseout");
  700. td.removeEvents("mousedown");
  701. td.removeEvents("mouseup");
  702. td.removeEvents("click");
  703. var m = idx+1;
  704. td.store("month", m);
  705. td.setStyles(this.css.calendarMonthSelectTdNode);
  706. td.setStyle("background-color", "#FFF");
  707. if ((this.year == todayY) && (idx == todayM)){
  708. new Element("div", {
  709. styles : _self.css.calendarMonthSelectTodayNode,
  710. text : ""+m+this.app.lp.month
  711. }).inject( td );
  712. }else if ((this.year == thisY) && (idx == thisM)){
  713. //td.setStyle("background-color", "#EEE");
  714. new Element("div", {
  715. styles : _self.css.calendarMonthSelectCurrentNode,
  716. text : ""+m+this.app.lp.month
  717. }).inject( td );
  718. }else{
  719. td.set("text", ""+m+this.app.lp.month);
  720. }
  721. td.addEvents({
  722. "mouseover": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_over);},
  723. "mouseout": function(){this.setStyles(_self.css.calendarMonthSelectTdNode);},
  724. "mousedown": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_down);},
  725. "mouseup": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_over);},
  726. "click": function(){
  727. _self.selectedMonth(this);
  728. }
  729. });
  730. }.bind(this));
  731. },
  732. setEvent: function(){
  733. this.monthSelectPrevYearNode.addEvent("click", function(){
  734. this.prevYear();
  735. }.bind(this));
  736. this.monthSelectNextYearNode.addEvent("click", function(){
  737. this.nextYear();
  738. }.bind(this));
  739. this.monthSelectBottomNode.addEvents({
  740. "mouuseover" : function(){ this.monthSelectBottomNode.setStyles( this.css.calendarMonthSelectBottomNode_over ); }.bind(this),
  741. "mouuseout" : function(){ this.monthSelectBottomNode.setStyles( this.css.calendarMonthSelectBottomNode ); }.bind(this),
  742. "click" : function(){ this.todayMonth(); }.bind(this)
  743. });
  744. },
  745. prevYear: function(){
  746. this.year--;
  747. if (this.year<1900) this.year=1900;
  748. this.monthSelectTextNode.set("text", this.year);
  749. this.loadMonth();
  750. },
  751. nextYear: function(){
  752. this.year++;
  753. //if (this.year<1900) this.year=1900;
  754. this.monthSelectTextNode.set("text", this.year);
  755. this.loadMonth();
  756. },
  757. todayMonth: function(){
  758. var d = new Date();
  759. this.calendar.changeMonthTo(d);
  760. this.hide();
  761. },
  762. selectedMonth: function(td){
  763. var m = td.retrieve("month");
  764. var d = Date.parse(this.year+"/"+m+"/1");
  765. this.calendar.changeMonthTo(d);
  766. this.hide();
  767. },
  768. show: function(){
  769. this.date = this.calendar.date;
  770. this.year = this.date.get("year");
  771. this.loadMonth();
  772. this.monthSelectNode.setStyle("display", "block");
  773. this.hideFun = this.hide.bind(this);
  774. document.body.addEvent("mousedown", this.hideFun);
  775. },
  776. hide: function(){
  777. this.monthSelectNode.setStyle("display", "none");
  778. document.body.removeEvent("mousedown", this.hideFun);
  779. },
  780. destroy: function(){
  781. //this.titleNode.destroy();
  782. //this.titleNode = null;
  783. //this.titleDayNode = null;
  784. //this.titleInforNode = null;
  785. //
  786. //delete this.calendar.days[this.key];
  787. //
  788. //this.node.empty();
  789. //MWF.release(this);
  790. }
  791. });