troubleDistributionComponents.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!-- 安全隐患分布 -->
  2. <template>
  3. <div class="troubleDistributionComponents">
  4. <title-page-img-components :propsData="propsData"></title-page-img-components>
  5. <div class="eCharts-max-big-box">
  6. <div class="button-box">
  7. <p class="left-button-box">一级指标隐患</p>
  8. <p class="right-button-box">未完成整改隐患</p>
  9. <checkSelectComponents :propsOption="propsOption" :placeholder="'全校'" class="position-check-select"></checkSelectComponents>
  10. </div>
  11. <div class="eCharts-flex">
  12. <div id="troubleDistributionEChartsLeft"></div>
  13. <div id="troubleDistributionEChartsRight"></div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import {
  20. getDeptDropList,
  21. reportReportBigDataDangerDistribution,
  22. } from "@/api/index";
  23. import checkSelectComponents from "@/components/checkSelectComponents.vue";
  24. import titlePageImgComponents from '@/components/titlePageImgComponents.vue'
  25. export default {
  26. name: 'troubleDistributionComponents',
  27. components: {
  28. checkSelectComponents,
  29. titlePageImgComponents
  30. },
  31. data () {
  32. return {
  33. propsData:{
  34. title:'安全隐患分布',
  35. // checkType:'troubleDistributionComponents', //二级未开发-暂时注掉
  36. },
  37. //eCharts定时器
  38. eChartsTimer:null,
  39. //选择器组件传参
  40. propsOption:[
  41. {label:'全校',value:'11'},
  42. {label:'农学院',value:'1'},
  43. {label:'理学院',value:'2'},
  44. {label:'生命科学',value:'3'},
  45. {label:'园林艺术',value:'4'},
  46. {label:'植物保护',value:'5'},
  47. {label:'化学与药物',value:'6'},
  48. {label:'资源环境',value:'7'},
  49. {label:'国重楼',value:'8'},
  50. ],
  51. deptId:0,
  52. }
  53. },
  54. created () {
  55. },
  56. mounted () {
  57. this.getDeptDropList();
  58. this.timedRefresh();
  59. },
  60. methods: {
  61. timedRefresh(){
  62. let self = this;
  63. self.getData();
  64. //定时动画
  65. window.clearInterval(self.eChartsTimer);
  66. self.eChartsTimer = setInterval(function(){
  67. self.getData();
  68. },1000*30);
  69. },
  70. getData(){
  71. reportReportBigDataDangerDistribution({deptId:this.deptId}).then( response => {
  72. let leftNameList = [];
  73. let leftDataList = [];
  74. let leftTextList = [];
  75. let rightNameList = [];
  76. let rightDataList = [];
  77. let rightTextList = [];
  78. let leftMax = 0;
  79. let rightMax = 0;
  80. for(let i=0;i<response.data.dangerOneList.length;i++){
  81. if(leftMax < response.data.dangerOneList[i].indicatorCount){
  82. leftMax = response.data.dangerOneList[i].indicatorCount;
  83. }
  84. }
  85. for(let i=0;i<response.data.dangerNoRectifyList.length;i++){
  86. if(rightMax < response.data.dangerNoRectifyList[i].indicatorCount){
  87. rightMax = response.data.dangerNoRectifyList[i].indicatorCount;
  88. }
  89. }
  90. for(let i=0;i<response.data.dangerOneList.length;i++){
  91. leftNameList.push({
  92. text:response.data.dangerOneList[i].indicatorName,
  93. max:leftMax,
  94. })
  95. leftDataList.push(response.data.dangerOneList[i].indicatorCount)
  96. leftTextList.push(response.data.dangerOneList[i].indicatorRate+'%')
  97. }
  98. for(let i=0;i<response.data.dangerNoRectifyList.length;i++){
  99. rightNameList.push({
  100. text:response.data.dangerNoRectifyList[i].indicatorName,
  101. max:rightMax,
  102. })
  103. rightDataList.push(response.data.dangerNoRectifyList[i].indicatorCount)
  104. rightTextList.push(response.data.dangerNoRectifyList[i].indicatorRate+'%')
  105. }
  106. this.eChartsMethodLeft(leftNameList,leftDataList,leftTextList);
  107. this.eChartsMethodRight(rightNameList,rightDataList,rightTextList);
  108. });
  109. },
  110. //组件方法
  111. checkSelectData(value){
  112. this.$set(this,'deptId',value);
  113. this.getData();
  114. },
  115. eChartsMethodLeft(leftNameList,leftDataList,leftTextList) {
  116. const indicatorList = leftNameList;
  117. let dataValue = leftDataList
  118. let option = {
  119. color: [
  120. "#FF6A00"
  121. ],
  122. radar: [
  123. {
  124. axisName: {
  125. rich: {
  126. a: {
  127. fontSize: 18,
  128. color: "#fff",
  129. fontWeight: 500,
  130. padding: [
  131. 10,
  132. 10,
  133. 10,
  134. 10
  135. ]
  136. },
  137. b: {
  138. fontSize: 18,
  139. fontWeight: 500,
  140. verticalAlign: "middle",
  141. color: "#FF6A00",
  142. }
  143. },
  144. formatter: function (name, indicator) {
  145. const text = indicator.text
  146. const index = indicatorList.findIndex(item => item.text === text)
  147. return `{a| ${name}}\n{b| ${leftTextList[index]}}`
  148. },
  149. },
  150. nameGap: 8,
  151. indicator: indicatorList,
  152. center: [
  153. "50%",
  154. "50%"
  155. ],
  156. radius: 80,
  157. splitNumber: 3,
  158. splitLine: {
  159. lineStyle: {
  160. color: [
  161. "rgba(53, 142, 254, 1)",
  162. "#E5E5E5",
  163. "#E5E5E5"
  164. ],
  165. type: [
  166. 5
  167. ]
  168. }
  169. },
  170. splitArea: {
  171. areaStyle: {
  172. color: [
  173. "#77EADF",
  174. "#26C3BE",
  175. "#64AFE9",
  176. "#428BD4"
  177. ],
  178. shadowColor: "rgba(0, 0, 0, 1)",
  179. shadowBlur: 10,
  180. opacity: 0
  181. }
  182. },
  183. axisLine: {
  184. lineStyle: {
  185. color: "#eee"
  186. }
  187. }
  188. }
  189. ],
  190. series: [
  191. {
  192. type: "radar",
  193. radarIndex: 0,
  194. data: [
  195. {
  196. value: dataValue,
  197. name: "Data D",
  198. areaStyle: {
  199. color: "rgba(255,106,0, 0.6)"
  200. },
  201. lineStyle: {
  202. join: "bevel"
  203. },
  204. itemStyle: {
  205. borderType: "solid",
  206. borderWidth: 4,
  207. borderJoin: "bevel"
  208. }
  209. }
  210. ]
  211. }
  212. ]
  213. };
  214. let echartsBox = this.$echarts.init(document.getElementById('troubleDistributionEChartsLeft'));
  215. echartsBox.clear();
  216. echartsBox.setOption(option);
  217. },
  218. eChartsMethodRight(rightNameList,rightDataList,rightTextList) {
  219. const indicatorList = rightNameList;
  220. let dataValue = rightDataList
  221. let option = {
  222. color: [
  223. "#00F6FF"
  224. ],
  225. radar: [
  226. {
  227. axisName: {
  228. rich: {
  229. a: {
  230. fontSize: 18,
  231. color: "#fff",
  232. fontWeight: 500,
  233. padding: [
  234. 10,
  235. 10,
  236. 10,
  237. 10
  238. ]
  239. },
  240. b: {
  241. fontSize: 18,
  242. fontWeight: 500,
  243. verticalAlign: "middle",
  244. color: "#00F6FF",
  245. }
  246. },
  247. formatter: function (name, indicator) {
  248. const text = indicator.text
  249. const index = indicatorList.findIndex(item => item.text === text)
  250. return `{a| ${name}}\n{b| ${rightTextList[index]}}`
  251. },
  252. },
  253. nameGap: 8,
  254. indicator: indicatorList,
  255. center: [
  256. "50%",
  257. "50%"
  258. ],
  259. radius: 80,
  260. splitNumber: 3,
  261. splitLine: {
  262. lineStyle: {
  263. color: [
  264. "rgba(53, 142, 254, 1)",
  265. "#E5E5E5",
  266. "#E5E5E5"
  267. ],
  268. type: [
  269. 5
  270. ]
  271. }
  272. },
  273. splitArea: {
  274. areaStyle: {
  275. color: [
  276. "#77EADF",
  277. "#26C3BE",
  278. "#64AFE9",
  279. "#428BD4"
  280. ],
  281. shadowColor: "rgba(0, 0, 0, 1)",
  282. shadowBlur: 10,
  283. opacity: 0
  284. }
  285. },
  286. axisLine: {
  287. lineStyle: {
  288. color: "#eee"
  289. }
  290. }
  291. }
  292. ],
  293. series: [
  294. {
  295. type: "radar",
  296. radarIndex: 0,
  297. data: [
  298. {
  299. value: dataValue,
  300. name: "Data D",
  301. areaStyle: {
  302. color: "rgba(0,246,255, 0.6)"
  303. },
  304. lineStyle: {
  305. join: "bevel"
  306. },
  307. itemStyle: {
  308. borderType: "solid",
  309. borderWidth: 4,
  310. borderJoin: "bevel"
  311. }
  312. }
  313. ]
  314. }
  315. ]
  316. };
  317. let echartsBox = this.$echarts.init(document.getElementById('troubleDistributionEChartsRight'));
  318. echartsBox.clear();
  319. echartsBox.setOption(option);
  320. },
  321. getDeptDropList(){
  322. getDeptDropList({level: 2, deptType: 1 }).then(response => {
  323. let list = [{label:'全校',value:'0'}];
  324. for(let i=0;i<response.data.length;i++){
  325. list.push({
  326. label:response.data[i].deptShortName,
  327. value:response.data[i].deptId,
  328. })
  329. }
  330. this.$set(this,'propsOption',list);
  331. });
  332. },
  333. },
  334. beforeDestroy() {
  335. //清除定时器
  336. window.clearInterval(this.eChartsTimer);
  337. },
  338. destroyed() {
  339. //清除定时器
  340. window.clearInterval(this.eChartsTimer);
  341. }
  342. }
  343. </script>
  344. <style scoped lang="scss">
  345. .troubleDistributionComponents{
  346. width:800px;
  347. height:474px;
  348. .eCharts-max-big-box {
  349. background: linear-gradient(180deg, rgba(4, 117, 129, 0.2) 0%, rgba(0, 15, 22, 0) 100%);
  350. .button-box {
  351. height: 113px;
  352. position: relative;
  353. .left-button-box{
  354. text-align: center;
  355. position: absolute;
  356. top: 73px;
  357. left:65px;
  358. width:280px;
  359. height:40px;
  360. background: no-repeat;
  361. background-image: url("../../../assets/ZDimages/img_bg_yjzbyh@1x.png");
  362. background-size: 100%;
  363. color:#00FFFF;
  364. font-size:22px;
  365. line-height:26px;
  366. }
  367. .right-button-box{
  368. text-align: center;
  369. position: absolute;
  370. top: 73px;
  371. left:453px;
  372. width:280px;
  373. height:40px;
  374. background: no-repeat;
  375. background-image: url("../../../assets/ZDimages/img_bg_yjzbyh@1x.png");
  376. background-size: 100%;
  377. color:#00FFFF;
  378. font-size:22px;
  379. line-height:26px;
  380. }
  381. .position-check-select{
  382. position: absolute;
  383. right:29px;
  384. top:20px;
  385. }
  386. }
  387. .eCharts-flex{
  388. width: 800px;
  389. height: 296px;
  390. display: flex;
  391. #troubleDistributionEChartsLeft{
  392. width:400px;
  393. height: 296px;
  394. }
  395. #troubleDistributionEChartsRight{
  396. width:400px;
  397. height: 296px;
  398. }
  399. }
  400. }
  401. }
  402. </style>