|
@@ -69,39 +69,41 @@ const transformGroupsAndDevices = (groups: DeviceGroupItem[], devices: AllDevice
|
|
});
|
|
});
|
|
|
|
|
|
// 转换顶级分组
|
|
// 转换顶级分组
|
|
- return groups.map((group) => {
|
|
|
|
- // 转换当前组
|
|
|
|
- const transformed: DeviceGroupTree = {
|
|
|
|
- ...group,
|
|
|
|
- label: group.groupName,
|
|
|
|
- children: [],
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // 转换子分组(二级分组),并过滤掉没有设备的分组
|
|
|
|
- if (group.deviceGroupChilds && group.deviceGroupChilds.length > 0) {
|
|
|
|
- transformed.children = group.deviceGroupChilds
|
|
|
|
- .map((child) => {
|
|
|
|
- const transformedChild: DeviceGroupTreeChild = {
|
|
|
|
- ...child,
|
|
|
|
- label: child.groupName,
|
|
|
|
- children: [],
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // 查找并添加属于这个二级分组的设备
|
|
|
|
- const childDevices = deviceMap.get(child.id) || [];
|
|
|
|
-
|
|
|
|
- transformedChild.children = childDevices.map((device) => ({
|
|
|
|
- ...device,
|
|
|
|
- label: device.deviceName,
|
|
|
|
- }));
|
|
|
|
-
|
|
|
|
- return transformedChild;
|
|
|
|
- })
|
|
|
|
- .filter((child) => child.children.length > 0); // 过滤掉没有设备的二级分组
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return transformed;
|
|
|
|
- });
|
|
|
|
|
|
+ return groups
|
|
|
|
+ .map((group) => {
|
|
|
|
+ // 转换当前组
|
|
|
|
+ const transformed: DeviceGroupTree = {
|
|
|
|
+ ...group,
|
|
|
|
+ label: group.groupName,
|
|
|
|
+ children: [],
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 转换子分组(二级分组),并过滤掉没有设备的分组
|
|
|
|
+ if (group.deviceGroupChilds && group.deviceGroupChilds.length > 0) {
|
|
|
|
+ transformed.children = group.deviceGroupChilds
|
|
|
|
+ .map((child) => {
|
|
|
|
+ const transformedChild: DeviceGroupTreeChild = {
|
|
|
|
+ ...child,
|
|
|
|
+ label: child.groupName,
|
|
|
|
+ children: [],
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 查找并添加属于这个二级分组的设备
|
|
|
|
+ const childDevices = deviceMap.get(child.id) || [];
|
|
|
|
+
|
|
|
|
+ transformedChild.children = childDevices.map((device) => ({
|
|
|
|
+ ...device,
|
|
|
|
+ label: device.deviceName,
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ return transformedChild;
|
|
|
|
+ })
|
|
|
|
+ .filter((child) => child.children.length > 0); // 过滤掉没有设备的二级分组
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return transformed;
|
|
|
|
+ })
|
|
|
|
+ .filter((parent) => parent.children.length > 0); // 过滤掉没有二级分组的一级分组
|
|
};
|
|
};
|
|
|
|
|
|
const checkModuleInfo = () => {
|
|
const checkModuleInfo = () => {
|