index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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="heatStaId">
  17. <el-tree-select
  18. v-model="searchParams.heatStaId"
  19. :data="state.heatList"
  20. :props="{
  21. label: 'name',
  22. children: 'children'
  23. }"
  24. node-key="id"
  25. :clearable="true"
  26. check-strictly
  27. size="default"
  28. style="width: 100%;"
  29. placeholder="请选择"
  30. :render-after-expand="true"
  31. />
  32. </el-form-item>
  33. <el-form-item label="负责人" prop="plotId">
  34. <el-select v-model="searchParams.plotId" placeholder="选择负责人" filterable clearable size="default">
  35. <el-option
  36. v-for="item in []"
  37. :key="item.id"
  38. :label="item.name"
  39. :value="item.id">
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="时间间隔(秒)" prop="plotId">
  44. <el-input-number v-model="searchParams.xx"></el-input-number>
  45. </el-form-item>
  46. <el-form-item label="流量限值" prop="plotId">
  47. <el-input-number v-model="searchParams.xx"></el-input-number>
  48. </el-form-item>
  49. <el-form-item>
  50. <el-button size="default" type="primary" class="ml10" @click="queryList">
  51. <el-icon>
  52. <ele-Search />
  53. </el-icon>
  54. 查询
  55. </el-button>
  56. <el-button size="default" @click="resetQuery(queryRef)">
  57. <el-icon>
  58. <ele-Refresh />
  59. </el-icon>
  60. 重置
  61. </el-button>
  62. <el-button size="default" type="success" class="ml10" @click="onOpenDialog()">
  63. <el-icon>
  64. <ele-FolderAdd />
  65. </el-icon>
  66. 导入
  67. </el-button>
  68. </el-form-item>
  69. </el-form>
  70. </div>
  71. <div style="height: 300px" ref="barChartRef"></div>
  72. <div style="height: 300px" ref="lineChartRef"></div>
  73. </el-card>
  74. </div>
  75. </template>
  76. <script lang="ts" setup>
  77. import { toRefs, reactive, onMounted, ref, watch, nextTick } from 'vue';
  78. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  79. import * as echarts from 'echarts';
  80. import { useStore } from '/@/store/index';
  81. import api from '/@/api/heatingDistrict';
  82. import heatApi from '/@/api/heatStation';
  83. let global: any = {
  84. barChart: null,
  85. lineChart: null,
  86. dispose: [null, '', undefined],
  87. };
  88. const queryRef = ref();
  89. const barChartRef = ref();
  90. const lineChartRef = ref();
  91. const searchParams = ref({
  92. })
  93. const store = useStore();
  94. const state = reactive({
  95. myCharts: [],
  96. charts: {
  97. theme: '',
  98. bgColor: '',
  99. color: '#303133',
  100. },
  101. heatList: []
  102. });
  103. const queryTree = () => {
  104. heatApi.heatStation.getList({
  105. name: '',
  106. code: '',
  107. status: -1
  108. })
  109. .then((res: any) => {
  110. state.heatList = res || [];
  111. });
  112. };
  113. // 页面加载时
  114. onMounted(() => {
  115. queryTree()
  116. });
  117. /** 重置按钮操作 */
  118. const resetQuery = (formEl: FormInstance | undefined) => {
  119. if (!formEl) return;
  120. formEl.resetFields();
  121. // queryList();
  122. };
  123. // 初始化图表
  124. const initBarChart = () => {
  125. if (!global.dispose.some((b: any) => b === global.barChart)) global.barChart.dispose();
  126. global.barChart = <any>echarts.init(barChartRef.value, state.charts.theme);
  127. const option = {
  128. tooltip: {
  129. trigger: 'axis',
  130. axisPointer: {
  131. type: 'shadow'
  132. }
  133. },
  134. legend: {},
  135. grid: {
  136. left: '3%',
  137. right: '4%',
  138. bottom: '3%',
  139. containLabel: true
  140. },
  141. xAxis: [
  142. {
  143. type: 'category',
  144. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  145. }
  146. ],
  147. yAxis: [
  148. {
  149. type: 'value'
  150. }
  151. ],
  152. series: [
  153. {
  154. name: '供水流量',
  155. type: 'bar',
  156. emphasis: {
  157. focus: 'series'
  158. },
  159. data: [320, 332, 301, 334, 390, 330, 320]
  160. },
  161. {
  162. name: '回水流量',
  163. type: 'bar',
  164. stack: 'Ad',
  165. emphasis: {
  166. focus: 'series'
  167. },
  168. data: [120, 132, 101, 134, 90, 230, 210]
  169. }
  170. ]
  171. };
  172. (<any>global.barChart).setOption(option);
  173. (<any>state.myCharts).push(global.barChart);
  174. }
  175. // 初始化图标
  176. const initLineChart = () => {
  177. if (!global.dispose.some((b: any) => b === global.lineChart)) global.lineChart.dispose();
  178. global.lineChart = <any>echarts.init(lineChartRef.value, state.charts.theme);
  179. const option = {
  180. backgroundColor: state.charts.bgColor,
  181. grid: { top: 70, right: 20, bottom: 30, left: 30 },
  182. tooltip: { trigger: 'axis' },
  183. legend: { data: ['一网回水压力', '一网供水压力'] },
  184. xAxis: {
  185. data: ['环路1', '环路2', '环路3', '环路4', '环路5'],
  186. },
  187. yAxis: [
  188. {
  189. type: 'value',
  190. name: '条数',
  191. splitLine: { show: true, lineStyle: { type: 'dashed', color: '#f5f5f5' } },
  192. },
  193. ],
  194. series: [
  195. {
  196. name: '一网回水压力',
  197. type: 'line',
  198. symbolSize: 6,
  199. symbol: 'circle',
  200. smooth: true,
  201. data: [41.1, 30.4, 65.1, 53.3, 53.3],
  202. lineStyle: { color: '#fe9a8b' },
  203. itemStyle: { color: '#fe9a8b', borderColor: '#fe9a8b' }
  204. },
  205. {
  206. name: '一网供水压力',
  207. type: 'line',
  208. symbolSize: 6,
  209. symbol: 'circle',
  210. smooth: true,
  211. data: [24.1, 7.2, 15.5, 42.4, 42.4],
  212. lineStyle: { color: '#9E87FF' },
  213. itemStyle: { color: '#9E87FF', borderColor: '#9E87FF' }
  214. }
  215. ]
  216. };
  217. (<any>global.lineChart).setOption(option);
  218. (<any>state.myCharts).push(global.lineChart);
  219. }
  220. // 批量设置 echarts resize
  221. const initEchartsResizeFun = () => {
  222. nextTick(() => {
  223. for (let i = 0; i < state.myCharts.length; i++) {
  224. setTimeout(() => {
  225. (<any>state.myCharts[i]).resize();
  226. }, i * 1000);
  227. }
  228. });
  229. };
  230. // 批量设置 echarts resize
  231. const initEchartsResize = () => {
  232. window.addEventListener('resize', initEchartsResizeFun);
  233. };
  234. // 页面加载时
  235. onMounted(() => {
  236. initEchartsResize();
  237. });
  238. // 监听 vuex 中是否开启深色主题
  239. watch(
  240. () => store.state.themeConfig.themeConfig.isIsDark,
  241. (isIsDark) => {
  242. nextTick(() => {
  243. state.charts.theme = isIsDark ? 'dark' : '';
  244. state.charts.bgColor = isIsDark ? 'transparent' : '';
  245. state.charts.color = isIsDark ? '#dadada' : '#303133';
  246. setTimeout(() => {
  247. initBarChart();
  248. initLineChart();
  249. }, 500)
  250. });
  251. },
  252. {
  253. deep: true,
  254. immediate: true,
  255. }
  256. );
  257. </script>