Jelajahi Sumber

最近文件刷新,加载清除顺序

liuQiang 1 tahun lalu
induk
melakukan
3b5e1e1e5d

+ 36 - 18
src/layout/NewIndex.vue

@@ -14,6 +14,7 @@
       :allDataTotal="allDataTotal"
       :allSearching="allSearching"
       :highSearching="highSearching"
+      :tableFileData="tableFileData"
       @changeSearch="changeSearch"
       @openMaxmin="openMaxmin"
     ></DefaultPage>
@@ -31,6 +32,8 @@ import useUserStore from "@/store/modules/user";
 import usePermissionStore from "@/store/modules/permission";
 import { searchAll } from "@/api/search/search.js";
 import { flieSearch } from "@/api/search/search.js";
+import { getInfo, getInfoByDirId } from "@/api/biz/info";
+import { listRecent, getRecent } from "@/api/biz/recent";
 const permissionStore = usePermissionStore();
 const sidebarRouters = computed(() => permissionStore.sidebarRouters);
 const roles = useUserStore().roles;
@@ -50,6 +53,7 @@ const hightDataTotal = ref(); // 高级搜索数据总数
 const allDataTotal = ref(); // 全域搜索数据总数
 const allSearching = ref(false);
 const highSearching = ref(false);
+const tableFileData = ref([]);
 
 // 将标签信息保存到本地
 const openMaxmin = (title, path) => {
@@ -96,6 +100,7 @@ const openMaxmin = (title, path) => {
         setTimeout(() => {
           iframeSize(id);
         }, 1000);
+        getList();
         return;
       },
       full: (id) => {
@@ -139,6 +144,7 @@ const openMaxmin = (title, path) => {
         setTimeout(() => {
           iframeSize(id);
         }, 1500);
+        getList();
         return;
       },
       full: (id) => {
@@ -158,6 +164,20 @@ const openMaxmin = (title, path) => {
     sessionStorage.setItem("tagList", JSON.stringify([item]));
   }
 };
+// 获取最近文件数据
+const getList = async () => {
+  const resN = await listRecent({ isFolder: "N" });
+  if (resN.code === 200) {
+    tableFileData.value.length = resN.rows.length;
+    for (let index = 0; index < resN.rows.length; index++) {
+      getInfo(resN.rows[index].relaId).then(async (res) => {
+        //  tableFileData.value.push(res.data);
+        tableFileData.value.splice(index, 1, res.data);
+        index++;
+      });
+    }
+  }
+};
 //判断标签是否存在
 const hasThis = (clickRowId) => {
   const storage = sessionStorage.getItem("tagList");
@@ -191,10 +211,8 @@ const iframeSize = (id) => {
   }
   // console.log('outIframe', outIframe);
   // console.log("div.parentElement", div.offsetHeight);
-  inIframe.style.height =
-    tagIfarme.offsetHeight + "px";
-  inIframe.style.width = 
-    tagIfarme.offsetWidth + "px";
+  inIframe.style.height = tagIfarme.offsetHeight + "px";
+  inIframe.style.width = tagIfarme.offsetWidth + "px";
 };
 
 // 点击logo回到主页
@@ -204,6 +222,7 @@ const goIndex = () => {
 
 // 页面刷新后清除标签
 onMounted(() => {
+  getList();
   // 判断是否页面刷新 刷新就清楚存储的标签
   switch (performance.navigation.type) {
     case 0:
@@ -240,8 +259,7 @@ onMounted(() => {
 onUnmounted(() => {
   clearInterval();
 });
-const changeSearch = async (val, text) => {
-  
+const changeSearch = (val, text) => {
   searchText.value = text;
   if (val) {
     if (searchText.value.length < 2) {
@@ -263,23 +281,23 @@ const changeSearch = async (val, text) => {
       pageSize: 99999,
       pageNum: 1,
     };
-    //高级搜索
-    searchAll(query).then((res) => {
-      // console.log("hightData", res);
-        allSearching.value = false;
-      // if (res.data) {
-        hightData.value = res.data;
-        hightDataTotal.value = res.total;
-      // }
-    });
-
     // 全域搜索
     flieSearch(allQuery).then((res2) => {
       allData.value = res2.rows;
       allDataTotal.value = res2.total;
-      highSearching.value = false;
+      allSearching.value = false;
+
       // console.log("allData", res2);
     });
+    //高级搜索
+    searchAll(query).then((res) => {
+      // console.log("hightData", res);
+      highSearching.value = false;
+      // if (res.data) {
+      hightData.value = res.data;
+      hightDataTotal.value = res.total;
+      // }
+    });
   }
 };
 </script>
@@ -308,7 +326,7 @@ const changeSearch = async (val, text) => {
   // border: 1px solid #000;
   background-color: #b5d2ea;
 }
-:deep(.is-message-box){
+:deep(.is-message-box) {
   z-index: 99999999 !important;
 }
 </style>

+ 7 - 28
src/layout/components/DefaultPage/DefaultPage.vue

@@ -153,7 +153,7 @@
         </div>
         <div class="list">
           <div
-            v-for="item in tableFileData"
+            v-for="item in props.tableFileData"
             :key="item"
             @click="toFile(item)"
             class="oneBox"
@@ -229,8 +229,6 @@
 
 <script setup>
 import { onMounted, ref, toRaw, inject, watchEffect } from "vue";
-import { getInfo, getInfoByDirId } from "@/api/biz/info";
-import { listRecent, getRecent } from "@/api/biz/recent";
 import { setIcon, canPreviewFile } from "@/utils/index.js";
 import { preview } from "@/api/common/common.js";
 import { ElMessage, ElLoading, ElMessageBox } from "element-plus";
@@ -243,7 +241,7 @@ import { listInfo, selectInfo, getFileByScanerId } from "@/api/scanner/info.js";
 import documents from "@/api/document/document";
 import uploadApi from "@/api/upload/upload";
 import bus from "@/utils/bus.js";
-const tableFileData = ref([]);
+
 const copyFileType = ref();
 const previewData = ref();
 const loadingPreview = ref(false);
@@ -301,6 +299,10 @@ const props = defineProps({
     type: Boolean,
     default: false,
   },
+  tableFileData: {
+    type: Array,
+    default: () => [],
+  },
 });
 //搜索事件
 const searchBtn = () => {
@@ -322,29 +324,7 @@ const searchBtn = () => {
   }
   emit("changeSearch", true, searchText.value);
 };
-// 获取数据
-const getList = async () => {
-  const resN = await listRecent({ isFolder: "N" });
-  if (resN.code === 200) {
-    tableFileData.value.length = resN.rows.length;
-    for (let index = 0; index < resN.rows.length; index++) {
-      getInfo(resN.rows[index].relaId).then(async (res) => {
-        //  tableFileData.value.push(res.data);
-        tableFileData.value.splice(index, 1, res.data);
-        index++;
-      });
-    }
-    // console.log('tableFileData',tableFileData.value);
-    // 将tableFileData里的数据按照createTime排序
-    // tableFileData.value = tableFileData.value.sort((a, b) => {
-    //   return new Date(b.createTime) - new Date(a.createTime);
-    // });
-    // resN.rows.map(async (item) => {
-    //   const detail = await getInfo(item.relaId);
-    //   tableFileData.value.push(detail.data);
-    // });
-  }
-};
+
 // 打开最近文件
 const toFile = async (row) => {
   copyFileType.value = row.fileType;
@@ -587,7 +567,6 @@ watch(
   }
 );
 onMounted(() => {
-  getList();
   getSpaceList();
   getDirId();
   getConfigKey("file.size.limit").then((response) => {

+ 22 - 2
src/layout/components/TopMenu/TopMenu.vue

@@ -52,7 +52,7 @@
           class="hand"
           alt=""
         />
-        <span class="yuandian" v-if="hasNewMessage"></span>
+        <span class="yuandian" v-if="false"></span>
       </div>
       <img
         v-if="hasRole"
@@ -144,7 +144,9 @@ import { getConfigKey } from "@/api/system/config.js";
 import ScanFile from "@/components/ScanFile/ScanFile.vue";
 import MoveTo from "@/components/MoveTo/MoveTo.vue";
 import myfile from "@/api/myfile/myfile";
+import useWebsoctStore from "@/store/modules/websocket";
 import { listInfo, selectInfo, getFileByScanerId } from "@/api/scanner/info.js";
+const websoctStore = useWebsoctStore();
 const menuList = ref([
   {
     name: "部门文件",
@@ -185,7 +187,7 @@ const scannerFiles = ref([]); //选择的扫描仪的文件
 const openScanMove = ref(false);
 const openScan = ref(false); //控制扫描文档显示
 const scanFileArr = ref([]); //认领的扫描文件数组
-const hasNewMessage = ref(false)
+const hasNewMessage = ref(false);
 const emit = defineEmits(["openMaxmin", "goIndex"]);
 // 鼠标移入 显示更多菜单
 const showMoreMenu = () => {
@@ -286,6 +288,7 @@ const closeOpenScanMove = () => {
   openScanMove.value = false;
   // refreshFile();
 };
+let lisetenMessageTime = null;
 onMounted(() => {
   document.addEventListener("click", (e) => {
     if (e.target.className !== "oneMenu finger") {
@@ -293,6 +296,23 @@ onMounted(() => {
     }
   });
   window.addEventListener("click", hideShowMenu, true);
+  //红点相关
+  clearInterval(lisetenMessageTime);
+  lisetenMessageTime = setInterval(() => {
+    let tmplist = localStorage.getItem("noreadlist");
+    if (tmplist == null || tmplist == "") {
+      hasNewMessage.value = false;
+      return;
+    }
+    tmplist = JSON.parse(tmplist);
+    if (tmplist != null) hasNewMessage.value = true;
+    else hasNewMessage.value = false;
+  }, 1000);
+});
+watchEffect(async () => {
+  if (websoctStore.noReadList != null) hasNewMessage.value = true;
+  else hasNewMessage.value = false;
+  // console.log("===============websoctStore.noReadList:",websoctStore.noReadList,'===========',hasNewMessage.value)
 });
 </script>