|
|
@@ -8,36 +8,13 @@
|
|
|
:right-style="{ overflow: 'hidden' }"
|
|
|
>
|
|
|
<!-- 左侧树形菜单 -->
|
|
|
- <div class="left-sidebar">
|
|
|
- <el-tabs
|
|
|
- v-model="activeTab"
|
|
|
- type="border-card"
|
|
|
- @tab-click="activeTabChange"
|
|
|
- >
|
|
|
- <el-tab-pane label="设备类型" name="org">
|
|
|
- <el-tree
|
|
|
- :data="orgTreeData"
|
|
|
- :props="treeProps"
|
|
|
- node-key="id"
|
|
|
- highlight-current
|
|
|
- @node-click="handleNodeClick"
|
|
|
- style="height: calc(100vh - 180px)"
|
|
|
- ref="treeRef"
|
|
|
- ></el-tree>
|
|
|
- </el-tab-pane>
|
|
|
- <el-tab-pane label="用能分区" name="energy">
|
|
|
- <el-tree
|
|
|
- :data="treeData"
|
|
|
- :props="treeProps"
|
|
|
- node-key="id"
|
|
|
- default-expand-all
|
|
|
- ref="treeRef1"
|
|
|
- highlight-current
|
|
|
- @node-click="handleNodeClick"
|
|
|
- ></el-tree>
|
|
|
- </el-tab-pane>
|
|
|
- </el-tabs>
|
|
|
- </div>
|
|
|
+ <left-sidebar
|
|
|
+ ref="leftSidebarRef"
|
|
|
+ :active-tab.sync="activeTab"
|
|
|
+ @tab-change="activeTabChange"
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ @first-node="handleFirstNode"
|
|
|
+ ></left-sidebar>
|
|
|
|
|
|
<!-- 右侧内容区 -->
|
|
|
<template v-slot:content>
|
|
|
@@ -183,8 +160,7 @@
|
|
|
<script>
|
|
|
import dictMixins from '@/mixins/dictMixins';
|
|
|
import tableColumnsMixin from '@/mixins/tableColumnsMixin';
|
|
|
- import { getTreeByPid } from '@/api/classifyManage';
|
|
|
- import { basicAreaPageAPI } from '@/api/factoryModel';
|
|
|
+ import LeftSidebar from '@/views/energyConsumptionStatistics/components/LeftSidebar.vue';
|
|
|
import {
|
|
|
statByDay,
|
|
|
statByMonth,
|
|
|
@@ -197,7 +173,9 @@
|
|
|
|
|
|
export default {
|
|
|
mixins: [dictMixins, tableColumnsMixin],
|
|
|
- components: {},
|
|
|
+ components: {
|
|
|
+ LeftSidebar
|
|
|
+ },
|
|
|
props: {
|
|
|
pageName: ''
|
|
|
},
|
|
|
@@ -206,16 +184,10 @@
|
|
|
activeTab: 'org',
|
|
|
// 更新时间
|
|
|
updateTime: dayjs().format('YYYY-M-D HH:mm:ss'),
|
|
|
- // 树形数据
|
|
|
- treeData: [],
|
|
|
- orgTreeData: [],
|
|
|
- treeProps: {
|
|
|
- children: 'children',
|
|
|
- label: 'name'
|
|
|
- },
|
|
|
|
|
|
areaId: '',
|
|
|
categoryLevelId: '',
|
|
|
+ substanceId: '',
|
|
|
// 表格列配置
|
|
|
cacheKeyUrl: ` ems-collectionList-${this.pageName}-list`,
|
|
|
energyConsumingUnitList,
|
|
|
@@ -234,26 +206,6 @@
|
|
|
created() {
|
|
|
// 设置默认日期
|
|
|
this.initDefaultDate();
|
|
|
- getTreeByPid('29').then((res) => {
|
|
|
- this.orgTreeData = res.data;
|
|
|
- if (this.orgTreeData.length) {
|
|
|
- this.handleNodeClick(this.orgTreeData[0]);
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.treeRef.setCurrentKey(this.orgTreeData[0].id);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- /* 获取区域集合 */
|
|
|
- basicAreaPageAPI({
|
|
|
- pageNum: 1,
|
|
|
- size: 9999
|
|
|
- }).then((res) => {
|
|
|
- this.treeData = this.$util.toTreeData({
|
|
|
- data: res,
|
|
|
- idField: 'id',
|
|
|
- parentIdField: 'parentId'
|
|
|
- });
|
|
|
- });
|
|
|
},
|
|
|
computed: {
|
|
|
columns() {
|
|
|
@@ -422,21 +374,13 @@
|
|
|
activeTabChange() {
|
|
|
this.categoryLevelId = '';
|
|
|
this.areaId = '';
|
|
|
- if (this.activeTab == 'org') {
|
|
|
- this.categoryLevelId = this.orgTreeData[0].id;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.treeRef &&
|
|
|
- this.$refs.treeRef.setCurrentKey(this.orgTreeData[0].id);
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.areaId = this.treeData[0] ? this.treeData[0].id : '';
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.treeRef1 &&
|
|
|
- this.$refs.treeRef1.setCurrentKey(this.treeData[0].id);
|
|
|
- });
|
|
|
- }
|
|
|
+ this.substanceId = '';
|
|
|
this.$refs.table.reload({ page: 1 });
|
|
|
},
|
|
|
+ // 处理第一个节点(由 LeftSidebar 组件加载完成后触发)
|
|
|
+ handleFirstNode(data) {
|
|
|
+ this.handleNodeClick(data);
|
|
|
+ },
|
|
|
// 搜索
|
|
|
handleSearch() {
|
|
|
// 校验日期不能为空
|
|
|
@@ -474,11 +418,16 @@
|
|
|
this.$refs.table.reload({ page: 1 });
|
|
|
},
|
|
|
// 树节点点击
|
|
|
- handleNodeClick(data) {
|
|
|
+ handleNodeClick(data, tab) {
|
|
|
this.categoryLevelId = '';
|
|
|
+ this.substanceId = '';
|
|
|
this.areaId = '';
|
|
|
- if (this.activeTab == 'org') {
|
|
|
- this.categoryLevelId = data.id;
|
|
|
+ if (tab === 'org') {
|
|
|
+ if (data.nodeType === 'instance') {
|
|
|
+ this.substanceId = data.id;
|
|
|
+ } else {
|
|
|
+ this.categoryLevelId = data.id;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.areaId = data.id;
|
|
|
}
|
|
|
@@ -504,7 +453,8 @@
|
|
|
size: limit,
|
|
|
...this.where,
|
|
|
areaId: this.areaId,
|
|
|
- categoryLevelId: this.categoryLevelId
|
|
|
+ categoryLevelId: this.categoryLevelId,
|
|
|
+ substanceId: this.substanceId
|
|
|
});
|
|
|
if (this.pageName == 'fullYearCollection') {
|
|
|
if (res.list.length) {
|
|
|
@@ -512,7 +462,7 @@
|
|
|
let data = {
|
|
|
substanceName: item.substanceName,
|
|
|
energyClassificationName: item.energyClassificationName,
|
|
|
- unit: item.unit,
|
|
|
+ unit: item.unit
|
|
|
};
|
|
|
for (let key in item.yearDataMap) {
|
|
|
data[key] = item.yearDataMap[key] || '';
|