high-incidence-disease.js 7.9 KB

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