Browse Source

fix(components): 优化表格搜索组件及导出逻辑

修复了多个页面中导出功能的异常处理逻辑,确保加载状态能正确关闭。同时优化
了 z-table 组件的搜索区域结构与类名,提升可维护性。另外,在构建配置中增加
了 terser 压缩选项以移除 console 和 debugger 语句,提升生产环境代码质量。
zhangtao 1 week ago
parent
commit
e221fbfb67

+ 3 - 3
src/components/zt/Table/z-table.vue

@@ -166,9 +166,9 @@ export default defineComponent({
 </script>
 
 <template>
-  <NCard v-if="getTableProps.showSearch" :bordered="false" size="small">
-    <NCollapse display-directive="show" :default-expanded-names="['role-search']">
-      <NCollapseItem title="搜索" name="role-search">
+  <NCard v-if="getTableProps.showSearch" :bordered="false" size="small" class="card-wrapper">
+    <NCollapse display-directive="show" :default-expanded-names="['search']">
+      <NCollapseItem title="搜索" name="search" display-directive="show">
         <BasicForm @register-form="registerSearchForm" @submit="handleSearch" @reset="handleReset" />
       </NCollapseItem>
     </NCollapse>

+ 5 - 1
src/views/config/dict/dict.data.ts

@@ -152,8 +152,12 @@ export const columns: NaiveUI.TableColumn<Api.System.DictData>[] = [
         uncheckedValue: 1,
         checkedValue: 0,
         onUpdateValue: async e => {
+          const oldStatus = rowData.status;
           rowData.status = e;
-          await fetchUpdateDictData(rowData);
+          const { response } = await fetchUpdateDictData(rowData);
+          if (response.data.code != '200') {
+            rowData.status = oldStatus;
+          }
         }
       });
     }

+ 6 - 3
src/views/delivery/after-sales-order/index.vue

@@ -344,9 +344,12 @@ function handleReset() {
 async function handleExport() {
   loading.value = true;
   try {
-    await commonExport('/platform/orderRefund/export', getFieldsValue(), '售后订单列表.xlsx');
-    loading.value = false;
-  } catch {
+    await commonExport(
+      '/platform/orderRefund/export',
+      { ...getFieldsValue(), returnMoneySts: activeTab.value },
+      '售后订单列表.xlsx'
+    );
+  } finally {
     loading.value = false;
   }
 }

+ 7 - 4
src/views/delivery/normal-order/index.vue

@@ -201,7 +201,7 @@ const { columns, data, loading, getData, mobilePagination } = useNaivePaginatedT
       key: 'operate',
       title: $t('common.operate'),
       align: 'center',
-      width: 130,
+      width: 150,
       fixed: 'right',
       render: row => {
         return (
@@ -332,9 +332,12 @@ function handleRefsh() {
 async function handleExport() {
   loading.value = true;
   try {
-    await commonExport('/platform/order/export', getFieldsValue(), '正常订单列表.xlsx');
-    loading.value = false;
-  } catch {
+    await commonExport(
+      '/platform/order/export',
+      { ...getFieldsValue(), orderStatus: activeTab.value },
+      '正常订单列表.xlsx'
+    );
+  } finally {
     loading.value = false;
   }
 }

+ 1 - 2
src/views/finance/commodity-freight/index.vue

@@ -165,8 +165,7 @@ async function handleExport() {
   setTableLoading(true);
   try {
     await commonExport('/platform/sku/freightStatisticsExcel', getSeachForm(), '运费明细列表.xlsx');
-    setTableLoading(false);
-  } catch {
+  } finally {
     setTableLoading(false);
   }
 }

+ 1 - 2
src/views/finance/summary/index.vue

@@ -116,8 +116,7 @@ async function handleExport() {
   setTableLoading(true);
   try {
     await commonExport('/platform/sku/skuStatisticsExcel', getSeachForm(), '对账单列表.xlsx');
-    setTableLoading(false);
-  } catch {
+  } finally {
     setTableLoading(false);
   }
 }

+ 1 - 2
src/views/goods/store-goods/index.vue

@@ -337,8 +337,7 @@ async function handleExport() {
   setTableLoading(true);
   try {
     await commonExport('/shop/shopProd/export', getSeachForm(), '商品列表.xlsx');
-    setTableLoading(false);
-  } catch {
+  } finally {
     setTableLoading(false);
   }
 }

+ 2 - 4
src/views/government/points/index.vue

@@ -265,8 +265,7 @@ async function hanleExportFailure(code: string) {
   loading.value = true;
   try {
     await commonExport('/platform/pointsFailureRecord/export', { code }, '失败的记录.xlsx');
-    loading.value = false;
-  } catch {
+  } finally {
     loading.value = false;
   }
 }
@@ -275,8 +274,7 @@ async function exportIntegral() {
   setTableLoading(true);
   try {
     await commonExport('/platform/pointsRecharge/export', getSeachForm(), '积分列表.xlsx');
-    setTableLoading(false);
-  } catch {
+  } finally {
     setTableLoading(false);
   }
 }

+ 1 - 2
src/views/government/user-list/index.vue

@@ -317,8 +317,7 @@ async function handleExport() {
   setTableLoading(true);
   try {
     await commonExport('/admin/enterprise/export', getSeachForm(), '员工列表.xlsx');
-    setTableLoading(false);
-  } catch {
+  } finally {
     setTableLoading(false);
   }
 }

+ 6 - 0
vite.config.ts

@@ -45,6 +45,12 @@ export default defineConfig(configEnv => {
       sourcemap: viteEnv.VITE_SOURCE_MAP === 'Y',
       commonjsOptions: {
         ignoreTryCatch: false
+      },
+      terserOptions: {
+        compress: {
+          drop_console: true,
+          drop_debugger: true
+        }
       }
     }
   };