index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!-- 二级学院单位实验室统计 -->
  2. <template>
  3. <div class="secondaryCollegeUnitLaboratoryStatistics">
  4. <div class="secondaryCollegeUnitLaboratoryStatistics-title">
  5. <p>二级学院单位实验室统计</p>
  6. </div>
  7. <div class="secondaryCollegeUnitLaboratoryStatisticsPage" id="secondaryCollegeUnitLaboratoryStatisticsECharts">
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import { laboratorySubRelInfoLabStateStatisticsAll } from "@/api/index";
  13. export default {
  14. name: 'index',
  15. data () {
  16. return {
  17. //echarts数据
  18. echartsBox:null,
  19. // 定时器
  20. echartsTimer:null,
  21. minTimer:null,
  22. //数据
  23. dataList:[],
  24. numIndex:0,
  25. maxNum: 0,
  26. }
  27. },
  28. created () {
  29. },
  30. mounted () {
  31. this.getList();
  32. this.timeFunction();
  33. },
  34. methods: {
  35. getList(){
  36. laboratorySubRelInfoLabStateStatisticsAll().then(response => {
  37. this.$set(this,'numIndex',0);
  38. this.$set(this,'maxNum',response.data.labLevelVOList.length-1);
  39. response.data.labLevelVOList.forEach((item)=>{
  40. item.num = item.levelOneCount + item.levelTwoCount + item.levelThreeCount + item.levelFourCount;
  41. })
  42. response.data.labLevelVOList = response.data.labLevelVOList.slice().sort((a, b) => b.num - a.num);
  43. this.$set(this,'dataList',response.data.labLevelVOList);
  44. this.minTimeFunction();
  45. // let obj = {
  46. // nameList:[],
  47. // dataListA : [],
  48. // dataListB : [],
  49. // dataListC : [],
  50. // dataListD : [],
  51. // dataListE : [],
  52. // };
  53. // const maxNum = response.data.labLevelVOList[0].levelOneCount + response.data.labLevelVOList[0].levelTwoCount + response.data.labLevelVOList[0].levelThreeCount + response.data.labLevelVOList[0].levelFourCount
  54. // response.data.labLevelVOList.forEach((item)=>{
  55. // let num = item.levelOneCount+item.levelTwoCount+item.levelThreeCount+item.levelFourCount
  56. // obj.nameList.push(item.deptName)
  57. // obj.dataListA.push(item.levelOneCount)
  58. // obj.dataListB.push(item.levelTwoCount)
  59. // obj.dataListC.push(item.levelThreeCount)
  60. // obj.dataListD.push(item.levelFourCount)
  61. // obj.dataListE.push({
  62. // name:num,
  63. // value:maxNum-num
  64. // })
  65. // })
  66. // this.eChartsMethod(obj);
  67. })
  68. },
  69. minTimeFunction(){
  70. let self = this;
  71. showTime();
  72. if(!this.minTimer){
  73. this.minTimer = window.setInterval(showTime, 10000);
  74. }
  75. function showTime() {
  76. if(self.dataList[0]){
  77. let newList = [];
  78. for(let i=0;i<5;i++){
  79. if(self.dataList[self.numIndex]){
  80. newList.push(self.dataList[self.numIndex])
  81. if(self.numIndex<self.maxNum){
  82. self.numIndex++;
  83. }else{
  84. self.numIndex=0;
  85. break
  86. }
  87. }
  88. }
  89. let obj = {
  90. nameList:[],
  91. dataListA : [],
  92. dataListB : [],
  93. dataListC : [],
  94. dataListD : [],
  95. dataListE : [],
  96. };
  97. if(newList[0]){
  98. const maxNum = newList[0].levelOneCount + newList[0].levelTwoCount + newList[0].levelThreeCount + newList[0].levelFourCount
  99. newList.forEach((item)=>{
  100. let num = item.levelOneCount+item.levelTwoCount+item.levelThreeCount+item.levelFourCount
  101. obj.nameList.push(item.deptName)
  102. obj.dataListA.push(item.levelOneCount)
  103. obj.dataListB.push(item.levelTwoCount)
  104. obj.dataListC.push(item.levelThreeCount)
  105. obj.dataListD.push(item.levelFourCount)
  106. obj.dataListE.push({
  107. name:num,
  108. value:maxNum-num
  109. })
  110. })
  111. self.eChartsMethod(obj);
  112. }
  113. }
  114. }
  115. },
  116. eChartsMethod(obj){
  117. let option = {
  118. title: {
  119. show:false,
  120. },
  121. tooltip: {
  122. show:false,
  123. trigger: "axis",
  124. axisPointer: {
  125. type: "shadow",
  126. textStyle: {
  127. color: "#fff",
  128. },
  129. },
  130. textStyle: {
  131. color: "#fff",
  132. },
  133. backgroundColor: "background: rgba(255,255,255,0.1);", //设置背景颜色
  134. borderColor: "rgba(255,255,255,0.1)",
  135. formatter:function (data) {
  136. return (data.name )
  137. },
  138. },
  139. legend: {
  140. icon:'rect',
  141. left: 'center',
  142. top:'15',
  143. itemGap:55,
  144. itemWidth:30,
  145. itemHeight:10,
  146. show: true,
  147. textStyle:{
  148. fontSize:34,
  149. color:'#fff',
  150. },
  151. data: [
  152. { name: 'I 级', itemStyle: { color: '#F38181' } }, // 设置系列1图例的文字颜色为红色
  153. { name: 'II 级', itemStyle: { color: '#D8A746' } }, // 设置系列1图例的文字颜色为红色
  154. { name: 'III 级', itemStyle: { color: '#3876E1' } }, // 设置系列1图例的文字颜色为红色
  155. { name: 'IV 级', itemStyle: { color: '#56A757' } } // 设置系列2图例的文字颜色为绿色
  156. // 可以继续添加更多系列及其图例颜色配置
  157. ],
  158. },
  159. grid: {
  160. left: "10%",
  161. right: "10%",
  162. bottom: "10%",
  163. top: "20%",
  164. },
  165. xAxis: {
  166. type: 'category',
  167. data: obj.nameList,
  168. axisLabel:{
  169. color:'#fff',
  170. fontSize:'30',
  171. },
  172. axisLine:{
  173. show:true,
  174. lineStyle:{
  175. color:'#41A4FF',
  176. }
  177. },
  178. splitLine: {
  179. show: false
  180. },
  181. axisTick: {
  182. show: false
  183. }
  184. },
  185. yAxis: {
  186. type: 'value',
  187. axisLabel:{
  188. color:'#fff',
  189. fontSize:'30',
  190. },
  191. axisLine:{
  192. show:true,
  193. lineStyle:{
  194. color:'#41A4FF',
  195. }
  196. },
  197. splitLine: {
  198. show: false
  199. },
  200. axisTick: {
  201. show: false
  202. }
  203. },
  204. series: [
  205. {
  206. name: 'I 级',
  207. type: 'bar',
  208. barWidth: 30,
  209. stack: '数量',
  210. data: obj.dataListA,
  211. itemStyle: {
  212. normal: {
  213. color: {//渐变色
  214. x: 0,
  215. y: 1,
  216. x2: 0,
  217. y2: 0,
  218. type: 'linear',
  219. global: false,
  220. colorStops: [
  221. {
  222. offset: 0,
  223. color: '#D8D8D8',
  224. },
  225. {
  226. offset: 1,
  227. color: '#F38181',
  228. },
  229. ],
  230. },
  231. }
  232. }
  233. },
  234. {
  235. name: 'II 级',
  236. type: 'bar',
  237. barWidth:30,
  238. stack: '数量',
  239. data: obj.dataListB,
  240. itemStyle: {
  241. normal: {
  242. color: {//渐变色
  243. x: 0,
  244. y: 1,
  245. x2: 0,
  246. y2: 0,
  247. type: 'linear',
  248. global: false,
  249. colorStops: [
  250. {
  251. offset: 0,
  252. color: '#D8D8D8',
  253. },
  254. {
  255. offset: 1,
  256. color: '#D8A746',
  257. },
  258. ],
  259. },
  260. }
  261. }
  262. },
  263. {
  264. name: 'III 级',
  265. type: 'bar',
  266. barWidth: 30,
  267. stack: '数量',
  268. data: obj.dataListC,
  269. itemStyle: {
  270. normal: {
  271. color: {//渐变色
  272. x: 0,
  273. y: 1,
  274. x2: 0,
  275. y2: 0,
  276. type: 'linear',
  277. global: false,
  278. colorStops: [
  279. {
  280. offset: 0,
  281. color: '#D8D8D8',
  282. },
  283. {
  284. offset: 1,
  285. color: '#3876E1',
  286. },
  287. ],
  288. },
  289. }
  290. }
  291. },
  292. {
  293. name: 'IV 级',
  294. type: 'bar',
  295. barWidth: 30,
  296. stack: '数量',
  297. data: obj.dataListD,
  298. itemStyle: {
  299. normal: {
  300. color: {//渐变色
  301. x: 0,
  302. y: 1,
  303. x2: 0,
  304. y2: 0,
  305. type: 'linear',
  306. global: false,
  307. colorStops: [
  308. {
  309. offset: 0,
  310. color: '#D8D8D8',
  311. },
  312. {
  313. offset: 1,
  314. color: '#56A757',
  315. },
  316. ],
  317. },
  318. }
  319. }
  320. },
  321. {
  322. name: '',
  323. type: 'bar',
  324. barWidth: 30,
  325. stack: '数量',
  326. data: obj.dataListE,
  327. label: {
  328. show: true,
  329. position: 'top',
  330. textStyle: {
  331. color: '#fff', //更改坐标轴文字颜色
  332. fontSize: '34',
  333. },
  334. formatter: function (data) {
  335. return (data.name )
  336. },
  337. },
  338. itemStyle: {
  339. normal: {
  340. color: {//渐变色
  341. x: 0,
  342. y: 1,
  343. x2: 0,
  344. y2: 0,
  345. type: 'linear',
  346. global: false,
  347. colorStops: [
  348. {
  349. offset: 0,
  350. color: 'rgba(216,216,216,0.1)',
  351. },
  352. {
  353. offset: 1,
  354. color: 'rgba(216,216,216,0.1)',
  355. },
  356. ],
  357. },
  358. }
  359. }
  360. },
  361. ]
  362. };
  363. this.echartsBox = this.$echarts.init(document.getElementById('secondaryCollegeUnitLaboratoryStatisticsECharts'));
  364. this.echartsBox.clear();
  365. this.echartsBox.setOption(option);
  366. },
  367. //时间定时器
  368. timeFunction(){
  369. let self = this;
  370. this.echartsTimer = window.setInterval(showTime, 180000);
  371. function showTime() {
  372. self.getList();
  373. }
  374. },
  375. },
  376. beforeDestroy() {
  377. //清除定时器
  378. window.clearInterval(this.echartsTimer);
  379. },
  380. destroyed() {
  381. //清除定时器
  382. window.clearInterval(this.echartsTimer);
  383. }
  384. }
  385. </script>
  386. <style scoped lang="scss">
  387. .secondaryCollegeUnitLaboratoryStatistics{
  388. margin: 16px 0 0 88px;
  389. .secondaryCollegeUnitLaboratoryStatistics-title{
  390. width:796px;
  391. height:84px;
  392. background: url("../../../assets/ZDimages/img_sy_fbt@1x.png");
  393. background-size: 100%;
  394. overflow: hidden;
  395. p{
  396. font-size:40px;
  397. line-height:40px;
  398. margin:18px 0 0 85px;
  399. font-weight:700;
  400. background: -webkit-linear-gradient(0deg, #0591F3, #FFFFFF); /* Chrome, Safari */
  401. background: linear-gradient(0deg, #0591F3, #FFFFFF); /* 标准语法 */
  402. -webkit-background-clip: text; /* Chrome, Safari */
  403. background-clip: text;
  404. -webkit-text-fill-color: transparent; /* Chrome, Safari */
  405. color: transparent; /* 其他浏览器 */
  406. }
  407. }
  408. .secondaryCollegeUnitLaboratoryStatisticsPage{
  409. height:665px;
  410. width:1167px;
  411. }
  412. }
  413. </style>