medical.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. skipShow:0
  44. },
  45. mounted: function() {
  46. this.allData = this.newObj(bigData);
  47. this.initData()
  48. },
  49. methods: {
  50. initData:function(){
  51. this.setLeftChart1();
  52. this.setLeftChart2();
  53. this.setRightChart1();
  54. this.setRightChart2();
  55. this.setTable1();
  56. this.setTable2();
  57. this.setleftData1();
  58. this.setYesterDay();
  59. this.setMapData();
  60. },
  61. setleftData1:function(){
  62. var options = null;
  63. if(this.timeType == 1){
  64. options= this.newObj(this.allData['上月']);
  65. }
  66. else{
  67. options= this.newObj(this.allData['本年'])
  68. }
  69. this.setFormater(options);
  70. this.leftData1 = options;
  71. },
  72. setYesterDay:function(){
  73. var options = null;
  74. options= this.newObj(this.allData['昨日数据'])
  75. this.setFormater(options);
  76. this.yesterdayData = options;
  77. },
  78. setLeftChart1:function(){
  79. var options =this.allData['门诊人次月趋势'];
  80. this.leftChart1 = options
  81. },
  82. setLeftChart2:function(){
  83. var options =this.allData['住院人次月趋势'];
  84. this.leftChart2 = options
  85. },
  86. setMapData:function(){
  87. var options =this.allData['各区县服务患者数'];
  88. this.mapData ={data:options} ;
  89. },
  90. setRightChart1:function(){
  91. var options =this.allData['门诊分类别月趋势'];
  92. this.rightChart1= options
  93. },
  94. setRightChart2:function(){
  95. var options =this.allData['住院平均日数月趋势'];
  96. this.rightChart2= options
  97. },
  98. setTable1:function(){
  99. var options =this.allData['门急诊服务情况'];
  100. this.tableData1= options
  101. },
  102. setTable2:function(){
  103. var options =this.allData['住院服务情况'];
  104. this.tableData2= options
  105. },
  106. setCity(item){
  107. this.city = item.townName;
  108. var that =this;
  109. this.town.map(function(v,i){
  110. if(v.townName == item.townName) {
  111. that.$refs.map.selectLineHeight(i) //高亮地图
  112. switch(i){
  113. case 0:that.allData = that.newObj(bigData);
  114. case 1:that.allData = that.newObj(bigData2);
  115. }
  116. }
  117. })
  118. console.log(that.allData);
  119. console.log(bigData);
  120. console.log(that.newObj(bigData));
  121. console.log(bigData2);
  122. console.log(that.newObj(bigData2));
  123. this.initData()
  124. },
  125. setTimeStr(v){
  126. this.timeType = v;
  127. this.setleftData1()
  128. },
  129. setFormater:function(obj){
  130. for(var c in obj){
  131. obj[c] =toThousands(obj[c])
  132. }
  133. },
  134. newObj:function(obj){
  135. return JSON.parse(JSON.stringify(obj))
  136. },
  137. clickMap:function(res){
  138. this.city = res.name;
  139. },
  140. skipClick:function(){
  141. console.log(222)
  142. this.skipShow == 0 ? this.skipShow = 1 : this.skipShow = 0
  143. }
  144. }
  145. });
  146. //数字格式化
  147. function toThousands(str) {
  148. if(!str)return
  149. str =parseInt(str);
  150. if(typeof(str) == 'number')str = str.toString()
  151. var newStr = "";
  152. var count = 0;
  153. if(str.indexOf(".") == -1) {
  154. for(var i = str.length - 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;
  163. } else {
  164. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  165. if(count % 3 == 0 && count != 0) {
  166. newStr = str.charAt(i) + "," + newStr;
  167. } else {
  168. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  169. }
  170. count++;
  171. }
  172. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  173. }
  174. return str;
  175. }