high-incidence-disease.js 8.5 KB

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