medical.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. new Vue({
  2. el: '#app',
  3. data: {
  4. city:'贵港市',
  5. town: [
  6. {
  7. "townName": "港北区",
  8. "result": "26531"
  9. },
  10. {
  11. "townName": "港南区",
  12. "result": "25634"
  13. },
  14. {
  15. "townName": "覃塘区",
  16. "result": "12587"
  17. },
  18. {
  19. "townName": "平南县",
  20. "result": "74128"
  21. },
  22. {
  23. "townName": "桂平市",
  24. "result": "113485"
  25. }
  26. ],
  27. leftData1:{}, //左边数据块1
  28. leftData2:{}, //左边数据块2
  29. leftChart1:null, //左边的图表1
  30. leftChart2:null, //左边的图表2
  31. leftChart3:null, //左边的图表3
  32. timeType:'1'//时间过滤条件 1是上月 2是半年
  33. },
  34. mounted: function() {
  35. this.initData()
  36. },
  37. methods: {
  38. initData:function(){
  39. this.setLeftChart1();
  40. this.setLeftChart2();
  41. this.setleftData1();
  42. window.leftData1 = this.leftData1
  43. },
  44. setleftData1:function(){
  45. var options = null;
  46. if(this.timeType == 1){
  47. options= this.newObj(bigData['上月']);
  48. }
  49. else{
  50. options= this.newObj(bigData['本年'])
  51. }
  52. this.setFormater(options);
  53. this.leftData1 = options;
  54. },
  55. setLeftChart1:function(){
  56. var options =bigData['门诊人次月趋势'];
  57. this.leftChart1 = options
  58. },
  59. setLeftChart2:function(){
  60. var options =bigData['住院人次月趋势'];
  61. this.leftChart2 = options
  62. },
  63. setLeftChart3:function(){
  64. var options =bigData['门诊分类别月趋势'];
  65. this.leftChart3= options
  66. },
  67. setCity(item){
  68. this.city = item.townName
  69. },
  70. setTimeStr(v){
  71. this.timeType = v;
  72. this.setleftData1()
  73. },
  74. setFormater:function(obj){
  75. for(var c in obj){
  76. obj[c] =toThousands(obj[c])
  77. }
  78. },
  79. newObj:function(obj){
  80. return JSON.parse(JSON.stringify(obj))
  81. }
  82. }
  83. });
  84. //数字格式化
  85. function toThousands(str) {
  86. if(!str)return
  87. str =parseInt(str);
  88. if(typeof(str) == 'number')str = str.toString()
  89. var newStr = "";
  90. var count = 0;
  91. if(str.indexOf(".") == -1) {
  92. for(var i = str.length - 1; i >= 0; i--) {
  93. if(count % 3 == 0 && count != 0) {
  94. newStr = str.charAt(i) + "," + newStr;
  95. } else {
  96. newStr = str.charAt(i) + newStr;
  97. }
  98. count++;
  99. }
  100. str = newStr;
  101. } else {
  102. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  103. if(count % 3 == 0 && count != 0) {
  104. newStr = str.charAt(i) + "," + newStr;
  105. } else {
  106. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  107. }
  108. count++;
  109. }
  110. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  111. }
  112. return str;
  113. }