Kaynağa Gözat

feat(dashboard): adjust some styles

Casper Dai 2 yıl önce
ebeveyn
işleme
313d7fb8ee

+ 0 - 2
src/views/dashboard/components/DeviceGroupAttention.vue

@@ -78,8 +78,6 @@ export default {
     },
     onChanged () {
       this.$emit('change', [{
-        id: 'tile',
-        name: '设备列表',
         children: [...this.groupOptions.list]
       }])
     }

+ 0 - 2
src/views/dashboard/components/DeviceGroupTile.vue

@@ -109,8 +109,6 @@ export default {
     },
     onChanged () {
       this.$emit('change', [{
-        id: 'tile',
-        name: '设备列表',
         children: [...this.groupOptions.list]
       }])
     }

+ 9 - 2
src/views/dashboard/components/DeviceGroupTree.vue

@@ -25,7 +25,11 @@ export default {
   methods: {
     init () {
       const rootOption = this.createNode()
-      this.setNodes(rootOption, this.groups.map(item => this.transfromGroup(item, rootOption)))
+      if (this.groups.length === 1 && (!this.groups[0].id || !this.groups[0].name)) {
+        this.setNodes(rootOption, this.transformDevices(this.groups[0].children, rootOption))
+      } else {
+        this.setNodes(rootOption, this.groups.map(item => this.transfromGroup(item, rootOption)))
+      }
       this.rootOption = rootOption
     },
     transfromGroup ({ id, name, children }, parent) {
@@ -33,9 +37,12 @@ export default {
         id,
         name
       }, parent)
-      this.setNodes(group, children.map(item => this.transformDevice(item, group)).sort(this.sort))
+      this.setNodes(group, this.transformDevices(children, group))
       return group
     },
+    transformDevices (children, parent) {
+      return children.map(item => this.transformDevice(item, parent)).sort(this.sort)
+    },
     transformDevice ({ id, name, productId, lastOnline, onlineStatus }, parent) {
       return this.createLeafNode(parent, {
         id, name, productId, lastOnline,