1
0

wind-line.vue 12 KB

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