hiddenDangerEchart.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="gasRiskBody">
  3. <p class="gasRiskTimeOut" @click="showYinHuan('0',true,'')">已超时:<span class="light-red">{{ yinHuanOverHourCount }}</span></p>
  4. <div id="hiddenDanger-pipeline" />
  5. <div v-show="!isShowBottom" class="echartsBottomTest" @mouseenter="isShowBottom = true" />
  6. <div v-show="isShowBottom" class="echartsBottom" @mouseleave="isShowBottom = false">
  7. <div class="bottomInfoBox" @click="showYinHuan('0',false,$constant.YINHUAN_GRADE.get('重大'))">
  8. <span class="iRed">{{ zhongDaCount }}</span>
  9. <span>重 大</span>
  10. </div>
  11. <div class="columLine" />
  12. <div class="bottomInfoBox" @click="showYinHuan('0',false,$constant.YINHUAN_GRADE.get('较大'))">
  13. <span class="iRed">{{ jiaoDaCount }}</span>
  14. <span>较 大</span>
  15. </div>
  16. <div class="columLine" />
  17. <div class="bottomInfoBox" @click="showYinHuan('0',false,$constant.YINHUAN_GRADE.get('一般'))">
  18. <span class="iGreen">{{ yiBanCount }}</span>
  19. <span>严 重</span>
  20. </div>
  21. <div class="columLine" />
  22. <div class="bottomInfoBox" @click="showYinHuan('0',false,$constant.YINHUAN_GRADE.get('低'))">
  23. <span class="iGreen">{{ diCount }}</span>
  24. <span>一 般</span>
  25. </div>
  26. </div>
  27. <!-- <el-dialog-->
  28. <!-- v-el-drag-dialog-->
  29. <!-- :close-on-click-modal="false"-->
  30. <!-- :close-on-press-escape="false"-->
  31. <!-- :lock-scroll="false"-->
  32. <!-- :modal="false"-->
  33. <!-- :visible.sync="dialogyinhuanVisible"-->
  34. <!-- custom-class="dialogNew width3840px"-->
  35. <!-- width="1920px"-->
  36. <!-- >-->
  37. <!-- <yinhuan v-if="dialogyinhuanVisible" ref="detailShow"/>-->
  38. <!-- </el-dialog>-->
  39. </div>
  40. </template>
  41. <script>
  42. import * as echarts from 'echarts'
  43. // import { number } from 'echarts/lib/export'
  44. import yinhuan from '@/views/yinhuan/yinhuan.vue'
  45. import constant from '@/static/utils/constant'
  46. import myBus from '@/views/life-line/monitor/assets/js/myBus'
  47. export default {
  48. name: 'GasRiskEchart',
  49. components: {
  50. yinhuan
  51. },
  52. props: {
  53. // eslint-disable-next-line vue/require-prop-type-constructor
  54. yinHuanOverHourCount: 0, // 超时数量
  55. yinHuan: { // 隐患
  56. type: Array,
  57. default: function() {
  58. return []
  59. }
  60. }
  61. },
  62. data() {
  63. return {
  64. isShowBottom: false,
  65. dialogyinhuanVisible: false,
  66. zhongDaCount: 0,
  67. jiaoDaCount: 0,
  68. yiBanCount: 0,
  69. diCount: 0,
  70. zhongDaCountBai: 0,
  71. jiaoDaCountBai: 0,
  72. yiBanCountBai: 0,
  73. diCountBai: 0
  74. }
  75. },
  76. deactivated() {
  77. this.dialogtestVueVisible = false
  78. },
  79. watch: {
  80. yinHuan(newVal, oldVal) {
  81. // 监听 num 属性的数据变化
  82. // 作用 : 只要 num 的值发生变化,这个方法就会被调用
  83. // 只要没有发生变化,就没有办法进行其他的操作
  84. // newData是更新后的数据
  85. // oldData是旧数据
  86. // //console.log('newVal:', newVal)
  87. // //console.log('oldVal:', oldVal)
  88. let zhongDaCount = 0
  89. let jiaoDaCount = 0
  90. let yiBanCount = 0
  91. let diCount = 0
  92. // 0-一级,1-二级,2-三级,3-四级,
  93. for (let i = 0; i < newVal.length; i++) {
  94. if (newVal[i].hidden_trouble_grade == constant.YINHUAN_GRADE.get('低')) {
  95. diCount = newVal[i].count
  96. } else if (newVal[i].hidden_trouble_grade == constant.YINHUAN_GRADE.get('一般')) {
  97. yiBanCount = newVal[i].count
  98. } else if (newVal[i].hidden_trouble_grade == constant.YINHUAN_GRADE.get('较大')) {
  99. jiaoDaCount = newVal[i].count
  100. } else if (newVal[i].hidden_trouble_grade == constant.YINHUAN_GRADE.get('重大')) {
  101. zhongDaCount = newVal[i].count
  102. }
  103. }
  104. this.zhongDaCount = zhongDaCount
  105. this.jiaoDaCount = jiaoDaCount
  106. this.yiBanCount = yiBanCount
  107. this.diCount = diCount
  108. const total = zhongDaCount + jiaoDaCount + yiBanCount + diCount
  109. this.zhongDaCountBai = (zhongDaCount / total * 100).toFixed(2)
  110. this.jiaoDaCountBai = (jiaoDaCount / total * 100).toFixed(2)
  111. this.yiBanCountBai = (yiBanCount / total * 100).toFixed(2)
  112. this.diCountBai = (diCount / total * 100).toFixed(2)
  113. this.getChart()
  114. }
  115. },
  116. mounted() {
  117. this.getChart()
  118. },
  119. methods: {
  120. // 显示风险小屏幕, sceneCode选择场景,isOver是否超时,selectGrade选择等级
  121. showYinHuan(sceneCode, isOver, selectGrade) {
  122. myBus.$emit('showYinHuan', { sceneCode: '4', isOver, selectGrade })
  123. // this.dialogyinhuanVisible = true
  124. // this.$nextTick(() => {
  125. // this.$refs.detailShow.toGetData('4', isOver, selectGrade)
  126. // })
  127. },
  128. contains(arrays, obj) {
  129. var i = arrays.length
  130. while (i--) {
  131. if (arrays[i].name === obj) {
  132. return i
  133. }
  134. }
  135. return false
  136. },
  137. getChart() {
  138. const myChart = echarts.init(document.getElementById('hiddenDanger-pipeline'))
  139. var mapData = [
  140. {
  141. 'name': '重大隐患',
  142. 'value': this.zhongDaCount,
  143. 'color': '#FB565E'
  144. },
  145. {
  146. 'name': '较大隐患',
  147. 'value': this.jiaoDaCount,
  148. 'color': '#F19904'
  149. },
  150. {
  151. 'name': '严重隐患',
  152. 'value': this.yiBanCount,
  153. 'color': '#2B78FF'
  154. }, {
  155. 'name': '一般隐患',
  156. 'value': this.diCount,
  157. 'color': '#00F2FF'
  158. }
  159. ]
  160. var data = []
  161. var IndustryArr = []
  162. var indicator = []
  163. var sum = 0
  164. mapData.forEach(item => {
  165. data.push(item.value)
  166. IndustryArr.push(item.name)
  167. sum += item.value
  168. if (sum === 0) {
  169. sum = 1
  170. }
  171. indicator.push({
  172. max: 100,
  173. name: item.name,
  174. value: item.value,
  175. color:item.color
  176. })
  177. })
  178. //console.log('sum', indicator)
  179. const colorList = ['#FB565E', '#F19904', '#2B78FF', '#00F2FF']
  180. var option = {
  181. tooltip: {
  182. show: false
  183. },
  184. radar: [{
  185. indicator: indicator,
  186. radius: '70%',
  187. nameGap: 10,
  188. center: ['50%', '50%'],
  189. splitNumber: 4,
  190. name: {
  191. formatter: (params, index) => {
  192. //console.log('param', indicator[i])
  193. var i = this.contains(indicator, params)
  194. var percent = ((indicator[i].value / sum) * 100).toFixed(2)
  195. return '{value|' + indicator[i].value + '个' + '}' + '\xa0' + '{percent|' + percent + '%' + '}' + '\n' + params
  196. // return `\xa0\xa0\xa0\xa0\xa0` + '处置率:' + indicator[index].percent + '%'
  197. },
  198. textStyle: {
  199. color: 'white',
  200. fontSize: 30,
  201. rich: {
  202. percent: {
  203. fontSize: 30,
  204. fontWeight: 'normal',
  205. color: 'white'
  206. }
  207. }
  208. }
  209. },
  210. splitArea: {
  211. areaStyle: {
  212. color: [
  213. 'rgba(100, 152, 255, 0.7)',
  214. 'rgba(100, 152, 255, 0.5)',
  215. 'rgba(100, 152, 255, 0.3)',
  216. 'rgba(100, 152, 255, 0.1)'
  217. // 'rgba(100, 152, 255, 0.3)',
  218. // 'rgba(100, 152, 255, 0.2)'
  219. ],
  220. shadowColor: 'rgba(0, 0, 0, 0.3)'
  221. }
  222. },
  223. axisLine: {
  224. lineStyle: {
  225. color: 'rgba(255, 255, 255, 0.2)'
  226. }
  227. },
  228. splitLine: {
  229. lineStyle: {
  230. color: 'rgba(255, 255, 255, 0)'
  231. }
  232. }
  233. }],
  234. series: [{
  235. name: '雷达图',
  236. type: 'radar',
  237. symbolSize: 15,
  238. emphasis: {
  239. areaStyle: {
  240. color: 'rgba(164, 199, 255, 1)'
  241. }
  242. },
  243. data: [{
  244. value: [...data],
  245. name: '行业贷款分布',
  246. textStyle: {
  247. fontSize: 30
  248. },
  249. areaStyle: {
  250. normal: {
  251. color: new echarts.graphic.LinearGradient(
  252. 0,
  253. 0,
  254. 0,
  255. 1,
  256. [
  257. {
  258. offset: 0,
  259. color: 'rgba(251, 86, 94, 1)'
  260. },
  261. {
  262. offset: 0.5,
  263. color: 'rgba(0, 242, 255, 1)'
  264. },
  265. {
  266. offset: 1,
  267. color: 'rgba(43, 120, 255, 1)'
  268. }
  269. ],
  270. false
  271. )
  272. }
  273. },
  274. lineStyle: {
  275. color: 'rgba(25, 86, 224, 1)'
  276. }
  277. }]
  278. }]
  279. }
  280. myChart.setOption(option)
  281. myChart.on('click', (e) => {
  282. //console.log(e)
  283. // 没有反应,所以不行
  284. // let selectGrade = ''
  285. // if (e.name === '重大风险') {
  286. // selectGrade = '3'
  287. // } else if (e.name === '较大风险') {
  288. // selectGrade = '2'
  289. // } else if (e.name === '一般风险') {
  290. // selectGrade = '1'
  291. // } else if (e.name === '低 风 险') {
  292. // selectGrade = '0'
  293. // }
  294. // this.showYinHuan('0', false, selectGrade)
  295. })
  296. }
  297. }
  298. }
  299. </script>
  300. <style scoped>
  301. #hiddenDanger-pipeline{
  302. width: 765px;
  303. height: 550px;
  304. }
  305. /deep/ .el-dialog__wrapper {
  306. pointer-events: none !important;
  307. }
  308. /deep/ .el-dialog {
  309. pointer-events: auto !important;
  310. }
  311. /deep/ .el-dialog__headerbtn {
  312. //font-size: 75px;
  313. z-index: 10000;
  314. }
  315. </style>