high-incidence-disease.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. (function() {
  2. Vue.component('high-incidence-disease', {
  3. template: '<div style="height: 100%;">\
  4. <h4 class="c-b5e1fc c-f16 c-t-center div-common-title">本月高发疾病排行</h4>\
  5. <img src="../images/icon.png" class="icon-img" @click="detailClick">\
  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. <img src="../images/icon.png" class="icon-img">\
  22. <label class="btn btn-default" :class="{active: index2 == 1}" @click="btnClick2(1)">\
  23. <input type="radio">本季\
  24. </label>\
  25. <label class="btn btn-default" :class="{active: index2 == 2}" @click="btnClick2(2)">\
  26. <input type="radio">本年\
  27. </label>\
  28. </div>\
  29. <div v-show="!hasData" class="no-result-panel">\
  30. <div class="no-result-img" style="padding-top:1.09375rem;">\
  31. <img src="../images/noData.png">\
  32. </div>\
  33. <div class="no-result-text">暂无数据!</div>\
  34. </div>\
  35. <div id="div-gaofa-disease-chart" v-show="hasData"></div>\
  36. </div>',
  37. props: ["data","city","cityVal"],
  38. data: function() {
  39. return {
  40. index1:0,
  41. index2:0,
  42. gaoBingFaData:null,
  43. isInit:true,
  44. fontSize: 0,
  45. linkageFilter:"",
  46. hasData:true,
  47. monthData:null,
  48. jiData:null,
  49. yearMonth:null,
  50. }
  51. },
  52. mounted: function() {
  53. var width = window.screen.width>=1920?window.screen.width:1920;
  54. this.fontSize = 0.007 * width;
  55. },
  56. watch:{
  57. data:function(data){
  58. if(data){
  59. this.monthData = data[0];
  60. this.yearData = data[1];
  61. this.jiData = data[2];
  62. this.initData();
  63. }
  64. }
  65. },
  66. methods: {
  67. detailClick:function(){
  68. var vm = this;
  69. var width = (0.7604 * window.screen.width) + 'px';
  70. var height = (0.41875 * window.screen.width) + 'px';
  71. vm.cityVal = vm.cityVal=="0"?"":vm.cityVal;
  72. top.layer.open({
  73. id: 'LAY_layuipro', //设定一个id,防止重复弹出
  74. type: 2,
  75. title: false,
  76. closeBtn: 0,
  77. shade: 0.5,
  78. shadeClose: true,
  79. area: [width, height],
  80. content: httpRequest.alertUrl+'/page/bigData/html/alert6.html?town='+vm.city+"&cityVal="+vm.cityVal
  81. });
  82. },
  83. btnClick1:function(idx){
  84. this.index1 = idx;
  85. this.initData();
  86. },
  87. btnClick2:function(idx){
  88. this.index2 = idx;
  89. this.initData();
  90. },
  91. initData:function(){//高发疾病
  92. if(this.index2==0){//本月
  93. this.gaoBingFaData = this.monthData.successFlg?this.monthData.obj.viewInfos&&JSON.parse(this.monthData.obj.viewInfos[0].options[0].option):{};
  94. }else if(this.index2==1){//本季
  95. this.gaoBingFaData = this.jiData.successFlg?this.jiData.obj.viewInfos&&JSON.parse(this.jiData.obj.viewInfos[0].options[0].option):{};
  96. }else if(this.index2==2){//本年
  97. this.gaoBingFaData = this.yearData.successFlg?this.yearData.obj.viewInfos&&JSON.parse(this.yearData.obj.viewInfos[0].options[0].option):{};
  98. }
  99. if(this.gaoBingFaData&&this.gaoBingFaData.xAxis[0].data){
  100. this.hasData = true;
  101. }else{
  102. this.hasData = false;
  103. return false;
  104. }
  105. var menZhenData = [],menZhenTitle = "";
  106. var xAxisData = (this.gaoBingFaData.xAxis[0].data)||[];
  107. var zhuYuanData = (this.gaoBingFaData.series[1].data)||[];
  108. var zhuYuanTitle = this.gaoBingFaData.series[1].name||"";
  109. if(this.index1==0){//全部(显示门诊/住院数据叠加)
  110. menZhenData = (this.gaoBingFaData.series[0].data);
  111. menZhenTitle = this.gaoBingFaData.series[0].name;
  112. }else if(this.index1==2){//门诊(显示单个柱状图)
  113. zhuYuanData = (this.gaoBingFaData.series[0].data);
  114. zhuYuanTitle = this.gaoBingFaData.series[0].name;
  115. menZhenData = [];
  116. menZhenTitle = "";
  117. }
  118. //数据排序(降序排列)
  119. if(this.index1==0){
  120. var formatData = _.map(zhuYuanData,function(item,idx){
  121. var total = parseInt(item)+parseInt(menZhenData[idx]);
  122. return {total:total,zhuyuanval:parseInt(item),menzhenval:parseInt(menZhenData[idx]),xAxis:xAxisData[idx]}
  123. })
  124. formatData = _.sortBy(formatData,"total").reverse();
  125. xAxisData = [],zhuYuanData=[],menZhenData=[];
  126. _.map(formatData,function(item,idx){
  127. xAxisData.push(item.xAxis);
  128. zhuYuanData.push(item.zhuyuanval);
  129. menZhenData.push(item.menzhenval);
  130. })
  131. }else if(this.index1==1 || this.index1==2){
  132. var formatData = _.map(zhuYuanData,function(item,idx){
  133. return {total:parseInt(item),zhuyuanval:parseInt(item),xAxis:xAxisData[idx]}
  134. })
  135. formatData = _.sortBy(formatData,"total").reverse();
  136. xAxisData = [],zhuYuanData=[];
  137. _.map(formatData,function(item,idx){
  138. xAxisData.push(item.xAxis);
  139. zhuYuanData.push(item.zhuyuanval);
  140. })
  141. }
  142. this.geoFaMainFun(xAxisData,menZhenData,zhuYuanData,menZhenTitle,zhuYuanTitle)
  143. },
  144. geoFaMainFun:function(xAxisData,menZhenData,zhuYuanData,menZhenTitle,zhuYuanTitle){
  145. var vm = this;
  146. var gaoFaChart = echarts.init(document.getElementById('div-gaofa-disease-chart'));
  147. var gaofaOption = {
  148. "tooltip": {
  149. "trigger": "axis"
  150. },
  151. grid: {top: 40, bottom: 30, left: 140,right:80},
  152. "yAxis": [{
  153. "type": "category",
  154. "name": "人次",
  155. "data": xAxisData.reverse(),
  156. axisPointer: {
  157. type: 'shadow'
  158. },
  159. axisTick: {
  160. show: false
  161. },
  162. axisLine: {
  163. lineStyle: {
  164. color: '#095f8e'
  165. }
  166. },
  167. axisLabel: {
  168. color: '#b5e1fc',
  169. fontSize:vm.fontSize,
  170. interval: 0,
  171. formatter: function(value) {
  172. if (value.length > 8) {
  173. return value.substring(0, 8) + "...";
  174. } else {
  175. return value;
  176. }
  177. }
  178. },
  179. nameTextStyle:{color: '#b5e1fc'},
  180. }],
  181. "xAxis": [{
  182. "type": "value",
  183. axisPointer: {
  184. type: 'shadow'
  185. },
  186. axisTick: {
  187. show: false
  188. },
  189. axisLine: {
  190. lineStyle: {
  191. color: '#095f8e'
  192. }
  193. },
  194. axisLabel: {
  195. color: '#fff',
  196. fontSize:vm.fontSize,
  197. interval:0
  198. },
  199. splitLine: {
  200. show: false // 不显示坐标轴刻度
  201. }
  202. }],
  203. "series": [{
  204. "smooth": true,
  205. "name": zhuYuanTitle,
  206. "type": "bar",
  207. stack: '高发疾病',
  208. barWidth: 20,
  209. "label": {
  210. show: true,
  211. position: "right",
  212. color: '#b5e1fc'
  213. },
  214. "itemStyle": {
  215. "normal": {
  216. "lineStyle": {
  217. "shadowColor": "rgba(0,0,0,0.4)"
  218. },
  219. color: '#00e6f3',
  220. barBorderRadius: [0, 8, 8, 0],
  221. }
  222. },
  223. "data": zhuYuanData.reverse()
  224. },
  225. ]
  226. }
  227. if(menZhenData.length>0){
  228. gaofaOption.series[0].label.show = false;
  229. gaofaOption.series[0].itemStyle.normal.color = "#6576e0";
  230. delete gaofaOption.series[0].itemStyle.normal.barBorderRadius;
  231. gaofaOption.series[1] = {
  232. "smooth": true,
  233. "name": menZhenTitle,
  234. "type": "bar",
  235. stack: '高发疾病',
  236. "label": {
  237. show: true,
  238. position: "right",
  239. color: '#b5e1fc',
  240. fontSize:vm.fontSize,
  241. formatter:function(param){
  242. var dataIndex = param.dataIndex,zhuYuanVal;
  243. _.map(zhuYuanData,function(item,idx){
  244. if(idx==dataIndex){
  245. zhuYuanVal = item
  246. }
  247. })
  248. return zhuYuanVal+"+"+param.value;
  249. },
  250. },
  251. "itemStyle": {
  252. "normal": {
  253. "lineStyle": {
  254. "shadowColor": "rgba(0,0,0,0.4)"
  255. },
  256. barBorderRadius: [0, 8, 8, 0],
  257. color: '#00e6f3'
  258. },
  259. },
  260. "data": menZhenData.reverse()
  261. }
  262. }else{
  263. gaofaOption.series = gaofaOption.series[0];
  264. }
  265. if(gaoFaChart){
  266. gaoFaChart.clear();
  267. }
  268. gaoFaChart.setOption(gaofaOption);
  269. }
  270. },
  271. })
  272. })()