|
|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="safetyList">
|
|
|
- <customHeader>数据中心-设备管理</customHeader>
|
|
|
+ <customHeader>数据中心-设备监测</customHeader>
|
|
|
<div class="content">
|
|
|
<a-tabs class="tab-box" v-model:activeKey="activeKey" @change="onChangeTab">
|
|
|
<a-tab-pane tab="设备监测" key="device" />
|
|
|
@@ -13,11 +13,12 @@
|
|
|
<div class="device-select">
|
|
|
<div class="device-select-box">
|
|
|
<a-tree
|
|
|
+ v-if="treeData && treeData.length > 0"
|
|
|
:show-line="true"
|
|
|
:tree-data="treeData"
|
|
|
v-model:selectedKeys="selectedKeys"
|
|
|
- :autoExpandParent="true"
|
|
|
v-model:expandedKeys="expandedKeys"
|
|
|
+ :defaultExpandAll="true"
|
|
|
@select="onSelect"
|
|
|
>
|
|
|
</a-tree>
|
|
|
@@ -30,8 +31,8 @@
|
|
|
size="small"
|
|
|
:scroll="{ y: 650 }"
|
|
|
:columns="outerColumns"
|
|
|
- :data-source="paginatedData2"
|
|
|
- :pagination="paginationConfig2"
|
|
|
+ :data-source="deviceList"
|
|
|
+ :pagination="false"
|
|
|
:row-key="(record) => record.id"
|
|
|
:expand-row-by-click="true"
|
|
|
:expanded-row-keys="expandedRowKeys"
|
|
|
@@ -59,8 +60,8 @@
|
|
|
<a-table
|
|
|
size="small"
|
|
|
:columns="innerColumns"
|
|
|
- :data-source="paginatedData"
|
|
|
- :pagination="paginationConfig"
|
|
|
+ :data-source="monitorList"
|
|
|
+ :pagination="false"
|
|
|
:loading="loadingMap[record.id]"
|
|
|
bordered
|
|
|
:scroll="{ y: 410 }"
|
|
|
@@ -97,12 +98,14 @@ import { getDeviceTypeList, getDeviceListByType, getDevMonitorListById } from '.
|
|
|
import { RightCircleTwoTone, DownCircleTwoTone } from '@ant-design/icons-vue';
|
|
|
import { alignElement } from 'dom-align';
|
|
|
import { active } from 'sortablejs';
|
|
|
+import { stubTrue } from 'lodash';
|
|
|
|
|
|
const { hasPermission } = usePermission();
|
|
|
let activeKey = ref('device');
|
|
|
const treeData = ref<TreeProps['treeData']>([]);
|
|
|
const selectedKeys = ref<string[]>([]);
|
|
|
const expandedKeys = ref<string[]>([]);
|
|
|
+const AllNodeKeys = ref<string[]>([]);
|
|
|
const deviceType = ref(''); // 监测设备类型
|
|
|
const systemType = ref('');
|
|
|
const systemID = ref(''); // 系统监测时,系统id
|
|
|
@@ -142,46 +145,46 @@ const paginatedData2 = computed(() => {
|
|
|
return deviceList.value.slice(start, end);
|
|
|
});
|
|
|
// 分页器配置 - 修复响应式问题
|
|
|
-const paginationConfig = computed(() => {
|
|
|
- return {
|
|
|
- current: paginationState.value.current,
|
|
|
- pageSize: paginationState.value.pageSize,
|
|
|
- total: monitorList.value.length,
|
|
|
- showSizeChanger: true,
|
|
|
- showQuickJumper: true,
|
|
|
- showTotal: (total) => `共 ${total} 条`,
|
|
|
- pageSizeOptions: ['10', '20', '50', '100'],
|
|
|
- size: 'small',
|
|
|
- onChange: (page, pageSize) => {
|
|
|
- paginationState.value.current = page;
|
|
|
- paginationState.value.pageSize = pageSize;
|
|
|
- },
|
|
|
- onShowSizeChange: (current, size) => {
|
|
|
- paginationState.value.current = 1;
|
|
|
- paginationState.value.pageSize = size;
|
|
|
- },
|
|
|
- };
|
|
|
-});
|
|
|
-const paginationConfig2 = computed(() => {
|
|
|
- return {
|
|
|
- current: paginationState2.value.current,
|
|
|
- pageSize: paginationState2.value.pageSize,
|
|
|
- total: deviceList.value.length,
|
|
|
- showSizeChanger: true,
|
|
|
- showQuickJumper: true,
|
|
|
- showTotal: (total) => `共 ${total} 条`,
|
|
|
- pageSizeOptions: ['10', '20', '50', '100'],
|
|
|
- size: 'small',
|
|
|
- onChange: (page, pageSize) => {
|
|
|
- paginationState2.value.current = page;
|
|
|
- paginationState2.value.pageSize = pageSize;
|
|
|
- },
|
|
|
- onShowSizeChange: (current, size) => {
|
|
|
- paginationState2.value.current = 1;
|
|
|
- paginationState2.value.pageSize = size;
|
|
|
- },
|
|
|
- };
|
|
|
-});
|
|
|
+// const paginationConfig = computed(() => {
|
|
|
+// return {
|
|
|
+// current: paginationState.value.current,
|
|
|
+// pageSize: paginationState.value.pageSize,
|
|
|
+// total: monitorList.value.length,
|
|
|
+// showSizeChanger: true,
|
|
|
+// showQuickJumper: true,
|
|
|
+// showTotal: (total) => `共 ${total} 条`,
|
|
|
+// pageSizeOptions: ['10', '20', '50', '100'],
|
|
|
+// size: 'small',
|
|
|
+// onChange: (page, pageSize) => {
|
|
|
+// paginationState.value.current = page;
|
|
|
+// paginationState.value.pageSize = pageSize;
|
|
|
+// },
|
|
|
+// onShowSizeChange: (current, size) => {
|
|
|
+// paginationState.value.current = 1;
|
|
|
+// paginationState.value.pageSize = size;
|
|
|
+// },
|
|
|
+// };
|
|
|
+// });
|
|
|
+// const paginationConfig2 = computed(() => {
|
|
|
+// return {
|
|
|
+// current: paginationState2.value.current,
|
|
|
+// pageSize: paginationState2.value.pageSize,
|
|
|
+// total: deviceList.value.length,
|
|
|
+// showSizeChanger: true,
|
|
|
+// showQuickJumper: true,
|
|
|
+// showTotal: (total) => `共 ${total} 条`,
|
|
|
+// pageSizeOptions: ['10', '20', '50', '100'],
|
|
|
+// size: 'small',
|
|
|
+// onChange: (page, pageSize) => {
|
|
|
+// paginationState2.value.current = page;
|
|
|
+// paginationState2.value.pageSize = pageSize;
|
|
|
+// },
|
|
|
+// onShowSizeChange: (current, size) => {
|
|
|
+// paginationState2.value.current = 1;
|
|
|
+// paginationState2.value.pageSize = size;
|
|
|
+// },
|
|
|
+// };
|
|
|
+// });
|
|
|
// 切换tab页面
|
|
|
async function onChangeTab(tab) {
|
|
|
activeKey.value = tab;
|
|
|
@@ -207,96 +210,44 @@ const onSelect: TreeProps['onSelect'] = (keys, e) => {
|
|
|
}
|
|
|
getDeviceList(deviceType.value);
|
|
|
};
|
|
|
-
|
|
|
-async function findTreeDataValue(obj) {
|
|
|
- const findDeviceType = (data: any[], obj, flag = true) => {
|
|
|
- return data.find((item: any) => {
|
|
|
- if (item.children.length > 0) {
|
|
|
- findDeviceType(item.children, obj);
|
|
|
+// 获取所有节点key的函数
|
|
|
+const getAllNodeKeys = (nodes) => {
|
|
|
+ const keys = [];
|
|
|
+ const traverse = (nodeList) => {
|
|
|
+ nodeList.forEach((node) => {
|
|
|
+ keys.push(node.key);
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ traverse(node.children);
|
|
|
}
|
|
|
- // debugger;
|
|
|
- if (obj.deviceType && obj.deviceType.startsWith('sys_')) {
|
|
|
- // debugger;
|
|
|
- if (item.type == obj.deviceid) {
|
|
|
- deviceType.value = 'sys';
|
|
|
- systemID.value = obj.deviceid;
|
|
|
- selectedKeys.value = [item.key];
|
|
|
- expandedKeys.value = [item.key];
|
|
|
- treeNodeTitle.value = item.title;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!flag) {
|
|
|
- if (obj.deviceType && item.type.startsWith(obj.deviceType)) {
|
|
|
- deviceType.value = item.type;
|
|
|
- selectedKeys.value = [item.key];
|
|
|
- expandedKeys.value = [item.key];
|
|
|
- treeNodeTitle.value = item.title;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- if (obj.deviceType && item.type == obj.deviceType) {
|
|
|
- deviceType.value = item.type;
|
|
|
- selectedKeys.value = [item.key];
|
|
|
- expandedKeys.value = [item.key];
|
|
|
- treeNodeTitle.value = item.title;
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
});
|
|
|
};
|
|
|
- const flag = findDeviceType(treeData.value, obj);
|
|
|
- if (!flag) {
|
|
|
- findDeviceType(treeData.value, obj, false);
|
|
|
- }
|
|
|
- // 无类型时
|
|
|
- if (!treeNodeTitle.value && treeData.value && treeData.value[0] && treeData.value[0]['children']) {
|
|
|
- const defaultData = treeData.value[0]['children'][0];
|
|
|
- if (deviceType.value !== defaultData.type) deviceType.value = defaultData.type;
|
|
|
- selectedKeys.value = [defaultData.key as string];
|
|
|
- expandedKeys.value = [defaultData.key as string];
|
|
|
- treeNodeTitle.value = defaultData.title;
|
|
|
- }
|
|
|
-}
|
|
|
+ traverse(nodes);
|
|
|
+ return keys;
|
|
|
+};
|
|
|
+
|
|
|
// 获取树形菜单数据
|
|
|
-async function getDeviceType(sysType?) {
|
|
|
- // if (treeData.value?.length > 0) return;
|
|
|
+async function getDeviceType() {
|
|
|
const result = await getDeviceTypeList({});
|
|
|
if (result.length > 0) {
|
|
|
- const dataSource = <TreeProps['treeData']>[];
|
|
|
+ const dataSource = [];
|
|
|
let key = '0';
|
|
|
const getData = (resultList, dataSourceList, keyVal) => {
|
|
|
resultList.forEach((item, index) => {
|
|
|
- if (item.deviceType != 'sys' && item.children && item.children.length > 0) {
|
|
|
- const children = getData(item.children, [], `${keyVal}-${index}`);
|
|
|
- // 判断关键阻力路线
|
|
|
- if (item.itemValue.startsWith(sysType) && children[0]) {
|
|
|
- systemID.value = item.children[0]['itemValue'];
|
|
|
- }
|
|
|
-
|
|
|
- dataSourceList.push({
|
|
|
- children: children,
|
|
|
- title: item.itemText,
|
|
|
- key: `${keyVal}-${index}`,
|
|
|
- type: item.itemValue,
|
|
|
- parentKey: `${keyVal}`,
|
|
|
- });
|
|
|
- } else {
|
|
|
- dataSourceList.push({
|
|
|
- children: [],
|
|
|
- title: item.itemText,
|
|
|
- key: `${keyVal}-${index}`,
|
|
|
- type: item.itemValue,
|
|
|
- parentKey: `${keyVal}`,
|
|
|
- });
|
|
|
- }
|
|
|
+ const children = item.children ? getData(item.children, [], `${keyVal}-${index}`) : [];
|
|
|
+ dataSourceList.push({
|
|
|
+ children: children,
|
|
|
+ title: item.itemText,
|
|
|
+ key: `${keyVal}-${index}`,
|
|
|
+ type: item.itemValue,
|
|
|
+ parentKey: `${keyVal}`,
|
|
|
+ });
|
|
|
});
|
|
|
return dataSourceList;
|
|
|
};
|
|
|
+
|
|
|
treeData.value = getData(result, dataSource, key);
|
|
|
+ // 数据就绪后设置展开key数组
|
|
|
+ expandedKeys.value = getAllNodeKeys(treeData.value);
|
|
|
}
|
|
|
}
|
|
|
// 根据选择设备获取设备列表
|
|
|
@@ -418,8 +369,8 @@ async function refreshData(deviceId: string) {
|
|
|
monitorList.value = Object.values(result.readData);
|
|
|
}
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
- await getDeviceType();
|
|
|
+onMounted(() => {
|
|
|
+ getDeviceType();
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
if (timer) {
|
|
|
@@ -500,7 +451,7 @@ watch(
|
|
|
align-items: center;
|
|
|
|
|
|
.left-box {
|
|
|
- width: 25%;
|
|
|
+ width: 20%;
|
|
|
height: 100%;
|
|
|
margin-right: 15px;
|
|
|
padding: 10px;
|
|
|
@@ -510,7 +461,7 @@ watch(
|
|
|
}
|
|
|
|
|
|
.right-box {
|
|
|
- width: calc(75% - 15px);
|
|
|
+ width: calc(80% - 15px);
|
|
|
height: 100%;
|
|
|
padding: 10px;
|
|
|
box-sizing: border-box;
|
|
|
@@ -607,7 +558,7 @@ watch(
|
|
|
|
|
|
.device-select-box {
|
|
|
margin-top: 60px;
|
|
|
- width: 208px;
|
|
|
+ width: 220px;
|
|
|
height: calc(100% - 70px);
|
|
|
overflow-y: auto;
|
|
|
color: #fff;
|
|
|
@@ -645,7 +596,7 @@ watch(
|
|
|
}
|
|
|
}
|
|
|
.device-select {
|
|
|
- width: 250px;
|
|
|
+ width: 280px !important;
|
|
|
height: calc(100% - 70px);
|
|
|
background: var(--image-tree-bg) no-repeat;
|
|
|
position: fixed;
|