From f86e41e97c01355d483475511a0fe3834a85061d Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期一, 15 三月 2021 14:49:41 +0800
Subject: [PATCH] 修改z-tree默认为展开
---
src/Pool/TreeData.ts | 5 ++++-
src/components/giantTree/index.vue | 44 ++++++++++++++++++++++----------------------
2 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/Pool/TreeData.ts b/src/Pool/TreeData.ts
index 6984c74..0289f6c 100644
--- a/src/Pool/TreeData.ts
+++ b/src/Pool/TreeData.ts
@@ -282,7 +282,7 @@
// vue-js-tree 榛樿灞曞紑,鎺у埗閮ㄥ垎鎶樺彔. z-tree 榛樿鎶樺彔, 鎺у埗閮ㄥ垎灞曞紑
if (this.foldNodeList[n.id]) {
if (this.zTree) {
- n.open = true
+ n.open = false
} else {
n.opened = false
}
@@ -326,6 +326,9 @@
node.forEach(n => {
if (n.children && n.children.length > 0) {
+ if (this.zTree) {
+ n.open = true
+ }
this.sortTreeData(n.children)
}
})
diff --git a/src/components/giantTree/index.vue b/src/components/giantTree/index.vue
index d7e96d0..aabca2d 100644
--- a/src/components/giantTree/index.vue
+++ b/src/components/giantTree/index.vue
@@ -68,7 +68,7 @@
default: 0
}
},
- data () {
+ data() {
return {
hoverNodeId: "",
showDialog: false,
@@ -86,7 +86,7 @@
curNodeTid: '',
};
},
- created () {
+ created() {
// console.log(this.height, '鏍戦珮搴�')
this.TreeDataPool.zTree = true;
@@ -134,7 +134,7 @@
}
},
- findTidByIdFromArr (arr) {
+ findTidByIdFromArr(arr) {
let len = arr.length;
let _this = this;
for (var i = 0; i < len; i++) {
@@ -142,13 +142,13 @@
_this.curNodeTid = arr[i].tId;
break;
}
- if(arr[i].children){
+ if (arr[i].children) {
this.findTidByIdFromArr(arr[i].children);
}
}
-
+
},
- onDblClick (evt, treeId, item) {
+ onDblClick(evt, treeId, item) {
if (item.type !== "4" || this.app !== "Camera") {
return;
}
@@ -207,13 +207,13 @@
this.TreeDataPool.activeVideoIndex = nullVideoIndex;
}
},
- addCamera (node) {
+ addCamera(node) {
this.$emit("addDevice", node);
},
- importCameras (node) {
+ importCameras(node) {
this.$emit("import", node);
},
- addNode (node) {
+ addNode(node) {
this.dialogForm = {
text: "",
method: "add",
@@ -221,7 +221,7 @@
};
this.showDialogBox(event);
},
- editNode (node) {
+ editNode(node) {
this.dialogForm = {
text: node.name,
method: "edit",
@@ -231,10 +231,10 @@
};
this.showDialogBox(event);
},
- delNode (node) {
+ delNode(node) {
this.TreeDataPool.del(node.id);
},
- submitForm () {
+ submitForm() {
// 鎻愪氦鏂板鎴栬�呯紪杈戝尯鍩熻妭鐐硅〃鍗�
this.$refs.dialogForm.validate(valid => {
if (valid) {
@@ -254,18 +254,18 @@
});
this.hideDialogBox();
},
- hideDialogBox () {
+ hideDialogBox() {
this.showDialog = false;
this.dialogForm = { text: "" };
},
- showDialogBox (event) {
+ showDialogBox(event) {
let { clientX = 0, offsetY = 0 } = event;
// this.clientX = clientX - 120;
this.clientX = 50;
this.clientY = offsetY;
this.showDialog = true;
},
- itemClick (evt, treeId, treeNode) {
+ itemClick(evt, treeId, treeNode) {
console.log(evt, treeId)
this.TreeDataPool.selectedNode = treeNode;
@@ -293,7 +293,7 @@
// this.TreeDataPool.updateZTreeCheckNodes([treeNode]);
// },
- itemCheck (evt, treeId, treeNode) {
+ itemCheck(evt, treeId, treeNode) {
this.TreeDataPool.selectedNode = treeNode;
this.TreeDataPool.treeType = this.treeName;
@@ -303,14 +303,14 @@
this.TreeDataPool.updateZTreeCheckNodes(checkedNodes);
},
//灞曞紑
- itemExpand (e, id, node) {
- this.TreeDataPool.foldNodeList[node.id] = true
- },
- // 鎶樺彔
- itemCollapse (e, id, node) {
+ itemExpand(e, id, node) {
delete this.TreeDataPool.foldNodeList[node.id]
},
- dropNode (node, item, draggedItem, e) {
+ // 鎶樺彔
+ itemCollapse(e, id, node) {
+ this.TreeDataPool.foldNodeList[node.id] = true
+ },
+ dropNode(node, item, draggedItem, e) {
// console.log('dropNode', node, item, draggedItem);
this.TreeDataPool.dropNode(draggedItem.id, item.id)
}
--
Gitblit v1.8.0