prescription-filter.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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" style="margin-left:0;margin-right:3%;" :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 mt10 plr20">\
  10. <div v-for="dis in diseases" class="c-33 mt10" style="margin-left:0;margin-right:3%;" :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 mt10 plr20">\
  14. <div v-for="year in years" class="c-33 mt10" style="margin-left:0;margin-right:3%;" :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. code: "other",
  54. name: "其他"
  55. }],
  56. years: []
  57. }
  58. },
  59. methods: {
  60. selectType: function(val){
  61. this.sumType = val;
  62. },
  63. selectDisease: function(val){
  64. this.disease = val;
  65. },
  66. selectYear: function(val){
  67. this.chooseYear = val;
  68. },
  69. resetClick:function(){
  70. this.sumType = this.types[0].value;
  71. this.disease = this.diseases[0].code;
  72. },
  73. confirmClick:function(){
  74. //触发刷新
  75. var vm = this;
  76. var type = _.findWhere(vm.types, {value: vm.sumType}),
  77. dis = _.findWhere(vm.diseases, {code: vm.disease});
  78. Vuedals.Bus.$emit('close', {
  79. sumType: vm.sumType,
  80. sumTypeName: type.name,
  81. disease: vm.disease,
  82. diseaseName: dis.name,
  83. chooseYear: vm.chooseYear
  84. });
  85. }
  86. },
  87. mounted: function(){
  88. //如果前一个页面返回的选中的年份
  89. if(!this.sumType){
  90. this.sumType = this.types[0].value;
  91. }
  92. if(!this.disease){
  93. this.disease = this.diseases[0].code;
  94. }
  95. var now = new Date(),
  96. year = now.getFullYear();
  97. // if(now.getMonth() < 6){
  98. // year = year - 1;
  99. // }
  100. for(i=year; i>=2017; i--){
  101. this.years.push(i);
  102. }
  103. if(!this.chooseYear){
  104. this.chooseYear = year;
  105. }
  106. }
  107. })
  108. })()