loopDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <div class="system-dic-container data-overview">
  3. <el-row :gutter="15" class="home-card-one">
  4. <el-col
  5. :xs="24"
  6. :sm="12"
  7. :md="12"
  8. :lg="6"
  9. :xl="6"
  10. v-for="(v, k) in dataOne"
  11. :key="k"
  12. :class="{ 'home-media home-media-lg': k > 1, 'home-media-sm': k === 1 }"
  13. >
  14. <div class="home-card-item">
  15. <div class="item-header">
  16. <img :src="isIsDark ? v.iconDark : v.icon" alt="" />
  17. <span>{{ v.title }}</span>
  18. </div>
  19. <div class="item-content w100" :class="` home-one-animation${k}`">
  20. <p>
  21. <span>{{ v.contentTitle1 }}</span>
  22. <span>{{ v.val1 }} {{ unitMap[v.contentTitle1] }}</span>
  23. </p>
  24. <p>
  25. <span>{{ v.contentTitle2 }}</span>
  26. <span
  27. >{{ v.val2 }}
  28. {{ unitMap[v.title + ':' + v.contentTitle2] ? unitMap[v.title + ':' + v.contentTitle2] : unitMap[v.contentTitle2] }}</span
  29. >
  30. </p>
  31. <p style="height: 30px">
  32. <template v-if="v.contentTitle3">
  33. <span>{{ v.contentTitle3 || ' ' }}</span>
  34. <span
  35. >{{ v.val3 || ' ' }}
  36. {{ unitMap[v.title + ':' + v.contentTitle3] ? unitMap[v.title + ':' + v.contentTitle3] : unitMap[v.contentTitle3] }}</span
  37. >
  38. </template>
  39. </p>
  40. </div>
  41. </div>
  42. </el-col>
  43. </el-row>
  44. <!-- 拓扑图 -->
  45. <el-row :gutter="15" class="home-card-one mt15" v-if="$route.query.code">
  46. <el-col :span="24">
  47. <div class="home-card-item p20" v-loading="loading">
  48. <!-- <el-tabs>
  49. <el-tab-pane label="环路监测"> -->
  50. <div class="flex-row">
  51. <el-tabs v-model="tabName" @tab-change="initLineChart">
  52. <el-tab-pane label="温度" :name="0"></el-tab-pane>
  53. <el-tab-pane label="压力" :name="1"></el-tab-pane>
  54. <el-tab-pane label="流量" :name="2"></el-tab-pane>
  55. <el-tab-pane label="失水量" :name="3"></el-tab-pane>
  56. </el-tabs>
  57. <el-button type="text" @click="goDetail()">更多 &gt;</el-button>
  58. </div>
  59. <div style="height: 300px" ref="homeLineRef"></div>
  60. <!-- </el-tab-pane>
  61. <el-tab-pane label="流程图" lazy>
  62. <div class="iframe-wrapper">
  63. <iframe :src="'/plugin/topo/?bgColor=000#/name/' + $route.query.code" height="400" width="100%" frameborder="0" class="mt15"></iframe>
  64. <div class="jump" @click="jump('/plugin/topo/?bgColor=000#/name/' + $route.query.code)">
  65. <img src="/@/assets/open.svg" />
  66. </div>
  67. </div>
  68. </el-tab-pane>
  69. </el-tabs> -->
  70. </div>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. </template>
  75. <script lang="ts">
  76. import { toRefs, reactive, onMounted, ref, defineComponent, nextTick, watch } from 'vue';
  77. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  78. import * as echarts from 'echarts';
  79. import api from '/@/api/loopSupervision';
  80. import apiDatahub from '/@/api/datahub';
  81. import ele from '/@/assets/img/ele.svg';
  82. import ele1 from '/@/assets/img/ele1.svg';
  83. import fire from '/@/assets/img/fire.svg';
  84. import fire1 from '/@/assets/img/fire1.svg';
  85. import map from '/@/assets/img/map.svg';
  86. import map1 from '/@/assets/img/map1.svg';
  87. import water from '/@/assets/img/water.svg';
  88. import water1 from '/@/assets/img/water1.svg';
  89. import { useRoute, useRouter } from 'vue-router';
  90. import { useStore } from '/@/store/index';
  91. let global: any = {
  92. homeCharThree: null,
  93. dispose: [null, '', undefined],
  94. };
  95. export default defineComponent({
  96. name: 'deviceproduct',
  97. setup() {
  98. const addDicRef = ref();
  99. const loading = ref(false);
  100. const editDicRef = ref();
  101. const queryRef = ref();
  102. const homeLineRef = ref();
  103. const router = useRouter();
  104. const route = useRoute();
  105. const store = useStore();
  106. const tabName = ref(0);
  107. const unitMap = ref<any>({});
  108. // 统计信息的单位的字典
  109. apiDatahub.template.getDictData({ DictType: 'overview_unit' }).then((res: any) => {
  110. res.values.forEach((v: any) => {
  111. unitMap.value[v.value] = v.key;
  112. });
  113. });
  114. const state = reactive({
  115. dataOne: [
  116. {
  117. icon: map,
  118. iconDark: map1,
  119. title: '供热面积',
  120. contentTitle1: '联网面积',
  121. val1: '0',
  122. unit1: '㎡',
  123. contentTitle2: '实供面积',
  124. val2: '0',
  125. unit2: '㎡',
  126. contentTitle3: '供热率',
  127. val3: '',
  128. unit3: '',
  129. },
  130. {
  131. icon: fire,
  132. iconDark: fire1,
  133. title: '热量',
  134. contentTitle1: '总耗热',
  135. val1: '0',
  136. unit1: 'GJ',
  137. contentTitle2: '总单耗',
  138. val2: '0',
  139. unit2: 'GJ/㎡',
  140. contentTitle3: '供热负荷',
  141. val3: '-',
  142. unit3: 'W',
  143. },
  144. {
  145. icon: ele,
  146. iconDark: ele1,
  147. title: '负荷',
  148. contentTitle1: '供热负荷',
  149. val1: '0',
  150. unit1: 'KW.h',
  151. contentTitle2: '平均供热负荷',
  152. val2: '0',
  153. unit2: 'KW.h/㎡',
  154. },
  155. {
  156. icon: water,
  157. iconDark: water1,
  158. title: '水量',
  159. contentTitle1: '总耗水',
  160. val1: '0',
  161. unit1: 'T',
  162. contentTitle2: '总单耗',
  163. val2: '0',
  164. unit2: 'T/㎡',
  165. },
  166. ],
  167. lineName: '环路监测',
  168. myCharts: [],
  169. charts: {
  170. theme: '',
  171. bgColor: '',
  172. color: '#303133',
  173. },
  174. searchParams: {
  175. name: '',
  176. },
  177. xAxisData: [],
  178. inTemperature1Echart: [], // 供水温度
  179. inTemperature2Echart: [],
  180. outTemperature1Echart: [],
  181. outTemperature2Echart: [],
  182. inPressure1Echart: [],
  183. inPressure2Echart: [],
  184. outPressure1Echart: [],
  185. outPressure2Echart: [],
  186. supplyWaterFlowEchart: [],
  187. secondWaterSupplyEchart: [],
  188. returnWaterFlowEchart: [],
  189. waterLossEchart: [],
  190. isIsDark: false,
  191. });
  192. const getNumDetail = () => {
  193. api
  194. .getLoopRegulationDetail({
  195. QueryType: 'num',
  196. types: 'loop',
  197. code: route.query.code,
  198. })
  199. .then((res: any) => {
  200. let data = res;
  201. state.dataOne[0].val1 = data.forRealArea;
  202. state.dataOne[0].val2 = data.heatingArea;
  203. state.dataOne[0].val3 = data.heatRate;
  204. state.dataOne[1].val1 = data.unitConsumptionTotal; //总热耗
  205. state.dataOne[1].val2 = data.unitConsumption; //热单耗
  206. state.dataOne[1].val3 = data.heatDemand;
  207. state.dataOne[2].val1 = data.elctricConsumptionTotal; //总电量
  208. state.dataOne[2].val2 = data.elctricConsumption; //电单耗
  209. state.dataOne[3].val1 = data.flowLossTotal; //总水量
  210. state.dataOne[3].val2 = data.flowLoss; //水量单耗
  211. });
  212. };
  213. const getChartDetail = () => {
  214. loading.value = true;
  215. api
  216. .getLoopRegulationDetail({
  217. QueryType: 'echart',
  218. types: 'loop',
  219. code: route.query.code,
  220. })
  221. .then((res: any) => {
  222. state.inTemperature1Echart = res.inTemperature1Echart.map((item: any) => item.value);
  223. state.inTemperature2Echart = res.inTemperature2Echart.map((item: any) => item.value);
  224. state.outTemperature1Echart = res.outTemperature1Echart.map((item: any) => item.value);
  225. state.outTemperature2Echart = res.outTemperature2Echart.map((item: any) => item.value);
  226. state.inPressure1Echart = res.inPressure1Echart.map((item: any) => item.value);
  227. state.inPressure2Echart = res.inPressure2Echart.map((item: any) => item.value);
  228. state.outPressure1Echart = res.outPressure1Echart.map((item: any) => item.value);
  229. state.outPressure2Echart = res.outPressure2Echart.map((item: any) => item.value);
  230. state.supplyWaterFlowEchart = res.supplyWaterFlowEchart.map((item: any) => item.value);
  231. state.secondWaterSupplyEchart = res.secondWaterSupplyEchart.map((item: any) => item.value);
  232. state.returnWaterFlowEchart = res.returnWaterFlowEchart.map((item: any) => item.value);
  233. state.waterLossEchart = res.waterLossEchart.map((item: any) => item.value);
  234. state.xAxisData = res.inTemperature1Echart.map((item: any) => item.time);
  235. nextTick(() => {
  236. initLineChart();
  237. });
  238. })
  239. .finally(() => {
  240. loading.value = false;
  241. });
  242. };
  243. const goDetail = () => {
  244. router.push({
  245. path: '/heating-monitor/loopSupervision/loopHistory',
  246. query: {
  247. code: route.query.code,
  248. },
  249. });
  250. };
  251. const jump = (iframeUrl: string) => {
  252. window.open(iframeUrl);
  253. };
  254. // 折线图
  255. const initLineChart = () => {
  256. if (!global.dispose.some((b: any) => b === global.homeCharThree)) global.homeCharThree.dispose();
  257. global.homeCharThree = <any>echarts.init(homeLineRef.value, state.charts.theme);
  258. const seriesList = [
  259. [
  260. { name: '一网供水温度', type: 'line', data: state.inTemperature1Echart },
  261. { name: '二网供水温度', type: 'line', data: state.inTemperature2Echart },
  262. { name: '一网回水温度', type: 'line', data: state.outTemperature1Echart },
  263. ],
  264. [
  265. { name: '一网供水压力', type: 'line', data: state.inPressure1Echart },
  266. { name: '二网供水压力', type: 'line', data: state.inPressure2Echart },
  267. { name: '一网回水压力', type: 'line', data: state.outPressure1Echart },
  268. { name: '二网回水压力', type: 'line', data: state.outPressure2Echart },
  269. ],
  270. [
  271. { name: '供水流量', type: 'line', data: state.supplyWaterFlowEchart },
  272. { name: '二网供水流量', type: 'line', data: state.secondWaterSupplyEchart },
  273. { name: '回水流量', type: 'line', data: state.returnWaterFlowEchart },
  274. ],
  275. [{ name: '失水量', type: 'line', data: state.waterLossEchart }],
  276. ];
  277. const units = ['°C', 'Mpa', 'T/h', 'T'];
  278. const option = {
  279. backgroundColor: state.charts.bgColor,
  280. tooltip: {},
  281. legend: {},
  282. grid: {
  283. top: 40,
  284. right: 20,
  285. bottom: 20,
  286. left: 20,
  287. containLabel: true,
  288. },
  289. xAxis: [
  290. {
  291. type: 'category',
  292. data: state.xAxisData,
  293. boundaryGap: true,
  294. axisTick: { show: false },
  295. },
  296. ],
  297. yAxis: [
  298. {
  299. type: 'value',
  300. scale: true,
  301. axisLabel: {
  302. formatter: '{value} ' + units[tabName.value],
  303. },
  304. },
  305. ],
  306. series: seriesList[tabName.value] || [],
  307. };
  308. (<any>global.homeCharThree).setOption(option);
  309. (<any>state.myCharts).push(global.homeCharThree);
  310. };
  311. // 批量设置 echarts resize
  312. const initEchartsResizeFun = () => {
  313. nextTick(() => {
  314. for (let i = 0; i < state.myCharts.length; i++) {
  315. setTimeout(() => {
  316. (<any>state.myCharts[i]).resize();
  317. }, i * 1000);
  318. }
  319. });
  320. };
  321. // 批量设置 echarts resize
  322. const initEchartsResize = () => {
  323. window.addEventListener('resize', initEchartsResizeFun);
  324. };
  325. // 监听 vuex 中是否开启深色主题
  326. watch(
  327. () => store.state.themeConfig.themeConfig.isIsDark,
  328. (isIsDark) => {
  329. nextTick(() => {
  330. state.charts.theme = isIsDark ? 'dark' : '';
  331. state.charts.bgColor = isIsDark ? 'transparent' : '';
  332. state.charts.color = isIsDark ? '#dadada' : '#303133';
  333. setTimeout(() => {
  334. initLineChart();
  335. }, 500);
  336. });
  337. },
  338. {
  339. deep: true,
  340. immediate: true,
  341. }
  342. );
  343. // 页面加载时
  344. onMounted(() => {
  345. getNumDetail();
  346. getChartDetail();
  347. initEchartsResize();
  348. // 获取布局配置信息
  349. state.isIsDark = store.state.themeConfig.themeConfig.isIsDark;
  350. });
  351. /** 重置按钮操作 */
  352. const resetQuery = (formEl: FormInstance | undefined) => {
  353. if (!formEl) return;
  354. formEl.resetFields();
  355. // typeList();
  356. };
  357. return {
  358. unitMap,
  359. jump,
  360. loading,
  361. initLineChart,
  362. tabName,
  363. addDicRef,
  364. editDicRef,
  365. queryRef,
  366. homeLineRef,
  367. ...toRefs(state),
  368. resetQuery,
  369. goDetail,
  370. };
  371. },
  372. });
  373. </script>
  374. <style lang="scss" scoped>
  375. $homeNavLengh: 8;
  376. .iframe-wrapper {
  377. position: relative;
  378. .jump {
  379. position: absolute;
  380. top: 24px;
  381. right: 12px;
  382. z-index: 10;
  383. cursor: pointer;
  384. img {
  385. width: 40px;
  386. height: 40px;
  387. display: block;
  388. }
  389. }
  390. }
  391. .home-card-one {
  392. @for $i from 0 through 3 {
  393. .home-one-animation#{$i} {
  394. opacity: 0;
  395. animation-name: error-num;
  396. animation-duration: 0.5s;
  397. animation-fill-mode: forwards;
  398. animation-delay: calc($i/10) + s;
  399. }
  400. }
  401. }
  402. .home-card-one .home-card-item {
  403. width: 100%;
  404. border-radius: 4px;
  405. transition: all ease 0.3s;
  406. overflow: hidden;
  407. background: var(--el-color-white);
  408. color: var(--el-text-color-primary);
  409. border: 1px solid var(--next-border-color-light);
  410. &:hover {
  411. box-shadow: 0 2px 12px var(--next-color-dark-hover);
  412. transition: all ease 0.3s;
  413. }
  414. &.p20 {
  415. padding: 20px;
  416. }
  417. .item-header {
  418. display: flex;
  419. justify-content: center;
  420. align-content: center;
  421. color: #101010;
  422. padding: 10px 0;
  423. border-bottom: 1px solid var(--next-border-color-light);
  424. font-size: 20px;
  425. font-weight: bold;
  426. img {
  427. margin-right: 32px;
  428. width: 24px;
  429. height: 24px;
  430. margin-top: 3px;
  431. }
  432. }
  433. .item-content {
  434. padding: 26px;
  435. p {
  436. display: flex;
  437. justify-content: space-between;
  438. align-content: center;
  439. span:nth-child(1) {
  440. // padding-top: 4px;
  441. line-height: 33px;
  442. font-size: 14px;
  443. }
  444. span:nth-child(2) {
  445. color: #101010;
  446. font-weight: bold;
  447. font-size: 22px;
  448. }
  449. }
  450. p:nth-child(2),
  451. p:nth-child(3) {
  452. margin-top: 5px;
  453. }
  454. }
  455. &-title {
  456. font-size: 15px;
  457. font-weight: bold;
  458. height: 30px;
  459. align-items: center;
  460. }
  461. }
  462. </style>