high-incidence-disease.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. (function() {
  2. //<img src="../images/icon.png" class="icon-img">
  3. Vue.component('high-incidence-disease', {
  4. template: '<div style="height: 100%;">\
  5. <h4 class="c-b5e1fc c-f16 c-t-center div-common-title">本月高发疾病排行</h4>\
  6. <div data-toggle="buttons" class="btn-group">\
  7. <label class="btn btn-default" :class="{active: index1 == 0}" @click="btnClick1(0)">\
  8. <input type="radio">全部\
  9. </label>\
  10. <label class="btn btn-default" :class="{active: index1 == 1}" @click="btnClick1(1)">\
  11. <input type="radio">住院\
  12. </label>\
  13. <label class="btn btn-default" :class="{active: index1 == 2}" @click="btnClick1(2)">\
  14. <input type="radio">门诊\
  15. </label>\
  16. </div>\
  17. <div data-toggle="buttons" class="btn-group fr mr20" style="margin-left: 0;">\
  18. <label class="btn btn-default" :class="{active: index2 == 0}" @click="btnClick2(0)">\
  19. <input type="radio">本月\
  20. </label>\
  21. <label class="btn btn-default" :class="{active: index2 == 1}" @click="btnClick2(1)">\
  22. <input type="radio">本季\
  23. </label>\
  24. <label class="btn btn-default" :class="{active: index2 == 2}" @click="btnClick2(2)">\
  25. <input type="radio">本年\
  26. </label>\
  27. </div>\
  28. <div id="div-gaofa-disease-chart" class="ml30"></div>\
  29. </div>',
  30. props: ["data"],
  31. data: function() {
  32. return {
  33. index1:0,
  34. index2:0,
  35. gaoBingFaData:null
  36. }
  37. },
  38. mounted: function() {
  39. var vm = this;
  40. setTimeout(function(){
  41. vm.gaoBingFaData = vm.data["本月高并发疾病"].全部.本月;
  42. vm.initData();
  43. },50)
  44. },
  45. watch:{
  46. data:function(data){
  47. this.data = data;
  48. this.refreshData();
  49. }
  50. },
  51. methods: {
  52. btnClick1:function(idx){
  53. this.index1 = idx;
  54. this.refreshData();
  55. },
  56. btnClick2:function(idx){
  57. this.index2 = idx;
  58. this.refreshData();
  59. },
  60. refreshData:function(){
  61. if(this.index1==0){//全部
  62. if(this.index2==0){//本月
  63. this.gaoBingFaData = this.data["本月高并发疾病"].全部.本月;
  64. }else if(this.index2==1){//本季
  65. this.gaoBingFaData = this.data["本月高并发疾病"].全部.本季;
  66. }else if(this.index2==2){//本年
  67. this.gaoBingFaData = this.data["本月高并发疾病"].全部.本年;
  68. }
  69. }else if(this.index1==1){//住院
  70. if(this.index2==0){//本月
  71. this.gaoBingFaData = this.data["本月高并发疾病"].住院[0].本月;
  72. }else if(this.index2==1){//本季
  73. this.gaoBingFaData = this.data["本月高并发疾病"].住院[1].本季;
  74. }else if(this.index2==2){//本年
  75. this.gaoBingFaData = this.data["本月高并发疾病"].住院[2].本年;
  76. }
  77. }else if(this.index1==2){//门诊
  78. if(this.index2==0){//本月
  79. this.gaoBingFaData = this.data["本月高并发疾病"].门诊[0].本月;
  80. }else if(this.index2==1){//本季
  81. this.gaoBingFaData = this.data["本月高并发疾病"].门诊[1].本季;
  82. }else if(this.index2==2){//本年
  83. this.gaoBingFaData = this.data["本月高并发疾病"].门诊[2].本年;
  84. }
  85. }
  86. this.initData();
  87. },
  88. initData:function(){//高发疾病
  89. var zhuYuanData = [],zhuYuanTitle = "";
  90. var xAxisData = this.gaoBingFaData.xAxis[0].data;
  91. var menZhenData = this.gaoBingFaData.series[0].data;
  92. var menZhenTitle = this.gaoBingFaData.series[0].name;
  93. if(this.index1==0){//全部,显示门诊/住院数据叠加
  94. zhuYuanData = this.gaoBingFaData.series[1].data;
  95. zhuYuanTitle = this.gaoBingFaData.series[1].name;
  96. this.geoFaMainFun(xAxisData,menZhenData,zhuYuanData,menZhenTitle,zhuYuanTitle)
  97. }
  98. else if(this.index1==1 || this.index1==2){//住院或门诊时,显示单个柱状图
  99. this.geoFaMainFun(xAxisData,menZhenData,zhuYuanData,menZhenTitle,zhuYuanTitle)
  100. }
  101. },
  102. geoFaMainFun:function(xAxisData,menZhenData,zhuYuanData,menZhenTitle,zhuYuanTitle){
  103. var gaoFaChart = echarts.init(document.getElementById('div-gaofa-disease-chart'));
  104. var gaofaOption = {
  105. "tooltip": {
  106. "trigger": "axis"
  107. },
  108. grid: {top: 40, bottom: 30, left: 80},
  109. "yAxis": [{
  110. "type": "category",
  111. "name": "人次",
  112. "data": xAxisData,
  113. axisPointer: {
  114. type: 'shadow'
  115. },
  116. axisTick: {
  117. show: false
  118. },
  119. axisLine: {
  120. lineStyle: {
  121. color: '#095f8e'
  122. }
  123. },
  124. axisLabel: {
  125. color: '#b5e1fc'
  126. },
  127. nameTextStyle:{color: '#b5e1fc'}
  128. }],
  129. "xAxis": [{
  130. "type": "value",
  131. axisPointer: {
  132. type: 'shadow'
  133. },
  134. axisTick: {
  135. show: false
  136. },
  137. axisLine: {
  138. lineStyle: {
  139. color: '#095f8e'
  140. }
  141. },
  142. axisLabel: {
  143. color: '#fff'
  144. },
  145. splitLine: {
  146. show: false // 不显示坐标轴刻度
  147. }
  148. }],
  149. "series": [{
  150. "smooth": true,
  151. "name": menZhenTitle,
  152. "type": "bar",
  153. stack: '高发疾病',
  154. barWidth: 20,
  155. "label": {
  156. show: true,
  157. position: "right",
  158. color: '#00e6f3'
  159. },
  160. "itemStyle": {
  161. "normal": {
  162. "lineStyle": {
  163. "shadowColor": "rgba(0,0,0,0.4)"
  164. },
  165. color: '#00e6f3',
  166. barBorderRadius: [0, 8, 8, 0],
  167. }
  168. },
  169. "data": menZhenData
  170. },
  171. ]
  172. }
  173. if(zhuYuanData.length>0){
  174. gaofaOption.series[0].label.show = false;
  175. gaofaOption.series[0].itemStyle.normal.color = "#6576e0";
  176. delete gaofaOption.series[0].itemStyle.normal.barBorderRadius;
  177. gaofaOption.series[1] = {
  178. "smooth": true,
  179. "name": zhuYuanTitle,
  180. "type": "bar",
  181. stack: '高发疾病',
  182. "label": {
  183. show: true,
  184. position: "right",
  185. formatter:function(param){
  186. var dataIndex = param.dataIndex,menZhenVal;
  187. _.map(menZhenData,function(item,idx){
  188. if(idx==dataIndex){
  189. menZhenVal = item
  190. }
  191. })
  192. return menZhenVal+"+"+param.value;
  193. },
  194. },
  195. "itemStyle": {
  196. "normal": {
  197. "lineStyle": {
  198. "shadowColor": "rgba(0,0,0,0.4)"
  199. },
  200. barBorderRadius: [0, 8, 8, 0],
  201. color: '#00e6f3'
  202. }
  203. },
  204. "data": zhuYuanData
  205. }
  206. }else{
  207. gaofaOption.series = gaofaOption.series[0];
  208. }
  209. if(gaoFaChart){
  210. gaoFaChart.clear();
  211. }
  212. gaoFaChart.setOption(gaofaOption);
  213. }
  214. },
  215. })
  216. })()