alert.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. options.tooltip = {
  104. trigger: 'axis',
  105. axisPointer: {
  106. type : 'shadow'
  107. },
  108. formatter: '{b} <br /> {a0}: {c0}<br />{a1}: {c1}' + "%"
  109. }
  110. this.alertChart5 = options
  111. },
  112. alertTitle:function(type){
  113. this.alertTime = 0;
  114. this.setAlertChart1(type);
  115. this.setAlertChart2(type);
  116. this.setAlertChart3(type);
  117. this.setAlertChart4(type);
  118. this.setAlertChart5(type,0);
  119. this.alertType = type;
  120. },
  121. alertChart:function(time){
  122. var type = this.alertType;
  123. this.alertTime = time;
  124. this.setAlertChart5(type,time);
  125. },
  126. closeAlertClick:function(){
  127. parent.layer.closeAll();
  128. },
  129. GetQueryString :function (name){
  130. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  131. var r = window.location.search.substr(1).match(reg);
  132. if(r!=null)return unescape(r[2]); return null;
  133. }
  134. }
  135. });
  136. //数字格式化
  137. function toThousands(str) {
  138. if(!str)return
  139. str =parseInt(str);
  140. if(typeof(str) == 'number')str = str.toString()
  141. var newStr = "";
  142. var count = 0;
  143. if(str.indexOf(".") == -1) {
  144. for(var i = str.length - 1; i >= 0; i--) {
  145. if(count % 3 == 0 && count != 0) {
  146. newStr = str.charAt(i) + "," + newStr;
  147. } else {
  148. newStr = str.charAt(i) + newStr;
  149. }
  150. count++;
  151. }
  152. str = newStr;
  153. } else {
  154. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  155. if(count % 3 == 0 && count != 0) {
  156. newStr = str.charAt(i) + "," + newStr;
  157. } else {
  158. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  159. }
  160. count++;
  161. }
  162. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  163. }
  164. return str;
  165. }