special-filter.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. (function(){
  2. Vue.component('special-filter', {
  3. template: '<div style="height: 400px;overflow: auto;">\
  4. <div class="mt10 ml10 filter-title">统计年份</div>\
  5. <div class="c-row ml40 mr10">\
  6. <div v-for="year in years" class="c-33 mt20" style="margin-left:0;margin-right:3%;" :class="{\'active\': year==selyear}" @click="chooseYear(year)"><a>{{year}}</a></div>\
  7. </div>\
  8. <div class="mt10 ml10 filter-title" v-if="dimensionValList&&dimensionValList.length">统计维度</div>\
  9. <div class="c-row ml40 mr10" v-if="dimensionValList&&dimensionValList.length">\
  10. <div v-for="item in dimensionValList" class="c-33 mt20" style="margin-left:0;margin-right:3%;" :class="{\'active\': item==dimensionVal}" @click="chooseItem(item,\'dimensionVal\')"><a>{{item}}</a></div>\
  11. </div>\
  12. <div id="footer">\
  13. <div class="c-row btn-wrap c-border-top fr">\
  14. <div class="div-foot-btn mr20" @click="resetClick">\
  15. <a href="#" class="c-666 f-fs16">重置</a>\
  16. </div>\
  17. <div class="div-foot-btn active" @click="confirmClick">\
  18. <a href="#" class="c-666 f-fs16">确定</a>\
  19. </div>\
  20. </div>\
  21. </div>\
  22. </div>',
  23. props:['selectedYear',"minYear","dimensionValList"],
  24. data: function(){
  25. return {
  26. selyear:"",
  27. years: [],
  28. dimensionVal:"",
  29. }
  30. },
  31. methods: {
  32. chooseYear:function(year){
  33. this.selyear = year;
  34. this[param] = ""
  35. },
  36. chooseItem:function(item,param){
  37. this[param] = item
  38. this.selyear = ""
  39. },
  40. resetClick:function(){
  41. this.selyear = this.years[0];
  42. this[param] = ""
  43. },
  44. confirmClick:function(){
  45. //触发刷新
  46. var vm = this;
  47. Vuedals.Bus.$emit('close', {
  48. chooseYear: vm.selyear,
  49. dimensionVal:vm.dimensionVal
  50. });
  51. }
  52. },
  53. mounted: function(){
  54. //显示年份最低是2016年
  55. var now = new Date(),
  56. year = now.getFullYear();
  57. var minYear = 2016
  58. if(this.minYear){
  59. minYear = this.minYear
  60. }
  61. // if(now.getMonth() >= 6){
  62. // this.years.push(year);
  63. // }
  64. for(i=year; i>=minYear; i--){
  65. this.years.push(i);
  66. }
  67. //如果前一个页面返回的选中的年份
  68. if(!this.selectedYear){
  69. this.selyear = this.years[0];
  70. }else{
  71. this.selyear = this.selectedYear
  72. }
  73. }
  74. })
  75. })()