death-cause.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. (function() {
  2. Vue.component('death-cause', {
  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 v-show="!hasData" class="no-result-panel">\
  7. <div class="no-result-img">\
  8. <img src="../images/noData.png">\
  9. </div>\
  10. <div class="no-result-text">暂无数据!</div>\
  11. </div>\
  12. <div v-show="hasData" style="height: 85%;">\
  13. <div id="div-shiwang-echart" class="ml10"></div>\
  14. <div class="div-siwang-type" v-if="causeData.length>0">\
  15. <div class="div-webkit-box" v-for="(cause, idx) in causeData">\
  16. <div class="c-b5e1fc div-webkit-box-flex1 c-f14">\
  17. <label class="bar-a" v-bind:class="idx | formatData"></label>\
  18. <label class="ml10">{{cause.name}}</label>\
  19. <label class="ml20">{{cause.value}}</label>\
  20. </div>\
  21. </div>\
  22. </div>\
  23. </div>\
  24. </div>',
  25. props: ["data","city","cityVal"],
  26. data: function() {
  27. return {
  28. causeData: [],
  29. hasData:true,
  30. newData:null
  31. }
  32. },
  33. mounted: function() {
  34. },
  35. watch:{
  36. data:function(data){
  37. if(data){
  38. this.newData = data.successFlg?data.obj.viewInfos&&JSON.parse(data.obj.viewInfos[0].options[0].option):{};
  39. if(this.newData.series&&this.newData.series[0].data&&this.newData.series[0].data.length>0){
  40. this.hasData = true;
  41. this.initData();
  42. }else{
  43. this.hasData = false;
  44. }
  45. }else{
  46. this.hasData = false;
  47. }
  48. }
  49. },
  50. filters:{
  51. formatData:function(index){
  52. var colorArr = ["bgc-00e6f3","bgc-03fa6c","bgc-ff616f","bgc-0fa5f2","bgc-6576e0","bgc-da0ff2","bgc-f24a0f","bgc-ebff61","bgc-fea92f"];
  53. return colorArr[index];
  54. }
  55. },
  56. methods: {
  57. detailClick:function(){
  58. var vm = this;
  59. var width = (0.7604 * window.screen.width) + 'px';
  60. var height = (0.41875 * window.screen.width) + 'px';
  61. vm.cityVal = vm.cityVal=="0"?"":vm.cityVal;
  62. top.layer.open({
  63. id: 'LAY_layuipro', //设定一个id,防止重复弹出
  64. type: 2,
  65. title: false,
  66. closeBtn: 0,
  67. shade: 0.5,
  68. shadeClose: true,
  69. area: [width, height],
  70. content: httpRequest.alertUrl+'/page/bigData/html/alert5.html?town='+vm.city+"&cityVal="+vm.cityVal
  71. });
  72. },
  73. initData:function(){//死亡原因
  74. this.causeData = this.newData.series[0].data;
  75. var myChart = echarts.init(document.getElementById('div-shiwang-echart'));
  76. var option = {
  77. // "title": {
  78. // "text": "性别分布",
  79. // "subtext": "性别分布",
  80. // "x": "center"
  81. // },
  82. "tooltip": {
  83. "trigger": "item"
  84. },
  85. color: ["#00e6f3","#03fa6c","#ff616f","#0fa5f2","#6576e0","#da0ff2","#f24a0f","#ebff61","#fea92f"],
  86. "series": [{
  87. "center": [
  88. "50%",
  89. "50%"
  90. ],
  91. radius: ['50%', '70%'],
  92. "name": "",
  93. "type": "pie",
  94. "itemStyle": {
  95. "normal": {
  96. "label": {
  97. "show": false
  98. },
  99. "labelLine": {
  100. "show": false
  101. }
  102. }
  103. },
  104. "data": this.causeData
  105. }]
  106. }
  107. if(myChart){
  108. myChart.clear();
  109. }
  110. myChart.setOption(option);
  111. }
  112. }
  113. })
  114. })()