prescription-filter.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. (function(){
  2. Vue.component('prescription-filter', {
  3. template: '<div style="height: 400px;overflow: auto;">\
  4. <div class="mt10 ml10 filter-title">统计维度</div>\
  5. <div class="c-row mt10 plr20">\
  6. <div v-for="type in types" class="c-33 mt10" :class="{\'active\': sumType==type.value}" @click="selectType(type.value)"><a>{{type.name}}</a></div>\
  7. </div>\
  8. <div class="mt10 ml10 filter-title">慢病类型</div>\
  9. <div class="c-row mt20 plr20">\
  10. <div v-for="dis in diseases" class="c-33 mt10" :class="{\'active\': disease==dis.code}" @click="selectDisease(dis.code)"><a>{{dis.name}}</a></div>\
  11. </div>\
  12. <div class="mt10 ml10 filter-title">年度维度</div>\
  13. <div class="c-row mt20 plr20">\
  14. <div v-for="year in years" class="c-33 mt10" :class="{\'active\': chooseYear==year}" @click="selectYear(year)"><a>{{year}}</a></div>\
  15. </div>\
  16. <div id="footer">\
  17. <div class="c-row btn-wrap c-border-top fr">\
  18. <div class="div-foot-btn mr20" @click="resetClick">\
  19. <a href="#" class="c-666 f-fs16">重置</a>\
  20. </div>\
  21. <div class="div-foot-btn active" @click="confirmClick">\
  22. <a href="#" class="c-666 f-fs16">确定</a>\
  23. </div>\
  24. </div>\
  25. </div>\
  26. </div>',
  27. props:['sumType', 'disease', 'chooseYear'],
  28. data: function(){
  29. return {
  30. types: [{
  31. value: 1,
  32. name: "订单统计"
  33. },{
  34. value: 2,
  35. name: "费用统计"
  36. },{
  37. value: 3,
  38. name: "配送统计"
  39. },{
  40. value: 4,
  41. name: "年龄统计"
  42. }],
  43. diseases: [{
  44. code: "",
  45. name: "全部"
  46. },{
  47. code: "HP0093",
  48. name: "高血压"
  49. },{
  50. code: "HP0047",
  51. name: "糖尿病"
  52. }],
  53. years: []
  54. }
  55. },
  56. methods: {
  57. selectType: function(val){
  58. this.sumType = val;
  59. },
  60. selectDisease: function(val){
  61. this.disease = val;
  62. },
  63. selectYear: function(val){
  64. this.chooseYear = val;
  65. },
  66. resetClick:function(){
  67. this.sumType = this.types[0].value;
  68. this.disease = this.diseases[0].code;
  69. },
  70. confirmClick:function(){
  71. //触发刷新
  72. var vm = this;
  73. var type = _.findWhere(vm.types, {value: vm.sumType}),
  74. dis = _.findWhere(vm.diseases, {code: vm.disease});
  75. Vuedals.Bus.$emit('close', {
  76. sumType: vm.sumType,
  77. sumTypeName: type.name,
  78. disease: vm.disease,
  79. diseaseName: dis.name,
  80. chooseYear: vm.chooseYear
  81. });
  82. }
  83. },
  84. mounted: function(){
  85. //如果前一个页面返回的选中的年份
  86. if(!this.sumType){
  87. this.sumType = this.types[0].value;
  88. }
  89. if(!this.disease){
  90. this.disease = this.diseases[0].code;
  91. }
  92. var now = new Date(),
  93. year = now.getFullYear();
  94. if(now.getMonth() < 6){
  95. year = year - 1;
  96. }
  97. for(i=year; i>=2017; i--){
  98. this.years.push(i);
  99. }
  100. if(!this.chooseYear){
  101. this.chooseYear = year;
  102. }
  103. }
  104. })
  105. })()