fix: 看板已激活追溯码与列表口径一致,修正未激活筛选返回已激活的码

This commit is contained in:
Nixevol
2026-11-15 14:57:24 +08:00
parent a5f7844125
commit c8f076a3a7
9 changed files with 76 additions and 13 deletions
+23 -2
View File
@@ -258,6 +258,8 @@ const query = reactive<{
batchId: number | null;
status: string | null;
outboundStatus: string | null;
// 是否激活过:YES 有激活时间,NO 从未激活。与看板「已激活追溯码」同一口径
activated: string | null;
keyword: string;
}>({
artworkId: fixedArtworkId.value,
@@ -265,6 +267,7 @@ const query = reactive<{
batchId: null,
status: null,
outboundStatus: null,
activated: null,
keyword: '',
});
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, embedded.value ? 20 : 20);
@@ -274,6 +277,11 @@ const outboundStatusOptions = computed(() => [
{ label: t('pages.traceCode.outRegistered'), value: 'OUTBOUND' },
{ label: t('pages.traceCode.notOutbound'), value: 'NOT_OUTBOUND' },
]);
const activatedOptions = computed(() => [
{ label: t('pages.traceCode.everActivated'), value: 'YES' },
{ label: t('pages.traceCode.neverActivated'), value: 'NO' },
]);
const activatedParam = () => (query.activated === 'YES' ? true : query.activated === 'NO' ? false : undefined);
const batchOptions = ref<{ label: string; value: number }[]>([]);
const batchMoveOptions = computed(() => batchOptions.value.map((b) => ({ label: b.label, value: b.value })));
@@ -471,7 +479,14 @@ const columns = computed<DataTableColumns<any>>(() => {
// 查询次数
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 100, align: 'center' },
// 激活时间
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 150, align: 'center', render: (r) => fmt(r.firstActivatedAt), ...sortProps('firstActivatedAt') },
{
title: () => renderFilterTitle(t('pages.traceCode.firstActivatedAt'), query.activated, activatedOptions.value, (value) => setHeaderFilter('activated', value)),
key: 'firstActivatedAt',
width: 170,
align: 'center',
render: (r) => fmt(r.firstActivatedAt),
...sortProps('firstActivatedAt'),
},
// 链接:拦截直跳,先告知「直接访问会激活/计数」,再让用户选预览或实际访问
{
title: () => t('pages.traceCode.url'),
@@ -592,7 +607,7 @@ function confirmVisitReal(row: any) {
});
}
type HeaderFilterField = 'batchId' | 'groupId' | 'status' | 'outboundStatus';
type HeaderFilterField = 'batchId' | 'groupId' | 'status' | 'outboundStatus' | 'activated';
type HeaderFilterValue = string | number | null;
type HeaderFilterOption = { label: string; value: string | number };
@@ -626,6 +641,8 @@ function renderFilterTitle(
size: 'tiny',
class: ['filter-trigger', { active }],
title: t('pages.traceCode.tableFilter'),
// 可排序的列点表头会切换排序,点筛选按钮时不要连带触发
onClick: (event: MouseEvent) => event.stopPropagation(),
},
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
),
@@ -673,6 +690,7 @@ async function load() {
batchId: query.batchId || undefined,
status: query.status || undefined,
outboundStatus: query.outboundStatus || undefined,
activated: activatedParam(),
keyword: query.keyword || undefined,
page: page.value,
pageSize: pageSize.value,
@@ -759,6 +777,7 @@ const hasActiveExportFilter = computed(() => Boolean(
query.batchId ||
query.status ||
query.outboundStatus ||
query.activated ||
(!fixedArtworkId.value && query.artworkId),
));
@@ -781,6 +800,7 @@ async function onExport() {
if (query.batchId) params.batchId = query.batchId;
if (query.status) params.status = query.status;
if (query.outboundStatus) params.outboundStatus = query.outboundStatus;
if (query.activated) params.activated = activatedParam();
if (query.keyword) params.keyword = query.keyword;
}
exporting.value = true;
@@ -1142,6 +1162,7 @@ onMounted(async () => {
genForm.artworkId = aid;
}
if (typeof route.query.status === 'string') query.status = route.query.status;
if (route.query.activated === '1') query.activated = 'YES';
}
await Promise.all([loadBatches(), loadGroups()]);
await load();
+2
View File
@@ -478,6 +478,8 @@
"reconfirmOnchain": "Reconfirm",
"confirmSubmitted": "Reconfirm task submitted",
"tableFilter": "Filter",
"everActivated": "Ever activated",
"neverActivated": "Never activated",
"onchainInfo": "On-chain Info",
"enableOne": "Enable",
"disableOne": "Disable",
+2
View File
@@ -478,6 +478,8 @@
"reconfirmOnchain": "重新确认",
"confirmSubmitted": "已提交重新确认任务",
"tableFilter": "筛选",
"everActivated": "激活过",
"neverActivated": "从未激活",
"onchainInfo": "上链信息",
"enableOne": "启用",
"disableOne": "禁用",
+1 -1
View File
@@ -90,7 +90,7 @@ const range = ref<[number, number] | null>(null);
const stats = computed(() => [
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864', open: () => router.push('/artworks') },
{ key: 'totalCodes', label: t('pages.dashboard.totalCodes'), icon: QrCodeOutline, color: '#2e5496', open: () => router.push('/trace-codes') },
{ key: 'activatedCodes', label: t('pages.dashboard.activatedCodes'), icon: CheckmarkCircleOutline, color: '#138a72', open: () => router.push({ path: '/trace-codes', query: { status: 'ACTIVE' } }) },
{ key: 'activatedCodes', label: t('pages.dashboard.activatedCodes'), icon: CheckmarkCircleOutline, color: '#138a72', open: () => router.push({ path: '/trace-codes', query: { activated: '1' } }) },
{ key: 'totalQueries', label: t('pages.dashboard.totalQueries'), icon: SearchOutline, color: '#3a7bd5', open: () => router.push('/query-logs') },
{ key: 'todayQueries', label: t('pages.dashboard.todayQueries'), icon: TodayOutline, color: '#b9851f', open: () => router.push({ path: '/query-logs', query: { quickRange: 'today' } }) },
{ key: 'abnormalQueries', label: t('pages.dashboard.abnormalQueries'), icon: WarningOutline, color: '#c0392b', open: () => router.push({ path: '/query-logs', query: { abnormal: '1' } }) },