alert.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. new Vue({
  2. el: '#main',
  3. data: {
  4. alertData1:'',//总人数
  5. alertData2:'',//新增人数
  6. alertData3:'',//门诊人次
  7. alertData4:'',//住院人次
  8. alertChart1:'',//左边第一块表格
  9. alertChart2:'',//右上第一块
  10. alertChart3:'',//右上第二块
  11. alertChart4:'',//右上第三块
  12. alertChart5:'',//右下
  13. bigData:'',//总数据
  14. alertType:0,
  15. alertTime:0,
  16. },
  17. mounted: function() {
  18. this.initData()
  19. },
  20. methods: {
  21. initData:function(){
  22. var vm = this;
  23. vm.bigData = bigData;
  24. vm.alertData1 = vm.bigData['总人数'];
  25. vm.alertData2 = vm.bigData['新增人数'];
  26. vm.alertData3 = vm.bigData['门诊人次'];
  27. vm.alertData4 = vm.bigData['住院人次'];
  28. this.setAlertChart1(0);
  29. this.setAlertChart2(0);
  30. this.setAlertChart3(0);
  31. this.setAlertChart4(0);
  32. this.setAlertChart5(0,0);
  33. console.log(vm.bigData)
  34. },
  35. setAlertChart1:function(type){
  36. var t = '';
  37. switch(type){
  38. case 0:t = '全部';break;
  39. case 1:t = '门诊';break;
  40. case 2:t = '住院';break;
  41. }
  42. var options = bigData[t]['区县分布'];
  43. this.alertChart1 = options
  44. },
  45. setAlertChart2:function(type){
  46. var t = '';
  47. switch(type){
  48. case 0:t = '全部';break;
  49. case 1:t = '门诊';break;
  50. case 2:t = '住院';break;
  51. }
  52. var options =bigData[t]['年龄段分布'];
  53. this.alertChart2 = options
  54. },
  55. setAlertChart3:function(type){
  56. var t = '';
  57. switch(type){
  58. case 0:t = '全部';break;
  59. case 1:t = '门诊';break;
  60. case 2:t = '住院';break;
  61. }
  62. var options =bigData[t]['性别分布'];
  63. this.alertChart3 = options
  64. },
  65. setAlertChart4:function(type){
  66. var t = '';
  67. switch(type){
  68. case 0:t = '全部';break;
  69. case 1:t = '门诊';break;
  70. case 2:t = '住院';break;
  71. }
  72. var options =bigData[t]["并发症"];
  73. this.alertChart4 = options
  74. },
  75. setAlertChart5:function(type,time){
  76. var t = '',m='';
  77. switch(type){
  78. case 0:t = '全部';break;
  79. case 1:t = '门诊';break;
  80. case 2:t = '住院';break;
  81. }
  82. switch(time){
  83. case 0:m = '日';break;
  84. case 1:m = '月';break;
  85. case 2:m = '季';break;
  86. case 3:m = '年';break;
  87. }
  88. var options =bigData[t]['新增患者趋势'][m];
  89. this.alertChart5 = options
  90. },
  91. alertTitle:function(type){
  92. this.alertTime = 0;
  93. this.setAlertChart1(type);
  94. this.setAlertChart2(type);
  95. this.setAlertChart3(type);
  96. this.setAlertChart4(type);
  97. this.setAlertChart5(type,0);
  98. this.alertType = type;
  99. },
  100. alertChart:function(time){
  101. var type = this.alertType;
  102. this.alertTime = time;
  103. this.setAlertChart5(type,time);
  104. }
  105. }
  106. });
  107. //数字格式化
  108. function toThousands(str) {
  109. if(!str)return
  110. str =parseInt(str);
  111. if(typeof(str) == 'number')str = str.toString()
  112. var newStr = "";
  113. var count = 0;
  114. if(str.indexOf(".") == -1) {
  115. for(var i = str.length - 1; i >= 0; i--) {
  116. if(count % 3 == 0 && count != 0) {
  117. newStr = str.charAt(i) + "," + newStr;
  118. } else {
  119. newStr = str.charAt(i) + newStr;
  120. }
  121. count++;
  122. }
  123. str = newStr;
  124. } else {
  125. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  126. if(count % 3 == 0 && count != 0) {
  127. newStr = str.charAt(i) + "," + newStr;
  128. } else {
  129. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  130. }
  131. count++;
  132. }
  133. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  134. }
  135. return str;
  136. }