index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div class="energy-statistics">
  3. <el-card shadow="never" class="statistics-card">
  4. <!-- 主内容区 -->
  5. <ele-split-layout
  6. width="220px"
  7. allow-collapse
  8. :right-style="{ overflow: 'hidden' }"
  9. >
  10. <!-- 左侧树形菜单 -->
  11. <left-sidebar
  12. ref="leftSidebarRef"
  13. :active-tab.sync="activeTab"
  14. @tab-change="activeTabChange"
  15. @node-click="handleNodeClick"
  16. @first-node="handleFirstNode"
  17. />
  18. <!-- 右侧内容区 -->
  19. <template v-slot:content>
  20. <div class="right-content">
  21. <!-- 搜索区域 -->
  22. <div class="search-area">
  23. <seek-page
  24. :seekList="seekList"
  25. @search="handleSearch"
  26. @reset="handleReset"
  27. :maxLength="4"
  28. style="flex: 1"
  29. ></seek-page>
  30. </div>
  31. <!-- 列表视图 -->
  32. <div class="list-view">
  33. <ele-pro-table
  34. ref="table"
  35. row-key="id"
  36. :columns="columns"
  37. :datasource="datasource"
  38. :cache-key="cacheKeyUrl"
  39. :initLoad="false"
  40. autoAmendPage
  41. height="calc(100vh - 300px)"
  42. >
  43. <template v-slot:type="{ row }">
  44. {{ getTypeText(row.type) }}
  45. </template>
  46. <template v-slot:energyType="{ row }">
  47. {{ getEnergyTypeText(row.energyType) }}
  48. </template>
  49. <template v-slot:timeRange="{ row }">
  50. {{ row.startTime }} 至 {{ row.endTime }}
  51. </template>
  52. <template v-slot:action="{ row }">
  53. <el-link
  54. type="primary"
  55. :underline="false"
  56. @click="handleView(row)"
  57. >
  58. 查看
  59. </el-link>
  60. </template>
  61. </ele-pro-table>
  62. </div>
  63. </div>
  64. </template>
  65. </ele-split-layout>
  66. </el-card>
  67. </div>
  68. </template>
  69. <script>
  70. import dictMixins from '@/mixins/dictMixins';
  71. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  72. import { getPage } from '@/api/energyConsumptionStatistics/index.js';
  73. import { energyConsumingUnitList } from '@/enum/dict.js';
  74. import LeftSidebar from './components/LeftSidebar.vue';
  75. export default {
  76. mixins: [dictMixins, tableColumnsMixin],
  77. components: {
  78. LeftSidebar
  79. },
  80. data() {
  81. return {
  82. // 搜索表单
  83. searchForm: {
  84. energyType: '',
  85. meterType: '',
  86. keyword: '',
  87. timeRange: []
  88. },
  89. // 当前激活的标签页
  90. activeTab: 'org',
  91. areaId: '',
  92. categoryLevelId: '',
  93. substanceId: '',
  94. // 表格列配置
  95. columns: [
  96. {
  97. columnKey: 'index',
  98. label: '序号',
  99. type: 'index',
  100. width: 55,
  101. align: 'center',
  102. fixed: 'left'
  103. },
  104. {
  105. prop: 'substanceCode',
  106. label: '表计设备编码',
  107. align: 'center',
  108. minWidth: 150,
  109. showOverflowTooltip: true
  110. },
  111. {
  112. prop: 'substanceName',
  113. label: '表计设备名称',
  114. align: 'center',
  115. minWidth: 150,
  116. showOverflowTooltip: true
  117. },
  118. {
  119. prop: 'meterEquipmentNumber',
  120. label: '表计设备编号',
  121. align: 'center',
  122. minWidth: 150,
  123. showOverflowTooltip: true
  124. },
  125. {
  126. prop: 'meterType',
  127. label: '表计类型',
  128. align: 'center',
  129. minWidth: 100,
  130. formatter: (_row, _column, cellValue) => {
  131. return this.getDictValue('表计类型', _row.meterType);
  132. },
  133. showOverflowTooltip: true
  134. },
  135. {
  136. prop: 'correlationSubstanceName',
  137. label: '关联设备',
  138. align: 'center',
  139. minWidth: 120,
  140. showOverflowTooltip: true
  141. },
  142. {
  143. prop: 'areaName',
  144. label: '区域',
  145. align: 'center',
  146. minWidth: 150,
  147. showOverflowTooltip: true
  148. },
  149. {
  150. prop: 'energyClassificationName',
  151. label: '用能分类',
  152. align: 'center',
  153. minWidth: 100,
  154. showOverflowTooltip: true
  155. },
  156. {
  157. prop: 'energyTypeName',
  158. label: '能源名称',
  159. align: 'center',
  160. minWidth: 120,
  161. showOverflowTooltip: true
  162. },
  163. {
  164. prop: 'meterReadingMethod',
  165. label: '数据来源',
  166. align: 'center',
  167. formatter: (_row, _column, cellValue) => {
  168. return _row.meterReadingMethod == 1 ? '手动录入' : '自动采集';
  169. },
  170. minWidth: 120,
  171. showOverflowTooltip: true
  172. },
  173. {
  174. prop: 'lastMeterReadingTime',
  175. label: '上期抄表时间',
  176. align: 'center',
  177. minWidth: 180,
  178. showOverflowTooltip: true
  179. },
  180. {
  181. prop: 'currentMeterReadingTime',
  182. label: '本期抄表时间',
  183. align: 'center',
  184. minWidth: 180,
  185. showOverflowTooltip: true
  186. },
  187. {
  188. prop: 'currentUsage',
  189. label: '本期用量',
  190. align: 'center',
  191. minWidth: 120,
  192. showOverflowTooltip: true
  193. },
  194. {
  195. prop: 'unit',
  196. label: '单位',
  197. align: 'center',
  198. minWidth: 80,
  199. showOverflowTooltip: true
  200. },
  201. {
  202. prop: 'unitPrice',
  203. label: '单价',
  204. align: 'center',
  205. minWidth: 80,
  206. showOverflowTooltip: true
  207. },
  208. {
  209. prop: 'total',
  210. label: '价格单位',
  211. align: 'center',
  212. minWidth: 120,
  213. formatter: (row) => {
  214. return energyConsumingUnitList
  215. .find((item) => item.value == row.energyClassificationCode)
  216. ?.priceUnit.find((item) => item.value == row.priceUnit)?.label;
  217. },
  218. showOverflowTooltip: true
  219. },
  220. {
  221. prop: 'currentExpenses',
  222. label: '本期费用(元',
  223. align: 'center',
  224. minWidth: 130,
  225. showOverflowTooltip: true
  226. }
  227. ],
  228. cacheKeyUrl: 'ems-energy-statistics-list'
  229. };
  230. },
  231. computed: {
  232. seekList() {
  233. return [
  234. {
  235. label: '关键词',
  236. value: 'keyword',
  237. type: 'input',
  238. placeholder: '表计编码、名称、编号'
  239. },
  240. {
  241. label: '用能分类',
  242. value: 'energyClassificationCode',
  243. type: 'select',
  244. placeholder: ' ',
  245. planList: energyConsumingUnitList
  246. },
  247. {
  248. label: '抄表方式',
  249. value: 'meterReadingMethod',
  250. type: 'select',
  251. placeholder: ' ',
  252. planList: [
  253. { label: '自动采集', value: 0 },
  254. { label: '手动录入', value: 1 }
  255. ]
  256. },
  257. {
  258. label: '抄表时间',
  259. value: 'createTime',
  260. type: 'date',
  261. width: 300,
  262. valueAr: [
  263. 'currentMeterReadingTimeStart',
  264. 'currentMeterReadingTimeEnd'
  265. ]
  266. }
  267. ];
  268. }
  269. },
  270. created() {
  271. // 数据在 LeftSidebar 组件内部获取
  272. },
  273. methods: {
  274. activeTabChange() {
  275. this.categoryLevelId = '';
  276. this.areaId = '';
  277. this.substanceId = '';
  278. // Tab切换时重置条件,由用户手动选择节点或使用默认
  279. this.$refs.table.reload({ page: 1 });
  280. },
  281. // 处理第一个节点(由 LeftSidebar 组件加载完成后触发)
  282. handleFirstNode(data) {
  283. this.handleNodeClick(data);
  284. },
  285. // 搜索
  286. handleSearch(where) {
  287. this.searchForm = { ...where };
  288. this.$refs.table.reload({ page: 1 });
  289. },
  290. // 重置
  291. handleReset() {
  292. this.searchForm = {
  293. energyType: '',
  294. meterType: '',
  295. keyword: '',
  296. timeRange: []
  297. };
  298. this.$refs.table.reload({ page: 1 });
  299. },
  300. // 树节点点击
  301. handleNodeClick(data) {
  302. this.categoryLevelId = '';
  303. this.substanceId = '';
  304. this.areaId = '';
  305. if (this.activeTab == 'org') {
  306. if (data.nodeType == 'instance') {
  307. this.substanceId = data.id;
  308. } else {
  309. this.categoryLevelId = data.id;
  310. }
  311. } else {
  312. this.areaId = data.id;
  313. }
  314. this.$refs.table.reload({ page: 1 });
  315. },
  316. // 表格数据源
  317. async datasource({ page, limit, where }) {
  318. return await getPage({
  319. pageNum: page,
  320. size: limit,
  321. ...where,
  322. ...this.searchForm,
  323. areaId: this.areaId,
  324. categoryLevelId: this.categoryLevelId,
  325. substanceId:this.substanceId
  326. });
  327. }
  328. }
  329. };
  330. </script>
  331. <style lang="scss" scoped>
  332. .energy-statistics {
  333. .statistics-card {
  334. height: calc(100vh - 100px);
  335. ::v-deep .el-card__body {
  336. height: 100%;
  337. padding: 15px;
  338. }
  339. }
  340. ::v-deep .ele-split-layout {
  341. .ele-split-layout-left {
  342. padding: 0;
  343. background: transparent;
  344. border: none;
  345. }
  346. .ele-split-layout-right {
  347. padding: 0;
  348. }
  349. .ele-split-layout-trigger {
  350. width: 8px;
  351. background: #f0f0f0;
  352. border-left: 1px solid #e0e0e0;
  353. border-right: 1px solid #e0e0e0;
  354. &:hover {
  355. background: #d0d0d0;
  356. }
  357. .ele-split-layout-trigger-icon {
  358. color: #909399;
  359. }
  360. }
  361. }
  362. .left-sidebar {
  363. height: 100%;
  364. ::v-deep .el-tabs--border-card {
  365. box-shadow: none;
  366. border: 1px solid #ebeef5;
  367. height: 100%;
  368. .el-tabs__header {
  369. background-color: #f5f7fa;
  370. border-bottom: 1px solid #ebeef5;
  371. margin: 0;
  372. .el-tabs__nav {
  373. width: 100%;
  374. display: flex;
  375. }
  376. .el-tabs__item {
  377. flex: 1;
  378. height: 39px;
  379. line-height: 39px;
  380. font-size: 13px;
  381. padding: 0;
  382. text-align: center;
  383. &.is-active {
  384. background-color: #fff;
  385. border-bottom-color: #fff;
  386. }
  387. }
  388. }
  389. .el-tabs__content {
  390. padding: 10px;
  391. height: calc(100% - 40px);
  392. overflow-y: auto;
  393. }
  394. }
  395. ::v-deep .el-tree {
  396. padding: 0;
  397. }
  398. }
  399. .right-content {
  400. flex: 1;
  401. min-width: 0;
  402. padding-left: 15px;
  403. .search-area {
  404. display: flex;
  405. justify-content: space-between;
  406. align-items: center;
  407. margin-bottom: 10px;
  408. padding-bottom: 10px;
  409. border-bottom: 1px solid #ebeef5;
  410. }
  411. .list-view {
  412. ::v-deep .ele-pro-table {
  413. .el-table {
  414. border: 1px solid #ebeef5;
  415. border-radius: 4px;
  416. }
  417. }
  418. }
  419. }
  420. }
  421. </style>