Преглед на файлове

feat: 文档工作区列表增加分类列

liujt преди 9 месеца
родител
ревизия
98a7e1b5ca
променени са 2 файла, в които са добавени 75 реда и са изтрити 3 реда
  1. 11 0
      src/views/doc/components/file-table-list.vue
  2. 64 3
      src/views/doc/components/main.vue

+ 11 - 0
src/views/doc/components/file-table-list.vue

@@ -466,6 +466,17 @@
               );
             }
           },
+          {label: '分类',
+            prop: 'typeName',
+            width: 180,
+            align: 'center',
+            fixed: 'left',
+            showOverflowTooltip: true,
+            formatter: () => {
+              // 优先使用fullPath,如果没有则回退到name
+              return this.parentData?.fullPath || this.parentData?.name || '';
+            }
+          },
           {
             label: '编码',
             prop: 'code',

+ 64 - 3
src/views/doc/components/main.vue

@@ -251,10 +251,16 @@ export default {
       this.loading = false;
     },
     /* 选择数据 */
-    onNodeClick(row) {
-      console.log(row,'row')
+    onNodeClick(row, node, list) {
+      console.log('row',row, node, list)
       if (row) {
-        this.current = row;
+        // 构建完整路径
+        const fullPath = this.buildFullPath(row, this.data);
+        // 将完整路径添加到current对象中
+        this.current = {
+          ...row,
+          fullPath: fullPath
+        };
         this.$nextTick(() => {
           this.$refs.tableRef.reload();
         });
@@ -262,6 +268,61 @@ export default {
         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) {
       //拖拽限制
       return dropNode.parent.id == draggingNode.parent.id && type != 'inner';