77681 16 jam lalu
induk
melakukan
631ed15823

+ 2 - 1
gw-slgc/src/main/resources/mapper/efinder/DocFolderMapper.xml

@@ -14,7 +14,8 @@
         select <include refid="BaseColumns"/>, PLAN_VALUE from DOC_FOLDER
         <where>
             <if test="name != null and name != ''">and FD_NAME like '%' || #{name} || '%'</if>
-            <if test="pid != null">and FD_PID = #{pid}</if>
+            <if test="pid != null and pid == 0">and (FD_PID = 0 or FD_PID is null)</if>
+            <if test="pid != null and pid != 0">and FD_PID = #{pid}</if>
             <if test="fdCate != null and fdCate != ''">and FD_CATE = #{fdCate}</if>
             <if test="parentName != null and parentName != ''">
                 and FD_PID = (select FD_ID from DOC_FOLDER where FD_NAME = #{parentName} and FD_PID is null)

+ 13 - 5
gw-ui/src/views/index.vue

@@ -152,7 +152,7 @@
 </template>
 
 <script setup>
-import { ref, onActivated } from 'vue'
+import { ref, onMounted, onActivated } from 'vue'
 import { useRouter } from 'vue-router'
 import { folderList, mkdir } from '@/api/efinder/finder'
 import { addProject } from '@/api/pms/addProject'
@@ -281,8 +281,8 @@ const isTopLevel = (item) => !item.pid || item.pid === 0
 
 const loadByCate = (cate, listRef, loadingRef, filterFn) => {
   loadingRef.value = true
-  // 传 pid=0 让后端只返回顶层(FD_PID = 0),避免全量拉取后再前端过滤
-  folderList({ fdCate: cate, pid: 0, pageSize: 999 }).then(res => {
+  // 拉取该分类全量,前端用 isTopLevel 过滤顶层(兼容 FD_PID=0 与 FD_PID IS NULL 两种数据)
+  folderList({ fdCate: cate, pageSize: 999 }).then(res => {
     const list = res.rows || res.data || []
     listRef.value = filterFn ? list.filter(item => filterFn(item, list)) : list
     loadingRef.value = false
@@ -302,8 +302,16 @@ function loadAll() {
   loadByCate('gzzd', gzzdList, loadingGzzd, isTopLevel)
 }
 
-// onActivated 在首次挂载和 keep-alive 返回时都会触发,统一在此加载,避免重复请求
-onActivated(loadAll)
+// 首次挂载:onMounted 必定触发加载(onActivated 只在 keep-alive 缓存组件时触发,首次可能不触发)
+// 缓存返回时:onActivated 触发刷新;mounted 标志防止首次挂载时两个钩子重复加载
+let dataLoaded = false
+onMounted(() => {
+  dataLoaded = true
+  loadAll()
+})
+onActivated(() => {
+  if (dataLoaded) loadAll()
+})
 </script>
 
 <style scoped>

+ 7 - 2
gw-ui/src/views/portal/ddjc.vue

@@ -280,10 +280,15 @@ function handleBatchDelete() {
   }).catch(() => {})
 }
 
-// onActivated 首次挂载和 keep-alive 返回时触发,刷新分类树与文件列表
-onActivated(() => {
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(() => {
+  dataLoaded = true
   getCategoryTree()
 })
+onActivated(() => {
+  if (dataLoaded) getCategoryTree()
+})
 </script>
 
 <style lang="scss" scoped>

+ 7 - 2
gw-ui/src/views/portal/gzzd.vue

@@ -295,10 +295,15 @@ function getFileIcon(fileType) {
   return map[fileType] || "file"
 }
 
-// onActivated 首次挂载和 keep-alive 返回时触发,刷新分类树与文档列表
-onActivated(() => {
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(() => {
+  dataLoaded = true
   getCategoryTree()
 })
+onActivated(() => {
+  if (dataLoaded) getCategoryTree()
+})
 </script>
 
 <style lang="scss" scoped>

+ 12 - 2
gw-ui/src/views/portal/tpz.vue

@@ -173,8 +173,10 @@ function uploadError() {
   proxy.$modal.msgError("上传失败")
 }
 
-// onActivated 首次挂载和 keep-alive 返回时触发
-onActivated(async () => {
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(async () => {
+  dataLoaded = true
   if (route.query.folderId) {
     categoryFolderId.value = parseInt(route.query.folderId)
   } else if (!categoryFolderId.value) {
@@ -186,6 +188,14 @@ onActivated(async () => {
   }
   getImageList()
 })
+onActivated(() => {
+  if (dataLoaded) {
+    if (route.query.folderId) {
+      categoryFolderId.value = parseInt(route.query.folderId)
+    }
+    getImageList()
+  }
+})
 </script>
 
 <style lang="scss" scoped>

+ 17 - 8
gw-ui/src/views/portal/wyh.vue

@@ -197,8 +197,10 @@ function getFileIcon(fileType) {
   return map[fileType] || "file"
 }
 
-// onActivated 首次挂载和 keep-alive 返回时触发
-onActivated(async () => {
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(async () => {
+  dataLoaded = true
   if (route.query.folderId && !currentFolder.value) {
     const fid = parseInt(route.query.folderId)
     const res = await folderList(queryParams.value)
@@ -214,16 +216,23 @@ onActivated(async () => {
     }
     folderItems.value = folders
     loading.value = false
-  } else if (currentFolder.value) {
-    // 已定位文件夹:返回时刷新文件夹列表和当前文件列表
-    getFolderList()
-    getFileList({ pid: currentFolder.value.id }).then(response => {
-      fileList.value = response.rows || response.data || []
-    })
   } else {
     getFolderList()
   }
 })
+onActivated(() => {
+  if (dataLoaded) {
+    if (currentFolder.value) {
+      // 已定位文件夹:返回时刷新文件夹列表和当前文件列表
+      getFolderList()
+      getFileList({ pid: currentFolder.value.id }).then(response => {
+        fileList.value = response.rows || response.data || []
+      })
+    } else {
+      getFolderList()
+    }
+  }
+})
 </script>
 
 <style lang="scss" scoped>

+ 9 - 2
gw-ui/src/views/portal/zdgc.vue

@@ -237,8 +237,15 @@ async function handleBatchDelete() {
   } catch (_) {}
 }
 
-// onActivated 首次挂载和返回时都会触发,统一加载避免重复请求
-onActivated(() => { loadTabs() })
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(() => {
+  dataLoaded = true
+  loadTabs()
+})
+onActivated(() => {
+  if (dataLoaded) loadTabs()
+})
 </script>
 
 <style lang="scss" scoped>

+ 9 - 2
gw-ui/src/views/portal/zggc.vue

@@ -189,8 +189,15 @@ async function handleBatchDelete() {
   } catch (_) {}
 }
 
-// onActivated 首次挂载和返回时都会触发,统一加载避免重复请求
-onActivated(() => { getFolderList() })
+// 首次挂载 onMounted 必定触发;keep-alive 缓存返回时 onActivated 刷新
+let dataLoaded = false
+onMounted(() => {
+  dataLoaded = true
+  getFolderList()
+})
+onActivated(() => {
+  if (dataLoaded) getFolderList()
+})
 </script>
 
 <style lang="scss" scoped>