|
@@ -251,10 +251,16 @@ export default {
|
|
|
this.loading = false;
|
|
this.loading = false;
|
|
|
},
|
|
},
|
|
|
/* 选择数据 */
|
|
/* 选择数据 */
|
|
|
- onNodeClick(row) {
|
|
|
|
|
- console.log(row,'row')
|
|
|
|
|
|
|
+ onNodeClick(row, node, list) {
|
|
|
|
|
+ console.log('row',row, node, list)
|
|
|
if (row) {
|
|
if (row) {
|
|
|
- this.current = row;
|
|
|
|
|
|
|
+ // 构建完整路径
|
|
|
|
|
+ const fullPath = this.buildFullPath(row, this.data);
|
|
|
|
|
+ // 将完整路径添加到current对象中
|
|
|
|
|
+ this.current = {
|
|
|
|
|
+ ...row,
|
|
|
|
|
+ fullPath: fullPath
|
|
|
|
|
+ };
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
this.$refs.tableRef.reload();
|
|
this.$refs.tableRef.reload();
|
|
|
});
|
|
});
|
|
@@ -262,6 +268,61 @@ export default {
|
|
|
this.current = null;
|
|
this.current = null;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ /* 构建完整路径 */
|
|
|
|
|
+ buildFullPath(currentNode, folderList) {
|
|
|
|
|
+ // 如果节点没有parentId,直接返回节点名称
|
|
|
|
|
+ if (!currentNode.parentId || currentNode.parentId === 0) {
|
|
|
|
|
+ return currentNode.name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 递归查找上级节点
|
|
|
|
|
+ function findParent(node, list) {
|
|
|
|
|
+ let path = [node.name];
|
|
|
|
|
+ let parentId = node.parentId;
|
|
|
|
|
+
|
|
|
|
|
+ // 递归查找所有父节点
|
|
|
|
|
+ function searchParent(id) {
|
|
|
|
|
+ for (const item of list) {
|
|
|
|
|
+ if (item.id === id) {
|
|
|
|
|
+ path.unshift(item.name); // 将父节点名称添加到路径开头
|
|
|
|
|
+ if (item.parentId && item.parentId !== 0) {
|
|
|
|
|
+ searchParent(item.parentId); // 继续查找上一级
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果当前节点有子节点,继续在子节点中查找
|
|
|
|
|
+ if (item.sonDirectoryList && item.sonDirectoryList.length > 0) {
|
|
|
|
|
+ searchParentInChildren(item.sonDirectoryList, id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 在子节点列表中查找父节点
|
|
|
|
|
+ function searchParentInChildren(children, id) {
|
|
|
|
|
+ for (const child of children) {
|
|
|
|
|
+ if (child.id === id) {
|
|
|
|
|
+ path.unshift(child.name);
|
|
|
|
|
+ if (child.parentId && child.parentId !== 0) {
|
|
|
|
|
+ searchParent(child.parentId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (child.sonDirectoryList && child.sonDirectoryList.length > 0) {
|
|
|
|
|
+ searchParentInChildren(child.sonDirectoryList, id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (parentId) {
|
|
|
|
|
+ searchParent(parentId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return path.join(' / ');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return findParent(currentNode, folderList);
|
|
|
|
|
+ },
|
|
|
allowDrop(draggingNode, dropNode, type) {
|
|
allowDrop(draggingNode, dropNode, type) {
|
|
|
//拖拽限制
|
|
//拖拽限制
|
|
|
return dropNode.parent.id == draggingNode.parent.id && type != 'inner';
|
|
return dropNode.parent.id == draggingNode.parent.id && type != 'inner';
|