新增小店抢购报告导出并优化停止条件

This commit is contained in:
yml2213
2026-08-09 16:06:46 +08:00
parent 8b867709b2
commit 0c55da1e97
12 changed files with 884 additions and 19 deletions
@@ -7,8 +7,9 @@ import type { Product } from '@/composables/useProducts'
import { useActivity } from '@/composables/useActivity'
import { useToast } from '@/composables/useToast'
import {
QueryXiaodianAccountExchangeRecords,
QueryXiaodianExchangeRecords
ExportLatestXiaodianReport,
QueryXiaodianAccountExchangeRecords,
QueryXiaodianExchangeRecords
} from '@wails/go/app/App'
const {
@@ -38,6 +39,8 @@ const recordsModal = ref<{ accountName: string; loading: boolean; error: string;
const exchangeLookup = ref<{ productId: string; productName: string; loading: boolean; results: Record<string, any> } | null>(null)
const deleteTargetAccount = ref<string | null>(null)
const deletingAccount = ref(false)
const reportFormat = ref<'xlsx' | 'csv'>('xlsx')
const exportingReport = ref(false)
watch(xiaodianQRCode, async (value) => {
qrImage.value = ''
@@ -58,6 +61,24 @@ const handleBind = async () => {
await bindXiaodianRole()
}
const exportXiaodianReport = async () => {
if (exportingReport.value) return
exportingReport.value = true
try {
const result = await ExportLatestXiaodianReport(reportFormat.value)
if (result.cancelled) return
if (!result.success) {
showToast('导出失败', result.error || '无法生成抢购报告', 'error')
return
}
showToast('导出成功', `账号 ${result.accountCount} 个,订单 ${result.recordCount} 条`, 'success')
} catch (e: any) {
showToast('导出失败', e?.message || '无法生成抢购报告', 'error')
} finally {
exportingReport.value = false
}
}
const requestDeleteAccount = (accountName: string) => {
deleteTargetAccount.value = accountName
}
@@ -260,6 +281,13 @@ const closeExchangeRecords = () => {
>
{{ exchangeLookup?.loading ? '查询中...' : '查询兑换记录' }}
</button>
<select v-model="reportFormat" class="report-format" :disabled="exportingReport" aria-label="选择报告导出格式">
<option value="xlsx">Excel</option>
<option value="csv">CSV</option>
</select>
<button class="btn btn-compact btn-export-report" :disabled="exportingReport" @click="exportXiaodianReport">
{{ exportingReport ? '导出中...' : '导出报告' }}
</button>
</div>
</div>
@@ -541,6 +569,23 @@ const closeExchangeRecords = () => {
.exchange-lookup-product:disabled { opacity: .6; cursor: not-allowed; }
.report-format {
width: 72px;
height: 28px;
padding: 0 6px;
border: 1px solid var(--line-strong);
border-radius: var(--radius-sm);
background: var(--field);
color: var(--text);
font-size: 12px;
}
.btn-export-report {
color: var(--success);
border-color: var(--success);
background: var(--success-soft);
}
.panel-title {
font-size: 13px;
font-weight: 600;