Browse Source

打开Excel文件列表时定时刷新

lxf 1 year ago
parent
commit
cfcd703b5c
1 changed files with 16 additions and 6 deletions
  1. 16 6
      src/views/group/finance/check-bill/ExcelFile.vue

+ 16 - 6
src/views/group/finance/check-bill/ExcelFile.vue

@@ -7,12 +7,6 @@
       :loading="loading"
       :loading="loading"
       :searchConfig="searchConfig"
       :searchConfig="searchConfig"
       highlight-current-row
       highlight-current-row
-      :action-list="[
-        // {
-        //   text: '刷新',
-        //   action: () => getList(),
-        // },
-      ]"
       @get-list="getList">
       @get-list="getList">
     </byTable>
     </byTable>
   </div>
   </div>
@@ -155,6 +149,7 @@ const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
   loading.value = true;
   proxy.post("/excelGenerateLog/page", sourceList.value.pagination).then((res) => {
   proxy.post("/excelGenerateLog/page", sourceList.value.pagination).then((res) => {
+    console.log(res.rows);
     sourceList.value.data = res.rows;
     sourceList.value.data = res.rows;
     sourceList.value.pagination.total = res.total;
     sourceList.value.pagination.total = res.total;
     setTimeout(() => {
     setTimeout(() => {
@@ -189,6 +184,21 @@ const clickDelete = (row) => {
     })
     })
     .catch(() => {});
     .catch(() => {});
 };
 };
+const timer = ref(null);
+const startTimer = () => {
+  timer.value = setInterval(() => {
+    if (sourceList.value.data && sourceList.value.data.length > 0) {
+      let list = sourceList.value.data.filter((item) => [1, 2, 3].includes(item.status));
+      if (list && list.length > 0) {
+        getList();
+      }
+    }
+  }, 5000);
+};
+startTimer();
+onBeforeUnmount(() => {
+  clearInterval(timer.value); // 清除定时器
+});
 </script>
 </script>
 
 
 <style lang="scss" scoped></style>
 <style lang="scss" scoped></style>