alert.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  54. this.alertChart1 = options
  55. },
  56. setAlertChart2:function(type){
  57. var t = '';
  58. switch(type){
  59. case 0:t = '全部';break;
  60. case 1:t = '门诊';break;
  61. case 2:t = '住院';break;
  62. }
  63. var options = this.bigData[t]['年龄段分布'];
  64. options.color = ["#00e6f3","#03fa6c","#ff616f","#0fa5f2","#6576e0"];
  65. this.alertChart2 = options
  66. },
  67. setAlertChart3:function(type){
  68. var t = '';
  69. switch(type){
  70. case 0:t = '全部';break;
  71. case 1:t = '门诊';break;
  72. case 2:t = '住院';break;
  73. }
  74. var options = this.bigData[t]['性别分布'];
  75. options.color = ["#0fa5f2","#ff616f"];
  76. this.alertChart3 = options
  77. },
  78. setAlertChart4:function(type){
  79. var t = '';
  80. switch(type){
  81. case 0:t = '全部';break;
  82. case 1:t = '门诊';break;
  83. case 2:t = '住院';break;
  84. }
  85. var options = this.bigData[t]["并发症"];
  86. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  87. this.alertChart4 = options
  88. },
  89. setAlertChart5:function(type,time){
  90. var t = '',m='';
  91. switch(type){
  92. case 0:t = '全部';break;
  93. case 1:t = '门诊';break;
  94. case 2:t = '住院';break;
  95. }
  96. switch(time){
  97. case 0:m = '日';break;
  98. case 1:m = '月';break;
  99. case 2:m = '季';break;
  100. case 3:m = '年';break;
  101. }
  102. var options = this.bigData[t]['新增患者趋势'][m];
  103. this.alertChart5 = options
  104. },
  105. alertTitle:function(type){
  106. this.alertTime = 0;
  107. this.setAlertChart1(type);
  108. this.setAlertChart2(type);
  109. this.setAlertChart3(type);
  110. this.setAlertChart4(type);
  111. this.setAlertChart5(type,0);
  112. this.alertType = type;
  113. },
  114. alertChart:function(time){
  115. var type = this.alertType;
  116. this.alertTime = time;
  117. this.setAlertChart5(type,time);
  118. },
  119. closeAlertClick:function(){
  120. parent.layer.closeAll();
  121. },
  122. GetQueryString :function (name){
  123. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  124. var r = window.location.search.substr(1).match(reg);
  125. if(r!=null)return unescape(r[2]); return null;
  126. }
  127. }
  128. });
  129. //数字格式化
  130. function toThousands(str) {
  131. if(!str)return
  132. str =parseInt(str);
  133. if(typeof(str) == 'number')str = str.toString()
  134. var newStr = "";
  135. var count = 0;
  136. if(str.indexOf(".") == -1) {
  137. for(var i = str.length - 1; i >= 0; i--) {
  138. if(count % 3 == 0 && count != 0) {
  139. newStr = str.charAt(i) + "," + newStr;
  140. } else {
  141. newStr = str.charAt(i) + newStr;
  142. }
  143. count++;
  144. }
  145. str = newStr;
  146. } else {
  147. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  148. if(count % 3 == 0 && count != 0) {
  149. newStr = str.charAt(i) + "," + newStr;
  150. } else {
  151. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  152. }
  153. count++;
  154. }
  155. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  156. }
  157. return str;
  158. }