death-cause.js 3.3 KB

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