Преглед на файлове

fix: 修改Tracking表格数据仍在加载但loading失效bug

zhouyuhao преди 1 година
родител
ревизия
85acf6a9f1
променени са 3 файла, в които са добавени 29 реда и са изтрити 13 реда
  1. 2 1
      src/auto-imports.d.ts
  2. 8 2
      src/utils/axios.ts
  3. 19 10
      src/views/Tracking/src/components/TrackingTable/src/TrackingTable.vue

+ 2 - 1
src/auto-imports.d.ts

@@ -3,6 +3,7 @@
 // @ts-nocheck
 // noinspection JSUnusedGlobalSymbols
 // Generated by unplugin-auto-import
+// biome-ignore lint: disable
 export {}
 declare global {
   const $api: typeof import('@/api/index')['default']
@@ -68,6 +69,6 @@ declare global {
 // for type re-export
 declare global {
   // @ts-ignore
-  export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
+  export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
   import('vue')
 }

+ 8 - 2
src/utils/axios.ts

@@ -78,14 +78,20 @@ class HttpAxios {
 
   _checkResponseError = (error: any) => {
     if (error.code === 'ECONNABORTED') {
-      ElMessage.error('请求超时,请稍后再试!!!')
+      ElMessage.error({
+        message: 'Request timed out, please try again later!!',
+        grouping: true
+      })
       return Promise.reject(error)
     }
 
     const status = error.response?.status
     const statusText = error.response?.statusText
     const message = error.message
-    ElMessage.error(CODE_MESSAGE[status] || statusText || message)
+    ElMessage.error({
+      message: CODE_MESSAGE[status] || statusText || message,
+      grouping: true
+    })
     return Promise.reject(error)
   }
 

+ 19 - 10
src/views/Tracking/src/components/TrackingTable/src/TrackingTable.vue

@@ -67,7 +67,7 @@ const handleColumns = (columns: any, status?: string) => {
 
 // 获取表格列
 const getTableColumns = async (isInit: boolean) => {
-  tableLoading.value = true
+  tableLoadingColumn.value = true
   await $api.getTrackingTableColumns().then((res: any) => {
     if (res.code === 200) {
       const index = trackingTable.value.columns.findIndex((item: any) => item.title === 'Action')
@@ -87,7 +87,7 @@ const getTableColumns = async (isInit: boolean) => {
     }
   })
   nextTick(() => {
-    !isInit && (tableLoading.value = false)
+    !isInit && (tableLoadingColumn.value = false)
   })
 }
 
@@ -114,6 +114,9 @@ const getSharedTableData = () => {
         })
       }
     }
+    nextTick(() => {
+      tableRef.value && autoWidth(trackingTable.value, tableRef.value)
+    })
 
     // 拥有所有字段的表格
     setTimeout(() => {
@@ -131,7 +134,7 @@ const getSharedTableData = () => {
 
 const getTableData = async (isInit: boolean, isPageChange?: boolean) => {
   const rc = isPageChange ? pageInfo.value.total : -1
-  tableLoading.value = true
+  tableLoadingTableData.value = true
   if (
     sessionStorage.getItem('clickParams') != null &&
     sessionStorage.getItem('clickParams') != '{}'
@@ -202,13 +205,13 @@ const getTableData = async (isInit: boolean, isPageChange?: boolean) => {
       })
   }
   nextTick(() => {
-    !isInit && (tableLoading.value = false)
+    !isInit && (tableLoadingTableData.value = false)
   })
 }
 
 // 查询列表数据
 const searchTableData = (data: any) => {
-  tableLoading.value = true
+  tableLoadingTableData.value = true
   filterdataobj = data
   $api
     .getTrackingTableData({
@@ -232,7 +235,9 @@ const searchTableData = (data: any) => {
         } else {
           trackingTable.value.data = res.data.searchData
           pageInfo.value.total = Number(res.data.rc)
-          tableLoading.value = false
+          nextTick(() => {
+            tableRef.value && autoWidth(trackingTable.value, tableRef.value)
+          })
 
           // 拥有所有字段的表格
           setTimeout(() => {
@@ -245,12 +250,15 @@ const searchTableData = (data: any) => {
         }
       }
     })
+    .finally(() => {
+      tableLoadingTableData.value = false
+    })
 }
 
 onMounted(() => {
-  tableLoading.value = true
+  tableLoadingColumn.value = true
   Promise.all([getTableColumns(true)]).finally(() => {
-    tableLoading.value = false
+    tableLoadingColumn.value = false
     nextTick(() => {
       tableRef.value && autoWidth(trackingTable.value, tableRef.value)
     })
@@ -376,7 +384,8 @@ const exportTable = (status: number) => {
   allTableRef.value?.exportData(exportConfig)
 }
 
-const tableLoading = ref(false)
+const tableLoadingColumn = ref(false)
+const tableLoadingTableData = ref(false)
 
 const CustomizeColumnsRef = ref()
 // 打开定制表格弹窗
@@ -466,7 +475,7 @@ defineExpose({
 
     <vxe-grid
       ref="tableRef"
-      v-vloading="tableLoading"
+      v-vloading="tableLoadingColumn || tableLoadingTableData"
       :height="props.height"
       :style="{ border: 'none' }"
       v-bind="trackingTable"