death-cause.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. }
  46. }
  47. },
  48. filters:{
  49. formatData:function(index){
  50. var colorArr = ["bgc-00e6f3","bgc-03fa6c","bgc-ff616f","bgc-0fa5f2","bgc-6576e0","bgc-da0ff2","bgc-f24a0f","bgc-ebff61","bgc-fea92f"];
  51. return colorArr[index];
  52. }
  53. },
  54. methods: {
  55. detailClick:function(){
  56. var vm = this;
  57. var width = (0.7604 * window.screen.width) + 'px';
  58. var height = (0.41875 * window.screen.width) + 'px';
  59. top.layer.open({
  60. id: 'LAY_layuipro', //设定一个id,防止重复弹出
  61. type: 2,
  62. title: false,
  63. closeBtn: 0,
  64. shade: 0.5,
  65. shadeClose: true,
  66. area: [width, height],
  67. content: httpRequest.alertUrl+'/page/bigData/html/alert5.html?town='+vm.city+"&cityVal="+vm.cityVal
  68. });
  69. },
  70. initData:function(){//死亡原因
  71. this.causeData = this.newData.series[0].data;
  72. var myChart = echarts.init(document.getElementById('div-shiwang-echart'));
  73. var option = {
  74. // "title": {
  75. // "text": "性别分布",
  76. // "subtext": "性别分布",
  77. // "x": "center"
  78. // },
  79. "tooltip": {
  80. "trigger": "item"
  81. },
  82. color: ["#00e6f3","#03fa6c","#ff616f","#0fa5f2","#6576e0","#da0ff2","#f24a0f","#ebff61","#fea92f"],
  83. "series": [{
  84. "center": [
  85. "50%",
  86. "50%"
  87. ],
  88. radius: ['50%', '70%'],
  89. "name": "",
  90. "type": "pie",
  91. "itemStyle": {
  92. "normal": {
  93. "label": {
  94. "show": false
  95. },
  96. "labelLine": {
  97. "show": false
  98. }
  99. }
  100. },
  101. "data": this.causeData
  102. }]
  103. }
  104. if(myChart){
  105. myChart.clear();
  106. }
  107. myChart.setOption(option);
  108. }
  109. }
  110. })
  111. })()