index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="system-dic-container">
  3. <el-card shadow="hover">
  4. <div class="system-user-search mb15">
  5. <el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="90px">
  6. <el-form-item label="时间范围" prop="dateRange">
  7. <el-date-picker
  8. v-model="state.tableData.param.dateRange"
  9. size="default"
  10. style="width: 240px"
  11. value-format="YYYY-MM-DD"
  12. type="daterange"
  13. range-separator="-"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期"
  16. >
  17. </el-date-picker>
  18. </el-form-item>
  19. <el-form-item label="排序" prop="sort">
  20. <el-select v-model="state.tableData.param.sort" placeholder="按照选择进行排名" filterable clearable size="default">
  21. <el-option label="总耗热" :value="1" />
  22. <el-option label="热单耗" :value="2" />
  23. <el-option label="总耗水" :value="5" />
  24. <el-option label="水单耗" :value="6" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="排序方式" prop="isdesc">
  28. <el-select v-model="state.tableData.param.isdesc" placeholder="按照选择进行排名" filterable clearable size="default">
  29. <el-option label="正序" :value="2" />
  30. <el-option label="倒序" :value="1" />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="换热站名称" prop="stationName">
  34. <el-input v-model="state.tableData.param.stationName" placeholder="输入" clearable size="default"> </el-input>
  35. </el-form-item>
  36. <el-form-item label="环路名称" prop="loopName">
  37. <el-input v-model="state.tableData.param.loopName" placeholder="输入" clearable size="default"> </el-input>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button size="default" type="primary" v-auth="'query'" class="ml10" @click="queryList">
  41. <el-icon>
  42. <ele-Search />
  43. </el-icon>
  44. 查询
  45. </el-button>
  46. <el-button size="default" v-auth="'reset'" @click="resetQuery(queryRef)">
  47. <el-icon>
  48. <ele-Refresh />
  49. </el-icon>
  50. 重置
  51. </el-button>
  52. <el-button size="default" v-auth="'reset'" @click="exportData()">
  53. <el-icon>
  54. <ele-Download />
  55. </el-icon>
  56. 导出
  57. </el-button>
  58. <!-- <el-button size="default" type="success" class="ml10" @click="onOpenDialog()">
  59. <el-icon>
  60. <ele-FolderAdd />
  61. </el-icon>
  62. 导入
  63. </el-button> -->
  64. </el-form-item>
  65. </el-form>
  66. </div>
  67. <div class="title">环路数据统计</div>
  68. <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
  69. <el-table-column type="index" label="序号" align="center" width="60" />
  70. <el-table-column label="环路名称" prop="huanLuName" />
  71. <el-table-column label="所属换热站" prop="stationName" />
  72. <el-table-column :label="`总热耗(${unitMap['单日总热耗单位']})`" prop="unitConsumptionTotal" />
  73. <el-table-column :label="`热单耗(${unitMap['单日供热单耗']})`" prop="unitConsumption" />
  74. <el-table-column :label="`总耗电(${unitMap['单日总电耗']})`" prop="elctricConsumptionTotal" />
  75. <el-table-column :label="`电单耗(${unitMap['单日用电单耗']})`" prop="elctricConsumption" />
  76. <el-table-column :label="`总耗水(${unitMap['日总水耗单位']})`" prop="flowLossTotal" />
  77. <el-table-column :label="`水单耗(${unitMap['日失水单耗']})`" prop="flowLoss" />
  78. <el-table-column :label="`供热负荷(${unitMap['供热负荷']})`" prop="unitConsumptionDemand" />
  79. <el-table-column :label="`供电负荷(${unitMap['供电负荷']})`" min-width="100" prop="elctricConsumptionDemand" />
  80. <el-table-column :label="`失水量(${unitMap['失水量']})`" prop="flowLossDemand" />
  81. </el-table>
  82. <pagination
  83. v-show="state.tableData.total > 0"
  84. :total="state.tableData.total"
  85. v-model:page="state.tableData.param.pageNum"
  86. v-model:limit="state.tableData.param.pageSize"
  87. @pagination="queryList"
  88. />
  89. <!-- <div class="title mt20">能耗红榜</div>
  90. <div class="chart-grid">
  91. <div style="height: 250px" ref="redChartOneRef"></div>
  92. <div style="height: 250px" ref="redChartTwoRef"></div>
  93. <div style="height: 250px" ref="redChartThreeRef"></div>
  94. </div>
  95. <div class="title mt20">能耗黑榜</div>
  96. <div class="chart-grid">
  97. <div style="height: 250px" ref="blackChartOneRef"></div>
  98. <div style="height: 250px" ref="blackChartTwoRef"></div>
  99. <div style="height: 250px" ref="blackChartThreeRef"></div>
  100. </div> -->
  101. </el-card>
  102. </div>
  103. </template>
  104. <script lang="ts" setup>
  105. import { reactive, onMounted, ref, watch, nextTick } from 'vue';
  106. import { FormInstance } from 'element-plus';
  107. import * as echarts from 'echarts';
  108. import { useStore } from '/@/store/index';
  109. import energyApi from '/@/api/energyAnalysis';
  110. import heatApi from '/@/api/heatStation';
  111. import downloadFile from '/@/utils/download';
  112. import apiDatahub from '/@/api/datahub';
  113. let global: any = {
  114. redChartOneRef: null,
  115. redChartTwoRef: null,
  116. redChartThreeRef: null,
  117. blackChartOneRef: null,
  118. blackChartTwoRef: null,
  119. blackChartThreeRef: null,
  120. dispose: [null, '', undefined],
  121. };
  122. const unitMap = ref<any>({});
  123. // 统计信息的单位的字典
  124. apiDatahub.template.getDictData({ DictType: 'overview_unit' }).then((res: any) => {
  125. res.values.forEach((v: any) => {
  126. unitMap.value[v.value] = v.key;
  127. });
  128. });
  129. const queryRef = ref();
  130. const redChartOneRef = ref();
  131. const redChartTwoRef = ref();
  132. const redChartThreeRef = ref();
  133. const blackChartOneRef = ref();
  134. const blackChartTwoRef = ref();
  135. const blackChartThreeRef = ref();
  136. const store = useStore();
  137. const state = reactive({
  138. myCharts: [],
  139. charts: {
  140. theme: '',
  141. bgColor: '',
  142. color: '#303133',
  143. },
  144. heatList: [],
  145. tableData: {
  146. data: [],
  147. loading: false,
  148. total: 0,
  149. param: {
  150. sort: 1,
  151. isdesc: 2,
  152. stationName: '',
  153. loopName: '',
  154. dateRange: [],
  155. pageNum: 1,
  156. pageSize: 10,
  157. },
  158. },
  159. });
  160. const queryTree = () => {
  161. heatApi.heatStation
  162. .getList({
  163. name: '',
  164. code: '',
  165. status: -1,
  166. })
  167. .then((res: any) => {
  168. state.heatList = res || [];
  169. });
  170. };
  171. const exportData = () => {
  172. energyApi.performanceExport(state.tableData.param).then((res: any) => {
  173. downloadFile(res, '绩效考核数据.xlsx');
  174. });
  175. };
  176. const queryList = () => {
  177. state.tableData.loading = true;
  178. energyApi.getEnergyPerformance(state.tableData.param).then((res) => {
  179. state.tableData.data = res.list || [];
  180. state.tableData.total = res.Total;
  181. state.tableData.loading = false;
  182. });
  183. };
  184. // 页面加载时
  185. onMounted(() => {
  186. // queryTree()
  187. queryList();
  188. });
  189. /** 重置按钮操作 */
  190. const resetQuery = (formEl: FormInstance | undefined) => {
  191. if (!formEl) return;
  192. formEl.resetFields();
  193. queryList();
  194. };
  195. let chartArr = [
  196. { globalKey: 'redChartOneRef', refKey: redChartOneRef },
  197. { globalKey: 'redChartTwoRef', refKey: redChartTwoRef },
  198. { globalKey: 'redChartThreeRef', refKey: redChartThreeRef },
  199. { globalKey: 'blackChartOneRef', refKey: blackChartOneRef },
  200. { globalKey: 'blackChartTwoRef', refKey: blackChartTwoRef },
  201. { globalKey: 'blackChartThreeRef', refKey: blackChartThreeRef },
  202. ];
  203. const initChart = () => {
  204. chartArr.forEach((item) => {
  205. initBarChart(item.globalKey, item.refKey);
  206. });
  207. };
  208. // 初始化图表
  209. const initBarChart = (gk: string, refKey: any) => {
  210. if (!global.dispose.some((b: any) => b === global[gk])) global[gk].dispose();
  211. global[gk] = <any>echarts.init(refKey.value, state.charts.theme);
  212. const option = {
  213. tooltip: {
  214. trigger: 'axis',
  215. axisPointer: {
  216. type: 'shadow',
  217. },
  218. },
  219. legend: {},
  220. grid: {
  221. left: '3%',
  222. right: '4%',
  223. bottom: '3%',
  224. containLabel: true,
  225. },
  226. xAxis: [
  227. {
  228. type: 'category',
  229. data: ['换热站1', '换热站2', '换热站3', '换热站4', '换热站5', '换热站6', '换热站7'],
  230. },
  231. ],
  232. yAxis: [
  233. {
  234. type: 'value',
  235. },
  236. ],
  237. series: [
  238. {
  239. name: '供水流量',
  240. type: 'bar',
  241. emphasis: {
  242. focus: 'series',
  243. },
  244. data: [320, 332, 301, 334, 390, 330, 320],
  245. },
  246. ],
  247. };
  248. (<any>global[gk]).setOption(option);
  249. (<any>state.myCharts).push(global[gk]);
  250. };
  251. // 批量设置 echarts resize
  252. const initEchartsResizeFun = () => {
  253. nextTick(() => {
  254. for (let i = 0; i < state.myCharts.length; i++) {
  255. setTimeout(() => {
  256. (<any>state.myCharts[i]).resize();
  257. }, i * 1000);
  258. }
  259. });
  260. };
  261. // 批量设置 echarts resize
  262. const initEchartsResize = () => {
  263. window.addEventListener('resize', initEchartsResizeFun);
  264. };
  265. // 页面加载时
  266. onMounted(() => {
  267. initEchartsResize();
  268. });
  269. // 监听 vuex 中是否开启深色主题
  270. watch(
  271. () => store.state.themeConfig.themeConfig.isIsDark,
  272. (isIsDark) => {
  273. nextTick(() => {
  274. state.charts.theme = isIsDark ? 'transparent' : '';
  275. state.charts.bgColor = isIsDark ? 'transparent' : '';
  276. state.charts.color = isIsDark ? '#dadada' : '#303133';
  277. setTimeout(() => {
  278. // initChart();
  279. }, 500);
  280. });
  281. },
  282. {
  283. deep: true,
  284. immediate: true,
  285. }
  286. );
  287. </script>
  288. <style lang="scss" scoped>
  289. .title {
  290. font-size: 16px;
  291. font-weight: bold;
  292. }
  293. .chart-grid {
  294. display: grid;
  295. grid-template-columns: repeat(3, 1fr);
  296. grid-column-gap: 10px;
  297. }
  298. .mt20 {
  299. margin-top: 20px;
  300. }
  301. </style>