77681 16 giờ trước cách đây
mục cha
commit
bb910942dc

+ 9 - 6
gw-ui/src/views/index.vue

@@ -152,7 +152,7 @@
 </template>
 
 <script setup>
-import { ref, onMounted } from 'vue'
+import { ref, onActivated } from 'vue'
 import { useRouter } from 'vue-router'
 import { folderList, mkdir } from '@/api/efinder/finder'
 import { addProject } from '@/api/pms/addProject'
@@ -180,6 +180,7 @@ const goToPage = (path) => {
 // 添加对话框
 const addVisible = ref(false)
 const addCate = ref('')
+const addSubmitting = ref(false)
 const addFormRef = ref(null)
 const addForm = reactive({ name: '', planValue: 0 })
 const addRules = { name: [{ required: true, message: '名称不能为空', trigger: 'blur' }] }
@@ -204,8 +205,6 @@ function resetAddForm() {
   addForm.planValue = 0
 }
 
-const addSubmitting = ref(false)
-
 function submitAdd() {
   if (addSubmitting.value) return
   addFormRef.value.validate(valid => {
@@ -282,7 +281,8 @@ const isTopLevel = (item) => !item.pid || item.pid === 0
 
 const loadByCate = (cate, listRef, loadingRef, filterFn) => {
   loadingRef.value = true
-  folderList({ fdCate: cate, pageSize: 999 }).then(res => {
+  // 传 pid=0 让后端只返回顶层(FD_PID = 0),避免全量拉取后再前端过滤
+  folderList({ fdCate: cate, pid: 0, pageSize: 999 }).then(res => {
     const list = res.rows || res.data || []
     listRef.value = filterFn ? list.filter(item => filterFn(item, list)) : list
     loadingRef.value = false
@@ -292,7 +292,7 @@ const loadByCate = (cate, listRef, loadingRef, filterFn) => {
   })
 }
 
-onMounted(() => {
+function loadAll() {
   // 首页所有模块统一只展示顶层(pid=0),子级目录不作为一级模块展示
   loadByCate('tpz', tpzItems, loadingTpz, isTopLevel)
   loadByCate('wyh', wyhItems, loadingWyh, isTopLevel)
@@ -300,7 +300,10 @@ onMounted(() => {
   loadByCate('zdgc', zdgcList, loadingZdgc, isTopLevel)
   loadByCate('ddjc', ddjcList, loadingDdjc, isTopLevel)
   loadByCate('gzzd', gzzdList, loadingGzzd, isTopLevel)
-})
+}
+
+// onActivated 在首次挂载和 keep-alive 返回时都会触发,统一在此加载,避免重复请求
+onActivated(loadAll)
 </script>
 
 <style scoped>

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

@@ -143,12 +143,11 @@ function getCategoryTree() {
   folderList({ fdCate: "ddjc", pageSize: 999 }).then(response => {
     const list = response.rows || response.data || []
     categoryTree.value = proxy.handleTree(list, "id", "pid")
-    if (list.length > 0 && !currentCategory.value) {
-      const fid = route.query.folderId ? parseInt(route.query.folderId) : null
-      if (fid) {
-        currentCategory.value = list.find(item => item.id === fid) || list[0]
-      } else {
-        currentCategory.value = list[0]
+    if (list.length > 0) {
+      // 支持首页传入 folderId 定位分类;已有选中分类时保持并刷新文件列表
+      if (!currentCategory.value) {
+        const fid = route.query.folderId ? parseInt(route.query.folderId) : null
+        currentCategory.value = fid ? (list.find(item => item.id === fid) || list[0]) : list[0]
       }
       getFileList()
     }
@@ -281,7 +280,8 @@ function handleBatchDelete() {
   }).catch(() => {})
 }
 
-onMounted(() => {
+// onActivated 首次挂载和 keep-alive 返回时触发,刷新分类树与文件列表
+onActivated(() => {
   getCategoryTree()
 })
 </script>

+ 8 - 5
gw-ui/src/views/portal/gzzd.vue

@@ -149,10 +149,12 @@ function getCategoryTree() {
   folderList({ fdCate: "gzzd", pageSize: 999 }).then(response => {
     const list = response.rows || response.data || []
     categoryTree.value = proxy.handleTree(list, "id", "pid")
-    if (list.length > 0 && !currentCategory.value) {
-      // 支持首页传入 folderId 定位分类
-      const fid = route.query.folderId ? parseInt(route.query.folderId) : null
-      currentCategory.value = fid ? (list.find(item => item.id === fid) || list[0]) : list[0]
+    if (list.length > 0) {
+      // 支持首页传入 folderId 定位分类;已有选中分类时保持并刷新文档列表
+      if (!currentCategory.value) {
+        const fid = route.query.folderId ? parseInt(route.query.folderId) : null
+        currentCategory.value = fid ? (list.find(item => item.id === fid) || list[0]) : list[0]
+      }
       getDocList()
     }
   })
@@ -293,7 +295,8 @@ function getFileIcon(fileType) {
   return map[fileType] || "file"
 }
 
-onMounted(() => {
+// onActivated 首次挂载和 keep-alive 返回时触发,刷新分类树与文档列表
+onActivated(() => {
   getCategoryTree()
 })
 </script>

+ 45 - 10
gw-ui/src/views/portal/portalDetail.vue

@@ -186,7 +186,6 @@ const loading = ref(false)
 const showSearch = ref(true)
 const total = ref(0)
 const ids = ref([])
-const single = ref(true)
 const multiple = ref(true)
 const currentPid = ref(undefined)
 const folderTreeRef = ref(null)
@@ -227,9 +226,19 @@ function goBack() {
   router.push(backMap[fdCate.value] || '/index')
 }
 
+// 树数据缓存:同一模块(fdCate)的文件夹树只拉取一次,切换项目时复用,减少重复请求
+const treeCache = new Map()
+
 function getFolderTree() {
-  return folderList({ fdCate: fdCate.value, pageSize: 999 }).then(response => {
-    const list = response.rows || response.data || []
+  const cached = treeCache.get(fdCate.value)
+  const load = cached
+    ? Promise.resolve(cached)
+    : folderList({ fdCate: fdCate.value, pageSize: 999 }).then(response => {
+        const list = response.rows || response.data || []
+        treeCache.set(fdCate.value, list)
+        return list
+      })
+  return load.then(list => {
     // 根据当前选中文件夹更新标题,体现二级模块跳转
     const current = list.find(f => f.id === currentPid.value)
     if (current) {
@@ -316,11 +325,14 @@ function resetQuery() {
 
 function handleSelectionChange(selection) {
   ids.value = selection.map(item => item.id)
-  single.value = selection.length !== 1
   multiple.value = !selection.length
 }
 
 function handleUpload() {
+  if (!currentPid.value) {
+    proxy.$modal.msgWarning('请先选择文件夹')
+    return
+  }
   uploadData.value = { pid: currentPid.value }
   uploadOpen.value = true
   nextTick(() => {
@@ -356,6 +368,10 @@ function uploadError() {
 }
 
 function handleMkdir() {
+  if (!currentPid.value) {
+    proxy.$modal.msgWarning('请先选择文件夹')
+    return
+  }
   dialogForm.value = { name: '' }
   dialogTitle.value = '新建文件夹'
   dialogOpen.value = true
@@ -367,6 +383,8 @@ function submitDialog() {
       mkdir({ name: dialogForm.value.name, pid: currentPid.value, fdCate: fdCate.value }).then(() => {
         proxy.$modal.msgSuccess('新建成功')
         dialogOpen.value = false
+        // 新建文件夹后清除树缓存,强制刷新
+        treeCache.delete(fdCate.value)
         getFolderTree()
       })
     }
@@ -433,16 +451,33 @@ function handleBatchDelete() {
 }
 
 function handleEditPlanValue() {
+  if (!currentPid.value) {
+    proxy.$modal.msgWarning('请先选择工程')
+    return
+  }
   planValueForm.id = currentPid.value
-  planValueForm.planValue = currentPlanValue.value || 0
-  planValueDialogVisible.value = true
+  // 点击时实时加载当前工程自身的进度,避免使用缓存导致显示旧值/其他工程的值
+  getPlanValue(currentPid.value).then(response => {
+    planValueForm.planValue = response.data || 0
+    currentPlanValue.value = planValueForm.planValue
+    planValueDialogVisible.value = true
+  }).catch(() => {
+    planValueForm.planValue = 0
+    planValueDialogVisible.value = true
+  })
 }
 
 function submitPlanValue() {
-  updatePlanValue({ id: planValueForm.id, planValue: planValueForm.planValue }).then(() => {
-    proxy.$modal.msgSuccess('修改成功')
-    currentPlanValue.value = planValueForm.planValue
-    planValueDialogVisible.value = false
+  updatePlanValue({ id: planValueForm.id, planValue: planValueForm.planValue }).then(res => {
+    if (res.code === 200) {
+      proxy.$modal.msgSuccess('修改成功')
+      currentPlanValue.value = planValueForm.planValue
+      planValueDialogVisible.value = false
+    } else {
+      proxy.$modal.msgError(res.msg || '修改失败')
+    }
+  }).catch(() => {
+    proxy.$modal.msgError('修改失败')
   })
 }
 

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

@@ -14,6 +14,7 @@
           <el-image
             :src="getImageUrl(item.id)"
             :preview-src-list="previewList"
+            :initial-index="currentPreviewIndex"
             fit="cover"
             class="gallery-image"
             lazy
@@ -172,10 +173,11 @@ function uploadError() {
   proxy.$modal.msgError("上传失败")
 }
 
-onMounted(async () => {
+// onActivated 首次挂载和 keep-alive 返回时触发
+onActivated(async () => {
   if (route.query.folderId) {
     categoryFolderId.value = parseInt(route.query.folderId)
-  } else {
+  } else if (!categoryFolderId.value) {
     const res = await folderList({ fdCate: "tpz", pageSize: 1 })
     const folder = (res.rows && res.rows[0]) || (res.data && res.data[0])
     if (folder) {

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

@@ -197,8 +197,9 @@ function getFileIcon(fileType) {
   return map[fileType] || "file"
 }
 
-onMounted(async () => {
-  if (route.query.folderId) {
+// onActivated 首次挂载和 keep-alive 返回时触发
+onActivated(async () => {
+  if (route.query.folderId && !currentFolder.value) {
     const fid = parseInt(route.query.folderId)
     const res = await folderList(queryParams.value)
     const folders = res.rows || res.data || []
@@ -213,6 +214,12 @@ onMounted(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()
   }

+ 4 - 4
gw-ui/src/views/portal/zdgc.vue

@@ -75,7 +75,7 @@
 </template>
 
 <script setup name="Zdgc">
-import { folderList, mkdir, deleteFolderRecursive } from "@/api/efinder/finder"
+import { folderList, deleteFolderRecursive } from "@/api/efinder/finder"
 import { addProject } from "@/api/pms/addProject"
 
 const { proxy } = getCurrentInstance()
@@ -113,11 +113,10 @@ function loadTabs() {
     tree.forEach(t => { t.projects = t.children || []; delete t.children })
     categoryTabs.value = tree
     if (tree.length > 0) {
-      // 支持首页传入 folderId 定位分类
+      // 支持首页传入 folderId 定位分类;赋值会触发 watch 加载项目列表
       const targetId = Number(route.query.folderId)
       const target = tree.find(t => t.id === targetId)
       activeTab.value = target ? String(target.id) : String(tree[0].id)
-      showTabProjects()
     }
   })
 }
@@ -238,7 +237,8 @@ async function handleBatchDelete() {
   } catch (_) {}
 }
 
-onMounted(() => { loadTabs() })
+// onActivated 首次挂载和返回时都会触发,统一加载避免重复请求
+onActivated(() => { loadTabs() })
 </script>
 
 <style lang="scss" scoped>

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

@@ -70,7 +70,7 @@
 </template>
 
 <script setup name="Zggc">
-import { folderList, mkdir, deleteFolderRecursive } from "@/api/efinder/finder"
+import { folderList, deleteFolderRecursive } from "@/api/efinder/finder"
 import { addProject } from "@/api/pms/addProject"
 
 const { proxy } = getCurrentInstance()
@@ -189,7 +189,8 @@ async function handleBatchDelete() {
   } catch (_) {}
 }
 
-onMounted(() => { getFolderList() })
+// onActivated 首次挂载和返回时都会触发,统一加载避免重复请求
+onActivated(() => { getFolderList() })
 </script>
 
 <style lang="scss" scoped>