|
|
@@ -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,
|