medical.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. new Vue({
  2. el: '#app',
  3. data: {
  4. city:'贵港市',
  5. town: [
  6. {
  7. "townName": "贵港市",
  8. "result": "0"
  9. },
  10. {
  11. "townName": "港北区",
  12. "result": "26531"
  13. },
  14. {
  15. "townName": "港南区",
  16. "result": "25634"
  17. },
  18. {
  19. "townName": "桂平市",
  20. "result": "113485"
  21. },
  22. {
  23. "townName": "平南县",
  24. "result": "74128"
  25. },
  26. {
  27. "townName": "覃塘区",
  28. "result": "12587"
  29. },
  30. ],
  31. timeType:'1',//时间过滤条件 1是上月 2是半年
  32. leftData1:{}, //左边数据块1
  33. leftData2:{}, //左边数据块2
  34. yesterdayData:{},
  35. leftChart1:null, //左边的图表1
  36. leftChart2:null, //左边的图表2
  37. rightChart1:null, //右边边的图表1
  38. rightChart2:null, //右边的图表2
  39. tableData1:null, //表格数据1
  40. tableData2:null, //表格数据2
  41. mapData:null,
  42. allData:null //所有的数据 用来切换区县
  43. },
  44. mounted: function() {
  45. this.initData()
  46. },
  47. methods: {
  48. initData:function(){
  49. this.allData = this.newObj(bigData);
  50. this.setLeftChart1();
  51. this.setLeftChart2();
  52. this.setRightChart1();
  53. this.setRightChart2();
  54. this.setTable1();
  55. this.setTable2();
  56. this.setleftData1();
  57. this.setYesterDay();
  58. this.setMapData();
  59. },
  60. setleftData1:function(){
  61. var options = null;
  62. if(this.timeType == 1){
  63. options= this.newObj(this.allData['上月']);
  64. }
  65. else{
  66. options= this.newObj(this.allData['本年'])
  67. }
  68. this.setFormater(options);
  69. this.leftData1 = options;
  70. },
  71. setYesterDay:function(){
  72. var options = null;
  73. options= this.newObj(this.allData['昨日数据'])
  74. this.setFormater(options);
  75. this.yesterdayData = options;
  76. },
  77. setLeftChart1:function(){
  78. var options =this.allData['门诊人次月趋势'];
  79. this.leftChart1 = options
  80. },
  81. setLeftChart2:function(){
  82. var options =this.allData['住院人次月趋势'];
  83. this.leftChart2 = options
  84. },
  85. setMapData:function(){
  86. var options =this.allData['各区县服务患者数'];
  87. this.mapData ={data:options} ;
  88. },
  89. setRightChart1:function(){
  90. var options =this.allData['门诊分类别月趋势'];
  91. this.rightChart1= options
  92. },
  93. setRightChart2:function(){
  94. var options =this.allData['住院平均日数月趋势'];
  95. this.rightChart2= options
  96. },
  97. setTable1:function(){
  98. var options =this.allData['门急诊服务情况'];
  99. this.tableData1= options
  100. },
  101. setTable2:function(){
  102. var options =this.allData['住院服务情况'];
  103. this.tableData2= options
  104. },
  105. setCity(item){
  106. this.city = item.townName;
  107. var that =this;
  108. this.town.map(function(v,i){
  109. if(v.townName == item.townName) {
  110. that.$refs.map.selectLineHeight(i) //高亮地图
  111. }
  112. })
  113. },
  114. setTimeStr(v){
  115. this.timeType = v;
  116. this.setleftData1()
  117. },
  118. setFormater:function(obj){
  119. for(var c in obj){
  120. obj[c] =toThousands(obj[c])
  121. }
  122. },
  123. newObj:function(obj){
  124. return JSON.parse(JSON.stringify(obj))
  125. },
  126. clickMap:function(res){
  127. this.city = res.name;
  128. }
  129. }
  130. });
  131. //数字格式化
  132. function toThousands(str) {
  133. if(!str)return
  134. str =parseInt(str);
  135. if(typeof(str) == 'number')str = str.toString()
  136. var newStr = "";
  137. var count = 0;
  138. if(str.indexOf(".") == -1) {
  139. for(var i = str.length - 1; i >= 0; i--) {
  140. if(count % 3 == 0 && count != 0) {
  141. newStr = str.charAt(i) + "," + newStr;
  142. } else {
  143. newStr = str.charAt(i) + newStr;
  144. }
  145. count++;
  146. }
  147. str = newStr;
  148. } else {
  149. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  150. if(count % 3 == 0 && count != 0) {
  151. newStr = str.charAt(i) + "," + newStr;
  152. } else {
  153. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  154. }
  155. count++;
  156. }
  157. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  158. }
  159. return str;
  160. }