Browse Source

设备中心 - 能耗监测 - 图表 左侧树和右侧组件联动

deploy-dev
fks-yangshouda 5 months ago
parent
commit
a698c69b7c
  1. 107
      hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue
  2. 158
      hx-ai-intelligent/src/view/monitor/energyMonitor/graphGraph/index.vue
  3. 122
      hx-ai-intelligent/src/view/monitor/energyMonitor/graphTable/index.vue
  4. 91
      hx-ai-intelligent/src/view/monitor/energyMonitor/index.vue
  5. 88
      hx-ai-intelligent/src/view/monitor/energyMonitor/page.vue
  6. 534
      hx-ai-intelligent/src/view/monitor/energyMonitor/tree/index.vue

107
hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue

@ -11,18 +11,16 @@
:tree-data="treeData1" :tree-data="treeData1"
@change="changeDeviceType" /> @change="changeDeviceType" />
<a-spin :spinning="treeLoading">
<a-tree <a-tree
v-model:expandedKeys="expandedKeys" v-model:expandedKeys="expandedKeys"
v-model:selectedKeys="selectedKeys" v-model:selectedKeys="selectedKeys"
v-model:checkedKeys="checkedKeys" v-model:checkedKeys="checkedKeys"
checkable checkable
style="width: 100%; margin-bottom: 10px" :height="340"
:tree-data="treeData2"> style="width: 100%; overflow-y: auto; margin-bottom: 10px; margin-top: 10px"
<!-- <template #title="{ title, key }"> :tree-data="treeData2" />
<span v-if="key === '0-0-1-0'" style="color: #1890ff">{{ title }}</span> </a-spin>
<template v-else>{{ title }}</template>
</template> -->
</a-tree>
<div class="fixed-bottom"> <div class="fixed-bottom">
<a-divider /> <a-divider />
@ -56,18 +54,18 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import type { TreeSelectProps, TreeProps, SelectProps } from 'ant-design-vue'; import type { TreeSelectProps, SelectProps } from 'ant-design-vue';
import { defineComponent, ref, onMounted } from 'vue'; import { defineComponent, ref, onMounted } from 'vue';
import { Dayjs } from 'dayjs'; import { Dayjs } from 'dayjs';
import { inject } from 'vue'; import { inject } from 'vue';
import { http } from '/nerv-lib/util'; import { http } from '/nerv-lib/util';
import { device } from '/@/api/deviceManage'; import { device } from '/@/api/deviceManage';
// import { device } from '/@/api/deviceManage';
export default defineComponent({ export default defineComponent({
// eslint-disable-next-line vue/multi-word-component-names // eslint-disable-next-line vue/multi-word-component-names
name: 'Tree', name: 'Tree',
setup() { setup() {
const treeLoading = ref(false);
const treeLine = ref(true); const treeLine = ref(true);
const showLeafIcon = ref(false); const showLeafIcon = ref(false);
const value = ref<string>(); const value = ref<string>();
@ -76,90 +74,31 @@
const result = JSON.parse(sessionStorage.getItem('ORGID')!); const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result; orgId.value = result;
const treeData1 = ref<TreeSelectProps['treeData']>([ const treeData1 = ref<TreeSelectProps['treeData']>([]);
// {
// title: '3.',
// value: '3',
// children: [
// {
// title: '301.',
// value: '301',
// },
// {
// title: '302.',
// value: '302',
// },
// ],
// },
// {
// title: '4.',
// value: '4',
// children: [
// {
// title: '401.',
// value: '401',
// },
// {
// title: '402.',
// value: '402',
// },
// {
// title: '403.',
// value: '403',
// },
// {
// title: '404.',
// value: '404',
// },
// ],
// },
]);
http.post(device.queryDeviceTree, { orgId: orgId.value }).then((res) => { http.post(device.queryDeviceTree, { orgId: orgId.value }).then((res) => {
treeData1.value = formatTreeData(res.data); treeData1.value = formatTreeData(res.data);
}); });
const formatTreeData = (data) => { const formatTreeData = (data: any) => {
return data.map((item) => ({ return data.map((item: any) => ({
title: item.code + '.' + item.deviceType, title: item.code + '.' + item.deviceType,
value: item.code, value: item.code,
children: item.children ? formatTreeData(item.children) : [], children: item.children ? formatTreeData(item.children) : [],
})); }));
}; };
// const treeData2: TreeProps['treeData'] = [ const treeData2 = ref<TreeSelectProps['treeData']>([]);
const treeData2 = ref<TreeSelectProps['treeData']>([
// {
// title: 'AC_001()',
// key: '1',
// children: [
// {
// title: 'AC_002()',
// key: '2',
// },
// {
// title: 'AC_003()',
// key: '3',
// },
// {
// title: 'AC_004()',
// key: '4',
// },
// {
// title: 'AC_005()',
// key: '5',
// },
// {
// title: 'AC_006()',
// key: '6',
// },
// ],
// },
]);
const changeDeviceType = (val, label, extra) => { const changeDeviceType = (val: any, label: any) => {
treeLoading.value = true;
http http
.post(device.queryDevicePage, { code: val, orgId: orgId.value, pageNum: 1, pageSize: 10 }) .post(device.queryDevicePage, {
code: val,
orgId: orgId.value,
pageNum: 1,
pageSize: 1000,
})
.then((res) => { .then((res) => {
if (!val) { if (!val) {
val = '999999999'; val = '999999999';
@ -174,6 +113,9 @@
let a: TreeSelectProps['treeData'] = [{ title: label[0], key: val, children: records }]; let a: TreeSelectProps['treeData'] = [{ title: label[0], key: val, children: records }];
treeData2.value = a; treeData2.value = a;
expandedKeys.value = [val]; expandedKeys.value = [val];
})
.finally(() => {
treeLoading.value = false;
}); });
}; };
@ -531,11 +473,9 @@
onMounted(() => { onMounted(() => {
getDianWeiList(); getDianWeiList();
changeDeviceType(); changeDeviceType(null, null);
}); });
// const dateFormat = 'YYYY-MM-DD';
return { return {
treeLine, treeLine,
showLeafIcon, showLeafIcon,
@ -560,6 +500,7 @@
hackValue, hackValue,
pageData, pageData,
changeDeviceType, changeDeviceType,
treeLoading,
}; };
}, },
}); });

158
hx-ai-intelligent/src/view/monitor/energyMonitor/graphGraph/index.vue

@ -3,129 +3,62 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, onMounted, ref } from 'vue'; import { defineComponent, onMounted, ref, inject, watch } from 'vue';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
const data = [
{
date: '2023-12-01 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '21',
},
{
name: 'AC_003(照明电表)',
value: '36',
},
{
name: 'AC_004(给排水电表)',
value: '5',
},
],
},
{
date: '2023-12-02 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '26',
},
{
name: 'AC_003(照明电表)',
value: '25',
},
{
name: 'AC_004(给排水电表)',
value: '47',
},
],
},
{
date: '2023-12-03 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '18',
},
{
name: 'AC_003(照明电表)',
value: '22',
},
{
name: 'AC_004(给排水电表)',
value: '26',
},
],
},
{
date: '2023-12-04 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '40',
},
{
name: 'AC_003(照明电表)',
value: '15',
},
{
name: 'AC_004(给排水电表)',
value: '12',
},
],
},
{
date: '2023-12-05 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '15',
},
{
name: 'AC_003(照明电表)',
value: '18',
},
{
name: 'AC_004(给排水电表)',
value: '15',
},
],
},
];
export default defineComponent({ export default defineComponent({
name: 'GraphGraph', name: 'GraphGraph',
setup() { setup() {
let data = ref<any[]>([]);
interface PageData {
graphTableList: any[];
graphTableColumns: any[];
graphGraphList: any[];
}
const pageData = inject<PageData>('pageData');
if (!pageData) {
throw new Error('pageData is not provided');
}
// pageData
watch(
() => pageData as PageData,
(_newValue, _oldValue) => {
//
draw();
},
{ deep: true },
);
const graphGraphchart = ref(null); const graphGraphchart = ref(null);
let chartInstance: echarts.ECharts | null = null; let chartInstance: echarts.ECharts | null = null;
onMounted(() => {
const draw = () => {
data.value = pageData.graphGraphList;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(graphGraphchart.value); chartInstance = echarts.init(graphGraphchart.value);
var seriesList = []; var seriesList = [];
var date = []; var date = [];
var legendList: string | any[] = []; var legendList: string | any[] = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.value.length; i++) {
date.push(data[i].date); date.push(data.value[i].date);
for (let j = 0; j < data[i].data.length; j++) { for (let j = 0; j < data.value[i].data.length; j++) {
if (seriesList.length < j + 1) { if (seriesList.length < j + 1) {
seriesList.push({ seriesList.push({
name: data[i].data[j].name, name: data.value[i].data[j].name,
data: [data[i].data[j].value], data: [data.value[i].data[j].value],
type: 'line', type: 'line',
smooth: true, smooth: true,
}); });
} else { } else {
seriesList[j].data.push(data[i].data[j].value); seriesList[j].data.push(data.value[i].data[j].value);
} }
if (legendList.length == 0 || legendList.length < j + 1) { if (legendList.length == 0 || legendList.length < j + 1) {
legendList.push(data[i].data[j].name); legendList.push(data.value[i].data[j].name);
} }
} }
} }
@ -142,7 +75,7 @@
const date = params[0].name; const date = params[0].name;
const values = params const values = params
.map((param: any) => { .map((param: any) => {
const unit = data.find((d) => d.date === date)?.unit || ''; const unit = data.value.find((d) => d.date === date)?.unit || '';
return `<tr> return `<tr>
<td>${param.marker}${param.seriesName}</td> <td>${param.marker}${param.seriesName}</td>
<td style="text-align: right;">${param.value} ${unit}</td> <td style="text-align: right;">${param.value} ${unit}</td>
@ -159,27 +92,14 @@
yAxis: { yAxis: {
type: 'value', type: 'value',
}, },
// dataZoom: [
// {
// height: 10,
// start: 0,
// end: 100,
// handleSize: '300%', //
// bottom: 15,
// },
// ],
// toolbox: {
// show: true,
// feature: {
// mark: { show: true },
// saveAsImage: { show: true },
// },
// },
series: seriesList, series: seriesList,
}; };
chartInstance = echarts.init(graphGraphchart.value); chartInstance = echarts.init(graphGraphchart.value);
chartInstance.setOption(option); chartInstance.setOption(option);
};
onMounted(() => {
draw();
}); });
// //

122
hx-ai-intelligent/src/view/monitor/energyMonitor/graphTable/index.vue

@ -0,0 +1,122 @@
<template>
<a-table :columns="columns" :data-source="data" bordered />
</template>
<script lang="ts">
import { defineComponent, watch, inject, ref, onMounted } from 'vue';
import type { TableColumnType } from 'ant-design-vue';
export default defineComponent({
name: 'EnvironmentTable',
setup() {
let data = ref<any[]>([]);
let columns = ref<TableColumnType[]>([]);
interface PageData {
graphTableList: any[];
graphTableColumns: any[];
graphGraphList: any[];
}
const pageData = inject<PageData>('pageData');
if (!pageData) {
throw new Error('pageData is not provided');
}
// pageData
watch(
() => pageData as PageData,
(_newValue, _oldValue) => {
data.value = pageData.graphTableList;
let columnA: any[] = [...column];
columnA.push(...pageData.graphTableColumns);
columns.value = columnA;
// pageData.graphList;
//
},
{ deep: true },
);
const getRowSpan = (dataIndex: string, record: any, data: any, dependents: string[] = []) => {
let rowSpan = 1;
for (let i = data.indexOf(record) + 1; i < data.length; i++) {
let shouldMerge = true;
for (const dependent of dependents) {
if (data[i][dependent] !== record[dependent]) {
shouldMerge = false;
break;
}
}
if (shouldMerge && data[i][dataIndex] === record[dataIndex]) {
rowSpan++;
} else {
break;
}
}
return rowSpan;
};
const column: TableColumnType[] = [
{
title: '设备/组名',
dataIndex: 'name',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('name', record, data.value);
if (rowIndex != 0 && data.value[rowIndex - 1].name == record.name) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
{
title: '参数名称',
dataIndex: 'paramName',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('paramName', record, data.value, ['name']);
if (rowIndex != 0 && data.value[rowIndex - 1].name == record.name) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
];
onMounted(() => {
data.value = pageData.graphTableList;
let columnA: any[] = [...column];
columnA.push(...pageData.graphTableColumns);
columns.value = columnA;
});
return {
data,
column,
columns,
};
},
});
</script>
<style lang="less" scoped></style>

91
hx-ai-intelligent/src/view/monitor/energyMonitor/index.vue

@ -1,88 +1,19 @@
<!-- eslint-disable vue/multi-word-component-names --> <!-- eslint-disable vue/multi-word-component-names -->
<template> <template>
<a-tabs v-model:activeKey="activeKey" style="height: 8%"> <page />
<a-tab-pane key="1" tab="图表" />
<a-tab-pane key="2" tab="分析" />
</a-tabs>
<a-row type="flex" style="height: 92%">
<a-col :span="4">
<div style="padding: 0 20px; width: 100%; height: 100%">
<tree ref="treeRef" />
</div>
</a-col>
<a-col :span="20">
<div style="width: 100%; height: 100%">
<div class="ns-right-title">
<span>统计数据</span>
<div class="button">
<ns-icon name="xiazai" size="18" style="margin-right: 10px" @click="downloadChart" />
<ns-icon :name="iconName" size="18" style="margin-right: 10px" @click="change" />
</div>
</div>
<div v-if="activeKey == '1'" style="height: 90%">
<graph-graph ref="graphRef" v-if="isGraph" />
<environment-table ref="tableRef" v-else />
</div>
</div>
</a-col>
</a-row>
</template> </template>
<script lang="ts" setup> <script setup>
import { ref } from 'vue'; import { reactive, provide } from 'vue';
import tree from './tree/index.vue'; import page from './page.vue';
import graphGraph from './graphGraph/index.vue';
import environmentTable from './table/index.vue';
const iconName = ref('biaoge'); //
const pageData = reactive({
const treeRef = ref(); graphTableList: [],
const graphRef = ref(); graphTableColumns: [],
const tableRef = ref(); graphGraphList: [],
let isGraph = ref(true);
const activeKey = ref('1');
defineOptions({
name: 'EnvironmentMonitorIndex', // name
}); });
const downloadChart = () => { // 使 provide
if (activeKey.value == '1' && isGraph) { provide('pageData', pageData);
if (graphRef.value) {
graphRef.value.downloadChart();
}
}
};
function change() {
isGraph.value = !isGraph.value;
if (iconName.value == 'biaoge') {
iconName.value = 'bingtu';
} else {
iconName.value = 'biaoge';
}
}
</script> </script>
<style lang="less" scoped>
.ns-right-title {
display: flex;
justify-content: space-between;
align-items: center;
user-select: text;
margin-bottom: 5px;
padding-bottom: 10px;
padding-top: 10px;
border-bottom: 1px solid #e9e9e9;
> span {
padding-left: 10px;
line-height: 20px;
}
}
.button {
display: inline-block;
padding-right: 10px;
}
</style>

88
hx-ai-intelligent/src/view/monitor/energyMonitor/page.vue

@ -0,0 +1,88 @@
<!-- eslint-disable vue/multi-word-component-names -->
<template>
<a-tabs v-model:activeKey="activeKey" style="height: 8%">
<a-tab-pane key="1" tab="图表" />
<a-tab-pane key="2" tab="分析" />
</a-tabs>
<a-row type="flex" style="height: 92%">
<a-col :span="4">
<div style="padding: 0 20px; width: 100%; height: 100%">
<tree ref="treeRef" />
</div>
</a-col>
<a-col :span="20">
<div style="width: 100%; height: 100%">
<div class="ns-right-title">
<span>统计数据</span>
<div class="button">
<ns-icon name="xiazai" size="18" style="margin-right: 10px" @click="downloadChart" />
<ns-icon :name="iconName" size="18" style="margin-right: 10px" @click="change" />
</div>
</div>
<div v-if="activeKey == '1'" style="height: 90%">
<graph-graph ref="graphRef" v-if="isGraph" />
<environment-table ref="tableRef" v-else />
</div>
</div>
</a-col>
</a-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import tree from './tree/index.vue';
import graphGraph from './graphGraph/index.vue';
import environmentTable from './graphTable/index.vue';
const iconName = ref('biaoge');
const treeRef = ref();
const graphRef = ref();
const tableRef = ref();
let isGraph = ref(true);
const activeKey = ref('1');
defineOptions({
name: 'EnvironmentMonitorIndex', // name
});
const downloadChart = () => {
if (activeKey.value == '1' && isGraph) {
if (graphRef.value) {
graphRef.value.downloadChart();
}
}
};
function change() {
isGraph.value = !isGraph.value;
if (iconName.value == 'biaoge') {
iconName.value = 'bingtu';
} else {
iconName.value = 'biaoge';
}
}
</script>
<style lang="less" scoped>
.ns-right-title {
display: flex;
justify-content: space-between;
align-items: center;
user-select: text;
margin-bottom: 5px;
padding-bottom: 10px;
padding-top: 10px;
border-bottom: 1px solid #e9e9e9;
> span {
padding-left: 10px;
line-height: 20px;
}
}
.button {
display: inline-block;
padding-right: 10px;
}
</style>

534
hx-ai-intelligent/src/view/monitor/energyMonitor/tree/index.vue

@ -4,30 +4,29 @@
<div class="ns-tree-title"> <div class="ns-tree-title">
<span>数据点位</span> <span>数据点位</span>
</div> </div>
<!-- <a-tree-select
v-model:value="value"
style="width: 100%"
:tree-line="treeLine && { showLeafIcon }"
:tree-data="treeData1"
>
</a-tree-select> -->
<a-select <a-select
ref="select" ref="select"
v-model:value="selectedValue" v-model:value="selectedValue"
placeholder="请选择能耗类型" placeholder="请选择能耗类型"
style="width: 100%; margin-bottom: 10px" style="width: 100%; margin-bottom: 10px"
:options="options1" /> :options="options1"
@change="changeEnergyType" />
<a-radio-group <a-radio-group
v-model:value="mode" v-model:value="mode"
@change="changeMode" @change="changeMode"
style="padding-bottom: 10px; width: 100%"> style="padding-bottom: 10px; width: 100%">
<a-radio-button value="1" style="width: 50%; text-align: center">设备</a-radio-button> <a-radio-button value="1" style="width: 50%; text-align: center" :disabled="shebei"
>设备</a-radio-button
>
<a-radio-button value="2" style="width: 50%; text-align: center">节点</a-radio-button> <a-radio-button value="2" style="width: 50%; text-align: center">节点</a-radio-button>
</a-radio-group> </a-radio-group>
<a-input v-model:value="value" placeholder="请输入设备名称" v-if="mode == '1'" /> <a-input
<a-input v-model:value="value" placeholder="请输入节点名称" v-else /> v-model:value="deviceName"
placeholder="请输入设备名称"
v-if="mode == '1'"
@change="changeMode" />
<a-input v-model:value="pointName" placeholder="请输入节点名称" v-else @change="changeMode" />
<a-spin :spinning="treeLoading">
<a-tree <a-tree
v-model:expandedKeys="expandedKeys" v-model:expandedKeys="expandedKeys"
v-model:selectedKeys="selectedKeys" v-model:selectedKeys="selectedKeys"
@ -36,6 +35,7 @@
:height="300" :height="300"
style="width: 100%; overflow-y: auto; margin-bottom: 10px; margin-top: 10px" style="width: 100%; overflow-y: auto; margin-bottom: 10px; margin-top: 10px"
:tree-data="treeData2" /> :tree-data="treeData2" />
</a-spin>
<div class="fixed-bottom"> <div class="fixed-bottom">
<a-divider /> <a-divider />
@ -52,193 +52,482 @@
@calendarChange="onCalendarChange" @calendarChange="onCalendarChange"
style="width: 100%; margin-bottom: 10px" style="width: 100%; margin-bottom: 10px"
:placeholder="['请选择日期', '请选择日期']" /> :placeholder="['请选择日期', '请选择日期']" />
<a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect" <a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect">
>查询</a-button 查询
> </a-button>
<!-- <a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect11">
模拟不同数据查询
</a-button> -->
</div> </div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import type { TreeSelectProps, TreeProps, SelectProps } from 'ant-design-vue'; import type { TreeSelectProps, SelectProps } from 'ant-design-vue';
import { defineComponent, ref, onMounted } from 'vue'; import { defineComponent, ref, onMounted, inject } from 'vue';
import { Dayjs } from 'dayjs'; import { Dayjs } from 'dayjs';
import { http } from '/nerv-lib/util';
import { device, group } from '/@/api/deviceManage';
import { dict } from '/@/api';
export default defineComponent({ export default defineComponent({
// eslint-disable-next-line vue/multi-word-component-names // eslint-disable-next-line vue/multi-word-component-names
name: 'Tree', name: 'Tree',
setup() { setup() {
// const treeLine = ref(true);
// const showLeafIcon = ref(false);
const value = ref<string>(); const value = ref<string>();
const deviceName = ref<string>();
const pointName = ref<string>();
const treeLoading = ref(false);
const shebei = ref(false);
//
const expandedKeys = ref<string[]>([]);
//
const selectedKeys = ref<string[]>([]);
//
const checkedKeys = ref<string[]>([]);
// list
const options1 = ref<SelectProps['options']>([]);
// list
const options2 = ref<SelectProps['options']>([]);
const mode = ref<String>('1');
//
const selectedValue = ref<string | undefined>();
//
const frequencyValue = ref<string | undefined>();
//
const dateRange = ref<[Dayjs, Dayjs] | undefined>();
const treeData1 = ref<TreeSelectProps['treeData']>([ //
const getOptionsList = async () => {
try {
const options = await dict({ params: { dicKey: 'ENERGY_TYPE' } });
options.data.data.forEach((item: any) => {
(item.value = item.cnValue), (item.label = item.cnValue);
});
options1.value = options.data.data; // options1.value
} catch (error) {
console.error('Failed to fetch options:', error);
}
options2.value = [
{
value: '1',
label: '5分钟',
},
{
value: '2',
label: '10分钟',
},
{ {
title: '3.电梯',
value: '3', value: '3',
children: [ label: '30分钟',
},
{ {
title: '301.扶梯', value: '4',
value: '301', label: '1小时',
}, },
];
};
interface PageData {
graphTableList: any[];
graphTableColumns: any[];
graphGraphList: any[];
}
const pageData = inject<PageData>('pageData');
if (!pageData) {
throw new Error('pageData is not provided');
}
//
const changeEnergyType = () => {
if (selectedValue.value == '8') {
shebei.value = true;
mode.value = '2';
} else {
shebei.value = false;
}
changeMode();
};
const getSelect = () => {
pageData.graphTableList = [
{ {
title: '302.直梯', key: '1',
value: '302', name: 'AC_002(暖通电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
}, },
], {
key: '1',
name: 'AC_002(暖通电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
}, },
{ {
title: '4.冷热源', key: '2',
value: '4', name: 'AC_003(照明电表)',
children: [ paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
},
{
key: '2',
name: 'AC_003(照明电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
},
{
key: '3',
name: 'AC_004(给排水电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
},
];
pageData.graphTableColumns = [
{
title: '日期',
dataIndex: 'date',
},
{ {
title: '401.冷水机组', title: '1:00',
value: '401', dataIndex: '1:00',
}, },
];
pageData.graphGraphList = [
{
date: '2023-12-01 0:00',
unit: 'V',
data: [
{ {
title: '402.热泵机组', name: 'AC_002(暖通电表)',
value: '402', value: '21',
}, },
{ {
title: '403.锅炉', name: 'AC_003(照明电表)',
value: '403', value: '36',
}, },
{ {
title: '404.水处理机组', name: 'AC_004(给排水电表)',
value: '404', value: '5',
}, },
], ],
}, },
]);
const expandedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const selectedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const checkedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const options1 = ref<SelectProps['options']>([]);
const options2 = ref<SelectProps['options']>([
{ {
value: '1', date: '2023-12-02 0:00',
label: '5分钟', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '26',
}, },
{ {
value: '2', name: 'AC_003(照明电表)',
label: '10分钟', value: '25',
}, },
{ {
value: '3', name: 'AC_004(给排水电表)',
label: '30分钟', value: '47',
},
],
}, },
{ {
value: '4', date: '2023-12-03 0:00',
label: '1小时', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '18',
}, },
]);
const mode = ref<String>('1');
const selectedValue = ref<string | undefined>();
const frequencyValue = ref<string | undefined>();
const dateRange = ref<[Dayjs, Dayjs] | undefined>();
const getDianWeiList = () => {
console.log('getDianWeiList 被调用');
options1.value = [
{ value: '1', label: '用电量' },
{ value: '2', label: '用水量' },
{ value: '3', label: '碳排量' },
{ value: '4', label: '标煤量' },
];
};
const getSelect = () => {};
const treeData2 = ref<TreeProps['treeData']>([]);
const changeMode = () => {
if (mode.value == '1') {
treeData2.value = [
{ {
title: 'AC_001(总电表)', name: 'AC_003(照明电表)',
key: '101', value: '22',
children: [ },
{
name: 'AC_004(给排水电表)',
value: '26',
},
],
},
{ {
title: 'AC_002(暖通电表)', date: '2023-12-04 0:00',
key: '102', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '40',
},
{
name: 'AC_003(照明电表)',
value: '15',
}, },
{ {
title: 'AC_003(照明电表)', name: 'AC_004(给排水电表)',
key: '103', value: '12',
},
],
}, },
{ {
title: 'AC_004(给排水电表)', date: '2023-12-05 0:00',
key: '104', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '15',
}, },
{ {
title: 'AC_005(通风电表)', name: 'AC_003(照明电表)',
key: '105', value: '18',
}, },
{ {
title: 'AC_006(电动门电表)', name: 'AC_004(给排水电表)',
key: '106', value: '15',
}, },
], ],
}, },
]; ];
} else { };
treeData2.value = [ const getSelect11 = () => {
pageData.graphTableList = [
{
key: '1',
name: 'AC_002(暖通电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
'2:00': '3626',
},
{ {
title: '功能分项',
key: '1', key: '1',
children: [ name: 'AC_002(暖通电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
'2:00': '3626',
},
{ {
title: '照明',
key: '2', key: '2',
children: [ name: 'AC_003(照明电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
'2:00': '3626',
},
{
key: '2',
name: 'AC_003(照明电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
'2:00': '3626',
},
{ {
title: '站台照明',
key: '3', key: '3',
name: 'AC_004(给排水电表)',
paramName: '用电量(kWh)',
date: '2023-12-01',
'1:00': '3626',
'2:00': '3626',
},
];
pageData.graphTableColumns = [
{
title: '日期',
dataIndex: 'date',
},
{
title: '1:00',
dataIndex: '1:00',
},
{
title: '2:00',
dataIndex: '2:00',
},
];
pageData.graphGraphList = [
{
date: '2023-12-01 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '21',
},
{
name: 'AC_003(照明电表)',
value: '36',
},
{
name: 'AC_004(给排水电表)',
value: '5',
},
{
name: 'AC_005(333333333)',
value: '22',
},
],
}, },
{ {
title: '站厅照明', date: '2023-12-02 0:00',
key: '4', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '26',
}, },
{ {
title: '应急照明', name: 'AC_003(照明电表)',
key: '5', value: '25',
}, },
{ {
title: '广告照明', name: 'AC_004(给排水电表)',
key: '6', value: '47',
},
{
name: 'AC_005(333333333)',
value: '28',
}, },
], ],
}, },
{ {
title: '暖通', date: '2023-12-03 0:00',
key: '7', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '18',
},
{
name: 'AC_003(照明电表)',
value: '22',
}, },
{ {
title: '排放', name: 'AC_004(给排水电表)',
key: '8', value: '26',
},
{
name: 'AC_005(333333333)',
value: '44',
},
],
}, },
{ {
title: '给排水', date: '2023-12-04 0:00',
key: '9', unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '40',
}, },
{ {
title: '光伏', name: 'AC_003(照明电表)',
key: '10', value: '15',
}, },
{ {
title: '电梯', name: 'AC_004(给排水电表)',
key: '11', value: '12',
}, },
{ {
title: '电动门', name: 'AC_005(333333333)',
key: '12', value: '26',
},
],
},
{
date: '2023-12-05 0:00',
unit: 'V',
data: [
{
name: 'AC_002(暖通电表)',
value: '15',
},
{
name: 'AC_003(照明电表)',
value: '18',
},
{
name: 'AC_004(给排水电表)',
value: '15',
},
{
name: 'AC_005(333333333)',
value: '35',
}, },
], ],
}, },
]; ];
};
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const treeData2 = ref<TreeSelectProps['treeData']>([]);
//
const changeMode = () => {
treeLoading.value = true;
if (mode.value == '1') {
http
.post(device.queryDevicePage, {
deviceName: deviceName.value,
energyType: selectedValue.value,
orgId: orgId.value,
pageNum: 1,
pageSize: 9999,
})
.then((res) => {
let val = '999999999';
let label = '所有设备';
let records = res.data.records;
records.forEach((item: any) => {
(item.title = item.deviceModel + ' ' + item.deviceName), (item.key = item.id);
});
let a: TreeSelectProps['treeData'] = [{ title: label, key: val, children: records }];
treeData2.value = a;
expandedKeys.value = [val];
})
.finally(() => {
treeLoading.value = false;
});
} else {
http
.post(group.queryDeviceGroupTree, {
pointName: pointName.value,
energyType: selectedValue.value,
orgId: orgId.value,
})
.then((res) => {
treeData2.value = [];
treeData2.value = formatTreeData(pointName.value ? res.data[0].searchList : res.data);
expandedKeys.value = getAllKeys(treeData2.value);
})
.finally(() => {
treeLoading.value = false;
});
} }
}; };
const getAllKeys = (data: any) => {
let keys: any[] = [];
data.forEach((item: any) => {
if (item.children) {
keys.push(item.key);
keys = keys.concat(getAllKeys(item.children));
}
});
return keys;
};
const formatTreeData = (data: any) => {
return data.map((item: any) => ({
title: item.pointName,
key: item.id,
children: item.children ? formatTreeData(item.children) : [],
}));
};
type RangeValue = [Dayjs, Dayjs]; type RangeValue = [Dayjs, Dayjs];
const dates = ref<RangeValue>(); const dates = ref<RangeValue>();
@ -270,17 +559,14 @@
dates.value = val; dates.value = val;
}; };
onMounted(() => { onMounted(() => {
getDianWeiList(); getOptionsList();
changeMode(); changeMode();
}); });
// const dateFormat = 'YYYY-MM-DD';
return { return {
// treeLine,
// showLeafIcon,
value, value,
treeData1, deviceName,
pointName,
treeData2, treeData2,
expandedKeys, expandedKeys,
selectedKeys, selectedKeys,
@ -291,14 +577,18 @@
selectedValue, selectedValue,
frequencyValue, frequencyValue,
dateRange, dateRange,
getDianWeiList, getOptionsList,
getSelect, getSelect,
getSelect11,
changeMode, changeMode,
disabledDate, disabledDate,
onCalendarChange, onCalendarChange,
onOpenChange, onOpenChange,
onChange, onChange,
hackValue, hackValue,
treeLoading,
changeEnergyType,
shebei,
}; };
}, },
}); });

Loading…
Cancel
Save