smfw-filter.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. (function(){
  2. Vue.component('smfw-filter',{
  3. template:'<div style="height: 400px;overflow: auto;margin-bottom: 50px;">\
  4. <div class="mt10 ml10 filter-title">统计年份</div>\
  5. <div class="c-row ml40 mr10" id="signYear">\
  6. <div v-for="year in years" class="c-33 mt20" style="margin-left:0;margin-right:3%;" :class="{\'active\': year==selyear}" @click="yearClick(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 class="mt20 ml10 filter-title">统计指标</div>\
  13. <div class="div-content">\
  14. <div class="mt20 div-group-btn c-row ml40 mr10">\
  15. <div class="div-btn c-33" v-for="item in smfuList" :class="{\'active\': smfu==item.code}" @click="selItem(item,\'smfu\')">\
  16. <a href="#" class="f-fs14">{{item.name}}</a>\
  17. </div>\
  18. </div>\
  19. </div>\
  20. <div class="mt20 ml10 filter-title" v-if="smfu == 2">统计维度</div>\
  21. <div class="div-content" v-if="smfu == 2">\
  22. <div class="c-row ml40 mr10">\
  23. <div class="c-33 mt20" style="margin-left:0;margin-right:3%;" :class="{\'active\': rhfs.length==0}" @click="selItems(\'\',\'rhfs\')">\
  24. <a href="#" class="f-fs14">全部</a>\
  25. </div>\
  26. <div class="c-33 mt20" style="margin-left:0;margin-right:3%;" v-for="item in rhfsList" :class="{\'active\': rhfs.indexOf(item.code)>-1}" @click="selItems(item,\'rhfs\')">\
  27. <a href="#" class="f-fs14">{{item.name}}</a>\
  28. </div>\
  29. </div>\
  30. </div>\
  31. <div id="footer">\
  32. <div class="c-row btn-wrap c-border-top fr">\
  33. <div class="div-foot-btn mr20" @click="resetClick">\
  34. <a href="#" class="c-666 f-fs16">重置</a>\
  35. </div>\
  36. <div class="div-foot-btn active" @click="confirmClick">\
  37. <a href="#" class="c-666 f-fs16">保存</a>\
  38. </div>\
  39. </div>\
  40. </div>\
  41. </div>',
  42. props:['chooseYear','minYear',"dimensionValList"],
  43. data: function(){
  44. return {
  45. selyear:"",
  46. years: [],
  47. smfuList:[{code:1,name:'上门服务'},{code:2,name:'入户访视'}], //上门服务
  48. smfu:1,
  49. rhfsList:[{code:"5",name:'孕产妇'},{code:"6",name:'新生儿'},
  50. {code:"9",name:'肺结核'},{code:"8",name:'80岁以上老人'},{code:"7",name:'重性精神疾病'}], //入户访视
  51. rhfs:[],
  52. dimensionVal:"",
  53. }
  54. },
  55. mounted: function(){
  56. var now = new Date(),
  57. year = now.getFullYear();
  58. var minYear = 2016
  59. if(this.minYear){
  60. minYear = this.minYear
  61. }
  62. // if(now.getMonth() < 6){
  63. // year --;
  64. // }
  65. for(i=year; i>=this.minYear; i--){
  66. this.years.push(i);
  67. }
  68. //如果前一个页面返回的选中的年份
  69. if(!this.chooseYear){
  70. this.selyear = this.years[0];
  71. this.dimensionVal=""
  72. }else{
  73. this.selyear = this.chooseYear
  74. this.dimensionVal=""
  75. }
  76. },
  77. methods: {
  78. yearClick:function(val){
  79. this.selyear = val;
  80. this.dimensionVal=""
  81. },
  82. chooseItem:function(item,param){
  83. this[param] = item
  84. this.selyear = ""
  85. },
  86. resetClick:function(){
  87. this.selyear=this.years[0]
  88. this.dimensionVal=""
  89. this.rhfs = []
  90. this.smfu = 1
  91. },
  92. confirmClick:function(){
  93. var vm = this;
  94. //触发刷新
  95. this.$emit('vuedals:close', {
  96. chooseYear: vm.selyear,
  97. rhfs: vm.rhfs.join(","),
  98. smfu: vm.smfu,
  99. dimensionVal:vm.dimensionVal
  100. });
  101. },
  102. selItem:function(item,index){
  103. var vm = this
  104. vm[index] = item.code
  105. },
  106. selItems:function(item,index){
  107. var vm=this
  108. if(item){
  109. var code = item.code
  110. var hasIndex = vm[index].indexOf(code)
  111. if(hasIndex>-1){
  112. vm[index].splice(hasIndex,1)
  113. }else{
  114. vm[index].push(code)
  115. }
  116. }else{
  117. vm[index] = []
  118. }
  119. },
  120. }
  121. });
  122. })()