wind-line.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div class="windLine">
  3. <div class="title-top" @click="getDetail">关键路线通风</div>
  4. <div class="toggle-search">
  5. <i class="icon-search">
  6. <SvgIcon class="icon" size="14" name="toggle" />
  7. </i>
  8. <a-select v-model:value="searchValue" style="width: 180px; margin-right: 10px" :options="lineTypeList"
  9. aria-placeholder="请选择" @change="changeSelect" />
  10. </div>
  11. <div class="line-echart">
  12. <div class="line" ref="line"></div>
  13. <div class="pic">
  14. <img src="../../../../../assets/images/home-container/pie.png" alt="" />
  15. </div>
  16. <div class="percent">
  17. <div class="percent-box">
  18. <span>{{ percentF }}</span>
  19. <span class="dw">%</span>
  20. </div>
  21. <div class="percent-box">
  22. <span>{{ percentT }}</span>
  23. <span class="dw">%</span>
  24. </div>
  25. <div class="percent-box">
  26. <span>{{ percentE }}</span>
  27. <span class="dw">%</span>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="line-card">
  32. <div class="card-item" v-for="(item, index) in tabList" :key="index">
  33. <div class="item-s">
  34. <div class="item-label">{{ item.name }}</div>
  35. <div class="item-val">{{ item.val }}</div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script lang="ts" setup>
  42. import { ref, reactive, onMounted, nextTick, defineProps, watch } from 'vue';
  43. import { SvgIcon } from '/@/components/Icon';
  44. import * as echarts from 'echarts';
  45. const emit = defineEmits(['goDetail'])
  46. let props = defineProps({
  47. lineList: Array,
  48. });
  49. //获取dom节点
  50. let line = ref<any>();
  51. let lineData = reactive<any[]>([]);
  52. let searchValue = ref('');
  53. const lineTypeList = reactive<any[]>([]);
  54. let echartData = reactive<any[]>([
  55. { name: '进风区', value: 0 },
  56. { name: '用风区', value: 0 },
  57. { name: '回风区', value: 0 },
  58. ]);
  59. let xData = reactive<any[]>([]);
  60. let yData = reactive<any[]>([]);
  61. let percentE = ref<any>(0);
  62. let percentF = ref<any>(0);
  63. let percentT = ref<any>(0);
  64. let tabList = reactive<any[]>([
  65. { name: '总风量(m³/min)', val: 0 },
  66. { name: '总阻力(Pa)', val: 0 },
  67. { name: '等积孔(m²)', val: 0 },
  68. ]);
  69. //跳转详情
  70. function getDetail() {
  71. console.log('跳转详情');
  72. emit('goDetail', 'majorpath')
  73. }
  74. //选项切换
  75. function changeSelect(val) {
  76. searchValue.value = val;
  77. switch (val) {
  78. case 'bet关键路线1':
  79. echartData[0].value = lineData[0].majorpath.drag_1 || 0;
  80. echartData[1].value = lineData[0].majorpath.drag_2 || 0;
  81. echartData[2].value = lineData[0].majorpath.drag_3 || 0;
  82. tabList[0].val = lineData[0].majorpath.drag_total || 0;
  83. tabList[1].val = lineData[0].majorpath.m3_total || 0;
  84. tabList[2].val = 0.78;
  85. percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  86. percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  87. percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  88. // echartData[0].value = Math.floor(Math.random() * (629 - 620 + 1)) + 620;
  89. // echartData[1].value = Math.floor(Math.random() * (949 - 940 + 1)) + 940;
  90. // echartData[2].value = Math.floor(Math.random() * (855 - 850 + 1)) + 850;
  91. // tabList[0].val = Math.floor(Math.random() * (10700 - 10600 + 1)) + 10600;
  92. // tabList[1].val = Math.floor(Math.random() * (2433 - 2423 + 1)) + 2423;
  93. // tabList[2].val = 0.56;
  94. // percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  95. // percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  96. // percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  97. getOption();
  98. break;
  99. case 'bet关键路线2':
  100. echartData[0].value = lineData[1].majorpath.drag_1 || 0;
  101. echartData[1].value = lineData[1].majorpath.drag_2 || 0;
  102. echartData[2].value = lineData[1].majorpath.drag_3 || 0;
  103. tabList[0].val = lineData[1].majorpath.drag_total || 0;
  104. tabList[1].val = lineData[1].majorpath.m3_total || 0;
  105. tabList[2].val = 0.83;
  106. percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  107. percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  108. percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  109. // echartData[0].value = Math.floor(Math.random() * (830 - 820 + 1)) + 820;
  110. // echartData[1].value = Math.floor(Math.random() * (620 - 600 + 1)) + 600;
  111. // echartData[2].value = Math.floor(Math.random() * (860 - 800 + 1)) + 800;
  112. // tabList[0].val = Math.floor(Math.random() * (10100 - 10000 + 1)) + 10000;
  113. // tabList[1].val = Math.floor(Math.random() * (2310 - 2210 + 1)) + 2210;
  114. // tabList[2].val = 0.78;
  115. // percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  116. // percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  117. // percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  118. getOption();
  119. break;
  120. case 'sw关键路线1':
  121. echartData[0].value = lineData[2].majorpath.drag_1 || 0;
  122. echartData[1].value = lineData[2].majorpath.drag_2 || 0;
  123. echartData[2].value = lineData[2].majorpath.drag_3 || 0;
  124. tabList[0].val = lineData[2].majorpath.drag_total || 0;
  125. tabList[1].val = lineData[2].majorpath.m3_total || 0;
  126. tabList[2].val = 0.88;
  127. percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  128. percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  129. percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  130. // echartData[0].value = Math.floor(Math.random() * (830 - 820 + 1)) + 820;
  131. // echartData[1].value = Math.floor(Math.random() * (620 - 600 + 1)) + 600;
  132. // echartData[2].value = Math.floor(Math.random() * (860 - 800 + 1)) + 800;
  133. // tabList[0].val = Math.floor(Math.random() * (10100 - 10000 + 1)) + 10000;
  134. // tabList[1].val = Math.floor(Math.random() * (2310 - 2210 + 1)) + 2210;
  135. // tabList[2].val = 0.78;
  136. // percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  137. // percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  138. // percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  139. getOption();
  140. break;
  141. case 'sw关键路线2':
  142. echartData[0].value = lineData[3].majorpath.drag_1 || 0;
  143. echartData[1].value = lineData[3].majorpath.drag_2 || 0;
  144. echartData[2].value = lineData[3].majorpath.drag_3 || 0;
  145. tabList[0].val = lineData[3].majorpath.drag_total || 0;
  146. tabList[1].val = lineData[3].majorpath.m3_total || 0;
  147. tabList[2].val = 0.93;
  148. percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  149. percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  150. percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2) || 0;
  151. // echartData[0].value = Math.floor(Math.random() * (830 - 820 + 1)) + 820;
  152. // echartData[1].value = Math.floor(Math.random() * (620 - 600 + 1)) + 600;
  153. // echartData[2].value = Math.floor(Math.random() * (860 - 800 + 1)) + 800;
  154. // tabList[0].val = Math.floor(Math.random() * (10100 - 10000 + 1)) + 10000;
  155. // tabList[1].val = Math.floor(Math.random() * (2310 - 2210 + 1)) + 2210;
  156. // tabList[2].val = 0.78;
  157. // percentF.value = ((echartData[0].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  158. // percentT.value = ((echartData[1].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  159. // percentE.value = ((echartData[2].value / (echartData[0].value + echartData[1].value + echartData[2].value)) * 100).toFixed(2);
  160. getOption();
  161. break;
  162. }
  163. }
  164. function getOption() {
  165. nextTick(() => {
  166. function deepCopy(obj) {
  167. if (typeof obj !== 'object') {
  168. return obj;
  169. }
  170. var newobj = {};
  171. for (var attr in obj) {
  172. newobj[attr] = obj[attr];
  173. }
  174. return newobj;
  175. }
  176. echartData.map((a, b) => {
  177. xData.push(a.name);
  178. yData.push(a.value);
  179. });
  180. var startColor = ['rgba(255, 224, 28,.6)', 'rgba(31, 248, 251,.6)', 'rgba(154, 255, 168,.6)'];
  181. var borderStartColor = ['#ffe01c', '#1ff8fb', '#9affa8'];
  182. var RealData = [];
  183. var borderData = [];
  184. echartData.map((item, index) => {
  185. var newobj = deepCopy(item);
  186. var newobj1 = deepCopy(item);
  187. RealData.push(newobj);
  188. borderData.push(newobj1);
  189. });
  190. RealData.map((item, index) => {
  191. item.itemStyle = {
  192. normal: {
  193. color: startColor[index],
  194. },
  195. };
  196. });
  197. borderData.map((item, index) => {
  198. item.itemStyle = {
  199. normal: {
  200. color: borderStartColor[index],
  201. },
  202. };
  203. });
  204. const myChart = echarts.init(line.value);
  205. let option = {
  206. legend: [
  207. {
  208. // orient: 'vertical',
  209. x: '50%',
  210. y: '12%',
  211. itemWidth: 10,
  212. itemHeight: 10,
  213. align: 'left',
  214. textStyle: {
  215. fontSize: 14,
  216. color: '#b3b8cc',
  217. },
  218. data: ['进风区'],
  219. },
  220. {
  221. // orient: 'vertical',
  222. x: '50%',
  223. y: '42%',
  224. itemWidth: 10,
  225. itemHeight: 10,
  226. align: 'left',
  227. textStyle: {
  228. fontSize: 14,
  229. color: '#b3b8cc',
  230. },
  231. data: ['用风区'],
  232. },
  233. {
  234. // orient: 'vertical',
  235. x: '50%',
  236. y: '70%',
  237. itemWidth: 10,
  238. itemHeight: 10,
  239. align: 'left',
  240. textStyle: {
  241. fontSize: 14,
  242. color: '#b3b8cc',
  243. },
  244. data: ['回风区'],
  245. },
  246. ],
  247. tooltip: {
  248. formatter: '{b}:{c}',
  249. },
  250. series: [
  251. // 主要展示层的
  252. {
  253. radius: ['40%', '80%'],
  254. center: ['25%', '50%'],
  255. type: 'pie',
  256. z: 10,
  257. label: {
  258. normal: {
  259. show: false,
  260. },
  261. emphasis: {
  262. show: false,
  263. },
  264. },
  265. labelLine: {
  266. normal: {
  267. show: false,
  268. },
  269. emphasis: {
  270. show: false,
  271. },
  272. },
  273. itemStyle: {
  274. normal: {
  275. borderWidth: 5,
  276. borderColor: 'rgba(1, 57, 134,1)',
  277. },
  278. },
  279. data: RealData,
  280. },
  281. // 边框的设置
  282. {
  283. radius: ['45%', '52%'],
  284. center: ['25%', '50%'],
  285. type: 'pie',
  286. z: 5,
  287. label: {
  288. normal: {
  289. show: false,
  290. },
  291. emphasis: {
  292. show: false,
  293. },
  294. },
  295. labelLine: {
  296. normal: {
  297. show: false,
  298. },
  299. emphasis: {
  300. show: false,
  301. },
  302. },
  303. animation: false,
  304. tooltip: {
  305. show: false,
  306. },
  307. data: borderData,
  308. },
  309. ],
  310. };
  311. myChart.setOption(option);
  312. window.onresize = function () {
  313. myChart.resize();
  314. };
  315. });
  316. }
  317. watch(
  318. () => props.lineList,
  319. (val) => {
  320. console.log(val, '关键路线数据');
  321. lineData = val;
  322. lineTypeList.length = 0;
  323. lineData.forEach((el) => {
  324. lineTypeList.push({
  325. label: el.deviceName,
  326. value: el.deviceName,
  327. });
  328. });
  329. if (searchValue.value) {
  330. changeSelect(searchValue.value);
  331. } else {
  332. searchValue.value = lineTypeList[0].value;
  333. changeSelect(searchValue.value);
  334. }
  335. },
  336. {
  337. deep: true,
  338. }
  339. );
  340. onMounted(() => { });
  341. </script>
  342. <style lang="less" scoped>
  343. @font-face {
  344. font-family: 'douyuFont';
  345. src: url('../../../../../assets/font/douyuFont.otf');
  346. }
  347. .windLine {
  348. width: 100%;
  349. height: 100%;
  350. position: relative;
  351. .title-top {
  352. position: absolute;
  353. top: 9px;
  354. left: 46px;
  355. color: #fff;
  356. font-size: 16px;
  357. font-family: 'douyuFont';
  358. cursor: pointer;
  359. &:hover {
  360. color: #66ffff;
  361. }
  362. }
  363. .toggle-search {
  364. position: absolute;
  365. left: 9px;
  366. top: 37px;
  367. display: flex;
  368. .icon-search {
  369. position: absolute;
  370. top: 50%;
  371. left: 5px;
  372. transform: translate(0%, -50%);
  373. }
  374. }
  375. .line-echart {
  376. position: absolute;
  377. top: 66px;
  378. left: 0;
  379. width: 100%;
  380. height: 120px;
  381. .line {
  382. width: 100%;
  383. height: 100%;
  384. }
  385. .pic {
  386. height: 100%;
  387. position: absolute;
  388. left: 45%;
  389. top: 0;
  390. display: flex;
  391. align-items: center;
  392. img {
  393. height: 60%;
  394. }
  395. }
  396. .percent {
  397. position: absolute;
  398. left: 75%;
  399. top: 0;
  400. width: 45px;
  401. height: 100%;
  402. display: flex;
  403. flex-direction: column;
  404. // justify-content: space-between;
  405. align-items: center;
  406. .percent-box {
  407. font-size: 14px;
  408. // color: #b3b8cc;
  409. &:nth-child(1) {
  410. position: absolute;
  411. top: 12%;
  412. color: #ffe01c;
  413. }
  414. &:nth-child(2) {
  415. position: absolute;
  416. top: 42%;
  417. color: #1ff8fb;
  418. }
  419. &:nth-child(3) {
  420. position: absolute;
  421. top: 70%;
  422. color: #9affa8;
  423. }
  424. .dw {
  425. color: #b3b8cc;
  426. margin-left: 5px;
  427. }
  428. }
  429. }
  430. }
  431. .line-card {
  432. position: absolute;
  433. top: 186px;
  434. left: 0;
  435. width: 100%;
  436. height: calc(100% - 186px);
  437. padding: 0px 15px 15px 15px;
  438. box-sizing: border-box;
  439. display: flex;
  440. justify-content: space-around;
  441. align-items: center;
  442. .card-item {
  443. display: flex;
  444. flex: 1;
  445. justify-content: center;
  446. align-items: center;
  447. height: 100%;
  448. .item-s {
  449. position: relative;
  450. width: 105px;
  451. height: 58px;
  452. margin-top: 20px;
  453. background: url('../../../../../assets/images/home-container/line-val.png') no-repeat;
  454. background-size: 100% 90%;
  455. .item-label {
  456. width: 100%;
  457. text-align: center;
  458. color: #b3b8cc;
  459. font-size: 12px;
  460. }
  461. .item-val {
  462. position: absolute;
  463. left: 50%;
  464. top: 26px;
  465. font-size: 14px;
  466. font-family: 'douyuFont';
  467. color: #fff;
  468. transform: translate(-50%, 0);
  469. }
  470. }
  471. }
  472. }
  473. }
  474. :deep .zxm-select-selector {
  475. width: 100%;
  476. height: 30px !important;
  477. padding: 0 11px 0px 25px !important;
  478. background-color: rgba(8, 148, 255, 0.3) !important;
  479. border: 1px solid #1d80da !important;
  480. }
  481. :deep .zxm-select-selection-item {
  482. color: #fff !important;
  483. line-height: 28px !important;
  484. }
  485. :deep .zxm-select-arrow {
  486. color: #fff !important;
  487. }
  488. </style>