feat: 完善档案删除与追溯码筛选
This commit is contained in:
@@ -105,6 +105,8 @@
|
||||
- 单件出库记录进入 C 端时间轴(2026-07-04):出库实况图/出库时间是 `TraceCode` 单件实物级数据,档案时间轴节点是 `Artwork.traceNodes` 档案级数据,二者不再依赖同一条手工节点。`PublicTraceService.trace` 在公开溯源返回时,如果当前追溯码存在 `outTime` 或 `outImage`,会自动在 `timeline` 末尾追加“本件出库记录”节点(`nodeType=OUTBOUND`,媒体来自 `TraceCode.outImage`),因此即使后台删除档案级“出库/流转”时间轴节点,C 端仍能展示该实物自己的出库记录。`AttestationService.trigger` 的上链摘要同步纳入 `batchNo`、`outTime`、`outImage`,保证触发上链时单件出库记录参与存证摘要。
|
||||
- 后端开发模式编译修复(2026-07-04):`apps/api/tsconfig.json` 禁用 `incremental`。原因是 `nest start --watch` 运行时依赖 `apps/api/dist`,如果开发服务运行中清理或部分删除了 `dist`,TS 增量编译可能只补变化文件,不会完整重吐未变化文件,导致运行时报 `Cannot find module './config/configuration'` 之类缺模块错误。后续清理构建产物时不要在 `dev.py` 运行中删除 API 的 `dist`;需要清理时先停开发服务再全量重启。
|
||||
- 艺术品新建页子资源提示(2026-07-04):艺术品档案新建时仍先保存基础信息以获得 `artworkId`,溯源时间轴与认证文件是挂在作品下的子资源,必须在作品存在后维护。后台 `ArtworkEdit.vue` 新建态不再隐藏这两个区块,而是显示锁定空状态,提示保存基础信息后可维护;保存后自动跳转详情页并启用原有节点/认证文件管理。
|
||||
- 艺术品档案删除约束(2026-07-04):艺术品档案删除仅用于误建/草稿类数据,后端 `ArtworkService.remove` 仍为软删除但会先检查该档案是否已有追溯码或查询日志;一旦存在业务痕迹则返回 `ARTWORK_IN_USE`,提示改为停用或归档。后台艺术品档案列表新增删除图标,仅 `codeCount=0` 时可点,已有追溯码的档案删除按钮置灰。
|
||||
- 追溯码列表表头筛选(2026-07-04):`TraceCodePanel` 工具栏保留短码/追溯码/档案号等输入查询,批次、出库状态、分组、追溯码状态改为表头下拉筛选,支持多条件叠加;追溯码列表新增创建时间列。后端 `QueryTraceCodeDto` / `ExportTraceCodeDto` 新增 `outboundStatus=OUTBOUND|NOT_OUTBOUND`,`TraceCodeService` 用 `AND` 合并出库状态和关键词等 OR 条件,避免筛选互相覆盖;导出当前筛选会带上出库状态。
|
||||
|
||||
## 当前代码基准与注意事项
|
||||
|
||||
@@ -113,6 +115,7 @@
|
||||
- 生码入口:主入口在艺术品档案列表的“数据管理”进入“批次与追溯码管理”;隐藏全局明细页也可生码但必须指定作品档案/款式。不存在“未绑定码池 → 绑定作品”的旧流程。
|
||||
- 出库导入:以短码定位具体一套码,导入列不再包含 SKU 或手填档案编号;档案编号由作品自动生成并在日志/导出/C 端展示。
|
||||
- 后台列表约定:新列表页优先复用 `apps/admin/src/composables/useTablePage.ts`,页面根容器使用 `class="page table-page"`,`n-data-table` 使用 `class="table-fill" flex-height` 且关闭内置分页,底部统一外置 `n-pagination`;后端列表查询如继承 `PaginationDto`,需遵守 `pageSize=0` 不分页语义。
|
||||
- 后台筛选约定:列表中输入型检索保留在工具栏;枚举/下拉型筛选优先放到对应表头下拉中,并把所有筛选条件集中到同一个 query 对象后叠加请求。
|
||||
- 开发脚本约定:`python scripts/dev.py` 会启动 `nest start --watch`,API 运行时不要手动或脚本化删除 `apps/api/dist`;如遇缺模块或半残 `dist`,停止当前 dev 进程后重新运行 `python scripts/dev.py`。
|
||||
- 客户端:当前 `Trace.vue` 依赖 `openMediaViewer.ts` + PhotoSwipe,不再使用旧 `MediaViewer.vue`;顶部语言菜单和追溯码复制是用户当前未提交改动的一部分,后续若继续修改客户端,需保护这些改动。
|
||||
- 文案残留:`apps/client/src/locales/*` 仍保留 `privacy.note`,但当前页面不显示底部隐私说明;若按合规要求恢复,需要在 `Trace.vue` 重新渲染对应文案。
|
||||
|
||||
@@ -1,30 +1,6 @@
|
||||
<template>
|
||||
<div :class="['trace-code-panel', { embedded }]">
|
||||
<div class="panel-toolbar">
|
||||
<n-select
|
||||
v-model:value="query.groupId"
|
||||
:options="groupFilterOptions"
|
||||
clearable
|
||||
:placeholder="t('pages.traceCode.allGroups')"
|
||||
class="toolbar-control"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-select
|
||||
v-model:value="query.batchId"
|
||||
:options="batchOptions"
|
||||
clearable
|
||||
:placeholder="t('pages.traceCode.batchNo')"
|
||||
class="toolbar-control wide"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-select
|
||||
v-model:value="query.status"
|
||||
:options="statusOptions"
|
||||
clearable
|
||||
:placeholder="t('common.label.status')"
|
||||
class="toolbar-control narrow"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('pages.traceCode.shortCode')"
|
||||
@@ -76,7 +52,7 @@
|
||||
class="table-fill"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1560"
|
||||
:scroll-x="1680"
|
||||
:row-key="(r) => r.id"
|
||||
v-model:checked-row-keys="checkedKeys"
|
||||
/>
|
||||
@@ -215,7 +191,7 @@ import { computed, h, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NDropdown, NIcon, NTag, NText, type DataTableColumns, type DropdownOption } from 'naive-ui';
|
||||
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline } from '@vicons/ionicons5';
|
||||
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline } from '@vicons/ionicons5';
|
||||
import dayjs from 'dayjs';
|
||||
import { TraceCodeStatus } from '@artveris/shared';
|
||||
import { traceCodeApi, jobApi, artworkApi, outboundApi } from '@/api';
|
||||
@@ -249,16 +225,22 @@ const query = reactive<{
|
||||
groupId: number | null;
|
||||
batchId: number | null;
|
||||
status: string | null;
|
||||
outboundStatus: string | null;
|
||||
keyword: string;
|
||||
}>({
|
||||
artworkId: fixedArtworkId.value,
|
||||
groupId: null,
|
||||
batchId: null,
|
||||
status: null,
|
||||
outboundStatus: null,
|
||||
keyword: '',
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, embedded.value ? 20 : 20);
|
||||
const statusOptions = Object.values(TraceCodeStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
const outboundStatusOptions = computed(() => [
|
||||
{ label: t('pages.traceCode.outRegistered'), value: 'OUTBOUND' },
|
||||
{ label: t('pages.traceCode.notOutbound'), value: 'NOT_OUTBOUND' },
|
||||
]);
|
||||
|
||||
const batchOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const batchMoveOptions = computed(() => batchOptions.value.map((b) => ({ label: b.label, value: b.value })));
|
||||
@@ -313,9 +295,17 @@ const outboundForm = reactive<any>({
|
||||
const columns = computed<DataTableColumns<any>>(() => {
|
||||
const base: DataTableColumns<any> = [
|
||||
{ type: 'selection' },
|
||||
{ title: () => t('pages.traceCode.batchNo'), key: 'batch', width: 150, render: (r) => r.batch?.batchNo || '-' },
|
||||
{
|
||||
title: () => t('pages.traceCode.outboundStatus'),
|
||||
title: () => renderFilterTitle(t('pages.traceCode.batchNo'), query.batchId, batchOptions.value, (value) => setHeaderFilter('batchId', value)),
|
||||
key: 'batch',
|
||||
width: 150,
|
||||
render: (r) => r.batch?.batchNo || '-',
|
||||
},
|
||||
{
|
||||
title: () =>
|
||||
renderFilterTitle(t('pages.traceCode.outboundStatus'), query.outboundStatus, outboundStatusOptions.value, (value) =>
|
||||
setHeaderFilter('outboundStatus', value),
|
||||
),
|
||||
key: 'outboundStatus',
|
||||
width: 96,
|
||||
render: (r) =>
|
||||
@@ -334,6 +324,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
: h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noOnchain') }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120 },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, render: (r) => fmt(r.createdAt) },
|
||||
{
|
||||
title: () => t('pages.traceCode.url'),
|
||||
key: 'url',
|
||||
@@ -346,9 +337,14 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
[r.url, h(NIcon, { component: OpenOutline, style: 'vertical-align:-2px;margin-left:4px' })],
|
||||
),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.group'), key: 'group', width: 110, render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }) },
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
title: () => renderFilterTitle(t('pages.traceCode.group'), query.groupId, groupFilterOptions.value, (value) => setHeaderFilter('groupId', value)),
|
||||
key: 'group',
|
||||
width: 110,
|
||||
render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }),
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle(t('common.label.status'), query.status, statusOptions, (value) => setHeaderFilter('status', value)),
|
||||
key: 'status',
|
||||
width: 96,
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||
@@ -393,6 +389,57 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
return base;
|
||||
});
|
||||
|
||||
type HeaderFilterField = 'batchId' | 'groupId' | 'status' | 'outboundStatus';
|
||||
type HeaderFilterValue = string | number | null;
|
||||
type HeaderFilterOption = { label: string; value: string | number };
|
||||
|
||||
function renderFilterTitle(
|
||||
label: string,
|
||||
value: HeaderFilterValue,
|
||||
options: HeaderFilterOption[],
|
||||
onSelect: (value: HeaderFilterValue) => void,
|
||||
) {
|
||||
const active = value !== null && value !== undefined && value !== '';
|
||||
const dropdownOptions: DropdownOption[] = [
|
||||
{ label: t('common.label.all'), key: '__all__' },
|
||||
...options.map((option) => ({ label: option.label, key: option.value })),
|
||||
];
|
||||
return h('div', { class: 'filter-title' }, [
|
||||
h('span', { class: 'filter-title-text' }, label),
|
||||
h(
|
||||
NDropdown,
|
||||
{
|
||||
trigger: 'click',
|
||||
options: dropdownOptions,
|
||||
onSelect: (key) => onSelect(key === '__all__' ? null : (key as string | number)),
|
||||
},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
quaternary: true,
|
||||
circle: true,
|
||||
size: 'tiny',
|
||||
class: ['filter-trigger', { active }],
|
||||
title: t('pages.traceCode.tableFilter'),
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
|
||||
),
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
function setHeaderFilter(field: HeaderFilterField, value: HeaderFilterValue) {
|
||||
if (field === 'batchId' || field === 'groupId') {
|
||||
query[field] = typeof value === 'number' ? value : null;
|
||||
} else {
|
||||
query[field] = value ? String(value) : null;
|
||||
}
|
||||
onSearch();
|
||||
}
|
||||
|
||||
function currentArtworkId() {
|
||||
return fixedArtworkId.value || query.artworkId || null;
|
||||
}
|
||||
@@ -418,6 +465,7 @@ async function load() {
|
||||
groupId: query.groupId || undefined,
|
||||
batchId: query.batchId || undefined,
|
||||
status: query.status || undefined,
|
||||
outboundStatus: query.outboundStatus || undefined,
|
||||
keyword: query.keyword || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
@@ -516,6 +564,7 @@ async function onExport(key: string) {
|
||||
if (query.groupId) params.groupId = query.groupId;
|
||||
if (query.batchId) params.batchId = query.batchId;
|
||||
if (query.status) params.status = query.status;
|
||||
if (query.outboundStatus) params.outboundStatus = query.outboundStatus;
|
||||
if (query.keyword) params.keyword = query.keyword;
|
||||
}
|
||||
await downloadFile('/trace-codes/export', `trace-codes.${format}`, params);
|
||||
@@ -785,6 +834,27 @@ onMounted(async () => {
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
}
|
||||
.filter-title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.filter-title-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.filter-trigger {
|
||||
flex: 0 0 auto;
|
||||
opacity: 0.62;
|
||||
}
|
||||
.filter-trigger.active {
|
||||
color: var(--brand);
|
||||
opacity: 1;
|
||||
}
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,9 @@
|
||||
"watermarkPending": "Generating watermark…",
|
||||
"editDetail": "Edit Details",
|
||||
"dataManage": "Data Management",
|
||||
"traceCodeManage": "Trace Code Management"
|
||||
"traceCodeManage": "Trace Code Management",
|
||||
"deleteConfirm": "Delete this artwork archive? Only archives without trace codes and query logs can be deleted.",
|
||||
"deleteDisabledTip": "This archive already has trace codes and cannot be deleted"
|
||||
},
|
||||
"traceCode": {
|
||||
"batches": "Batches",
|
||||
@@ -276,6 +278,7 @@
|
||||
"outRegistered": "Recorded",
|
||||
"notOutbound": "Not Outbound",
|
||||
"noOnchain": "Not On-chain",
|
||||
"tableFilter": "Filter",
|
||||
"registerOutbound": "Record Outbound / Chain",
|
||||
"enableOne": "Enable",
|
||||
"disableOne": "Disable",
|
||||
|
||||
@@ -232,7 +232,9 @@
|
||||
"watermarkPending": "水印生成中…",
|
||||
"editDetail": "编辑详情",
|
||||
"dataManage": "数据管理",
|
||||
"traceCodeManage": "追溯码管理"
|
||||
"traceCodeManage": "追溯码管理",
|
||||
"deleteConfirm": "确认删除该艺术品档案?仅未生成追溯码、无查询记录的档案可删除。",
|
||||
"deleteDisabledTip": "该档案已生成追溯码,不能删除"
|
||||
},
|
||||
"traceCode": {
|
||||
"batches": "批次列表",
|
||||
@@ -276,6 +278,7 @@
|
||||
"outRegistered": "已登记",
|
||||
"notOutbound": "未出库",
|
||||
"noOnchain": "未上链",
|
||||
"tableFilter": "筛选",
|
||||
"registerOutbound": "登记出库/上链",
|
||||
"enableOne": "启用",
|
||||
"disableOne": "禁用",
|
||||
|
||||
@@ -49,12 +49,13 @@ import { h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NIcon, NTag, NAvatar, type DataTableColumns } from 'naive-ui';
|
||||
import { SearchOutline, AddOutline, CreateOutline, BarChartOutline } from '@vicons/ionicons5';
|
||||
import { SearchOutline, AddOutline, CreateOutline, BarChartOutline, TrashOutline } from '@vicons/ionicons5';
|
||||
import { ArtworkStatus } from '@artveris/shared';
|
||||
import { artworkApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { dialog, message } from '@/utils/feedback';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -106,7 +107,7 @@ const columns: DataTableColumns<any> = [
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
width: 112,
|
||||
width: 148,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
render: (r) =>
|
||||
@@ -133,6 +134,21 @@ const columns: DataTableColumns<any> = [
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(BarChartOutline) }) },
|
||||
),
|
||||
auth.canWrite
|
||||
? h(
|
||||
NButton,
|
||||
{
|
||||
quaternary: true,
|
||||
circle: true,
|
||||
size: 'small',
|
||||
type: 'error',
|
||||
disabled: (r.codeCount ?? 0) > 0,
|
||||
title: (r.codeCount ?? 0) > 0 ? t('pages.artwork.deleteDisabledTip') : t('common.action.delete'),
|
||||
onClick: () => remove(r),
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) },
|
||||
)
|
||||
: null,
|
||||
]),
|
||||
},
|
||||
];
|
||||
@@ -159,6 +175,19 @@ function onSearch() {
|
||||
function goCreate() {
|
||||
router.push('/artworks/new');
|
||||
}
|
||||
function remove(r: any) {
|
||||
dialog.warning({
|
||||
title: t('common.action.delete'),
|
||||
content: t('pages.artwork.deleteConfirm'),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await artworkApi.remove(r.id);
|
||||
message.success(t('common.msg.deleted'));
|
||||
await load();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
@@ -170,6 +170,17 @@ export class ArtworkService {
|
||||
|
||||
async remove(id: number) {
|
||||
await this.ensureExists(id);
|
||||
const [traceCodeCount, queryLogCount] = await this.prisma.$transaction([
|
||||
this.prisma.traceCode.count({ where: { artworkId: id } }),
|
||||
this.prisma.queryLog.count({ where: { artworkId: id } }),
|
||||
]);
|
||||
if (traceCodeCount > 0 || queryLogCount > 0) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.ARTWORK_IN_USE,
|
||||
'该档案已生成追溯码或存在查询记录,不能删除;请改为停用或归档',
|
||||
400,
|
||||
);
|
||||
}
|
||||
await this.prisma.artwork.update({ where: { id }, data: { deletedAt: new Date() } });
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -60,6 +60,11 @@ export class QueryTraceCodeDto extends PaginationDto {
|
||||
@IsEnum(TraceCodeStatus)
|
||||
status?: TraceCodeStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: '出库状态', enum: ['OUTBOUND', 'NOT_OUTBOUND'] })
|
||||
@IsOptional()
|
||||
@IsIn(['OUTBOUND', 'NOT_OUTBOUND'])
|
||||
outboundStatus?: 'OUTBOUND' | 'NOT_OUTBOUND';
|
||||
|
||||
@ApiPropertyOptional({ description: '分组 ID' })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@@ -203,6 +208,11 @@ export class ExportTraceCodeDto {
|
||||
@IsEnum(TraceCodeStatus)
|
||||
status?: TraceCodeStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: '出库状态', enum: ['OUTBOUND', 'NOT_OUTBOUND'] })
|
||||
@IsOptional()
|
||||
@IsIn(['OUTBOUND', 'NOT_OUTBOUND'])
|
||||
outboundStatus?: 'OUTBOUND' | 'NOT_OUTBOUND';
|
||||
|
||||
@ApiPropertyOptional({ description: '关键词' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -344,20 +344,36 @@ export class TraceCodeService {
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
}
|
||||
|
||||
async list(query: QueryTraceCodeDto) {
|
||||
private buildTraceCodeWhere(
|
||||
query: Pick<QueryTraceCodeDto | ExportTraceCodeDto, 'artworkId' | 'batchId' | 'groupId' | 'status' | 'outboundStatus' | 'keyword'>,
|
||||
): Prisma.TraceCodeWhereInput {
|
||||
const where: Prisma.TraceCodeWhereInput = {};
|
||||
const and: Prisma.TraceCodeWhereInput[] = [];
|
||||
if (query.artworkId) where.artworkId = query.artworkId;
|
||||
if (query.batchId) where.batchId = query.batchId;
|
||||
if (query.groupId) where.groupId = query.groupId;
|
||||
if (query.status) where.status = query.status;
|
||||
if (query.keyword) {
|
||||
where.OR = [
|
||||
{ shortCode: { contains: query.keyword } },
|
||||
{ code: { contains: query.keyword } },
|
||||
{ artwork: { archiveNo: { contains: query.keyword } } },
|
||||
{ artwork: { title: { contains: query.keyword } } },
|
||||
];
|
||||
if (query.outboundStatus === 'OUTBOUND') {
|
||||
and.push({ OR: [{ outTime: { not: null } }, { outImage: { not: null } }] });
|
||||
} else if (query.outboundStatus === 'NOT_OUTBOUND') {
|
||||
and.push({ outTime: null, outImage: null });
|
||||
}
|
||||
if (query.keyword) {
|
||||
and.push({
|
||||
OR: [
|
||||
{ shortCode: { contains: query.keyword } },
|
||||
{ code: { contains: query.keyword } },
|
||||
{ artwork: { archiveNo: { contains: query.keyword } } },
|
||||
{ artwork: { title: { contains: query.keyword } } },
|
||||
],
|
||||
});
|
||||
}
|
||||
if (and.length) where.AND = and;
|
||||
return where;
|
||||
}
|
||||
|
||||
async list(query: QueryTraceCodeDto) {
|
||||
const where = this.buildTraceCodeWhere(query);
|
||||
const [list, total] = await this.prisma.$transaction([
|
||||
this.prisma.traceCode.findMany({
|
||||
where,
|
||||
@@ -413,18 +429,7 @@ export class TraceCodeService {
|
||||
.map((s) => BigInt(s));
|
||||
where.id = { in: idList };
|
||||
} else {
|
||||
if (dto.artworkId) where.artworkId = dto.artworkId;
|
||||
if (dto.batchId) where.batchId = dto.batchId;
|
||||
if (dto.groupId) where.groupId = dto.groupId;
|
||||
if (dto.status) where.status = dto.status;
|
||||
if (dto.keyword) {
|
||||
where.OR = [
|
||||
{ shortCode: { contains: dto.keyword } },
|
||||
{ code: { contains: dto.keyword } },
|
||||
{ artwork: { archiveNo: { contains: dto.keyword } } },
|
||||
{ artwork: { title: { contains: dto.keyword } } },
|
||||
];
|
||||
}
|
||||
Object.assign(where, this.buildTraceCodeWhere(dto));
|
||||
}
|
||||
|
||||
const codes = await this.prisma.traceCode.findMany({
|
||||
|
||||
@@ -34,6 +34,7 @@ export const ErrorCode = {
|
||||
CERTIFICATE_NOT_FOUND: 3012,
|
||||
JOB_NOT_FOUND: 3013,
|
||||
BATCH_NOT_FOUND: 3014,
|
||||
ARTWORK_IN_USE: 3015,
|
||||
} as const;
|
||||
|
||||
export type ErrorCodeValue = (typeof ErrorCode)[keyof typeof ErrorCode];
|
||||
@@ -67,4 +68,5 @@ export const ErrorMessage: Record<number, string> = {
|
||||
[ErrorCode.CERTIFICATE_NOT_FOUND]: '认证文件不存在',
|
||||
[ErrorCode.JOB_NOT_FOUND]: '任务不存在',
|
||||
[ErrorCode.BATCH_NOT_FOUND]: '批次不存在',
|
||||
[ErrorCode.ARTWORK_IN_USE]: '艺术品档案已有业务数据,无法删除',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user