key-service-population.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. (function() {
  2. Vue.component('key-service-population', {
  3. template: '<div style="height: 100%;">\
  4. <h4 class="c-b5e1fc c-f16 c-t-center div-common-title">重点服务人群增加趋势</h4>\
  5. <div data-toggle="buttons" class="btn-group fr mr40 mt0" style="position: absolute;right: 0.208rem;top: 0.05rem;z-index: 99999;">\
  6. <label class="btn btn-default" :class="{active: activeIndex == 0}" @click="btnClick(0)">\
  7. <input type="radio">月\
  8. </label>\
  9. <label class="btn btn-default" :class="{active: activeIndex == 1}" @click="btnClick(1)">\
  10. <input type="radio">季\
  11. </label>\
  12. <label class="btn btn-default" :class="{active: activeIndex == 2}" @click="btnClick(2)">\
  13. <input type="radio">年\
  14. </label>\
  15. </div>\
  16. <div v-show="!hasData" class="no-result-panel">\
  17. <div class="no-result-img">\
  18. <img src="../images/noData.png">\
  19. </div>\
  20. <div class="no-result-text">暂无数据!</div>\
  21. </div>\
  22. <div id="div-zhongidan-echart" class="ml30" v-show="hasData"></div>\
  23. </div>',
  24. props: ["data"],
  25. data: function() {
  26. return {
  27. keyServiceData:null,
  28. activeIndex:0,
  29. fontSize: 0,
  30. hasData:true,
  31. monthData:null,
  32. jiData:null,
  33. yearData:null,
  34. }
  35. },
  36. mounted: function() {
  37. var width = window.screen.width>=1920?window.screen.width:1920;
  38. this.fontSize = 0.007 * width;
  39. },
  40. watch:{
  41. data:function(newData){
  42. this.data = newData;
  43. if(this.data && JSON.parse(this.data[0].obj.viewInfos[0].options[0].option).series[0].data){
  44. this.monthData = this.data[0].successFlg?this.data[0].obj.viewInfos&&JSON.parse(this.data[0].obj.viewInfos[0].options[0].option):{};
  45. this.jiData = this.data[1].successFlg?this.data[1].obj.viewInfos&&JSON.parse(this.data[1].obj.viewInfos[0].options[0].option):{};
  46. this.yearData = this.data[2].successFlg?this.data[2].obj.viewInfos&&JSON.parse(this.data[2].obj.viewInfos[0].options[0].option):{};
  47. this.initData();
  48. this.hasData = true;
  49. }else{
  50. this.hasData = false;
  51. }
  52. }
  53. },
  54. methods: {
  55. initData:function(){//重点人群
  56. this.activeIndex = 0;
  57. this.changeData();
  58. this.chartMainFun();
  59. },
  60. changeData:function(){
  61. if(this.activeIndex==0){//月
  62. this.keyServiceData = this.monthData;
  63. }else if(this.activeIndex==1){//季度
  64. this.keyServiceData = this.jiData;
  65. }else if(this.activeIndex==2){//年
  66. this.keyServiceData = this.yearData;
  67. }
  68. },
  69. btnClick:function(type){
  70. this.activeIndex = type;
  71. this.changeData();
  72. this.chartMainFun();
  73. },
  74. chartMainFun:function(){
  75. var vm = this;
  76. var xAxisData = this.keyServiceData.xAxis[0].data;
  77. var pjcrsData = this.keyServiceData.series[0].data;
  78. var huanbiData = this.keyServiceData.series[1].data;
  79. huanbiData = _.map(huanbiData,function(item,idx){
  80. item = item=="--"?0:item;
  81. return item;
  82. })
  83. var zhongdianChart = echarts.init(document.getElementById('div-zhongidan-echart'));
  84. var zhongdianOption = {
  85. tooltip: {
  86. trigger: 'axis',
  87. axisPointer: {
  88. type : 'shadow'
  89. },
  90. formatter: '{b} <br /> {a0}: {c0}<br />{a1}: {c1}' + "%"
  91. },
  92. grid: {top: 50, bottom: 30, left: 30,right:80},
  93. legend: {
  94. data:['新增人数','环比'],
  95. textStyle: {
  96. color: '#b5e1fc'
  97. }
  98. },
  99. xAxis: [
  100. {
  101. type: 'category',
  102. data: xAxisData,
  103. axisPointer: {
  104. type: 'shadow'
  105. },
  106. axisTick: {
  107. show: false
  108. },
  109. axisLine: {
  110. lineStyle: {
  111. color: '#095f8e'
  112. }
  113. },
  114. axisLabel: {
  115. color: '#b5e1fc',
  116. fontSize:vm.fontSize
  117. }
  118. }
  119. ],
  120. yAxis: [
  121. {
  122. type: 'value',
  123. name: '新增人数',
  124. nameTextStyle: {
  125. color: '#b5e1fc' // 坐标轴名称颜色
  126. },
  127. splitLine: {
  128. show: false
  129. },
  130. axisLine: {
  131. lineStyle: {
  132. color: '#095f8e'
  133. }
  134. },
  135. axisLabel: {
  136. color: '#b5e1fc',
  137. fontSize:vm.fontSize
  138. }
  139. },
  140. {
  141. type: 'value',
  142. name: '环比',
  143. nameTextStyle: {
  144. color: '#b5e1fc' // 坐标轴名称颜色
  145. },
  146. splitLine: {
  147. show: false // 不显示坐标轴刻度
  148. },
  149. axisLine: {
  150. lineStyle: {
  151. color: '#095f8e' // 坐标轴轴线颜色
  152. }
  153. },
  154. axisLabel: {
  155. color: '#b5e1fc' ,// 坐标轴刻度标签文本颜色
  156. fontSize:vm.fontSize
  157. },
  158. show: true
  159. }
  160. ],
  161. series: [
  162. {
  163. name:'新增人数',
  164. type:'bar',
  165. data:pjcrsData,
  166. barWidth: 20,
  167. label: {
  168. normal: {
  169. show: true,
  170. position: 'top', // 在柱状图上方显示
  171. color: '#fff',// 柱状图上方显示的数值颜色
  172. }
  173. },
  174. itemStyle: {
  175. barBorderRadius: [8,8,0,0],
  176. color: '#00e6f3'
  177. }
  178. },
  179. {
  180. name:'环比',
  181. type:'line',
  182. yAxisIndex: 1,
  183. data:huanbiData,
  184. itemStyle: {
  185. color: '#03fa6d'
  186. },
  187. }
  188. ]
  189. };
  190. if(zhongdianChart){
  191. zhongdianChart.clear();
  192. }
  193. zhongdianChart.setOption(zhongdianOption);
  194. },
  195. }
  196. })
  197. })()