alert.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 = ["#6576e0","#03fa6c","#ff616f","#0fa5f2","#00e6f3"];
  65. options.legend.formatter = function(name) {
  66. var index = 0;
  67. var clientlabels = options.legend.data;
  68. var clientcounts = _.map(options.series[0].data,function(item,idx){
  69. return item.value;
  70. });
  71. clientlabels.forEach(function(value,i){
  72. if(value == name){
  73. index = i;
  74. }
  75. });
  76. return name + " " + clientcounts[index];
  77. }
  78. options.legend.left = '48%';
  79. options.legend.top = 0.044 * window.screen.width;//85;
  80. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  81. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  82. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  83. options.series[0].center = ['25%','55%'];
  84. this.alertChart2 = options
  85. },
  86. setAlertChart3:function(type){
  87. var t = '';
  88. switch(type){
  89. case 0:t = '全部';break;
  90. case 1:t = '门诊';break;
  91. case 2:t = '住院';break;
  92. }
  93. var options = this.bigData[t]['性别分布'];
  94. options.color = ["#00E7F3","#ff616f"];
  95. options.legend.formatter = function(name) {
  96. var index = 0;
  97. var clientlabels = options.legend.data;
  98. var clientcounts = _.map(options.series[0].data,function(item,idx){
  99. return item.value;
  100. });
  101. clientlabels.forEach(function(value,i){
  102. if(value == name){
  103. index = i;
  104. }
  105. });
  106. return name + " " + clientcounts[index];
  107. }
  108. options.legend.left = '48%';
  109. options.legend.top = 0.0625 * window.screen.width;//120
  110. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  111. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  112. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  113. options.series[0].center = ['25%','55%'];
  114. this.alertChart3 = options
  115. },
  116. setAlertChart4:function(type){
  117. var t = '';
  118. switch(type){
  119. case 0:t = '全部';break;
  120. case 1:t = '门诊';break;
  121. case 2:t = '住院';break;
  122. }
  123. var options = this.bigData[t]["并发症"];
  124. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'};
  125. options.series[0].itemStyle.normal.color = '#FFF71A';
  126. this.alertChart4 = options
  127. },
  128. setAlertChart5:function(type,time){
  129. var t = '',m='';
  130. switch(type){
  131. case 0:t = '全部';break;
  132. case 1:t = '门诊';break;
  133. case 2:t = '住院';break;
  134. }
  135. switch(time){
  136. case 0:m = '日';break;
  137. case 1:m = '月';break;
  138. case 2:m = '季';break;
  139. case 3:m = '年';break;
  140. }
  141. var options = this.bigData[t]['新增患者趋势'][m];
  142. options.tooltip = {
  143. trigger: 'axis',
  144. axisPointer: {
  145. type : 'shadow'
  146. },
  147. formatter: '{b} <br /> {a0}: {c0}<br />{a1}: {c1}' + "%"
  148. }
  149. options.series[0].itemStyle.color = '#FF606E';
  150. this.alertChart5 = options
  151. },
  152. alertTitle:function(type){
  153. this.alertTime = 0;
  154. this.setAlertChart1(type);
  155. this.setAlertChart2(type);
  156. this.setAlertChart3(type);
  157. this.setAlertChart4(type);
  158. this.setAlertChart5(type,0);
  159. this.alertType = type;
  160. },
  161. alertChart:function(time){
  162. var type = this.alertType;
  163. this.alertTime = time;
  164. this.setAlertChart5(type,time);
  165. },
  166. closeAlertClick:function(){
  167. parent.layer.closeAll();
  168. },
  169. GetQueryString :function (name){
  170. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  171. var r = window.location.search.substr(1).match(reg);
  172. if(r!=null)return unescape(r[2]); return null;
  173. }
  174. }
  175. });
  176. //数字格式化
  177. function toThousands(str) {
  178. if(!str)return
  179. str =parseInt(str);
  180. if(typeof(str) == 'number')str = str.toString()
  181. var newStr = "";
  182. var count = 0;
  183. if(str.indexOf(".") == -1) {
  184. for(var i = str.length - 1; i >= 0; i--) {
  185. if(count % 3 == 0 && count != 0) {
  186. newStr = str.charAt(i) + "," + newStr;
  187. } else {
  188. newStr = str.charAt(i) + newStr;
  189. }
  190. count++;
  191. }
  192. str = newStr;
  193. } else {
  194. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  195. if(count % 3 == 0 && count != 0) {
  196. newStr = str.charAt(i) + "," + newStr;
  197. } else {
  198. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  199. }
  200. count++;
  201. }
  202. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  203. }
  204. return str;
  205. }