fix: 优化追溯码管理入口和筛选

This commit is contained in:
Nixevol
2026-07-05 03:59:35 +08:00
parent 6a5cebf07b
commit eecc4ceb6e
9 changed files with 58 additions and 26 deletions
+1
View File
@@ -146,6 +146,7 @@
- 默认主题与语言初始化(2026-07-05):后台主题无用户保存值时默认 `auto`,跟随浏览器/系统 `prefers-color-scheme`;后台语言无保存值时按 `navigator.languages / navigator.language` 匹配 `zh-CN` 或 `en-US`,并同步设置 `<html lang>`。后台登录页右上角现在同时提供主题切换和语言切换。客户端语言继续默认识别浏览器语言,并补充 `<html lang>` 同步;客户端基础色板通过 CSS `prefers-color-scheme` 跟随系统,新增 `--card-bg/--soft-bg/--border/--shell-shadow` 等变量,首页和通用卡片使用变量适配明暗色。
- 客户端溯源页体验优化(2026-07-05):客户端溯源详情页顶部标题栏显示当前档案编号,未加载完成时回退平台名;顶栏配色改为清爽商务风浅色/暗色自适应。正品验证卡片移动到顶部媒体轮播下方,并在首次激活查询时弹窗展示,弹窗右上角有关闭图标。轮播在首尾克隆瞬移时给容器加 `no-anim`,同时禁用轨道和卡片缩放过渡,避免手动/自动切回第一张时闪烁。数字身份与区块链存证里的唯一追溯码、交易哈希、数据哈希复制入口统一为圆形图标按钮;正品验证卡片内追溯码也使用复制图标。认证文件展示改为居中单卡,多文件时用左右切换按钮和圆点切换,点击图片仍进入 PhotoSwipe 预览。
- 后台顶部操作栏粘性规则(2026-07-05):全局 `.page-toolbar` 改为内容区顶部 sticky 工具栏,带背景、边线和轻阴影,覆盖艺术品列表/详情、追溯码管理、模板、出库、审核、查询日志、操作日志、用户等所有统一页面工具栏,滚动长表单/详情时返回、保存、新增、导出等顶部操作不会被顶走。备份恢复组件的局部 `backup-toolbar` 也增加 sticky 兜底;设置页底部保存和个人中心表单按钮不是顶部工具栏,保持原位置。
- 追溯码管理入口与筛选修正(2026-07-05):全局 `/trace-codes` 从隐藏页恢复为左侧独立导航“追溯码管理”,仍保留艺术品详情页的数据管理入口;艺术品档案列表中点击“档案编号”改为进入作品编辑/详情页,右侧“数据管理”图标继续进入该档案追溯码管理。追溯码管理搜索框加宽,后端关键词搜索扩展到追溯码、完整编码、链接、档案编号、名称、艺术家、批次编号、分组名称和备注。分组管理接口不带参数时仍返回全部分组;生成追溯码弹窗会预加载作品下拉,避免初次点开显示无数据,并在选择作品后按该作品已有追溯码使用过的分组加载分组选项。
## 当前代码基准与注意事项
+1 -1
View File
@@ -65,7 +65,7 @@ export const traceCodeApi = {
qrBlob: (id: string) => download(`/trace-codes/${id}/qrcode`),
onchain: (id: string) => post(`/trace-codes/${id}/onchain`, {}),
// 分组
groups: () => get<any[]>('/trace-code-groups'),
groups: (params?: object) => get<any[]>('/trace-code-groups', params),
createGroup: (data: { name: string; remark?: string }) => post('/trace-code-groups', data),
updateGroup: (id: number, data: { name: string; remark?: string }) =>
put(`/trace-code-groups/${id}`, data),
+36 -16
View File
@@ -74,13 +74,14 @@
:options="artworkOptions"
:placeholder="t('pages.artwork.selectArtworkTip')"
@search="searchArtworks"
@focus="loadArtworkOptions('')"
/>
</n-form-item>
<n-form-item :label="t('pages.traceCode.quantity')">
<n-input-number v-model:value="genForm.quantity" :min="1" :max="10000" style="width: 100%" />
</n-form-item>
<n-form-item :label="t('pages.traceCode.group')">
<n-select v-model:value="genForm.groupId" :options="groupPlainOptions" clearable :placeholder="t('pages.traceCode.noGroup')" />
<n-select v-model:value="genForm.groupId" :options="generateGroupOptions" clearable :placeholder="t('pages.traceCode.noGroup')" />
</n-form-item>
<n-form-item :label="t('pages.traceCode.batchNo')">
<n-input v-model:value="genForm.batchNo" placeholder="(auto)" />
@@ -249,8 +250,9 @@ const outboundStatusOptions = computed(() => [
const batchOptions = ref<{ label: string; value: number }[]>([]);
const batchMoveOptions = computed(() => batchOptions.value.map((b) => ({ label: b.label, value: b.value })));
const groups = ref<any[]>([]);
const generateGroups = ref<any[]>([]);
const groupFilterOptions = computed(() => groups.value.map((g) => ({ label: g.name, value: g.id })));
const groupPlainOptions = computed(() => groups.value.map((g) => ({ label: g.name, value: g.id })));
const generateGroupOptions = computed(() => generateGroups.value.map((g) => ({ label: g.name, value: g.id })));
const groupAssignOptions = computed(() => [
{ label: t('pages.traceCode.noGroup'), key: '__none__' },
...groups.value.map((g) => ({ label: g.name, key: String(g.id) })),
@@ -466,6 +468,10 @@ async function loadGroups() {
groups.value = await traceCodeApi.groups();
}
async function loadGenerateGroups(artworkId: number | null) {
generateGroups.value = artworkId ? await traceCodeApi.groups({ artworkId }) : [];
}
async function load() {
loading.value = true;
checkedKeys.value = [];
@@ -493,25 +499,28 @@ function onSearch() {
load();
}
function openGenerate() {
async function openGenerate() {
genForm.artworkId = fixedArtworkId.value || query.artworkId;
await Promise.all([loadArtworkOptions(''), loadGenerateGroups(genForm.artworkId)]);
genModal.value = true;
}
async function loadArtworkOptions(keyword: string) {
artworkSearching.value = true;
try {
const res: any = await artworkApi.list({ keyword: keyword || undefined, pageSize: 20 });
artworkOptions.value = res.list.map((a: any) => ({
label: `${a.archiveNo || '-'} - ${a.title}`,
value: a.id,
}));
} finally {
artworkSearching.value = false;
}
}
function searchArtworks(keyword: string) {
if (artworkTimer) clearTimeout(artworkTimer);
artworkTimer = setTimeout(async () => {
artworkSearching.value = true;
try {
const res: any = await artworkApi.list({ keyword: keyword || undefined, pageSize: 20 });
artworkOptions.value = res.list.map((a: any) => ({
label: `${a.archiveNo || '-'} - ${a.title}`,
value: a.id,
}));
} finally {
artworkSearching.value = false;
}
}, 300);
artworkTimer = setTimeout(() => loadArtworkOptions(keyword), 300);
}
async function generate() {
@@ -810,12 +819,23 @@ watch(
query.artworkId = aid;
genForm.artworkId = aid;
query.batchId = null;
genForm.groupId = null;
await loadGenerateGroups(aid);
resetPage();
await loadBatches();
await load();
},
);
watch(
() => genForm.artworkId,
async (aid, oldAid) => {
if (aid === oldAid) return;
genForm.groupId = null;
await loadGenerateGroups(aid);
},
);
onMounted(async () => {
if (!fixedArtworkId.value) {
const aid = Number(route.query.artworkId);
@@ -850,7 +870,7 @@ onUnmounted(() => {
margin-bottom: 12px;
}
.toolbar-control {
width: 170px;
width: 320px;
}
.toolbar-control.wide {
width: 210px;
+3 -1
View File
@@ -64,6 +64,7 @@ import {
GridOutline,
DocumentTextOutline,
ImagesOutline,
QrCodeOutline,
CubeOutline,
ListOutline,
PeopleOutline,
@@ -99,6 +100,7 @@ const menuOptions = computed<MenuOption[]>(() => {
{ label: t('menu.dashboard'), key: 'dashboard', icon: renderIcon(GridOutline) },
{ label: t('menu.templates'), key: 'templates', icon: renderIcon(DocumentTextOutline) },
{ label: t('menu.artworks'), key: 'artworks', icon: renderIcon(ImagesOutline) },
{ label: t('menu.traceCodes'), key: 'traceCodes', icon: renderIcon(QrCodeOutline) },
{ label: t('menu.outbound'), key: 'outbound', icon: renderIcon(CubeOutline) },
{ label: t('menu.audit'), key: 'audit', icon: renderIcon(ShieldCheckmarkOutline), auditOnly: true },
{ label: t('menu.queryLogs'), key: 'queryLogs', icon: renderIcon(ListOutline) },
@@ -111,7 +113,7 @@ const menuOptions = computed<MenuOption[]>(() => {
);
});
const activeKey = computed(() => (['artwork-detail', 'artwork-trace-codes', 'traceCodes'].includes(route.name as string) ? 'artworks' : (route.name as string)));
const activeKey = computed(() => (['artwork-detail', 'artwork-trace-codes'].includes(route.name as string) ? 'artworks' : (route.name as string)));
const currentTitle = computed(() => {
if (route.name === 'traceCodes' || route.name === 'artwork-trace-codes') return t('pages.artwork.traceCodeManage');
return activeKey.value ? t(`menu.${activeKey.value}`) : '';
+2 -2
View File
@@ -158,7 +158,7 @@
"dashboard": "Dashboard",
"templates": "Templates",
"artworks": "Artwork Files",
"traceCodes": "Trace Code Details",
"traceCodes": "Trace Code Management",
"outbound": "Outbound & Chain",
"audit": "Content Audit",
"queryLogs": "Query Logs",
@@ -307,7 +307,7 @@
"shortCode": "Trace Code",
"code": "Trace Code",
"url": "Link",
"keywordPlaceholder": "Trace code / link / archive no. / name",
"keywordPlaceholder": "Trace code / link / archive no. / name / artist / batch / group / note",
"queryCount": "Queries",
"firstActivatedAt": "First Activated",
"exportBatch": "Export Batch",
+2 -2
View File
@@ -158,7 +158,7 @@
"dashboard": "数据看板",
"templates": "溯源模板",
"artworks": "艺术品档案",
"traceCodes": "追溯码明细",
"traceCodes": "追溯码管理",
"outbound": "出库与上链",
"audit": "内容审核",
"queryLogs": "查询日志",
@@ -307,7 +307,7 @@
"shortCode": "追溯码",
"code": "追溯码",
"url": "链接",
"keywordPlaceholder": "追溯码 / 链接 / 档案编号 / 名称",
"keywordPlaceholder": "追溯码 / 链接 / 档案编号 / 名称 / 艺术家 / 批次 / 分组 / 备注",
"queryCount": "查询次数",
"firstActivatedAt": "首次激活时间",
"exportBatch": "导出本批",
+1 -1
View File
@@ -94,7 +94,7 @@ const columns: DataTableColumns<any> = [
render: (r) =>
h(
NButton,
{ text: true, type: 'primary', title: t('pages.artwork.traceCodeManage'), onClick: () => router.push(`/artworks/${r.id}/trace-codes`) },
{ text: true, type: 'primary', title: t('pages.artwork.editDetail'), onClick: () => router.push(`/artworks/${r.id}`) },
{ default: () => r.archiveNo || '-' },
),
},
@@ -50,8 +50,9 @@ export class TraceCodeController {
@Get('trace-code-groups')
@ApiOperation({ summary: '分组列表' })
groups() {
return this.service.listGroups();
groups(@Query('artworkId') artworkId?: string) {
const id = artworkId ? Number(artworkId) : undefined;
return this.service.listGroups(id && Number.isFinite(id) ? id : undefined);
}
@Post('trace-code-groups')
@@ -65,6 +65,8 @@ export class TraceCodeService {
});
if (!artwork) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '鑹烘湳鍝佷笉瀛樺湪', 404);
if (dto.groupId !== undefined && dto.groupId !== null) await this.ensureGroup(dto.groupId);
const batchNo = dto.batchNo || `B${dayjs().format('YYYYMMDDHHmmss')}`;
const exists = await this.prisma.batch.findUnique({ where: { batchNo } });
if (exists) {
@@ -89,8 +91,9 @@ export class TraceCodeService {
}
// ===== 鍒嗙粍绠$悊 =====
listGroups() {
listGroups(artworkId?: number) {
return this.prisma.traceCodeGroup.findMany({
where: artworkId ? { traceCodes: { some: { artworkId } } } : undefined,
orderBy: { id: 'desc' },
include: { _count: { select: { traceCodes: true } } },
});
@@ -394,8 +397,13 @@ export class TraceCodeService {
OR: [
{ shortCode: { contains: query.keyword } },
{ code: { contains: query.keyword } },
{ url: { contains: query.keyword } },
{ remark: { contains: query.keyword } },
{ artwork: { archiveNo: { contains: query.keyword } } },
{ artwork: { title: { contains: query.keyword } } },
{ artwork: { artist: { contains: query.keyword } } },
{ batch: { batchNo: { contains: query.keyword } } },
{ group: { name: { contains: query.keyword } } },
],
});
}