Selaa lähdekoodia

feat: 转账记录下载报表按钮接入导出接口(跟随表单筛选),清理旧导出死代码

alphaH 2 viikkoa sitten
vanhempi
sitoutus
4f9473ed09
1 muutettua tiedostoa jossa 18 lisäystä ja 149 poistoa
  1. 18 149
      frontend/src/views/module_payment/account/index.vue

+ 18 - 149
frontend/src/views/module_payment/account/index.vue

@@ -285,14 +285,16 @@
             <template #header>
               <div class="card-header">
                 <span>转账记录</span>
-                <!-- <el-button
+                <el-button
                   type="primary"
                   icon="Download"
                   class="ml-auto"
-                  @click="showDownloadMenu = true"
+                  :loading="transferExportLoading"
+                  v-hasPerm="['module_payment:account:transfer:list']"
+                  @click="handleExportTransfer"
                 >
                   下载报表
-                </el-button> -->
+                </el-button>
               </div>
             </template>
             <div class="mb-4">
@@ -741,43 +743,6 @@
         <el-button type="primary" :loading="withdrawLoading" @click="handleWithdraw">确认提现</el-button>
       </template>
     </el-dialog>
-
-    <!-- 下载报表弹窗 -->
-    <el-dialog title="下载转账报表" v-model="showDownloadMenu" width="500px" :close-on-click-modal="false">
-      <div class="download-options">
-        <div class="option-group">
-          <p class="option-title">快捷时间范围</p>
-          <div class="option-buttons">
-            <el-button
-              v-for="option in quickOptions"
-              :key="option.value"
-              :type="selectedQuickOption === option.value ? 'primary' : ''"
-              @click="selectedQuickOption = option.value"
-            >
-              {{ option.label }}
-            </el-button>
-          </div>
-        </div>
-        <div class="option-group mt-4">
-          <p class="option-title">自定义时间范围</p>
-          <el-date-picker
-            v-model="customDateRange"
-            type="daterange"
-            range-separator="至"
-            start-placeholder="开始日期"
-            end-placeholder="结束日期"
-            class="w-full"
-            @change="handleCustomDateChange"
-          />
-        </div>
-      </div>
-      <template #footer>
-        <el-button @click="showDownloadMenu = false">取消</el-button>
-        <el-button type="primary" @click="handleDownload" :loading="downloadLoading">
-          下载报表
-        </el-button>
-      </template>
-    </el-dialog>
   </div>
 </template>
 
@@ -816,18 +781,7 @@ const depositLoading = ref(false);
 const transferLoading = ref(false);
 const consumeLoading = ref(false);
 const transferListLoading = ref(false);
-const downloadLoading = ref(false);
-
-const showDownloadMenu = ref(false);
-const selectedQuickOption = ref("today");
-const customDateRange = ref<Date[] | null>(null);
-
-const quickOptions = [
-  { label: "当天", value: "today" },
-  { label: "近3天", value: "3days" },
-  { label: "近15天", value: "15days" },
-  { label: "近30天", value: "30days" },
-];
+const transferExportLoading = ref(false);
 
 const authorizeFormRef = ref<FormInstance>();
 const createFormRef = ref<FormInstance>();
@@ -2081,101 +2035,33 @@ onMounted(async() => {
   }
 });
 
-async function handleDownload() {
-  downloadLoading.value = true;
+async function handleExportTransfer() {
+  transferExportLoading.value = true;
   try {
-    let start_time: string;
-    let end_time: string;
-
-    if (selectedQuickOption.value !== "custom") {
-      const range = calculateTimeRange(selectedQuickOption.value);
-      start_time = range.start_time;
-      end_time = range.end_time;
-    } else {
-      if (!customDateRange.value || customDateRange.value.length !== 2) {
-        ElMessage.warning("请选择时间范围");
-        return;
-      }
-      const [start, end] = customDateRange.value;
-      start_time = formatDateTime(start, "start");
-      end_time = formatDateTime(end, "end");
-    }
-
     const res = await AccountAPI.exportTransferReport({
-      start_time,
-      end_time,
-      enterprise_id: currentEnterpriseId.value || undefined,
+      out_biz_no: transferSearchForm.out_biz_no || undefined,
+      status: transferSearchForm.status || undefined,
+      tenant_id: transferSearchForm.tenant_id || undefined,
+      enterprise_id: transferSearchForm.enterprise_id || undefined,
+      start_time: transferSearchForm.start_time || undefined,
+      end_time: transferSearchForm.end_time || undefined,
     });
-
     const blob = new Blob([res.data], {
       type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
     });
     const url = window.URL.createObjectURL(blob);
     const a = document.createElement("a");
     a.href = url;
-    a.download = `转账报表_${start_time}_${end_time}.xlsx`;
+    a.download = "转账记录.xlsx";
     document.body.appendChild(a);
     a.click();
     document.body.removeChild(a);
     window.URL.revokeObjectURL(url);
-
-    ElMessage.success("报表下载成功");
-    showDownloadMenu.value = false;
-    selectedQuickOption.value = "today";
-    customDateRange.value = null;
+    ElMessage.success("导出成功");
   } catch (error) {
-    ElMessage.error("下载失败,请稍后重试");
+    ElMessage.error("导出失败,请稍后重试");
   } finally {
-    downloadLoading.value = false;
-  }
-}
-
-function calculateTimeRange(type: string): { start_time: string; end_time: string } {
-  const now = new Date();
-  const start = new Date();
-
-  switch (type) {
-    case "today":
-      start.setHours(0, 0, 0, 0);
-      break;
-    case "3days":
-      start.setDate(now.getDate() - 3);
-      start.setHours(0, 0, 0, 0);
-      break;
-    case "15days":
-      start.setDate(now.getDate() - 15);
-      start.setHours(0, 0, 0, 0);
-      break;
-    case "30days":
-      start.setDate(now.getDate() - 30);
-      start.setHours(0, 0, 0, 0);
-      break;
-  }
-
-  const end = new Date(now);
-  end.setHours(23, 59, 59, 999);
-
-  return {
-    start_time: formatDateTime(start),
-    end_time: formatDateTime(end),
-  };
-}
-
-function formatDateTime(date: Date, type: string = "start"): string {
-  const year = date.getFullYear();
-  const month = String(date.getMonth() + 1).padStart(2, "0");
-  const day = String(date.getDate()).padStart(2, "0");
-  
-  if (type === "start") {
-    return `${year}-${month}-${day} 00:00:00`;
-  } else {
-    return `${year}-${month}-${day} 23:59:59`;
-  }
-}
-
-function handleCustomDateChange() {
-  if (customDateRange.value && customDateRange.value.length === 2) {
-    selectedQuickOption.value = "custom";
+    transferExportLoading.value = false;
   }
 }
 
@@ -2270,21 +2156,4 @@ function handleCustomDateChange() {
     }
   }
 }
-
-.download-options {
-  .option-group {
-    .option-title {
-      font-size: 14px;
-      font-weight: 500;
-      color: #606266;
-      margin-bottom: 12px;
-    }
-
-    .option-buttons {
-      display: flex;
-      flex-wrap: wrap;
-      gap: 8px;
-    }
-  }
-}
 </style>