index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="system-dic-container">
  3. <el-card shadow="hover">
  4. <div class="system-user-search mb15">
  5. <el-form :model="searchParams" ref="queryRef" :inline="true" label-width="120px">
  6. <el-form-item label="环路名称" prop="plotId">
  7. <el-select v-model="searchParams.plotId" placeholder="选择环路名称" filterable clearable size="default">
  8. <el-option
  9. v-for="item in []"
  10. :key="item.id"
  11. :label="item.name"
  12. :value="item.id">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="负责人" prop="plotId">
  17. <el-select v-model="searchParams.plotId" placeholder="选择负责人" filterable clearable size="default">
  18. <el-option
  19. v-for="item in []"
  20. :key="item.id"
  21. :label="item.name"
  22. :value="item.id">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button size="default" type="primary" class="ml10" @click="queryList">
  28. <el-icon>
  29. <ele-Search />
  30. </el-icon>
  31. 查询
  32. </el-button>
  33. <el-button size="default" @click="resetQuery(queryRef)">
  34. <el-icon>
  35. <ele-Refresh />
  36. </el-icon>
  37. 重置
  38. </el-button>
  39. <el-button size="default" type="success" class="ml10" @click="onOpenDialog()">
  40. <el-icon>
  41. <ele-FolderAdd />
  42. </el-icon>
  43. 导入
  44. </el-button>
  45. </el-form-item>
  46. </el-form>
  47. </div>
  48. <div class="title">环路数据统计</div>
  49. <el-table :data="[]" style="width: 100%" >
  50. <el-table-column type="index" label="序号" align="center" width="60" />
  51. <el-table-column label="环路名称" prop="name" />
  52. <el-table-column label="区域负责人" prop="number" />
  53. <el-table-column label="总热耗" prop="number" />
  54. <el-table-column label="热单耗" prop="number" />
  55. <el-table-column label="总耗电" prop="number" />
  56. <el-table-column label="电单耗" prop="number" />
  57. <el-table-column label="总耗水" prop="number" />
  58. <el-table-column label="水单耗" prop="number" />
  59. </el-table>
  60. <div class="title mt20">能耗红榜</div>
  61. <div class="chart-grid">
  62. <div style="height: 250px" ref="redChartOneRef"></div>
  63. <div style="height: 250px" ref="redChartTwoRef"></div>
  64. <div style="height: 250px" ref="redChartThreeRef"></div>
  65. </div>
  66. <div class="title mt20">能耗黑榜</div>
  67. <div class="chart-grid">
  68. <div style="height: 250px" ref="blackChartOneRef"></div>
  69. <div style="height: 250px" ref="blackChartTwoRef"></div>
  70. <div style="height: 250px" ref="blackChartThreeRef"></div>
  71. </div>
  72. </el-card>
  73. </div>
  74. </template>
  75. <script lang="ts" setup>
  76. import { toRefs, reactive, onMounted, ref, watch, nextTick } from 'vue';
  77. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  78. import * as echarts from 'echarts';
  79. import { useStore } from '/@/store/index';
  80. import api from '/@/api/heatingDistrict';
  81. import heatApi from '/@/api/heatStation';
  82. let global: any = {
  83. redChartOneRef: null,
  84. redChartTwoRef: null,
  85. redChartThreeRef: null,
  86. blackChartOneRef: null,
  87. blackChartTwoRef: null,
  88. blackChartThreeRef: null,
  89. dispose: [null, '', undefined],
  90. };
  91. const queryRef = ref();
  92. const redChartOneRef = ref();
  93. const redChartTwoRef = ref();
  94. const redChartThreeRef = ref();
  95. const blackChartOneRef = ref();
  96. const blackChartTwoRef = ref();
  97. const blackChartThreeRef = ref();
  98. const searchParams = ref({
  99. })
  100. const store = useStore();
  101. const state = reactive({
  102. myCharts: [],
  103. charts: {
  104. theme: '',
  105. bgColor: '',
  106. color: '#303133',
  107. },
  108. heatList: []
  109. });
  110. const queryTree = () => {
  111. heatApi.heatStation.getList({
  112. name: '',
  113. code: '',
  114. status: -1
  115. })
  116. .then((res: any) => {
  117. state.heatList = res || [];
  118. });
  119. };
  120. // 页面加载时
  121. onMounted(() => {
  122. queryTree()
  123. });
  124. /** 重置按钮操作 */
  125. const resetQuery = (formEl: FormInstance | undefined) => {
  126. if (!formEl) return;
  127. formEl.resetFields();
  128. // queryList();
  129. };
  130. let chartArr = [
  131. { globalKey: 'redChartOneRef', refKey: redChartOneRef },
  132. { globalKey: 'redChartTwoRef', refKey: redChartTwoRef },
  133. { globalKey: 'redChartThreeRef', refKey: redChartThreeRef },
  134. { globalKey: 'blackChartOneRef', refKey: blackChartOneRef },
  135. { globalKey: 'blackChartTwoRef', refKey: blackChartTwoRef },
  136. { globalKey: 'blackChartThreeRef', refKey: blackChartThreeRef }
  137. ]
  138. const initChart = () => {
  139. chartArr.forEach((item) => {
  140. initBarChart(item.globalKey, item.refKey)
  141. })
  142. }
  143. // 初始化图表
  144. const initBarChart = (gk: string, refKey: any) => {
  145. if (!global.dispose.some((b: any) => b === global[gk])) global[gk].dispose();
  146. global[gk] = <any>echarts.init(refKey.value, state.charts.theme);
  147. const option = {
  148. tooltip: {
  149. trigger: 'axis',
  150. axisPointer: {
  151. type: 'shadow'
  152. }
  153. },
  154. legend: {},
  155. grid: {
  156. left: '3%',
  157. right: '4%',
  158. bottom: '3%',
  159. containLabel: true
  160. },
  161. xAxis: [
  162. {
  163. type: 'category',
  164. data: ['换热站1', '换热站2', '换热站3', '换热站4', '换热站5', '换热站6', '换热站7']
  165. }
  166. ],
  167. yAxis: [
  168. {
  169. type: 'value'
  170. }
  171. ],
  172. series: [
  173. {
  174. name: '供水流量',
  175. type: 'bar',
  176. emphasis: {
  177. focus: 'series'
  178. },
  179. data: [320, 332, 301, 334, 390, 330, 320]
  180. }
  181. ]
  182. };
  183. (<any>global[gk]).setOption(option);
  184. (<any>state.myCharts).push(global[gk]);
  185. }
  186. // 批量设置 echarts resize
  187. const initEchartsResizeFun = () => {
  188. nextTick(() => {
  189. for (let i = 0; i < state.myCharts.length; i++) {
  190. setTimeout(() => {
  191. (<any>state.myCharts[i]).resize();
  192. }, i * 1000);
  193. }
  194. });
  195. };
  196. // 批量设置 echarts resize
  197. const initEchartsResize = () => {
  198. window.addEventListener('resize', initEchartsResizeFun);
  199. };
  200. // 页面加载时
  201. onMounted(() => {
  202. initEchartsResize();
  203. });
  204. // 监听 vuex 中是否开启深色主题
  205. watch(
  206. () => store.state.themeConfig.themeConfig.isIsDark,
  207. (isIsDark) => {
  208. nextTick(() => {
  209. state.charts.theme = isIsDark ? 'dark' : '';
  210. state.charts.bgColor = isIsDark ? 'transparent' : '';
  211. state.charts.color = isIsDark ? '#dadada' : '#303133';
  212. setTimeout(() => {
  213. initChart();
  214. }, 500)
  215. });
  216. },
  217. {
  218. deep: true,
  219. immediate: true,
  220. }
  221. );
  222. </script>
  223. <style lang="scss" scoped>
  224. .title {
  225. font-size: 16px;
  226. font-weight: bold;
  227. }
  228. .chart-grid {
  229. display: grid;
  230. grid-template-columns: repeat(3, 1fr);
  231. grid-column-gap: 10px;
  232. }
  233. .mt20 {
  234. margin-top: 20px;
  235. }
  236. </style>