diff --git a/src/views/home/components/drawpic.vue b/src/views/home/components/drawpic.vue
index c5b2385..a99ab40 100644
--- a/src/views/home/components/drawpic.vue
+++ b/src/views/home/components/drawpic.vue
@@ -753,27 +753,40 @@ export default {
},
//删除图片和数据
deletePic() {
- this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
+ deleteApi({
+ path: this.parentdata.name + "/" + this.currentNodeData.name,
})
- .then(() => {
- deleteApi({
- path: this.parentdata.name + "/" + this.currentNodeData.name,
- })
- .then((res) => {
- console.log(res);
- this.$message({
- type: "success",
- message: "删除成功!",
- });
- EventBus.$emit("treelist");
- localStorage.removeItem("currentData");
- })
- .catch((err) => {});
+ .then((res) => {
+ console.log(res);
+ this.$message({
+ type: "success",
+ message: "删除成功!",
+ });
+ //EventBus.$emit("treelist");
+ localStorage.removeItem("currentData");
})
- .catch(() => {});
+ .catch((err) => {});
+ // this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
+ // confirmButtonText: "确定",
+ // cancelButtonText: "取消",
+ // type: "warning",
+ // })
+ // .then(() => {
+ // deleteApi({
+ // path: this.parentdata.name + "/" + this.currentNodeData.name,
+ // })
+ // .then((res) => {
+ // console.log(res);
+ // this.$message({
+ // type: "success",
+ // message: "删除成功!",
+ // });
+ // //EventBus.$emit("treelist");
+ // localStorage.removeItem("currentData");
+ // })
+ // .catch((err) => {});
+ // })
+ // .catch(() => {});
},
},
};
diff --git a/src/views/home/components/picTree.vue b/src/views/home/components/picTree.vue
index 2a0852e..f0f78cd 100644
--- a/src/views/home/components/picTree.vue
+++ b/src/views/home/components/picTree.vue
@@ -14,11 +14,11 @@
>
- {{ node.label }}
+ {{ node.label }} ({{ data.children.length }})
- {{ node.label }}
+ {{ node.label }}
@@ -98,7 +98,7 @@ export default {
})
.catch((err) => {});
},
- handleNodeClick(node) {
+ handleNodeClick(node, data) {
//点击父节点收起
if (node.children?.length) {
this.$nextTick(() => {
@@ -108,8 +108,18 @@ export default {
}
this.currentNodeKey = node.name;
console.log(node); // 你会看到当前节点的数据
- const parentNode = this.$refs.tree.getNode(node).parent.data;
- console.log(parentNode); // 输出父节点的数据对象
+ console.log(data);
+ const parentNode = this.findParentNode(data.id, this.piclist);
+
+ if (parentNode) {
+ // 找到了父节点,打印父节点的数据
+ console.log(parentNode); // 输出父节点的数据对象
+ } else {
+ // 没找到父节点,处理错误情况
+ console.error("未能找到父节点");
+ }
+ //const parentNode = this.$refs.tree.getNode(node).parent;
+ // //const parentNode = this.$refs.tree.getNode(node).parent.data;
EventBus.$emit("currentNodeData", node);
EventBus.$emit("perentNode", parentNode);
this.defaultExpandedKeys = [parentNode.name];
@@ -118,6 +128,18 @@ export default {
this.getlabels();
localStorage.setItem("currentData", JSON.stringify(node));
},
+ findParentNode(childId, treeData) {
+ console.log(childId);
+ console.log(treeData);
+ // 递归查找父节点
+ return treeData.find((parent) => {
+ console.log(parent);
+ return (
+ parent.children &&
+ parent.children.find((child) => child.$treeNodeId === childId)
+ );
+ });
+ },
getlabels() {
getLabelsApi({
path: this.pathParams,
@@ -150,7 +172,7 @@ export default {