medical.js 6.1 KB

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