loopDetail.vue 17 KB

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