fix: 简化追溯码导出按钮

This commit is contained in:
Nixevol
2026-07-05 04:05:27 +08:00
parent f0736f5cc5
commit 09a68ad0df
3 changed files with 22 additions and 20 deletions
+20 -19
View File
@@ -17,12 +17,10 @@
<template #icon><n-icon :component="FolderOutline" /></template>
{{ t('pages.traceCode.manageGroups') }}
</n-button>
<n-dropdown v-if="auth.canWrite" trigger="click" :options="exportOptions" @select="onExport">
<n-button>
<template #icon><n-icon :component="DownloadOutline" /></template>
{{ t('common.action.export') }}
</n-button>
</n-dropdown>
<n-button v-if="auth.canWrite" @click="onExport">
<template #icon><n-icon :component="DownloadOutline" /></template>
{{ exportButtonText }}
</n-button>
<n-button v-if="auth.canWrite" type="primary" @click="openGenerate">
<template #icon><n-icon :component="AddOutline" /></template>
{{ t('pages.traceCode.generate') }}
@@ -562,22 +560,25 @@ async function showQr(r: any) {
qrModal.value = true;
}
const exportOptions = computed(() => {
const cur = t('pages.traceCode.exportCurrent');
const opts: Array<{ label: string; key: string }> = [
{ label: cur, key: 'filter' },
];
if (checkedKeys.value.length) {
const sel = t('pages.traceCode.selected', { n: checkedKeys.value.length });
opts.push({ label: sel, key: 'selected' });
}
return opts;
const hasActiveExportFilter = computed(() => Boolean(
query.keyword ||
query.groupId ||
query.batchId ||
query.status ||
query.outboundStatus ||
(!fixedArtworkId.value && query.artworkId),
));
const exportButtonText = computed(() => {
const base = t('common.action.export');
if (checkedKeys.value.length) return `${base}(${t('pages.traceCode.selected', { n: checkedKeys.value.length })})`;
if (hasActiveExportFilter.value) return `${base}(${t('pages.traceCode.exportCurrent')})`;
return base;
});
async function onExport(key: string) {
const scope = key;
async function onExport() {
const params: Record<string, unknown> = {};
if (scope === 'selected') {
if (checkedKeys.value.length) {
params.ids = checkedKeys.value.map(String).join(',');
} else {
const aid = currentArtworkId();