From fee1efc490b59113b9f13010f51a325a13eda57c Mon Sep 17 00:00:00 2001 From: Nixevol Date: Thu, 16 Jul 2026 11:50:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8B=86=E5=88=86=E4=B8=8A=E9=93=BE?= =?UTF-8?q?=E4=B8=8E=E5=87=BA=E5=BA=93=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/src/api/index.ts | 57 +- apps/admin/src/components/BatchJobModal.vue | 264 +++++ .../src/components/OnchainProofModal.vue | 279 +++++ .../src/components/OutboundImageManager.vue | 285 +++++ .../src/components/OutboundRecordModal.vue | 183 +++ .../components/TraceCodeOperationTable.vue | 1018 +++++++++++++++++ apps/admin/src/components/TraceCodePanel.vue | 301 ++--- apps/admin/src/layouts/MainLayout.vue | 2 + apps/admin/src/locales/en-US.json | 132 ++- apps/admin/src/locales/zh-CN.json | 132 ++- apps/admin/src/router/index.ts | 3 +- apps/admin/src/utils/format.ts | 4 + apps/admin/src/utils/operationReason.ts | 16 + apps/admin/src/views/ArtworkEdit.vue | 6 +- apps/admin/src/views/Onchain.vue | 15 + apps/admin/src/views/OperationLogs.vue | 10 +- apps/admin/src/views/Outbound.vue | 23 +- apps/admin/src/views/OutboundManagement.vue | 47 + apps/client/src/api.ts | 11 + apps/client/src/locales/en-US.json | 22 + apps/client/src/locales/zh-CN.json | 22 + apps/client/src/views/Trace.vue | 262 ++++- 22 files changed, 2844 insertions(+), 250 deletions(-) create mode 100644 apps/admin/src/components/BatchJobModal.vue create mode 100644 apps/admin/src/components/OnchainProofModal.vue create mode 100644 apps/admin/src/components/OutboundImageManager.vue create mode 100644 apps/admin/src/components/OutboundRecordModal.vue create mode 100644 apps/admin/src/components/TraceCodeOperationTable.vue create mode 100644 apps/admin/src/utils/operationReason.ts create mode 100644 apps/admin/src/views/Onchain.vue create mode 100644 apps/admin/src/views/OutboundManagement.vue diff --git a/apps/admin/src/api/index.ts b/apps/admin/src/api/index.ts index f50ae5f..1f14323 100644 --- a/apps/admin/src/api/index.ts +++ b/apps/admin/src/api/index.ts @@ -1,6 +1,21 @@ import { get, post, put, del, download } from './request'; import type { PageResult } from '@artveris/shared'; +export interface TraceCodeFilters { + keyword?: string; + artworkId?: number; + batchId?: number; + groupId?: number; + status?: string; + activated?: boolean; + outboundStatus?: string; + proofStatus?: string; +} + +export type BatchSelection = + | { mode: 'IDS'; ids: string[] } + | { mode: 'FILTER'; filters: TraceCodeFilters; excludeIds: string[] }; + export interface LoginResult { token: string; user: { id: number; username: string; realName?: string; role: string }; @@ -61,13 +76,8 @@ export const artworkApi = { remove: (id: number) => del(`/artworks/${id}`), // nodes listNodes: (artworkId: number) => get(`/artworks/${artworkId}/nodes`), - createNode: (artworkId: number, data: object) => post(`/artworks/${artworkId}/nodes`, data), - updateNode: (id: number, data: object) => put(`/nodes/${id}`, data), - removeNode: (id: number) => del(`/nodes/${id}`), // certificates listCerts: (artworkId: number) => get(`/artworks/${artworkId}/certificates`), - createCert: (artworkId: number, data: object) => post(`/artworks/${artworkId}/certificates`, data), - removeCert: (id: number) => del(`/certificates/${id}`), // audit audit: (id: number, data: { approved: boolean; remark?: string }) => post(`/artworks/${id}/audit`, data), }; @@ -83,7 +93,6 @@ export const traceCodeApi = { batchDelete: (ids: string[]) => post('/trace-codes/batch/delete', { ids }), qrUrl: (id: string) => `/api/trace-codes/${id}/qrcode`, qrBlob: (id: string) => download(`/trace-codes/${id}/qrcode`), - onchain: (id: string) => post(`/trace-codes/${id}/onchain`, {}), confirmProof: (id: number) => post(`/blockchain-proofs/${id}/confirm`, {}), previewToken: () => get<{ token: string; clientBase: string; periodMs: number }>('/trace-codes/preview-token'), // 分组 @@ -99,10 +108,38 @@ export const traceCodeApi = { put('/trace-codes/batch/move', { ids, ...data }), batchStatus: (ids: string[], disabled: boolean) => put('/trace-codes/batch/status', { ids, disabled }), + match: (codes: string[], operation: 'ONCHAIN' | 'OUTBOUND') => + post<{ + matched: any[]; + missing: string[]; + duplicates: string[]; + }>('/trace-codes/match', { codes, operation }), +}; + +export const onchainApi = { + createJob: (selection: BatchSelection) => post('/blockchain/onchain-jobs', { selection }), + resync: (chunkId: string) => post(`/blockchain/onchain-chunks/${chunkId}/resync`, {}), + markFailed: (chunkId: string, reason: string) => + post(`/blockchain/onchain-chunks/${chunkId}/mark-failed`, { reason }), + recordTransaction: (proofId: number, txHash: string) => + post(`/blockchain-proofs/${proofId}/transaction`, { txHash }), }; export const outboundApi = { - updateSingle: (id: string, data: object) => put(`/outbound/trace-codes/${id}`, data), + getRecord: (id: string, silent = false) => + get(`/outbound/${id}`, undefined, { silentError: silent }), + updateRecord: (id: string, data: { outTime: string; remark?: string | null }) => + put(`/outbound/${id}`, data), + createJob: (selection: BatchSelection, outTime: string, remark?: string) => + post('/outbound/jobs', { selection, outTime, remark: remark || undefined }), + images: (id: string, params: { page: number; pageSize: number }) => + get<{ items: any[]; total: number; page: number; pageSize: number }>(`/outbound/${id}/images`, params), + uploadImage: (id: string, data: FormData) => + post(`/outbound/${id}/images`, data, { timeout: 0 }), + removeImage: (id: string, imageId: string) => + del(`/outbound/${id}/images/${imageId}`), + moveImage: (id: string, imageId: string, direction: 'UP' | 'DOWN') => + put(`/outbound/${id}/images/${imageId}/move`, { direction }), templateUrl: '/api/outbound/import/template', preview: (data: FormData) => post('/outbound/import/preview', data, { timeout: 0 }), requestSession: (requestId: string, silent = false) => @@ -124,6 +161,12 @@ export const auditApi = { export const jobApi = { get: (id: string, silent = false) => get(`/jobs/${id}`, undefined, { silentError: silent }), list: (params: object) => get>('/jobs', params), + items: (id: string, params: { page: number; pageSize: number; status?: string }, silent = false) => + get<{ items?: any[]; list?: any[]; total: number; page: number; pageSize: number }>( + `/jobs/${id}/items`, + params, + { silentError: silent }, + ), }; export const queryLogApi = { diff --git a/apps/admin/src/components/BatchJobModal.vue b/apps/admin/src/components/BatchJobModal.vue new file mode 100644 index 0000000..be9ade6 --- /dev/null +++ b/apps/admin/src/components/BatchJobModal.vue @@ -0,0 +1,264 @@ + + + + + diff --git a/apps/admin/src/components/OnchainProofModal.vue b/apps/admin/src/components/OnchainProofModal.vue new file mode 100644 index 0000000..6ef512c --- /dev/null +++ b/apps/admin/src/components/OnchainProofModal.vue @@ -0,0 +1,279 @@ + + + + + diff --git a/apps/admin/src/components/OutboundImageManager.vue b/apps/admin/src/components/OutboundImageManager.vue new file mode 100644 index 0000000..1844d2b --- /dev/null +++ b/apps/admin/src/components/OutboundImageManager.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/apps/admin/src/components/OutboundRecordModal.vue b/apps/admin/src/components/OutboundRecordModal.vue new file mode 100644 index 0000000..be332eb --- /dev/null +++ b/apps/admin/src/components/OutboundRecordModal.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/apps/admin/src/components/TraceCodeOperationTable.vue b/apps/admin/src/components/TraceCodeOperationTable.vue new file mode 100644 index 0000000..1b4b7ba --- /dev/null +++ b/apps/admin/src/components/TraceCodeOperationTable.vue @@ -0,0 +1,1018 @@ + + + + + diff --git a/apps/admin/src/components/TraceCodePanel.vue b/apps/admin/src/components/TraceCodePanel.vue index 10a0784..778e19f 100644 --- a/apps/admin/src/components/TraceCodePanel.vue +++ b/apps/admin/src/components/TraceCodePanel.vue @@ -144,93 +144,23 @@ - - - - - - {{ outboundForm.outTime || '-' }} - - - - {{ outboundForm.remark || '-' }} - - - - - - - - - - - - {{ t('pages.outbound.onchainAutoTip') }} - - - - + + + @@ -239,17 +169,19 @@ import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue'; import { useRoute, useRouter } 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, FilterOutline, CopyOutline } from '@vicons/ionicons5'; -import dayjs from 'dayjs'; +import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline, EllipsisHorizontalOutline, FilterOutline } from '@vicons/ionicons5'; import { TraceCodeStatus } from '@artveris/shared'; -import { traceCodeApi, jobApi, artworkApi, outboundApi } from '@/api'; +import { traceCodeApi, jobApi, artworkApi, onchainApi } from '@/api'; import { useAuthStore } from '@/stores/auth'; import { message, dialog } from '@/utils/feedback'; import { fmt, statusType } from '@/utils/format'; import { downloadFile } from '@/utils/download'; import { useTablePage } from '@/composables/useTablePage'; import { useRemoteSort } from '@/utils/tableSort'; -import MediaUpload from '@/components/MediaUpload.vue'; +import { localizeOperationReason } from '@/utils/operationReason'; +import BatchJobModal from '@/components/BatchJobModal.vue'; +import OnchainProofModal from '@/components/OnchainProofModal.vue'; +import OutboundRecordModal from '@/components/OutboundRecordModal.vue'; const props = defineProps<{ artworkId?: number; @@ -334,35 +266,35 @@ const editingGroup = ref(null); const batchModal = ref(false); const batchTarget = ref(null); const batchForm = reactive<{ batchValue: number | string | null }>({ batchValue: null }); -const outboundModal = ref(false); -const outboundSaving = ref(false); -const outboundTriggering = ref(false); -const outboundTarget = ref(null); -const outImages = ref([]); -const outboundForm = reactive({ - outTime: null, - remark: '', -}); +const outboundRecordVisible = ref(false); +const proofVisible = ref(false); +const operationTarget = ref(null); +const jobVisible = ref(false); +const jobId = ref(''); function rowIsOutbound(row: any) { if (!row) return false; - return Boolean(row.outTime || getOutImages(row).length); + return Boolean(row.outbound || row.outTime || getOutImages(row).length); } function rowIsOnchain(row: any) { - // 已提交上链即视为已上链:ONCHAIN(已确认)/CONFIRMING(确认中)/PENDING(待处理) 均不允许重复上链,仅 FAILED 可重试 - const s = row?.latestAnyProof?.status; - return s === 'ONCHAIN' || s === 'CONFIRMING' || s === 'PENDING'; + const s = proofOf(row)?.status || row?.proofStatus; + return s === 'ONCHAIN' || s === 'CONFIRMING' || s === 'SUBMITTING' || s === 'PENDING'; } -function outboundMenuLabel(row: any) { - if (rowIsOnchain(row)) return t('pages.traceCode.onchainInfo'); - if (rowIsOutbound(row)) return t('pages.traceCode.triggerOnchainOnly'); - return t('pages.traceCode.registerOutbound'); +function proofOf(row: any) { + return row?.latestAnyProof ?? row?.proof ?? null; +} +function canRunOnchain(row: any) { + if (typeof row?.onchainEligible === 'boolean') return row.onchainEligible; + const status = proofOf(row)?.status || row?.proofStatus || 'NONE'; + return status === 'NONE' || status === 'FAILED'; +} +function outboundActionLabel(row: any) { + return rowIsOutbound(row) ? t('pages.outbound.editRecord') : t('pages.outbound.registerRecord'); +} +function onchainActionLabel(row: any) { + if (rowIsOnchain(row) || proofOf(row)) return t('pages.traceCode.onchainInfo'); + return canRunOnchain(row) ? t('pages.blockchain.trigger') : t('pages.operations.onchainUnavailable'); } -const targetOutbound = computed(() => rowIsOutbound(outboundTarget.value)); -const targetOnchain = computed(() => rowIsOnchain(outboundTarget.value)); -const outboundReadonly = computed(() => targetOutbound.value || targetOnchain.value); -const targetProof = computed(() => outboundTarget.value?.latestProof ?? outboundTarget.value?.latestAnyProof ?? null); -const outboundModalTitle = computed(() => outboundMenuLabel(outboundTarget.value)); const columns = computed>(() => { const cols: DataTableColumns = [ @@ -426,7 +358,7 @@ const columns = computed>(() => { align: 'center', render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }), }, - // 出库状态:点击打开该行「出库上链」详情弹窗(弹窗按状态自动呈现登记/上链/只读信息形态) + // 出库状态仅打开出库记录,不再夹带上链操作。 { title: () => renderFilterTitle(t('pages.traceCode.outboundStatus'), query.outboundStatus, outboundStatusOptions.value, (value) => @@ -438,7 +370,7 @@ const columns = computed>(() => { render: (r) => h( 'span', - { class: 'cell-click', title: outboundMenuLabel(r), onClick: () => openOutboundModal(r) }, + { class: 'cell-click', title: outboundActionLabel(r), onClick: () => openOutboundRecord(r) }, [ r.outTime || getOutImages(r).length ? h(NTag, { size: 'small', type: 'success' }, { default: () => t('pages.traceCode.outRegistered') }) @@ -446,7 +378,7 @@ const columns = computed>(() => { ], ), }, - // 上链状态:同上,点击进详情弹窗 + // 上链状态仅打开存证详情。 { title: () => t('pages.traceCode.onchainStatus'), key: 'onchainStatus', @@ -455,10 +387,14 @@ const columns = computed>(() => { render: (r) => h( 'span', - { class: 'cell-click', title: outboundMenuLabel(r), onClick: () => openOutboundModal(r) }, + { + class: 'cell-click', + title: localizeOperationReason(r.onchainReason) || onchainActionLabel(r), + onClick: () => openProof(r), + }, [ - r.latestAnyProof - ? h(NTag, { size: 'small', type: proofStatusType(r.latestAnyProof) }, { default: () => proofStatusText(r.latestAnyProof) }) + proofOf(r) + ? h(NTag, { size: 'small', type: proofStatusType(proofOf(r)) }, { default: () => proofStatusText(proofOf(r)) }) : h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noOnchain') }), ], ), @@ -833,9 +769,17 @@ function rowActionOptions(row: any): DropdownOption[] { const options: DropdownOption[] = [ { label: t('pages.traceCode.changeGroup'), key: 'changeGroup', children: rowGroupOptions.value }, { label: t('pages.traceCode.changeBatch'), key: 'batch:open' }, - { label: outboundMenuLabel(row), key: 'outbound:open' }, + { label: outboundActionLabel(row), key: 'outbound:open' }, + canRunOnchain(row) + ? { + label: proofOf(row)?.status === 'FAILED' ? t('pages.blockchain.retry') : t('pages.blockchain.trigger'), + key: 'onchain:run', + } + : proofOf(row) + ? { label: t('pages.traceCode.onchainInfo'), key: 'onchain:info' } + : { label: t('pages.operations.onchainUnavailable'), key: 'onchain:unavailable', disabled: true }, ]; - if (canManualConfirm(row.latestAnyProof)) { + if (canManualConfirm(proofOf(row))) { options.push({ label: t('pages.traceCode.reconfirmOnchain'), key: 'onchain:confirm' }); } options.push( @@ -865,12 +809,22 @@ async function onRowAction(row: any, key: string) { } if (key === 'outbound:open') { - openOutboundModal(row); + openOutboundRecord(row); + return; + } + + if (key === 'onchain:run') { + await runOnchainRow(row); + return; + } + + if (key === 'onchain:info') { + openProof(row); return; } if (key === 'onchain:confirm') { - await confirmProof(row.latestAnyProof); + await confirmProof(proofOf(row)); return; } @@ -958,10 +912,6 @@ async function applyBatchMove() { emit('changed'); } -function formatDateTime(value?: string | Date | null) { - return value ? dayjs(value).format('YYYY-MM-DD HH:mm') : null; -} - function fileName(key: string) { return key.split('/').pop() || key; } @@ -973,58 +923,43 @@ function getOutImages(row: any) { ); } -async function copyValue(value: unknown) { - const text = value === null || value === undefined ? '' : String(value); - if (!text) return; - try { - await navigator.clipboard.writeText(text); - message.success(t('common.msg.copied')); - } catch { - message.error(t('common.msg.copyFailed')); - } +function openOutboundRecord(row: any) { + operationTarget.value = row; + outboundRecordVisible.value = true; } -function openOutboundModal(row: any) { - outboundTarget.value = row; - // 出库时间必填:未出库时默认此刻;已出库时回显既有时间(只读) - outboundForm.outTime = row.outTime ? formatDateTime(row.outTime) : dayjs().format('YYYY-MM-DD HH:mm'); - outboundForm.remark = row.remark || ''; - outImages.value = getOutImages(row); - outboundModal.value = true; +function openProof(row: any) { + operationTarget.value = row; + proofVisible.value = true; } -async function saveOutbound(triggerOnchain: boolean) { - if (!outboundTarget.value) return; - if (!outboundReadonly.value && !outboundForm.outTime) { - message.warning(t('pages.outbound.outTimeRequired')); - return; - } - if (triggerOnchain) { - outboundTriggering.value = true; +function runOnchainRow(row: any) { + operationTarget.value = row; + dialog.warning({ + title: t('pages.blockchain.trigger'), + content: t('pages.operations.singleOnchainConfirm', { code: row.shortCode }), + positiveText: t('common.action.confirm'), + negativeText: t('common.action.cancel'), + onPositiveClick: () => submitOnchainRow(row), + }); +} + +async function submitOnchainRow(row: any) { + const result: any = await onchainApi.createJob({ mode: 'IDS', ids: [String(row.id)] }); + proofVisible.value = false; + const id = String(result?.jobId || result?.id || result?.job?.id || ''); + if (id) { + jobId.value = id; + jobVisible.value = true; } else { - outboundSaving.value = true; - } - try { - if (!outboundReadonly.value) { - await outboundApi.updateSingle(String(outboundTarget.value.id), { - outTime: outboundForm.outTime ? dayjs(outboundForm.outTime).toISOString() : null, - outImageKey: outImages.value[0]?.key ?? null, - outImageKeys: outImages.value.map((item) => item.key).filter(Boolean), - remark: outboundForm.remark || null, - }); - } - if (triggerOnchain) { - await traceCodeApi.onchain(String(outboundTarget.value.id)); - } - message.success(t('common.msg.saved')); - outboundModal.value = false; - outboundTarget.value = null; - await load(); - emit('changed'); - } finally { - outboundSaving.value = false; - outboundTriggering.value = false; + message.success(t('pages.operations.jobSubmitted')); } + await load(); +} + +async function reloadAfterOperation() { + await load(); + emit('changed'); } function resetGroupForm() { @@ -1175,9 +1110,6 @@ onUnmounted(() => { .mr8 { margin-right: 8px; } -.onchain-tip { - margin-top: 4px; -} /* 表格单元格由 n-data-table 子组件渲染,不带本组件 scope 属性,必须用 :deep() 才能命中 */ :deep(.cell-link) { color: var(--brand); @@ -1196,23 +1128,6 @@ onUnmounted(() => { :deep(.cell-click:hover) { opacity: 0.75; } -.onchain-mono { - font-family: 'JetBrains Mono', Consolas, monospace; - font-size: 12px; - word-break: break-all; -} -.onchain-val { - display: flex; - align-items: center; - gap: 6px; -} -.onchain-val > :first-child { - flex: 1; - min-width: 0; -} -.onchain-val .n-button { - flex: 0 0 auto; -} @media (max-width: 720px) { .toolbar-control, .toolbar-control.wide, diff --git a/apps/admin/src/layouts/MainLayout.vue b/apps/admin/src/layouts/MainLayout.vue index 943fae5..1e8fa56 100644 --- a/apps/admin/src/layouts/MainLayout.vue +++ b/apps/admin/src/layouts/MainLayout.vue @@ -73,6 +73,7 @@ import { LogOutOutline, KeyOutline, ShieldCheckmarkOutline, + LinkOutline, } from '@vicons/ionicons5'; import { useAuthStore } from '@/stores/auth'; import { settingsApi } from '@/api'; @@ -101,6 +102,7 @@ const menuOptions = computed(() => { { 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.onchain'), key: 'onchain', icon: renderIcon(LinkOutline) }, { 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) }, diff --git a/apps/admin/src/locales/en-US.json b/apps/admin/src/locales/en-US.json index 596df2d..133d82e 100644 --- a/apps/admin/src/locales/en-US.json +++ b/apps/admin/src/locales/en-US.json @@ -55,11 +55,15 @@ "UNBOUND": "Unbound", "INACTIVE": "Inactive", "PENDING": "Pending", + "SUBMITTING": "Submitting", "CONFIRMING": "Confirming", "PROCESSING": "Processing", "SUCCESS": "Success", "PARTIAL": "Partial", "FAILED": "Failed", + "UNKNOWN": "Unknown", + "SKIPPED": "Skipped", + "CANCELLED": "Cancelled", "ONCHAIN": "On-chain", "GENERATING": "Generating", "DONE": "Done" @@ -165,7 +169,8 @@ "templates": "Templates", "artworks": "Artwork Files", "traceCodes": "Trace Code Management", - "outbound": "Outbound & Chain", + "onchain": "On-chain Management", + "outbound": "Outbound Management", "audit": "Content Audit", "queryLogs": "Query Logs", "operationLogs": "Operation Logs", @@ -324,6 +329,7 @@ "nodes": "Timeline", "certificates": "Certificates", "saveDraft": "Save Draft", + "saveChanges": "Save Changes", "submitReview": "Submit for Audit", "submittedReview": "Submitted for audit. Changes take effect only after approval.", "noChangeTip": "No artwork content changes to submit.", @@ -425,8 +431,6 @@ "reconfirmOnchain": "Reconfirm", "confirmSubmitted": "Reconfirm task submitted", "tableFilter": "Filter", - "registerOutbound": "Outbound & On-chain", - "triggerOnchainOnly": "On-chain", "onchainInfo": "On-chain Info", "enableOne": "Enable", "disableOne": "Disable", @@ -434,15 +438,22 @@ "assignGroup": "Assign group" }, "outbound": { + "recordsTab": "Outbound Records", + "zipTab": "ZIP Batch Import", "batchImportTitle": "Outbound Batch Import", "import": "Batch Import", "outTime": "Outbound Time", "outImage": "Outbound Photo", - "onchainSection": "On-chain Info", - "txHashTip": "Written automatically from the blockchain API response", - "moreOnchainInfo": "More On-chain Info", "saveRecord": "Save Record", - "saveAndTriggerOnchain": "Save & Trigger On-chain", + "registerRecord": "Register Outbound", + "editRecord": "Edit Outbound Record", + "addImage": "Add Outbound Photo", + "imageCount": "{n} photo(s)", + "moveImageUp": "Move earlier", + "moveImageDown": "Move later", + "imageFormatTip": "Only JPG, JPEG, PNG, and WebP images are supported", + "imageSizeTip": "Each image must not exceed 100MB", + "deleteImageConfirm": "Delete this outbound photo?", "selectFile": "Select File", "importing": "Importing…", "importResult": "Import Result", @@ -495,7 +506,6 @@ "previewExpired": "The import preview expired or its status changed", "duplicateTraceCode": "This trace code is duplicated in the import (first used on row {row})", "batchNoMismatch": "Batch number does not match; the actual value is {value}", - "tooManyImages": "Each row can contain at most {count} outbound images", "duplicateZipImage": "The ZIP contains a duplicate image path: {path}", "imageTooLarge": "Image exceeds the 100MB limit: {path}", "tooManyRows": "The import exceeds the {count}-row limit", @@ -505,9 +515,9 @@ "missingHeaders": "The xlsx file is missing required headers: {value}", "unsafeImagePath": "Image path is unsafe: {path}", "imageOutsideDirectory": "Image must be inside the images directory: {path}", + "imageCodeDirectory": "Image must be stored under images/<12-digit trace code>/: {path}", + "orphanImageDirectory": "The image directory's trace code is not present in the xlsx file: {code}", "unsupportedImage": "Unsupported image format: {path}", - "duplicateImage": "The same image is referenced more than once in this row: {path}", - "imageMissing": "Image not found: {path}", "imageFormat": "Image content does not match its file extension: {path}", "imagePixels": "Image dimensions exceed the allowed limit: {path}", "animatedImage": "Multi-frame images are not supported: {path}", @@ -519,8 +529,8 @@ "zipInvalidSize": "The ZIP contains an invalid file size", "xlsxInvalidSize": "The xlsx file contains an invalid file size", "zipEntryLimit": "The ZIP contains more than {count} entries", + "tempDiskSpace": "Insufficient temporary disk space for outbound import; at least {mb}MB is required", "xlsxEntryLimit": "The xlsx file contains more than {count} entries", - "imageReferenceLimit": "The import contains more than {count} image references", "incompleteRows": "Import row states are incomplete: {success} succeeded, {fail} failed, {remaining} pending, {total} total", "previewSessionMissing": "The import preview session no longer exists", "previewJobMismatch": "The preview task does not match this import session", @@ -542,21 +552,105 @@ "FAILED": "Failed", "EXPIRED": "Expired" }, - "onchainAutoTip": "On-chain hash, attestation link, and on-chain time are written automatically from the configured blockchain API response.", "outTimeRequired": "Outbound time is required" }, + "operations": { + "filterArtwork": "Filter artwork", + "traceStatus": "Trace Code Status", + "activationFilter": "Activation", + "activated": "Activated", + "notActivated": "Not Activated", + "matchCodes": "Match Trace Codes", + "matchPlaceholder": "Enter one 12-digit trace code per line", + "startMatch": "Match", + "matchedCount": "{n} matched", + "missingCount": "{n} missing", + "duplicateCount": "{n} duplicate", + "invalidCodeCount": "{n} invalid", + "matchLimit": "Up to {n} trace codes can be matched at once", + "addSelected": "Add Selected ({n})", + "available": "Available", + "unavailable": "Unavailable", + "onchainUnavailable": "On-chain Unavailable", + "selectAllFiltered": "Select All Filtered", + "selectEligibleFilterTip": "Select all is available only for eligible status filters", + "replaceFilterSelectionTitle": "Replace Filter Selection", + "replaceFilterSelectionConfirm": "Matching trace codes will clear the current select-all-filtered selection. Continue?", + "clearSelection": "Clear Selection", + "filterSelectionSummary": "Selected all {n} eligible filtered records; {excluded} excluded", + "idSelectionSummary": "{n} selected across pages", + "batchOnchain": "On-chain ({n})", + "batchOutbound": "Batch Outbound", + "batchOutboundWithCount": "Outbound ({n})", + "batchOnchainTitle": "Batch On-chain", + "batchOnchainConfirm": "Submit {n} trace codes for on-chain processing?", + "singleOnchainConfirm": "Submit trace code {code} for on-chain processing?", + "confirmBatch": "Confirm ({n})", + "jobSubmitted": "Task submitted", + "recentJob": "The latest batch task is available", + "viewProgress": "View Progress", + "onchainProgress": "Batch On-chain Progress", + "outboundProgress": "Batch Outbound Progress", + "total": "Total", + "success": "Success", + "failed": "Failed", + "skipped": "Skipped", + "allResults": "All Results", + "processedAt": "Processed At", + "resultReason": "Result", + "proofStatus": { + "ELIGIBLE": "Eligible", + "NONE": "Not On-chain", + "PENDING": "Queued", + "SUBMITTING": "Submitting", + "CONFIRMING": "Confirming", + "ONCHAIN": "On-chain", + "FAILED": "Failed", + "UNKNOWN": "Unknown" + }, + "itemStatus": { + "PENDING": "Pending", + "PROCESSING": "Processing", + "SUCCESS": "Success", + "FAILED": "Failed", + "SKIPPED": "Skipped", + "UNKNOWN": "Unknown" + }, + "jobStatus": { + "PENDING": "Pending", + "PROCESSING": "Processing", + "SUCCESS": "Completed", + "PARTIAL": "Partially Completed", + "FAILED": "Failed", + "CANCELLED": "Cancelled" + }, + "reason": { + "alreadyOutbound": "This trace code is already outbound", + "traceCodeUnavailable": "Disabled or abnormal trace codes cannot be submitted on-chain", + "artworkUnavailable": "The artwork is inactive or has not been approved", + "missingPrimaryImage": "The artwork does not have a valid primary image", + "alreadyOnchain": "This trace code is already on-chain", + "onchainProcessing": "This trace code is being processed on-chain" + } + }, "blockchain": { "title": "Blockchain Attestation", "status": "On-chain Status", - "dataHash": "Data Hash", "txHash": "Tx Hash", + "chainName": "Chain", "blockHeight": "Block Height", - "tokenId": "Token ID", "contract": "Contract Address", "onchainAt": "On-chain Time", "explorer": "Explorer", + "openExplorer": "Open Explorer", "trigger": "Trigger On-chain", - "triggered": "On-chain task submitted" + "triggered": "On-chain task submitted", + "retry": "Retry On-chain", + "unknownTip": "The transaction result cannot be confirmed yet. Resync it or correct the status manually.", + "resync": "Resync", + "recordTransaction": "Record Transaction Hash", + "markFailed": "Mark Failed", + "markFailedConfirm": "Mark this unknown attestation as failed? Use this only after manual verification." }, "queryLog": { "result": "Result", @@ -723,7 +817,12 @@ "outboundTemplate": "Download outbound import template", "traceExport": "Export trace codes and QR images", "traceBatchDelete": "Batch delete trace codes", + "traceMatch": "Match trace codes", "traceOnchain": "Trace code on-chain attestation", + "batchOnchain": "Submit batch on-chain task", + "batchOutbound": "Submit batch outbound task", + "outboundRecord": "Create or update outbound record", + "outboundImages": "Manage outbound photos", "backupCreate": "Create backup", "backupDelete": "Delete backup", "backupDownload": "Download backup package", @@ -735,6 +834,9 @@ "storageConfirm": "Switch storage config", "blockchainRetry": "Retry blockchain proof", "blockchainConfirm": "Query blockchain confirmation", + "blockchainResync": "Resync blockchain proof", + "blockchainRecordTransaction": "Record transaction hash manually", + "blockchainMarkFailed": "Mark on-chain task as failed", "changePassword": "Change password", "login": "Sign in to admin", "upload": "Upload file" diff --git a/apps/admin/src/locales/zh-CN.json b/apps/admin/src/locales/zh-CN.json index 9e91454..b845096 100644 --- a/apps/admin/src/locales/zh-CN.json +++ b/apps/admin/src/locales/zh-CN.json @@ -55,11 +55,15 @@ "UNBOUND": "未绑定", "INACTIVE": "未激活", "PENDING": "等待中", + "SUBMITTING": "提交中", "CONFIRMING": "确认中", "PROCESSING": "处理中", "SUCCESS": "成功", "PARTIAL": "部分成功", "FAILED": "失败", + "UNKNOWN": "状态未知", + "SKIPPED": "已跳过", + "CANCELLED": "已取消", "ONCHAIN": "已上链", "GENERATING": "生成中", "DONE": "已完成" @@ -165,7 +169,8 @@ "templates": "溯源模板", "artworks": "艺术品档案", "traceCodes": "追溯码管理", - "outbound": "出库与上链", + "onchain": "上链管理", + "outbound": "出库管理", "audit": "内容审核", "queryLogs": "查询日志", "operationLogs": "操作日志", @@ -324,6 +329,7 @@ "nodes": "溯源时间轴", "certificates": "认证文件", "saveDraft": "保存草稿", + "saveChanges": "保存修改", "submitReview": "提交审核", "submittedReview": "已提交审核,审核通过后修改才会生效", "noChangeTip": "作品内容未发生变化,无需提交审核", @@ -425,8 +431,6 @@ "reconfirmOnchain": "重新确认", "confirmSubmitted": "已提交重新确认任务", "tableFilter": "筛选", - "registerOutbound": "出库上链", - "triggerOnchainOnly": "上链", "onchainInfo": "上链信息", "enableOne": "启用", "disableOne": "禁用", @@ -434,15 +438,22 @@ "assignGroup": "设为分组" }, "outbound": { + "recordsTab": "出库登记", + "zipTab": "ZIP 批量导入", "batchImportTitle": "出库批量导入", "import": "批量导入", "outTime": "出库时间", "outImage": "出库实况图", - "onchainSection": "上链信息", - "txHashTip": "由区块链接口返回后自动写入", - "moreOnchainInfo": "更多上链信息", "saveRecord": "保存登记", - "saveAndTriggerOnchain": "保存并触发上链", + "registerRecord": "登记出库", + "editRecord": "编辑出库记录", + "addImage": "补录实况图", + "imageCount": "共 {n} 张", + "moveImageUp": "前移", + "moveImageDown": "后移", + "imageFormatTip": "仅支持 JPG、JPEG、PNG、WebP 图片", + "imageSizeTip": "单张图片不能超过 100MB", + "deleteImageConfirm": "确认删除该出库实况图?", "selectFile": "选择文件", "importing": "导入中…", "importResult": "导入结果", @@ -495,7 +506,6 @@ "previewExpired": "导入预览会话已过期或状态已变化", "duplicateTraceCode": "追溯码在本次导入中重复(首次出现于第 {row} 行)", "batchNoMismatch": "批次编号不匹配,实际为 {value}", - "tooManyImages": "每行最多填写 {count} 张出库图", "duplicateZipImage": "ZIP 中存在重复图片路径:{path}", "imageTooLarge": "图片超过 100MB:{path}", "tooManyRows": "导入数据超过 {count} 行限制", @@ -505,9 +515,9 @@ "missingHeaders": "xlsx 缺少必填表头:{value}", "unsafeImagePath": "图片路径不安全:{path}", "imageOutsideDirectory": "图片必须位于 images 目录:{path}", + "imageCodeDirectory": "图片必须位于 images/<12位追溯码>/ 目录:{path}", + "orphanImageDirectory": "图片目录对应的追溯码未出现在 xlsx 中:{code}", "unsupportedImage": "不支持的图片格式:{path}", - "duplicateImage": "同一行重复引用图片:{path}", - "imageMissing": "图片不存在:{path}", "imageFormat": "图片实际格式与扩展名不一致:{path}", "imagePixels": "图片像素尺寸超过限制:{path}", "animatedImage": "不支持多帧图片:{path}", @@ -519,8 +529,8 @@ "zipInvalidSize": "ZIP 包含无效文件大小", "xlsxInvalidSize": "xlsx 包含无效文件大小", "zipEntryLimit": "ZIP 文件数量超过限制(最多 {count} 个)", + "tempDiskSpace": "出库导入临时磁盘空间不足,至少需要 {mb}MB 可用空间", "xlsxEntryLimit": "xlsx 文件数量超过限制(最多 {count} 个)", - "imageReferenceLimit": "出库图片引用总数超过限制(最多 {count} 张)", "incompleteRows": "导入行状态不完整:成功 {success},失败 {fail},待处理 {remaining},总数 {total}", "previewSessionMissing": "导入预览会话不存在", "previewJobMismatch": "导入预览任务与会话不匹配", @@ -542,21 +552,105 @@ "FAILED": "失败", "EXPIRED": "已过期" }, - "onchainAutoTip": "链上哈希、存证链接、上链时间由当前配置的区块链接口返回后自动写入。", "outTimeRequired": "出库时间不能为空" }, + "operations": { + "filterArtwork": "筛选艺术品", + "traceStatus": "追溯码状态", + "activationFilter": "激活状态", + "activated": "已激活", + "notActivated": "未激活", + "matchCodes": "按追溯码匹配", + "matchPlaceholder": "每行输入一个 12 位追溯码", + "startMatch": "开始匹配", + "matchedCount": "匹配 {n} 个", + "missingCount": "不存在 {n} 个", + "duplicateCount": "重复 {n} 个", + "invalidCodeCount": "格式错误 {n} 个", + "matchLimit": "一次最多匹配 {n} 个追溯码", + "addSelected": "加入所选({n})", + "available": "可操作", + "unavailable": "不可操作", + "onchainUnavailable": "不可上链", + "selectAllFiltered": "选择全部筛选结果", + "selectEligibleFilterTip": "仅在筛选为可操作状态时支持全部选择", + "replaceFilterSelectionTitle": "替换当前筛选选择", + "replaceFilterSelectionConfirm": "按追溯码匹配将清空当前“全部筛选结果”选择,是否继续?", + "clearSelection": "清空选择", + "filterSelectionSummary": "已选择全部可操作筛选结果,共 {n} 项,已排除 {excluded} 项", + "idSelectionSummary": "已跨页选择 {n} 项", + "batchOnchain": "批量上链({n})", + "batchOutbound": "批量出库", + "batchOutboundWithCount": "批量出库({n})", + "batchOnchainTitle": "批量上链", + "batchOnchainConfirm": "确认提交 {n} 个追溯码进行上链?", + "singleOnchainConfirm": "确认提交追溯码 {code} 进行上链?", + "confirmBatch": "确认处理({n})", + "jobSubmitted": "任务已提交", + "recentJob": "最近提交的批量任务仍可查看", + "viewProgress": "查看任务进度", + "onchainProgress": "批量上链进度", + "outboundProgress": "批量出库进度", + "total": "总数", + "success": "成功", + "failed": "失败", + "skipped": "跳过", + "allResults": "全部结果", + "processedAt": "处理时间", + "resultReason": "结果说明", + "proofStatus": { + "ELIGIBLE": "可上链", + "NONE": "未上链", + "PENDING": "排队中", + "SUBMITTING": "提交中", + "CONFIRMING": "确认中", + "ONCHAIN": "已上链", + "FAILED": "上链失败", + "UNKNOWN": "状态未知" + }, + "itemStatus": { + "PENDING": "待处理", + "PROCESSING": "处理中", + "SUCCESS": "成功", + "FAILED": "失败", + "SKIPPED": "已跳过", + "UNKNOWN": "结果未知" + }, + "jobStatus": { + "PENDING": "等待中", + "PROCESSING": "处理中", + "SUCCESS": "已完成", + "PARTIAL": "部分完成", + "FAILED": "失败", + "CANCELLED": "已取消" + }, + "reason": { + "alreadyOutbound": "该追溯码已登记出库", + "traceCodeUnavailable": "停用或异常追溯码不可上链", + "artworkUnavailable": "作品未生效或未审核通过", + "missingPrimaryImage": "作品缺少有效主图", + "alreadyOnchain": "该追溯码已上链", + "onchainProcessing": "该追溯码正在上链处理中" + } + }, "blockchain": { "title": "区块链存证", "status": "上链状态", - "dataHash": "数据哈希", "txHash": "交易哈希", + "chainName": "链名称", "blockHeight": "区块高度", - "tokenId": "数字商品ID", "contract": "合约地址", "onchainAt": "上链时间", "explorer": "存证查询", + "openExplorer": "打开存证查询", "trigger": "触发上链", - "triggered": "已提交上链任务" + "triggered": "已提交上链任务", + "retry": "重新上链", + "unknownTip": "链上交易结果暂时无法确认,可重新同步或由管理员修正状态。", + "resync": "重新同步", + "recordTransaction": "登记交易哈希", + "markFailed": "标记失败", + "markFailedConfirm": "确认将该未知状态存证标记为失败?此操作仅用于人工核验后的异常恢复。" }, "queryLog": { "result": "查询结果", @@ -723,7 +817,12 @@ "outboundTemplate": "下载出库导入模板", "traceExport": "导出追溯码与二维码", "traceBatchDelete": "批量删除追溯码", + "traceMatch": "按追溯码批量匹配", "traceOnchain": "追溯码上链存证", + "batchOnchain": "提交批量上链任务", + "batchOutbound": "提交批量出库任务", + "outboundRecord": "登记或修改出库记录", + "outboundImages": "维护出库实况图", "backupCreate": "创建备份", "backupDelete": "删除备份", "backupDownload": "下载备份包", @@ -735,6 +834,9 @@ "storageConfirm": "切换存储配置", "blockchainRetry": "重试区块链存证", "blockchainConfirm": "查询区块链确认结果", + "blockchainResync": "重新同步区块链存证", + "blockchainRecordTransaction": "人工登记交易哈希", + "blockchainMarkFailed": "人工标记上链失败", "changePassword": "修改密码", "login": "登录后台", "upload": "上传文件" diff --git a/apps/admin/src/router/index.ts b/apps/admin/src/router/index.ts index 3821a16..d285c09 100644 --- a/apps/admin/src/router/index.ts +++ b/apps/admin/src/router/index.ts @@ -27,7 +27,8 @@ export const routes: RouteRecordRaw[] = [ { path: 'artworks/:id', name: 'artwork-detail', component: () => import('@/views/ArtworkEdit.vue') }, { path: 'artworks/:id/trace-codes', name: 'artwork-trace-codes', component: () => import('@/views/ArtworkTraceCodes.vue') }, { path: 'trace-codes', name: 'traceCodes', component: () => import('@/views/TraceCodes.vue') }, - { path: 'outbound', name: 'outbound', component: () => import('@/views/Outbound.vue') }, + { path: 'onchain', name: 'onchain', component: () => import('@/views/Onchain.vue') }, + { path: 'outbound', name: 'outbound', component: () => import('@/views/OutboundManagement.vue') }, { path: 'audit', name: 'audit', component: () => import('@/views/Audit.vue'), meta: { roles: ['SUPER_ADMIN', 'AUDITOR'] } }, { path: 'query-logs', name: 'queryLogs', component: () => import('@/views/QueryLogs.vue') }, { path: 'operation-logs', name: 'operationLogs', component: () => import('@/views/OperationLogs.vue'), meta: { roles: ['SUPER_ADMIN'] } }, diff --git a/apps/admin/src/utils/format.ts b/apps/admin/src/utils/format.ts index 7926b30..c4c408a 100644 --- a/apps/admin/src/utils/format.ts +++ b/apps/admin/src/utils/format.ts @@ -22,10 +22,14 @@ const STATUS_TYPE: Record = { + '该追溯码已登记出库': 'alreadyOutbound', + '停用或异常追溯码不可上链': 'traceCodeUnavailable', + '作品未生效或未审核通过': 'artworkUnavailable', + '作品缺少有效主图': 'missingPrimaryImage', + '该追溯码已上链': 'alreadyOnchain', + '该追溯码正在上链处理中': 'onchainProcessing', +}; + +export function localizeOperationReason(value: unknown): string { + const text = typeof value === 'string' ? value : ''; + const key = REASON_KEYS[text]; + return key ? i18n.global.t(`pages.operations.reason.${key}`) : text; +} diff --git a/apps/admin/src/views/ArtworkEdit.vue b/apps/admin/src/views/ArtworkEdit.vue index daaa8f3..0c05e22 100644 --- a/apps/admin/src/views/ArtworkEdit.vue +++ b/apps/admin/src/views/ArtworkEdit.vue @@ -16,9 +16,9 @@ :loading="saving" :disabled="!auth.canWrite || (!isNew && !hasArtworkChanges)" :title="!isNew && !hasArtworkChanges ? t('pages.artwork.noChangeTip') : ''" - @click="isNew ? saveArtwork(false) : openSubmitReview()" + @click="isNew || auth.isSuperAdmin ? saveArtwork(false) : openSubmitReview()" > - {{ isNew ? t('common.action.save') : t('pages.artwork.submitReview') }} + {{ isNew ? t('common.action.save') : auth.isSuperAdmin ? t('pages.artwork.saveChanges') : t('pages.artwork.submitReview') }} @@ -303,7 +303,7 @@ - + diff --git a/apps/admin/src/views/Onchain.vue b/apps/admin/src/views/Onchain.vue new file mode 100644 index 0000000..ec228d5 --- /dev/null +++ b/apps/admin/src/views/Onchain.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/apps/admin/src/views/OperationLogs.vue b/apps/admin/src/views/OperationLogs.vue index a876efd..884205f 100644 --- a/apps/admin/src/views/OperationLogs.vue +++ b/apps/admin/src/views/OperationLogs.vue @@ -198,7 +198,7 @@ function effectiveAction(row: any) { if (path.includes('/backups') && method === 'DELETE') return 'delete'; if (isBackupRoot && method === 'POST') return 'backup'; if (path.includes('/trace-codes/batch/delete')) return 'delete'; - if (path.includes('/outbound/import/preview') || /\/outbound\/import\/?$/.test(cleanPath)) return 'upload'; + if (path.includes('/outbound/import/preview')) return 'upload'; if (path.includes('/outbound/import-sessions') && path.includes('/commit')) return 'update'; if (path.includes('/outbound/import-sessions') && path.includes('/result')) return 'download'; if (path.includes('/storage/test') || path.includes('/storage/migrate') || path.includes('/storage/confirm')) return 'update'; @@ -215,6 +215,14 @@ function pathLabel(path?: string, action?: string, method?: string) { const isBackupRoot = /\/backups\/?$/.test(cleanPath); if (path.includes('/auth/change-password')) return t('pages.operationLog.paths.changePassword'); if (path.includes('/auth/login')) return t('pages.operationLog.paths.login'); + if (path.includes('/trace-codes/match')) return t('pages.operationLog.paths.traceMatch'); + if (path.includes('/blockchain/onchain-jobs')) return t('pages.operationLog.paths.batchOnchain'); + if (path.includes('/outbound/jobs')) return t('pages.operationLog.paths.batchOutbound'); + if (/\/outbound\/\d+\/images/.test(cleanPath)) return t('pages.operationLog.paths.outboundImages'); + if (/\/outbound\/\d+\/?$/.test(cleanPath)) return t('pages.operationLog.paths.outboundRecord'); + if (path.includes('/blockchain/onchain-chunks/') && path.includes('/resync')) return t('pages.operationLog.paths.blockchainResync'); + if (path.includes('/blockchain-proofs/') && path.includes('/transaction')) return t('pages.operationLog.paths.blockchainRecordTransaction'); + if (path.includes('/blockchain/onchain-chunks/') && path.includes('/mark-failed')) return t('pages.operationLog.paths.blockchainMarkFailed'); if (path.includes('/outbound/import/preview')) return t('pages.operationLog.paths.outboundPreview'); if (path.includes('/outbound/import-sessions') && path.includes('/commit')) return t('pages.operationLog.paths.outboundCommit'); if (path.includes('/outbound/import-sessions') && path.includes('/result')) return t('pages.operationLog.paths.outboundResult'); diff --git a/apps/admin/src/views/Outbound.vue b/apps/admin/src/views/Outbound.vue index b44de91..86c5f2c 100644 --- a/apps/admin/src/views/Outbound.vue +++ b/apps/admin/src/views/Outbound.vue @@ -1,5 +1,5 @@