StatisticsView.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. MWF.xApplication.Report = MWF.xApplication.Report || {};
  2. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  3. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  4. MWF.xDesktop.requireApp("Template", "MSelector", null, false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. MWF.xApplication.Report.StatisticsView = new Class({
  7. Extends: MWF.widget.Common,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default"
  11. },
  12. initialize: function (node, app, actions, options) {
  13. this.setOptions(options);
  14. this.app = app;
  15. this.lp = app.lp;
  16. this.path = "../x_component_Report/$StatisticsView/";
  17. this.loadCss();
  18. this.actions = actions;
  19. this.node = $(node);
  20. },
  21. loadCss: function () {
  22. this.cssPath = this.path + this.options.style + "/css.wcss";
  23. this._loadCss();
  24. },
  25. load: function () {
  26. this.createMiddleContent();
  27. //this.app.addEvent("resize", function(){
  28. // this.resizeContent();
  29. //}.bind(this));
  30. },
  31. reload:function(year){
  32. this.currentYear = year;
  33. this.createMiddleContent();
  34. },
  35. createMiddleContent : function(){
  36. this.node.empty();
  37. this.middleContent = new Element("div.middleContent",{"styles":this.css.middleContent}).inject(this.node);
  38. this.viewNode = new Element("div.viewNode" ).inject(this.node);
  39. this.createNavi();
  40. },
  41. createNavi: function(){
  42. this.naviContent = new Element("div.naviContent",{"styles":this.css.naviContent}).inject(this.middleContent);
  43. this.naviRightContent = new Element("div.naviRightContent",{"styles":this.css.naviRightContent}).inject(this.middleContent);
  44. this.keyWorkNavi = new Element("div.naviNode",{
  45. "styles":this.css.naviNode,
  46. "text" : "按公司工作重点"
  47. }).inject(this.naviContent).addEvent("click", function() {
  48. this.departmentNavi.setStyles( this.css.naviNode );
  49. this.keyWorkNavi.setStyles( this.css.naviNode_current );
  50. this.currentType = "keywork";
  51. }.bind(this));
  52. this.departmentNavi = new Element("div.naviNode",{
  53. "styles":this.css.naviNode,
  54. "text" : "按责任部门"
  55. }).inject(this.naviContent).addEvent("click", function() {
  56. this.departmentNavi.setStyles( this.css.naviNode_current );
  57. this.keyWorkNavi.setStyles( this.css.naviNode );
  58. this.currentType = "department";
  59. }.bind(this));
  60. this.keyWorkNavi.click();
  61. this.loadFilter();
  62. new Element("button.action",{
  63. "styles":this.css.action,
  64. "text" : "统计"
  65. }).inject(this.naviRightContent).addEvent("click", function() {
  66. var filterData = {
  67. year : this.yearSelector.getValue(),
  68. month : this.monthSelector.getValue()
  69. };
  70. if( this.currentType == "department" ){
  71. this.actions.statByUnit( year, function(){} );
  72. }else{
  73. this.actions.statByKeyWork( year, function(){} );
  74. }
  75. }.bind(this));
  76. },
  77. loadFilter: function(options, callback){
  78. this.yearSelectorArea = new Element("div",{ styles : this.css.yearSelectorArea }).inject(this.naviRightContent);
  79. this.yearSelector = new MWF.xApplication.Report.StatisticsView.YearSelect(this.yearSelectorArea ,{}, this.app );
  80. this.yearSelector.load();
  81. this.monthSelectorArea = new Element("div",{ styles : this.css.yearSelectorArea }).inject(this.naviRightContent);
  82. this.monthSelector = new MWF.xApplication.Report.StatisticsView.MonthSelect(this.monthSelectorArea ,{}, this.app );
  83. this.monthSelector.load();
  84. },
  85. destroy : function(){
  86. this.node.empty();
  87. }
  88. });
  89. MWF.xApplication.Report.StatisticsView.YearSelect = new Class({
  90. Extends: MSelector,
  91. options : {
  92. "style": "default",
  93. "width": "100px",
  94. "height": "30px",
  95. "textField" : "text",
  96. "valueField" : "value",
  97. "emptyOptionEnable" : false,
  98. "value" : (new Date()).getFullYear().toString()
  99. },
  100. _selectItem : function( itemNode, itemData ){
  101. },
  102. _loadData : function( callback ){
  103. var arr = [];
  104. var data = new Date();
  105. data.decrement("year",5);
  106. for( var i=0; i<11; i++ ){
  107. data.increment("year",1);
  108. arr.push({
  109. text : data.getFullYear()+ "年",
  110. value : data.getFullYear().toString()
  111. })
  112. }
  113. if(callback)callback( arr );
  114. }
  115. });
  116. MWF.xApplication.Report.StatisticsView.MonthSelect = new Class({
  117. Extends: MSelector,
  118. options : {
  119. "style": "default",
  120. "width": "100px",
  121. "height": "30px",
  122. "textField" : "text",
  123. "valueField" : "value",
  124. "emptyOptionEnable" : false,
  125. "value" : (new Date().get("month")+1).toString()
  126. },
  127. _selectItem : function( itemNode, itemData ){
  128. },
  129. _loadData : function( callback ){
  130. var arr = [];
  131. [1,2,3,4,5,6,7,8,9,10,11,12].each( function( i ){
  132. arr.push({
  133. text : i + "月",
  134. value : i.toString()
  135. })
  136. });
  137. if(callback)callback( arr );
  138. }
  139. });