alert.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. type:'',
  17. title:'',
  18. },
  19. mounted: function() {
  20. var vm = this;
  21. this.type = this.GetQueryString("type");
  22. if(this.type == 0){
  23. this.title = '高血压人群分布';
  24. vm.bigData = bigData;
  25. }else if(this.type == 1){
  26. this.title = '糖尿病人群分布';
  27. vm.bigData = bigData2;
  28. }
  29. this.initData();
  30. },
  31. methods: {
  32. initData:function(){
  33. var vm = this;
  34. vm.alertData1 = vm.bigData['总人数'];
  35. vm.alertData2 = vm.bigData['新增人数'];
  36. vm.alertData3 = vm.bigData['门诊人次'];
  37. vm.alertData4 = vm.bigData['住院人次'];
  38. this.setAlertChart1(0);
  39. this.setAlertChart2(0);
  40. this.setAlertChart3(0);
  41. this.setAlertChart4(0);
  42. this.setAlertChart5(0,0);
  43. console.log(vm.bigData)
  44. },
  45. setAlertChart1: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 = this.bigData[t]['区县分布'];
  53. this.alertChart1 = options
  54. },
  55. setAlertChart2: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 = this.bigData[t]['年龄段分布'];
  63. this.alertChart2 = options
  64. },
  65. setAlertChart3: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 = this.bigData[t]['性别分布'];
  73. this.alertChart3 = options
  74. },
  75. setAlertChart4:function(type){
  76. var t = '';
  77. switch(type){
  78. case 0:t = '全部';break;
  79. case 1:t = '门诊';break;
  80. case 2:t = '住院';break;
  81. }
  82. var options = this.bigData[t]["并发症"];
  83. this.alertChart4 = options
  84. },
  85. setAlertChart5:function(type,time){
  86. var t = '',m='';
  87. switch(type){
  88. case 0:t = '全部';break;
  89. case 1:t = '门诊';break;
  90. case 2:t = '住院';break;
  91. }
  92. switch(time){
  93. case 0:m = '日';break;
  94. case 1:m = '月';break;
  95. case 2:m = '季';break;
  96. case 3:m = '年';break;
  97. }
  98. var options = this.bigData[t]['新增患者趋势'][m];
  99. this.alertChart5 = options
  100. },
  101. alertTitle:function(type){
  102. this.alertTime = 0;
  103. this.setAlertChart1(type);
  104. this.setAlertChart2(type);
  105. this.setAlertChart3(type);
  106. this.setAlertChart4(type);
  107. this.setAlertChart5(type,0);
  108. this.alertType = type;
  109. },
  110. alertChart:function(time){
  111. var type = this.alertType;
  112. this.alertTime = time;
  113. this.setAlertChart5(type,time);
  114. },
  115. closeAlertClick:function(){
  116. parent.layer.closeAll();
  117. },
  118. GetQueryString :function (name){
  119. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  120. var r = window.location.search.substr(1).match(reg);
  121. if(r!=null)return unescape(r[2]); return null;
  122. }
  123. }
  124. });
  125. //数字格式化
  126. function toThousands(str) {
  127. if(!str)return
  128. str =parseInt(str);
  129. if(typeof(str) == 'number')str = str.toString()
  130. var newStr = "";
  131. var count = 0;
  132. if(str.indexOf(".") == -1) {
  133. for(var i = str.length - 1; i >= 0; i--) {
  134. if(count % 3 == 0 && count != 0) {
  135. newStr = str.charAt(i) + "," + newStr;
  136. } else {
  137. newStr = str.charAt(i) + newStr;
  138. }
  139. count++;
  140. }
  141. str = newStr;
  142. } else {
  143. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  144. if(count % 3 == 0 && count != 0) {
  145. newStr = str.charAt(i) + "," + newStr;
  146. } else {
  147. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  148. }
  149. count++;
  150. }
  151. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  152. }
  153. return str;
  154. }