浏览代码

添加所属文件夹

Zhangtf 2 周之前
父节点
当前提交
973568facf

+ 14 - 8
xzl-admin/src/main/resources/mapper/KnowledgeFileMapper.xml

@@ -18,6 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
+        <!-- 添加文件夹名称映射 -->
+        <result property="folderName"   column="folder_name"  />
     </resultMap>
 
     <sql id="selectSysFileVo">
@@ -25,15 +27,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectSysFileList" parameterType="KnowledgeFile" resultMap="SysFileResult">
-        <include refid="selectSysFileVo"/>
+        SELECT
+        a.*,b.folder_name
+        FROM
+        sys_file a
+        LEFT JOIN sys_file_folder b on a.folder_id=b.folder_id
         <where>
-            <if test="folderId != null "> and folder_id = #{folderId}</if>
-            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
-            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
-            <if test="fileSize != null "> and file_size = #{fileSize}</if>
-            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
-            <if test="downloadCount != null "> and download_count = #{downloadCount}</if>
-            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="folderId != null "> and a.folder_id = #{folderId}</if>
+            <if test="fileName != null  and fileName != ''"> and a.file_name like concat('%', #{fileName}, '%')</if>
+            <if test="fileType != null  and fileType != ''"> and a.file_type = #{fileType}</if>
+            <if test="fileSize != null "> and a.file_size = #{fileSize}</if>
+            <if test="filePath != null  and filePath != ''"> and a.file_path = #{filePath}</if>
+            <if test="downloadCount != null "> and a.download_count = #{downloadCount}</if>
+            <if test="status != null  and status != ''"> and a.status = #{status}</if>
         </where>
     </select>
 

+ 14 - 0
xzl-common/src/main/java/com/xzl/common/core/domain/entity/KnowledgeFile.java

@@ -2,6 +2,7 @@ package com.xzl.common.core.domain.entity;
 
 import com.xzl.common.annotation.Excel;
 import com.xzl.common.core.domain.BaseEntity;
+import jdk.nashorn.internal.ir.annotations.Ignore;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -48,7 +49,19 @@ public class KnowledgeFile extends BaseEntity
 
     /** 删除标志(0存在 2删除) */
     private String delFlag;
+    // 添加文件夹名称属性
+    @Ignore
+    private String folderName;
 
+    // 省略其他getter和setter
+
+    public String getFolderName() {
+        return folderName;
+    }
+
+    public void setFolderName(String folderName) {
+        this.folderName = folderName;
+    }
     public void setFileId(Long fileId)
     {
         this.fileId = fileId;
@@ -131,6 +144,7 @@ public class KnowledgeFile extends BaseEntity
         return delFlag;
     }
 
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 43 - 50
xzl-ui/src/views/fileTree/folder/index.vue

@@ -26,21 +26,24 @@
             @node-click="handleNodeClick"
           >
             <template #default="{ node, data }">
-              <el-tree-node-content :node="node" :data="data">
-                <svg t="1750230337349" class="icon" viewBox="0 0 1024 1024" version="1.1"
-                     xmlns="http://www.w3.org/2000/svg" p-id="1538" width="1em" height="1em">
-                  <path
-                    d="M918.673 883H104.327C82.578 883 65 867.368 65 848.027V276.973C65 257.632 82.578 242 104.327 242h814.346C940.422 242 958 257.632 958 276.973v571.054C958 867.28 940.323 883 918.673 883z"
-                    fill="#FFE9B4" p-id="1539"></path>
-                  <path
-                    d="M512 411H65V210.37C65 188.597 82.598 171 104.371 171h305.92c17.4 0 32.71 11.334 37.681 28.036L512 411z"
-                    fill="#FFB02C" p-id="1540"></path>
-                  <path
-                    d="M918.673 883H104.327C82.578 883 65 865.42 65 843.668V335.332C65 313.58 82.578 296 104.327 296h814.346C940.422 296 958 313.58 958 335.332v508.336C958 865.32 940.323 883 918.673 883z"
-                    fill="#FFCA28" p-id="1541"></path>
-                </svg>
-                {{ data.label }}
-              </el-tree-node-content>
+    <span class="custom-tree-node">
+      <!-- 文件夹图标 -->
+      <svg t="1750230337349" class="icon" viewBox="0 0 1024 1024" version="1.1"
+           xmlns="http://www.w3.org/2000/svg" p-id="1538" width="1em" height="1em">
+        <path
+          d="M918.673 883H104.327C82.578 883 65 867.368 65 848.027V276.973C65 257.632 82.578 242 104.327 242h814.346C940.422 242 958 257.632 958 276.973v571.054C958 867.28 940.323 883 918.673 883z"
+          fill="#FFE9B4" p-id="1539"></path>
+        <path
+          d="M512 411H65V210.37C65 188.597 82.598 171 104.371 171h305.92c17.4 0 32.71 11.334 37.681 28.036L512 411z"
+          fill="#FFB02C" p-id="1540"></path>
+        <path
+          d="M918.673 883H104.327C82.578 883 65 865.42 65 843.668V335.332C65 313.58 82.578 296 104.327 296h814.346C940.422 296 958 313.58 958 335.332v508.336C958 865.32 940.323 883 918.673 883z"
+          fill="#FFCA28" p-id="1541"></path>
+      </svg>
+
+      <!-- 文件夹名称 -->
+      <span style="margin-left: 6px;">{{ data.label }}</span>
+    </span>
             </template>
           </el-tree>
           >
@@ -295,18 +298,6 @@
           </el-col>
         </el-row>
 
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="NLP文件名">
-              <el-input v-model="form.nlpName" placeholder="请输入NLP文件名" maxlength="32"/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="NLP密码">
-              <el-input v-model="form.nlpPwd" placeholder="请输入NLP密码" maxlength="32"/>
-            </el-form-item>
-          </el-col>
-        </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -364,11 +355,12 @@ import {
 import {getToken} from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
-import {folderTreeSelect} from "@/api/system/folder";
+import {folderTreeSelect, getFolder} from "@/api/system/folder";
 import {addFile, delFile, getFile, listFile, updateFile} from "@/api/system/file";
 import dict from "@/utils/dict";
 import {parseTime} from "../../../utils/xzl";
 import {updateFileStatus} from "@/api/system/file";
+import {getDept, listDeptExcludeChild} from "@/api/system/dept";
 
 
 export default {
@@ -603,7 +595,7 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
-      getFile(row.fileId).then(res => {
+      getFolder(row.fileId).then(res => {
         this.form = res.data;
         this.open = true;
         this.title = '修改文件';
@@ -671,27 +663,28 @@ export default {
       this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
       this.getList();
     },
-    async getParentFolderName(row, column, cellValue, index) {
-      if (!cellValue) {
-        return '根目录';
-      }
-
-      // 如果已缓存,直接返回
-      if (this.parentFolderCache[cellValue]) {
-        return this.parentFolderCache[cellValue];
-      }
-
-      try {
-        const response = await getFileParentName(cellValue); // 调用接口获取父文件夹名
-        const folderName = response.data || '未知';
-
-        // 缓存结果
-        this.parentFolderCache[cellValue] = folderName;
-        return folderName;
-      } catch (error) {
-        console.error(`获取父文件夹名称失败(文件夹ID: ${cellValue})`, error);
-        return '错误';
-      }
+     getParentFolderName(row, column, cellValue, index) {
+      return row.folderName
+      // if (!cellValue) {
+      //   return '根目录';
+      // }
+      //
+      // // 如果已缓存,直接返回
+      // if (this.parentFolderCache[cellValue]) {
+      //   return this.parentFolderCache[cellValue];
+      // }
+      //
+      // try {
+      //   const response = await getFileParentName(cellValue); // 调用接口获取父文件夹名
+      //   const folderName = response.data || '未知';
+      //
+      //   // 缓存结果
+      //   this.parentFolderCache[cellValue] = folderName;
+      //   return folderName;
+      // } catch (error) {
+      //   console.error(`获取父文件夹名称失败(文件夹ID: ${cellValue})`, error);
+      //   return '错误';
+      // }
     },
   }
 };