loopDetail.vue 13 KB

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