cageDangerComponent.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="cageDangerComponent">
  3. <title-page-img-components :propsData="propsData"></title-page-img-components>
  4. <div class="eCharts-max-big-box">
  5. <div class="position-button-left">
  6. <p @click="checkButton(1)" :class="buttonType == 1?'left-border-1':'left-border-2'">年度</p>
  7. <p @click="checkButton(2)" :class="buttonType == 1?'center-border-2':(buttonType == 2?'center-border-1':(buttonType == 3?'center-border-3':''))">季度</p>
  8. <p @click="checkButton(3)" :class="buttonType == 3?'right-border-1':'right-border-2'">月度</p>
  9. </div>
  10. <div class="position-text-box">
  11. <p class="position-text">隐患数</p>
  12. <p class="position-num">{{dangerNum}}</p>
  13. <div class="position-num-box" v-if="yearOverYear>0">
  14. <p class="null-p"></p>
  15. <p class="text-num-p">同比 {{yearOverYear}}% </p>
  16. <img src="@/assets/ZDimages/icom_whpclph_sz@1x.png">
  17. <p class="null-p"></p>
  18. </div>
  19. </div>
  20. <p class="position-img-box rotate-animation"></p>
  21. <div id="cageDangerComponentECharts">
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import {
  28. reportReportBsEquipDangerList,
  29. } from "@/api/index";
  30. import titlePageImgComponents from '@/components/titlePageImgComponents.vue'
  31. export default {
  32. name: 'cageDangerComponent',
  33. components: {
  34. titlePageImgComponents
  35. },
  36. data () {
  37. return {
  38. propsData:{
  39. title:'笼位实验室隐患统计',
  40. // checkType:'cageDangerComponent',
  41. },
  42. //eCharts定时器
  43. eChartsTimer:null,
  44. buttonType:1,
  45. dangerNum:0,
  46. yearOverYear:0,
  47. }
  48. },
  49. created(){
  50. },
  51. mounted() {
  52. this.timedRefresh();
  53. },
  54. methods: {
  55. timedRefresh(){
  56. let self = this;
  57. self.getData();
  58. //定时动画
  59. window.clearInterval(self.eChartsTimer);
  60. self.eChartsTimer = setInterval(function(){
  61. self.getData();
  62. },1000*30);
  63. },
  64. getData(){
  65. reportReportBsEquipDangerList({dangerType:2,statisticsType:this.buttonType}).then(response => {
  66. this.$set(this,'dangerNum',response.data.dangerNum?response.data.dangerNum:0);
  67. this.$set(this,'yearOverYear',response.data.yearOverYear?response.data.yearOverYear:0);
  68. let list = [];
  69. for(let i=0;i<response.data.subjectList.length;i++){
  70. list.push({
  71. name:response.data.subjectList[i].subjectName,
  72. value:response.data.subjectList[i].dangerNum
  73. });
  74. }
  75. if(list[0]){
  76. this.eChartsMethod(list);
  77. }
  78. })
  79. },
  80. checkButton(type){
  81. if(this.buttonType != type){
  82. this.$set(this,'buttonType',type);
  83. this.getData();
  84. }
  85. },
  86. eChartsMethod(list) {
  87. let option = {
  88. legend: {
  89. orient: 'vertical',
  90. icon:'rect',
  91. itemWidth:20,
  92. itemHeight:10,
  93. itemGap: 30,
  94. left:343,
  95. top:100,
  96. textStyle:{
  97. // 个
  98. fontSize:18,
  99. color: '#fff',
  100. },
  101. },
  102. tooltip: {
  103. trigger: 'item',
  104. textStyle:{
  105. // 个
  106. fontSize:18,
  107. },
  108. },
  109. color: ['#00E6FF', '#FF912A', '#00A6FF', '#254DEB', '#06CA47'],
  110. series: [
  111. {
  112. name: '',
  113. type: 'pie',
  114. radius: ['40%', '50%'],
  115. center: ['30%', '57%'],
  116. label: {
  117. show: false
  118. },
  119. data: list
  120. }
  121. ]
  122. };
  123. let echartsBox = this.$echarts.init(document.getElementById('cageDangerComponentECharts'));
  124. echartsBox.clear();
  125. echartsBox.setOption(option);
  126. }
  127. },
  128. beforeDestroy() {
  129. //清除定时器
  130. window.clearInterval(this.eChartsTimer);
  131. },
  132. destroyed() {
  133. //清除定时器
  134. window.clearInterval(this.eChartsTimer);
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .cageDangerComponent{
  140. height: 431px;
  141. width:587px;
  142. .eCharts-max-big-box {
  143. height:369px;
  144. background: linear-gradient(180deg, rgba(4, 117, 129, 0.2) 0%, rgba(0, 15, 22, 0) 100%);
  145. overflow: hidden;
  146. position: relative;
  147. .position-button-left {
  148. z-index:5;
  149. position: absolute;
  150. margin:21px 0 0 29px;
  151. display: flex;
  152. p{
  153. width:70px;
  154. line-height:36px;
  155. text-align: center;
  156. color:#fff;
  157. font-size:18px;
  158. background-color: #063D40;
  159. cursor: pointer;
  160. }
  161. p:nth-child(1){
  162. border-top-left-radius:4px;
  163. border-bottom-left-radius:4px;
  164. }
  165. p:nth-child(3){
  166. border-top-right-radius:4px;
  167. border-bottom-right-radius:4px;
  168. }
  169. .left-border-1{
  170. border: 1px solid #00E6FF;
  171. color:#00E6FF;
  172. }
  173. .left-border-2{
  174. border: 1px solid #15827C;
  175. border-right:none;
  176. }
  177. .center-border-1{
  178. border: 1px solid #00E6FF;
  179. color:#00E6FF;
  180. }
  181. .center-border-2{
  182. border: 1px solid #15827C;
  183. border-left:none;
  184. }
  185. .center-border-3{
  186. border: 1px solid #15827C;
  187. border-right:none;
  188. }
  189. .right-border-1{
  190. border: 1px solid #00E6FF;
  191. color:#00E6FF;
  192. }
  193. .right-border-2{
  194. border: 1px solid #15827C;
  195. border-left:none;
  196. }
  197. }
  198. .position-text-box{
  199. width:140px;
  200. z-index:5;
  201. position: absolute;
  202. top:160px;
  203. left:106px;
  204. .position-text{
  205. text-align: center;
  206. height:18px;
  207. line-height:18px;
  208. font-size:18px;
  209. color:#fff;
  210. }
  211. .position-num{
  212. margin:12px 0;
  213. text-align: center;
  214. height:36px;
  215. font-size:36px;
  216. line-height:36px;
  217. background: -webkit-linear-gradient(0deg, #FFFFFF, #FF912A); /* Chrome, Safari */
  218. background: linear-gradient(0deg, #FFFFFF, #FF912A); /* 标准语法 */
  219. -webkit-background-clip: text; /* Chrome, Safari */
  220. background-clip: text;
  221. -webkit-text-fill-color: transparent; /* Chrome, Safari */
  222. color: transparent; /* 其他浏览器 */
  223. font-family: 'ysFonts', sans-serif;
  224. }
  225. .position-num-box{
  226. text-align: center;
  227. display: flex;
  228. .null-p{
  229. flex:1;
  230. }
  231. .text-num-p{
  232. height:18px;
  233. line-height:18px;
  234. font-size:18px;
  235. color:#fff;
  236. }
  237. img{
  238. margin-left:5px;
  239. display: block;
  240. width:11px;
  241. height:14px;
  242. }
  243. }
  244. }
  245. .position-img-box{
  246. position: absolute;
  247. top:100px;
  248. left:65px;
  249. z-index:0;
  250. height:220px;
  251. width:220px;
  252. background: no-repeat;
  253. background-size: 100%;
  254. background-image: url("../../../assets/ZDimages/img_tzsb_wq@1x.png");
  255. }
  256. .rotate-animation {
  257. animation: rotate 10s infinite linear;
  258. }
  259. @keyframes rotate {
  260. from {
  261. transform: rotate(0deg);
  262. }
  263. to {
  264. transform: rotate(360deg);
  265. }
  266. }
  267. #cageDangerComponentECharts{
  268. width:587px;
  269. height:369px;
  270. }
  271. }
  272. }
  273. </style>