feat: 完成 PRD 差距与修复,新增审核流与日志清理功能,支持出库信息与动态字段,优化 C 端用户体验
This commit is contained in:
@@ -41,6 +41,8 @@ export const artworkApi = {
|
||||
listCerts: (artworkId: number) => get<any[]>(`/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),
|
||||
};
|
||||
|
||||
export const traceCodeApi = {
|
||||
@@ -70,6 +72,11 @@ export const outboundApi = {
|
||||
templateUrl: '/api/outbound/import/template',
|
||||
};
|
||||
|
||||
export const auditApi = {
|
||||
list: (params: object) => get<PageResult<any>>('/artworks', params),
|
||||
audit: (id: number, data: { approved: boolean; remark?: string }) => post(`/artworks/${id}/audit`, data),
|
||||
};
|
||||
|
||||
export const jobApi = {
|
||||
get: (id: string) => get(`/jobs/${id}`),
|
||||
list: (params: object) => get<PageResult<any>>('/jobs', params),
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
PersonCircleOutline,
|
||||
LogOutOutline,
|
||||
KeyOutline,
|
||||
ShieldCheckmarkOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { settingsApi } from '@/api';
|
||||
@@ -87,17 +88,20 @@ function renderIcon(icon: unknown) {
|
||||
}
|
||||
|
||||
const menuOptions = computed<MenuOption[]>(() => {
|
||||
const items: Array<MenuOption & { superOnly?: boolean }> = [
|
||||
const items: Array<MenuOption & { superOnly?: boolean; auditOnly?: boolean }> = [
|
||||
{ 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) },
|
||||
{ label: t('menu.users'), key: 'users', icon: renderIcon(PeopleOutline), superOnly: true },
|
||||
{ label: t('menu.settings'), key: 'settings', icon: renderIcon(SettingsOutline), superOnly: true },
|
||||
];
|
||||
return items.filter((i) => !i.superOnly || auth.isSuperAdmin);
|
||||
return items.filter(
|
||||
(i) => (!i.superOnly || auth.isSuperAdmin) && (!i.auditOnly || auth.canAudit),
|
||||
);
|
||||
});
|
||||
|
||||
const activeKey = computed(() => (route.name === 'artwork-detail' ? 'artworks' : (route.name as string)));
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
"DISABLED": "Disabled",
|
||||
"ABNORMAL": "Abnormal"
|
||||
},
|
||||
"auditStatus": {
|
||||
"PENDING": "Pending",
|
||||
"APPROVED": "Approved",
|
||||
"REJECTED": "Rejected"
|
||||
},
|
||||
"fieldType": {
|
||||
"TEXT": "Text",
|
||||
"NUMBER": "Number",
|
||||
@@ -117,6 +122,7 @@
|
||||
"artworks": "Artworks",
|
||||
"traceCodes": "Trace Codes",
|
||||
"outbound": "Outbound & Chain",
|
||||
"audit": "Content Audit",
|
||||
"queryLogs": "Query Logs",
|
||||
"users": "Users",
|
||||
"settings": "Settings",
|
||||
@@ -158,7 +164,20 @@
|
||||
"create": "New Template",
|
||||
"edit": "Edit Template",
|
||||
"namePlaceholder": "Enter template name",
|
||||
"fieldKeyTip": "Unique key, e.g. craft"
|
||||
"fieldKeyTip": "Unique key, e.g. craft",
|
||||
"sortHint": "Field order = display order on consumer page; use arrows to reorder"
|
||||
},
|
||||
"audit": {
|
||||
"status": "Audit Status",
|
||||
"approve": "Approve",
|
||||
"reject": "Reject",
|
||||
"approved": "Approved",
|
||||
"rejected": "Rejected",
|
||||
"remark": "Audit Note",
|
||||
"remarkPlaceholder": "Enter rejection reason or suggestions",
|
||||
"approveConfirm": "Approve \"{title}\"? It will become visible on the consumer page.",
|
||||
"rejectedTip": "This artwork was rejected. Please revise per the notes, save and resubmit for audit.",
|
||||
"pendingTip": "Pending audit; visible on consumer page only after approval. Saving edits re-enters pending."
|
||||
},
|
||||
"artwork": {
|
||||
"title": "Title",
|
||||
@@ -202,6 +221,7 @@
|
||||
"shortCode": "Short Code",
|
||||
"code": "Trace Code",
|
||||
"url": "Short URL",
|
||||
"archiveNo": "Archive No.",
|
||||
"queryCount": "Queries",
|
||||
"firstActivatedAt": "First Activated",
|
||||
"exportBatch": "Export Batch",
|
||||
@@ -231,13 +251,18 @@
|
||||
"sku": "SKU",
|
||||
"archiveNo": "Archive No.",
|
||||
"outTime": "Outbound Time",
|
||||
"outImage": "Outbound Photo",
|
||||
"selectCode": "Select Trace Code",
|
||||
"selectCodePlaceholder": "Search by short code / SKU / archive no.",
|
||||
"onchainSection": "On-chain info (optional; filling a hash records the result)",
|
||||
"txHashTip": "Paste the on-chain transaction/attestation hash",
|
||||
"selectFile": "Select File",
|
||||
"importing": "Importing…",
|
||||
"importResult": "Import Result",
|
||||
"successCount": "Success",
|
||||
"failCount": "Failed",
|
||||
"downloadResult": "Download Details",
|
||||
"tip": "Download the template first, fill it in and upload (xlsx)"
|
||||
"tip": "Download the template first, fill it in and upload (xlsx). Includes outbound photo, on-chain hash/time/block height."
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "Blockchain Attestation",
|
||||
@@ -255,7 +280,8 @@
|
||||
"device": "Device",
|
||||
"queriedAt": "Time",
|
||||
"startTime": "Start",
|
||||
"endTime": "End"
|
||||
"endTime": "End",
|
||||
"keywordPlaceholder": "Short code / trace code / SKU / archive no."
|
||||
},
|
||||
"user": {
|
||||
"username": "Username",
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
"DISABLED": "停用",
|
||||
"ABNORMAL": "异常"
|
||||
},
|
||||
"auditStatus": {
|
||||
"PENDING": "待审核",
|
||||
"APPROVED": "已通过",
|
||||
"REJECTED": "已驳回"
|
||||
},
|
||||
"fieldType": {
|
||||
"TEXT": "文本",
|
||||
"NUMBER": "数字",
|
||||
@@ -117,6 +122,7 @@
|
||||
"artworks": "艺术品建档",
|
||||
"traceCodes": "追溯码管理",
|
||||
"outbound": "出库与上链",
|
||||
"audit": "内容审核",
|
||||
"queryLogs": "查询日志",
|
||||
"users": "用户管理",
|
||||
"settings": "系统设置",
|
||||
@@ -158,7 +164,20 @@
|
||||
"create": "新建模板",
|
||||
"edit": "编辑模板",
|
||||
"namePlaceholder": "请输入模板名称",
|
||||
"fieldKeyTip": "英文唯一标识,如 craft"
|
||||
"fieldKeyTip": "英文唯一标识,如 craft",
|
||||
"sortHint": "字段顺序即 C 端展示顺序,可用上下箭头调整"
|
||||
},
|
||||
"audit": {
|
||||
"status": "审核状态",
|
||||
"approve": "通过",
|
||||
"reject": "驳回",
|
||||
"approved": "已通过审核",
|
||||
"rejected": "已驳回",
|
||||
"remark": "审核意见",
|
||||
"remarkPlaceholder": "请填写驳回原因或修改建议",
|
||||
"approveConfirm": "确认通过《{title}》的审核?通过后将对 C 端可见。",
|
||||
"rejectedTip": "该作品审核未通过,请按意见修改后保存再次提交审核",
|
||||
"pendingTip": "该作品待审核,审核通过后方可在 C 端展示;保存修改会重新进入待审核"
|
||||
},
|
||||
"artwork": {
|
||||
"title": "作品名称",
|
||||
@@ -202,6 +221,7 @@
|
||||
"shortCode": "短码",
|
||||
"code": "追溯码",
|
||||
"url": "短链",
|
||||
"archiveNo": "档案编号",
|
||||
"queryCount": "查询次数",
|
||||
"firstActivatedAt": "首次激活时间",
|
||||
"exportBatch": "导出本批",
|
||||
@@ -231,13 +251,18 @@
|
||||
"sku": "SKU",
|
||||
"archiveNo": "档案编号",
|
||||
"outTime": "出库时间",
|
||||
"outImage": "出库实况图",
|
||||
"selectCode": "选择追溯码",
|
||||
"selectCodePlaceholder": "输入短码 / SKU / 档案号搜索",
|
||||
"onchainSection": "上链信息(选填,填写哈希即登记上链结果)",
|
||||
"txHashTip": "粘贴链上交易/存证哈希",
|
||||
"selectFile": "选择文件",
|
||||
"importing": "导入中…",
|
||||
"importResult": "导入结果",
|
||||
"successCount": "成功",
|
||||
"failCount": "失败",
|
||||
"downloadResult": "下载结果明细",
|
||||
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)"
|
||||
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)。模板含出库实况图、上链哈希/时间/区块高度等字段。"
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "区块链存证",
|
||||
@@ -255,7 +280,8 @@
|
||||
"device": "设备信息",
|
||||
"queriedAt": "查询时间",
|
||||
"startTime": "开始时间",
|
||||
"endTime": "结束时间"
|
||||
"endTime": "结束时间",
|
||||
"keywordPlaceholder": "短码 / 追溯码 / SKU / 档案号"
|
||||
},
|
||||
"user": {
|
||||
"username": "用户名",
|
||||
|
||||
@@ -21,9 +21,10 @@ export const routes: RouteRecordRaw[] = [
|
||||
{ path: 'artworks/:id', name: 'artwork-detail', component: () => import('@/views/ArtworkEdit.vue') },
|
||||
{ path: 'trace-codes', name: 'traceCodes', component: () => import('@/views/TraceCodes.vue') },
|
||||
{ path: 'outbound', name: 'outbound', component: () => import('@/views/Outbound.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: 'users', name: 'users', component: () => import('@/views/Users.vue') },
|
||||
{ path: 'settings', name: 'settings', component: () => import('@/views/Settings.vue') },
|
||||
{ path: 'users', name: 'users', component: () => import('@/views/Users.vue'), meta: { roles: ['SUPER_ADMIN'] } },
|
||||
{ path: 'settings', name: 'settings', component: () => import('@/views/Settings.vue'), meta: { roles: ['SUPER_ADMIN'] } },
|
||||
{ path: 'profile', name: 'profile', component: () => import('@/views/Profile.vue') },
|
||||
],
|
||||
},
|
||||
@@ -53,6 +54,11 @@ router.beforeEach(async (to) => {
|
||||
return { name: 'login' };
|
||||
}
|
||||
}
|
||||
// 角色守卫:受限路由仅允许指定角色访问,越权回看板
|
||||
const roles = to.meta.roles as string[] | undefined;
|
||||
if (roles && roles.length && !roles.includes(auth.role)) {
|
||||
return { name: 'dashboard' };
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ export const useAuthStore = defineStore('auth', {
|
||||
isLoggedIn: (state) => !!state.token,
|
||||
isSuperAdmin: (state) => state.user?.role === 'SUPER_ADMIN',
|
||||
canWrite: (state) => state.user?.role === 'SUPER_ADMIN' || state.user?.role === 'OPERATOR',
|
||||
canAudit: (state) => state.user?.role === 'SUPER_ADMIN' || state.user?.role === 'AUDITOR',
|
||||
isViewer: (state) => state.user?.role === 'VIEWER',
|
||||
role: (state) => state.user?.role || '',
|
||||
},
|
||||
actions: {
|
||||
async login(username: string, password: string) {
|
||||
|
||||
@@ -12,6 +12,27 @@
|
||||
<!-- 基础信息 -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.basicInfo')" :bordered="false">
|
||||
<template v-if="!isNew" #header-extra>
|
||||
<n-tag :type="auditTagType(artwork?.auditStatus)" size="small">
|
||||
{{ t('pages.audit.status') }}:{{ t(`common.auditStatus.${artwork?.auditStatus || 'PENDING'}`) }}
|
||||
</n-tag>
|
||||
</template>
|
||||
<n-alert
|
||||
v-if="!isNew && artwork?.auditStatus === 'REJECTED'"
|
||||
type="error"
|
||||
:show-icon="true"
|
||||
style="margin-bottom: 12px"
|
||||
>
|
||||
{{ t('pages.audit.rejectedTip') }}{{ artwork?.auditRemark ? ':' + artwork.auditRemark : '' }}
|
||||
</n-alert>
|
||||
<n-alert
|
||||
v-else-if="!isNew && artwork?.auditStatus === 'PENDING'"
|
||||
type="info"
|
||||
:show-icon="true"
|
||||
style="margin-bottom: 12px"
|
||||
>
|
||||
{{ t('pages.audit.pendingTip') }}
|
||||
</n-alert>
|
||||
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi span="2 m:1" path="templateId" :label="t('pages.artwork.template')">
|
||||
@@ -35,12 +56,18 @@
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.dynamicFields') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi v-for="f in currentFields" :key="f.fieldKey" span="2 m:1" :label="f.label">
|
||||
<n-form-item-gi
|
||||
v-for="f in currentFields"
|
||||
:key="f.fieldKey"
|
||||
span="2 m:1"
|
||||
:label="f.required ? `${f.label} *` : f.label"
|
||||
>
|
||||
<n-date-picker
|
||||
v-if="f.type === 'DATE'"
|
||||
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
@@ -49,6 +76,30 @@
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/>
|
||||
<n-input-number
|
||||
v-else-if="f.type === 'NUMBER'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<n-input
|
||||
v-else-if="f.type === 'LINK'"
|
||||
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||
placeholder="https://"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'IMAGE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="image"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = v[0]?.url || '')"
|
||||
/>
|
||||
<media-upload
|
||||
v-else-if="f.type === 'FILE'"
|
||||
:model-value="toMedia(form.dynamicFields[f.fieldKey])"
|
||||
type="file"
|
||||
:max="1"
|
||||
@update:model-value="(v) => (form.dynamicFields[f.fieldKey] = v[0]?.url || '')"
|
||||
/>
|
||||
<n-input v-else v-model:value="form.dynamicFields[f.fieldKey]" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
@@ -299,6 +350,14 @@ function onTemplateChange() {
|
||||
form.dynamicFields = {};
|
||||
}
|
||||
|
||||
// 动态字段 IMAGE/FILE 适配:dynamicFields 存 url 字符串,MediaUpload 需要 MediaItem[]
|
||||
function toMedia(url: unknown) {
|
||||
return url ? [{ key: String(url), url: String(url), name: String(url) }] : [];
|
||||
}
|
||||
function auditTagType(s?: string) {
|
||||
return s === 'APPROVED' ? 'success' : s === 'REJECTED' ? 'error' : 'warning';
|
||||
}
|
||||
|
||||
async function loadTemplates() {
|
||||
templates.value = await templateApi.options();
|
||||
}
|
||||
|
||||
@@ -90,10 +90,21 @@ const columns: DataTableColumns<any> = [
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
key: 'status',
|
||||
width: 90,
|
||||
width: 84,
|
||||
render: (r) => h(NTag, { type: statusType(r.status), size: 'small' }, { default: () => t(`common.status.${r.status}`) }),
|
||||
},
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, render: (r) => fmt(r.createdAt) },
|
||||
{
|
||||
title: () => t('pages.audit.status'),
|
||||
key: 'auditStatus',
|
||||
width: 90,
|
||||
render: (r) =>
|
||||
h(
|
||||
NTag,
|
||||
{ size: 'small', type: r.auditStatus === 'APPROVED' ? 'success' : r.auditStatus === 'REJECTED' ? 'error' : 'warning' },
|
||||
{ default: () => t(`common.auditStatus.${r.auditStatus || 'PENDING'}`) },
|
||||
),
|
||||
},
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, render: (r) => fmt(r.createdAt) },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('common.label.keyword')"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-select
|
||||
v-model:value="query.auditStatus"
|
||||
:options="auditStatusOptions"
|
||||
clearable
|
||||
:placeholder="t('pages.audit.status')"
|
||||
style="width: 150px"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-button type="primary" @click="onSearch">
|
||||
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||
{{ t('common.action.search') }}
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="rejectModal" preset="card" :title="t('pages.audit.reject')" style="width: 420px">
|
||||
<n-form label-placement="top">
|
||||
<n-form-item :label="t('pages.audit.remark')">
|
||||
<n-input v-model:value="rejectRemark" type="textarea" :rows="3" :placeholder="t('pages.audit.remarkPlaceholder')" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
<n-button class="mr8" @click="rejectModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||
<n-button type="error" :loading="acting" @click="doReject">{{ t('pages.audit.reject') }}</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
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, EyeOutline, CheckmarkCircleOutline, CloseCircleOutline } from '@vicons/ionicons5';
|
||||
import { AuditStatus } from '@artveris/shared';
|
||||
import { auditApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt } from '@/utils/format';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const acting = ref(false);
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null; page: number; pageSize: number }>({
|
||||
keyword: '',
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
function auditTagType(s: string) {
|
||||
return s === 'APPROVED' ? 'success' : s === 'REJECTED' ? 'error' : 'warning';
|
||||
}
|
||||
|
||||
const rejectModal = ref(false);
|
||||
const rejectRemark = ref('');
|
||||
const rejectId = ref<number | null>(null);
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
{
|
||||
title: () => t('pages.artwork.images'),
|
||||
key: 'cover',
|
||||
width: 70,
|
||||
render: (r) =>
|
||||
r.images?.[0]?.url
|
||||
? h(NAvatar, { src: r.images[0].url, size: 40, style: 'border-radius:8px' })
|
||||
: h(NAvatar, { size: 40, style: 'border-radius:8px' }, { default: () => '—' }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.title'), key: 'title', ellipsis: { tooltip: true } },
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', width: 110, render: (r) => r.artist || '-' },
|
||||
{
|
||||
title: () => t('pages.audit.status'),
|
||||
key: 'auditStatus',
|
||||
width: 100,
|
||||
render: (r) => h(NTag, { size: 'small', type: auditTagType(r.auditStatus) }, { default: () => t(`common.auditStatus.${r.auditStatus}`) }),
|
||||
},
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
{ title: () => t('common.label.updatedAt'), key: 'updatedAt', width: 160, render: (r) => fmt(r.updatedAt) },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
width: 150,
|
||||
render: (r) =>
|
||||
h('div', { style: 'display:flex;gap:2px' }, [
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('common.action.detail'), onClick: () => router.push(`/artworks/${r.id}`) }, { icon: () => h(NIcon, null, { default: () => h(EyeOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'success', title: t('pages.audit.approve'), disabled: r.auditStatus === 'APPROVED', onClick: () => approve(r) }, { icon: () => h(NIcon, null, { default: () => h(CheckmarkCircleOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'error', title: t('pages.audit.reject'), disabled: r.auditStatus === 'REJECTED', onClick: () => openReject(r) }, { icon: () => h(NIcon, null, { default: () => h(CloseCircleOutline) }) }),
|
||||
]),
|
||||
},
|
||||
];
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await auditApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
});
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
load();
|
||||
}
|
||||
function approve(r: any) {
|
||||
dialog.success({
|
||||
title: t('pages.audit.approve'),
|
||||
content: t('pages.audit.approveConfirm', { title: r.title }),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await auditApi.audit(r.id, { approved: true });
|
||||
message.success(t('pages.audit.approved'));
|
||||
load();
|
||||
},
|
||||
});
|
||||
}
|
||||
function openReject(r: any) {
|
||||
rejectId.value = r.id;
|
||||
rejectRemark.value = '';
|
||||
rejectModal.value = true;
|
||||
}
|
||||
async function doReject() {
|
||||
if (rejectId.value === null) return;
|
||||
acting.value = true;
|
||||
try {
|
||||
await auditApi.audit(rejectId.value, { approved: false, remark: rejectRemark.value });
|
||||
message.success(t('pages.audit.rejected'));
|
||||
rejectModal.value = false;
|
||||
load();
|
||||
} finally {
|
||||
acting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,65 +1,186 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<n-card :title="t('pages.outbound.import')" :bordered="false">
|
||||
<n-alert type="info" :show-icon="true" style="margin-bottom: 16px">{{ t('pages.outbound.tip') }}</n-alert>
|
||||
<n-space>
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('common.action.downloadTemplate') }}
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.xls"
|
||||
:custom-request="doImport"
|
||||
:disabled="importing || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="importing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
{{ t('pages.outbound.selectFile') }}
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
<n-card :bordered="false">
|
||||
<n-tabs type="line" animated>
|
||||
<!-- 单条录入 -->
|
||||
<n-tab-pane name="single" :tab="t('pages.outbound.single')">
|
||||
<n-form label-placement="top" style="max-width: 560px">
|
||||
<n-form-item :label="t('pages.outbound.selectCode')" required>
|
||||
<n-select
|
||||
v-model:value="form.traceCodeId"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:loading="searching"
|
||||
:options="codeOptions"
|
||||
:placeholder="t('pages.outbound.selectCodePlaceholder')"
|
||||
@search="searchCodes"
|
||||
@update:value="onPickCode"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi :label="t('pages.outbound.sku')">
|
||||
<n-input v-model:value="form.sku" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.outbound.archiveNo')">
|
||||
<n-input v-model:value="form.archiveNo" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.outbound.outTime')">
|
||||
<n-date-picker v-model:formatted-value="form.outTime" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('common.label.remark')">
|
||||
<n-input v-model:value="form.remark" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
<n-form-item :label="t('pages.outbound.outImage')">
|
||||
<media-upload v-model="outImages" type="image" :max="1" />
|
||||
</n-form-item>
|
||||
|
||||
<n-card v-if="result" embedded :title="t('pages.outbound.importResult')" style="margin-top: 16px">
|
||||
<n-space align="center" size="large">
|
||||
<n-statistic :label="t('common.label.total')" :value="result.total" />
|
||||
<n-statistic :label="t('pages.outbound.successCount')">
|
||||
<span style="color: #138a72">{{ result.successCount }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic :label="t('pages.outbound.failCount')">
|
||||
<span style="color: #c0392b">{{ result.failCount }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(result.status)">{{ t(`common.status.${result.status}`) }}</n-tag>
|
||||
<n-button v-if="result.resultFileUrl" text tag="a" :href="result.resultFileUrl" target="_blank" type="primary">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('pages.outbound.downloadResult') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
<n-divider style="margin: 4px 0 14px">{{ t('pages.outbound.onchainSection') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi span="2" :label="t('pages.blockchain.txHash')">
|
||||
<n-input v-model:value="form.txHash" :placeholder="t('pages.outbound.txHashTip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.blockchain.onchainAt')">
|
||||
<n-date-picker v-model:formatted-value="form.onchainAt" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.blockchain.blockHeight')">
|
||||
<n-input-number v-model:value="form.blockHeight" :min="0" style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-button type="primary" :loading="saving" :disabled="!auth.canWrite || !form.traceCodeId" @click="saveSingle">
|
||||
{{ t('common.action.save') }}
|
||||
</n-button>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
|
||||
<!-- 批量导入 -->
|
||||
<n-tab-pane name="import" :tab="t('pages.outbound.import')">
|
||||
<n-alert type="info" :show-icon="true" style="margin-bottom: 16px">{{ t('pages.outbound.tip') }}</n-alert>
|
||||
<n-space>
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('common.action.downloadTemplate') }}
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.xls"
|
||||
:custom-request="doImport"
|
||||
:disabled="importing || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="importing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
{{ t('pages.outbound.selectFile') }}
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
|
||||
<n-card v-if="result" embedded :title="t('pages.outbound.importResult')" style="margin-top: 16px">
|
||||
<n-space align="center" size="large">
|
||||
<n-statistic :label="t('common.label.total', { n: result.total })" :value="result.total" />
|
||||
<n-statistic :label="t('pages.outbound.successCount')">
|
||||
<span style="color: #138a72">{{ result.successCount }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic :label="t('pages.outbound.failCount')">
|
||||
<span style="color: #c0392b">{{ result.failCount }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(result.status)">{{ t(`common.status.${result.status}`) }}</n-tag>
|
||||
<n-button v-if="result.resultFileUrl" text tag="a" :href="result.resultFileUrl" target="_blank" type="primary">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('pages.outbound.downloadResult') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { UploadCustomRequestOptions } from 'naive-ui';
|
||||
import { DownloadOutline, CloudUploadOutline } from '@vicons/ionicons5';
|
||||
import { jobApi, outboundApi, post } from '@/api';
|
||||
import { jobApi, outboundApi, traceCodeApi, post } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import { message } from '@/utils/feedback';
|
||||
import { statusType } from '@/utils/format';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
|
||||
/* 单条录入 */
|
||||
const saving = ref(false);
|
||||
const searching = ref(false);
|
||||
const codeOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const outImages = ref<any[]>([]);
|
||||
const form = reactive<any>({
|
||||
traceCodeId: null,
|
||||
sku: '',
|
||||
archiveNo: '',
|
||||
outTime: null,
|
||||
remark: '',
|
||||
txHash: '',
|
||||
onchainAt: null,
|
||||
blockHeight: null,
|
||||
});
|
||||
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
function searchCodes(keyword: string) {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(async () => {
|
||||
searching.value = true;
|
||||
try {
|
||||
const res: any = await traceCodeApi.list({ keyword: keyword || undefined, pageSize: 20 });
|
||||
codeOptions.value = res.list.map((c: any) => ({
|
||||
label: `${c.shortCode}${c.artwork ? ' · ' + c.artwork.title : ''}${c.sku ? ' · ' + c.sku : ''}`,
|
||||
value: String(c.id),
|
||||
raw: c,
|
||||
}));
|
||||
} finally {
|
||||
searching.value = false;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
function onPickCode(_id: string, opt: any) {
|
||||
const c = opt?.raw;
|
||||
if (!c) return;
|
||||
form.sku = c.sku || '';
|
||||
form.archiveNo = c.archiveNo || '';
|
||||
form.remark = c.remark || '';
|
||||
outImages.value = c.outImage ? [{ key: c.outImage, url: c.outImage, name: c.outImage }] : [];
|
||||
}
|
||||
async function saveSingle() {
|
||||
if (!form.traceCodeId) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
await outboundApi.updateSingle(form.traceCodeId, {
|
||||
sku: form.sku || undefined,
|
||||
archiveNo: form.archiveNo || undefined,
|
||||
outTime: form.outTime ? new Date(form.outTime).toISOString() : undefined,
|
||||
outImageKey: outImages.value[0]?.key || undefined,
|
||||
txHash: form.txHash || undefined,
|
||||
onchainAt: form.onchainAt ? new Date(form.onchainAt).toISOString() : undefined,
|
||||
blockHeight: form.blockHeight ?? undefined,
|
||||
remark: form.remark || undefined,
|
||||
});
|
||||
message.success(t('common.msg.saved'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* 批量导入 */
|
||||
const importing = ref(false);
|
||||
const result = ref<any>(null);
|
||||
|
||||
async function downloadTemplate() {
|
||||
await downloadFile('/outbound/import/template', 'outbound-import-template.xlsx');
|
||||
}
|
||||
|
||||
async function doImport({ file, onFinish, onError }: UploadCustomRequestOptions) {
|
||||
importing.value = true;
|
||||
result.value = null;
|
||||
|
||||
@@ -3,9 +3,23 @@
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('pages.traceCode.shortCode')"
|
||||
:placeholder="t('pages.queryLog.keywordPlaceholder')"
|
||||
clearable
|
||||
style="width: 180px"
|
||||
style="width: 200px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-input
|
||||
v-model:value="query.sku"
|
||||
placeholder="SKU"
|
||||
clearable
|
||||
style="width: 130px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-input
|
||||
v-model:value="query.batchNo"
|
||||
:placeholder="t('pages.traceCode.batchNo')"
|
||||
clearable
|
||||
style="width: 150px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-select
|
||||
@@ -13,14 +27,14 @@
|
||||
:options="resultOptions"
|
||||
clearable
|
||||
:placeholder="t('pages.queryLog.result')"
|
||||
style="width: 150px"
|
||||
style="width: 140px"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-date-picker
|
||||
v-model:value="range"
|
||||
type="datetimerange"
|
||||
clearable
|
||||
style="width: 360px"
|
||||
style="width: 340px"
|
||||
@update:value="onRange"
|
||||
/>
|
||||
<n-button type="primary" @click="onSearch">
|
||||
@@ -55,8 +69,10 @@ const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
const query = reactive<{ keyword: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; sku: string; batchNo: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
keyword: '',
|
||||
sku: '',
|
||||
batchNo: '',
|
||||
result: null,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
@@ -65,21 +81,31 @@ const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const resultOptions = Object.values(QueryResult).map((v) => ({ label: t(`common.queryResult.${v}`), value: v }));
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 130, render: (r) => r.shortCode || '-' },
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120, render: (r) => r.shortCode || '-' },
|
||||
{ title: 'SKU', key: 'sku', width: 120, render: (r) => r.sku || '-' },
|
||||
{ title: () => t('pages.traceCode.archiveNo'), key: 'archiveNo', width: 110, render: (r) => r.archiveNo || '-' },
|
||||
{ title: () => t('pages.traceCode.batchNo'), key: 'batchNo', width: 130, render: (r) => r.batchNo || '-' },
|
||||
{
|
||||
title: () => t('pages.queryLog.result'),
|
||||
key: 'queryResult',
|
||||
width: 110,
|
||||
width: 104,
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.queryResult) }, { default: () => t(`common.queryResult.${r.queryResult}`) }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 90, render: (r) => (r.queryCount ?? '-') },
|
||||
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 160, render: (r) => fmt(r.firstActivatedAt) },
|
||||
{
|
||||
title: () => t('pages.queryLog.ip'),
|
||||
key: 'ip',
|
||||
width: 200,
|
||||
width: 190,
|
||||
render: (r) => `${r.ip || '-'} / ${r.region || '-'}`,
|
||||
},
|
||||
{ title: () => t('pages.queryLog.device'), key: 'deviceType', width: 110, render: (r) => r.deviceType || '-' },
|
||||
{ title: () => t('pages.queryLog.queriedAt'), key: 'queriedAt', width: 170, render: (r) => fmt(r.queriedAt) },
|
||||
{
|
||||
title: () => t('pages.queryLog.device'),
|
||||
key: 'deviceType',
|
||||
width: 150,
|
||||
render: (r) => [r.deviceType, r.os, r.browser].filter(Boolean).join(' / ') || '-',
|
||||
},
|
||||
{ title: () => t('pages.queryLog.queriedAt'), key: 'queriedAt', width: 160, render: (r) => fmt(r.queriedAt) },
|
||||
];
|
||||
|
||||
async function load() {
|
||||
@@ -87,6 +113,8 @@ async function load() {
|
||||
try {
|
||||
const res: any = await queryLogApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
sku: query.sku || undefined,
|
||||
batchNo: query.batchNo || undefined,
|
||||
result: query.result || undefined,
|
||||
startTime: query.startTime,
|
||||
endTime: query.endTime,
|
||||
|
||||
@@ -42,16 +42,32 @@
|
||||
<n-form-item :label="t('common.label.remark')">
|
||||
<n-input v-model:value="form.remark" type="textarea" :rows="2" />
|
||||
</n-form-item>
|
||||
<n-form-item v-if="editing" :label="t('common.label.status')">
|
||||
<n-switch v-model:value="form.status" :checked-value="'ENABLED'" :unchecked-value="'DISABLED'">
|
||||
<template #checked>{{ t('common.status.ENABLED') }}</template>
|
||||
<template #unchecked>{{ t('common.status.DISABLED') }}</template>
|
||||
</n-switch>
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.template.fields')">
|
||||
<div style="width: 100%">
|
||||
<div class="field-hint">{{ t('pages.template.sortHint') }}</div>
|
||||
<div v-for="(f, i) in form.fields" :key="i" class="field-row">
|
||||
<n-input v-model:value="f.fieldKey" :placeholder="t('pages.template.fieldKeyTip')" style="width: 130px" />
|
||||
<n-input v-model:value="f.label" :placeholder="t('pages.template.fieldLabel')" style="width: 120px" />
|
||||
<n-select v-model:value="f.type" :options="fieldTypeOptions" style="width: 120px" />
|
||||
<span class="field-order">{{ i + 1 }}</span>
|
||||
<n-input v-model:value="f.fieldKey" :placeholder="t('pages.template.fieldKeyTip')" style="width: 120px" />
|
||||
<n-input v-model:value="f.label" :placeholder="t('pages.template.fieldLabel')" style="width: 110px" />
|
||||
<n-select v-model:value="f.type" :options="fieldTypeOptions" style="width: 110px" />
|
||||
<n-checkbox v-model:checked="f.required">{{ t('pages.template.required') }}</n-checkbox>
|
||||
<n-button quaternary circle type="error" @click="form.fields.splice(i, 1)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
<span class="field-ops">
|
||||
<n-button quaternary circle size="small" :disabled="i === 0" @click="moveField(i, -1)">
|
||||
<template #icon><n-icon :component="ArrowUpOutline" /></template>
|
||||
</n-button>
|
||||
<n-button quaternary circle size="small" :disabled="i === form.fields.length - 1" @click="moveField(i, 1)">
|
||||
<template #icon><n-icon :component="ArrowDownOutline" /></template>
|
||||
</n-button>
|
||||
<n-button quaternary circle type="error" size="small" @click="form.fields.splice(i, 1)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</span>
|
||||
</div>
|
||||
<n-button dashed block @click="addField">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
@@ -74,8 +90,16 @@
|
||||
import { h, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NIcon, NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||
import { SearchOutline, AddOutline, TrashOutline, CreateOutline } from '@vicons/ionicons5';
|
||||
import { FieldType } from '@artveris/shared';
|
||||
import {
|
||||
SearchOutline,
|
||||
AddOutline,
|
||||
TrashOutline,
|
||||
CreateOutline,
|
||||
ArrowUpOutline,
|
||||
ArrowDownOutline,
|
||||
PowerOutline,
|
||||
} from '@vicons/ionicons5';
|
||||
import { FieldType, TemplateStatus } from '@artveris/shared';
|
||||
import { templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
@@ -95,7 +119,7 @@ const showModal = ref(false);
|
||||
const editing = ref<number | null>(null);
|
||||
const saving = ref(false);
|
||||
const formRef = ref<FormInst | null>(null);
|
||||
const form = reactive<{ name: string; remark: string; fields: any[] }>({ name: '', remark: '', fields: [] });
|
||||
const form = reactive<{ name: string; remark: string; status: string; fields: any[] }>({ name: '', remark: '', status: 'ENABLED', fields: [] });
|
||||
const rules: FormRules = { name: { required: true, message: () => t('pages.template.namePlaceholder'), trigger: 'blur' } };
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
@@ -123,12 +147,24 @@ const columns: DataTableColumns<any> = [
|
||||
? h('div', { style: 'display:flex;gap:4px' }, [
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small', onClick: () => openEdit(r) },
|
||||
{ quaternary: true, circle: true, size: 'small', title: t('common.action.edit'), onClick: () => openEdit(r) },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(CreateOutline) }) },
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small', type: 'error', onClick: () => remove(r) },
|
||||
{
|
||||
quaternary: true,
|
||||
circle: true,
|
||||
size: 'small',
|
||||
title: r.status === 'ENABLED' ? t('common.status.DISABLED') : t('common.status.ENABLED'),
|
||||
type: r.status === 'ENABLED' ? 'warning' : 'success',
|
||||
onClick: () => toggleStatus(r),
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(PowerOutline) }) },
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small', type: 'error', title: t('common.action.delete'), onClick: () => remove(r) },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) },
|
||||
),
|
||||
])
|
||||
@@ -136,6 +172,13 @@ const columns: DataTableColumns<any> = [
|
||||
},
|
||||
];
|
||||
|
||||
async function toggleStatus(r: any) {
|
||||
const next = r.status === TemplateStatus.ENABLED ? TemplateStatus.DISABLED : TemplateStatus.ENABLED;
|
||||
await templateApi.update(r.id, { status: next });
|
||||
message.success(t('common.msg.updated'));
|
||||
load();
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -156,10 +199,17 @@ function onPage(p: number) {
|
||||
function addField() {
|
||||
form.fields.push({ fieldKey: '', label: '', type: FieldType.TEXT, required: false });
|
||||
}
|
||||
function moveField(i: number, dir: -1 | 1) {
|
||||
const j = i + dir;
|
||||
if (j < 0 || j >= form.fields.length) return;
|
||||
const arr = form.fields;
|
||||
[arr[i], arr[j]] = [arr[j], arr[i]];
|
||||
}
|
||||
function openCreate() {
|
||||
editing.value = null;
|
||||
form.name = '';
|
||||
form.remark = '';
|
||||
form.status = 'ENABLED';
|
||||
form.fields = [{ fieldKey: '', label: '', type: FieldType.TEXT, required: false }];
|
||||
showModal.value = true;
|
||||
}
|
||||
@@ -167,6 +217,7 @@ function openEdit(r: any) {
|
||||
editing.value = r.id;
|
||||
form.name = r.name;
|
||||
form.remark = r.remark || '';
|
||||
form.status = r.status || 'ENABLED';
|
||||
form.fields = (r.fields || []).map((f: any) => ({ ...f }));
|
||||
showModal.value = true;
|
||||
}
|
||||
@@ -182,7 +233,10 @@ async function save() {
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = { name: form.name, remark: form.remark, fields: form.fields };
|
||||
// 排序:按当前顺序写 sortOrder
|
||||
const fields = form.fields.map((f, i) => ({ ...f, sortOrder: i }));
|
||||
const payload: any = { name: form.name, remark: form.remark, fields };
|
||||
if (editing.value) payload.status = form.status;
|
||||
if (editing.value) {
|
||||
await templateApi.update(editing.value, payload);
|
||||
message.success(t('common.msg.updated'));
|
||||
@@ -220,6 +274,22 @@ onMounted(load);
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.field-order {
|
||||
width: 18px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.field-ops {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
}
|
||||
.field-hint {
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"@nestjs/core": "^10.4.15",
|
||||
"@nestjs/jwt": "^10.2.0",
|
||||
"@nestjs/platform-express": "^10.4.15",
|
||||
"@nestjs/schedule": "^6.1.3",
|
||||
"@nestjs/serve-static": "^4.0.2",
|
||||
"@nestjs/swagger": "^8.1.0",
|
||||
"@prisma/client": "^5.22.0",
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `artwork` ADD COLUMN `audit_remark` VARCHAR(191) NULL,
|
||||
ADD COLUMN `audit_status` ENUM('PENDING', 'APPROVED', 'REJECTED') NOT NULL DEFAULT 'PENDING',
|
||||
ADD COLUMN `audited_at` DATETIME(3) NULL,
|
||||
ADD COLUMN `audited_by` INTEGER NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `query_log` ADD COLUMN `archive_no` VARCHAR(191) NULL,
|
||||
ADD COLUMN `batch_no` VARCHAR(191) NULL,
|
||||
ADD COLUMN `browser` VARCHAR(191) NULL,
|
||||
ADD COLUMN `code` VARCHAR(191) NULL,
|
||||
ADD COLUMN `first_activated_at` DATETIME(3) NULL,
|
||||
ADD COLUMN `os` VARCHAR(191) NULL,
|
||||
ADD COLUMN `query_count` INTEGER NULL,
|
||||
ADD COLUMN `sku` VARCHAR(191) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `artwork_audit_status_idx` ON `artwork`(`audit_status`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `query_log_sku_idx` ON `query_log`(`sku`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `query_log_batch_no_idx` ON `query_log`(`batch_no`);
|
||||
@@ -40,6 +40,12 @@ enum ArtworkStatus {
|
||||
DISABLED
|
||||
}
|
||||
|
||||
enum AuditStatus {
|
||||
PENDING
|
||||
APPROVED
|
||||
REJECTED
|
||||
}
|
||||
|
||||
enum NodeType {
|
||||
CREATE
|
||||
PRODUCE
|
||||
@@ -152,6 +158,10 @@ model Artwork {
|
||||
dynamicFields Json? @map("dynamic_fields")
|
||||
images Json?
|
||||
status ArtworkStatus @default(DRAFT)
|
||||
auditStatus AuditStatus @default(PENDING) @map("audit_status")
|
||||
auditRemark String? @map("audit_remark")
|
||||
auditedBy Int? @map("audited_by")
|
||||
auditedAt DateTime? @map("audited_at")
|
||||
createdBy Int? @map("created_by")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
@@ -165,6 +175,7 @@ model Artwork {
|
||||
|
||||
@@index([templateId])
|
||||
@@index([status])
|
||||
@@index([auditStatus])
|
||||
@@map("artwork")
|
||||
}
|
||||
|
||||
@@ -279,21 +290,31 @@ model BlockchainProof {
|
||||
}
|
||||
|
||||
model QueryLog {
|
||||
id BigInt @id @default(autoincrement())
|
||||
traceCodeId BigInt? @map("trace_code_id")
|
||||
artworkId Int? @map("artwork_id")
|
||||
shortCode String? @map("short_code")
|
||||
queriedAt DateTime @default(now()) @map("queried_at")
|
||||
queryResult QueryResult @map("query_result")
|
||||
ip String?
|
||||
region String?
|
||||
userAgent String? @db.Text @map("user_agent")
|
||||
deviceType String? @map("device_type")
|
||||
id BigInt @id @default(autoincrement())
|
||||
traceCodeId BigInt? @map("trace_code_id")
|
||||
artworkId Int? @map("artwork_id")
|
||||
shortCode String? @map("short_code")
|
||||
code String?
|
||||
sku String?
|
||||
archiveNo String? @map("archive_no")
|
||||
batchNo String? @map("batch_no")
|
||||
queryCount Int? @map("query_count")
|
||||
firstActivatedAt DateTime? @map("first_activated_at")
|
||||
queriedAt DateTime @default(now()) @map("queried_at")
|
||||
queryResult QueryResult @map("query_result")
|
||||
ip String?
|
||||
region String?
|
||||
userAgent String? @db.Text @map("user_agent")
|
||||
deviceType String? @map("device_type")
|
||||
browser String?
|
||||
os String?
|
||||
|
||||
traceCode TraceCode? @relation(fields: [traceCodeId], references: [id])
|
||||
|
||||
@@index([traceCodeId])
|
||||
@@index([queriedAt])
|
||||
@@index([sku])
|
||||
@@index([batchNo])
|
||||
@@map("query_log")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PrismaClient, RoleType } from '@prisma/client';
|
||||
import { PrismaClient, RoleType, AuditStatus } from '@prisma/client';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
||||
import { dirname, join, resolve } from 'path';
|
||||
@@ -108,6 +108,9 @@ async function ensureSampleData(): Promise<void> {
|
||||
title: s.title,
|
||||
artist: s.artist,
|
||||
status: 'ACTIVE',
|
||||
auditStatus: AuditStatus.APPROVED,
|
||||
auditedBy: admin?.id,
|
||||
auditedAt: new Date(),
|
||||
createdBy: admin?.id,
|
||||
dynamicFields: { craft: s.craft, material: s.material, size: s.size, year: s.year },
|
||||
images: [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import configuration from './config/configuration';
|
||||
import { PrismaModule } from './prisma/prisma.module';
|
||||
import { AppController } from './app.controller';
|
||||
@@ -30,6 +31,7 @@ import { SettingsModule } from './settings/settings.module';
|
||||
load: [configuration],
|
||||
envFilePath: ['../../.env', '.env'],
|
||||
}),
|
||||
ScheduleModule.forRoot(),
|
||||
PrismaModule,
|
||||
RedisModule,
|
||||
StorageModule,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, Query }
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { RoleType } from '@artveris/shared';
|
||||
import { ArtworkService } from './artwork.service';
|
||||
import { CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
|
||||
|
||||
@@ -38,6 +38,17 @@ export class ArtworkController {
|
||||
return this.artworkService.update(id, dto);
|
||||
}
|
||||
|
||||
@Post(':id/audit')
|
||||
@Roles(RoleType.AUDITOR)
|
||||
@ApiOperation({ summary: '审核艺术品(通过/驳回,审核员)' })
|
||||
audit(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() dto: AuditArtworkDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.artworkService.audit(id, dto, user.id);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '停用/删除艺术品(软删除)' })
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ArtworkStatus, ErrorCode } from '@artveris/shared';
|
||||
import { AuditStatus, ErrorCode } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
import { CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
|
||||
interface MediaItem {
|
||||
key: string;
|
||||
@@ -54,6 +54,7 @@ export class ArtworkService {
|
||||
];
|
||||
}
|
||||
if (query.status) where.status = query.status;
|
||||
if (query.auditStatus) where.auditStatus = query.auditStatus;
|
||||
if (query.templateId) where.templateId = query.templateId;
|
||||
|
||||
const [rows, total] = await this.prisma.$transaction([
|
||||
@@ -105,6 +106,11 @@ export class ArtworkService {
|
||||
title: dto.title,
|
||||
artist: dto.artist,
|
||||
status: dto.status,
|
||||
// 内容变更需重新审核:编辑后回到待审核
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
auditRemark: null,
|
||||
auditedBy: null,
|
||||
auditedAt: null,
|
||||
};
|
||||
if (dto.dynamicFields !== undefined) {
|
||||
data.dynamicFields = dto.dynamicFields as Prisma.InputJsonValue;
|
||||
@@ -116,6 +122,21 @@ export class ArtworkService {
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
// 审核:通过 / 驳回(审核员或超管)
|
||||
async audit(id: number, dto: AuditArtworkDto, auditorId: number) {
|
||||
await this.ensureExists(id);
|
||||
await this.prisma.artwork.update({
|
||||
where: { id },
|
||||
data: {
|
||||
auditStatus: dto.approved ? AuditStatus.APPROVED : AuditStatus.REJECTED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
auditedBy: auditorId,
|
||||
auditedAt: new Date(),
|
||||
},
|
||||
});
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
async remove(id: number) {
|
||||
await this.ensureExists(id);
|
||||
await this.prisma.artwork.update({ where: { id }, data: { deletedAt: new Date() } });
|
||||
|
||||
@@ -11,7 +11,8 @@ import {
|
||||
MaxLength,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { ArtworkStatus } from '@artveris/shared';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ArtworkStatus, AuditStatus } from '@artveris/shared';
|
||||
import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||
|
||||
export class MediaItemDto {
|
||||
@@ -104,9 +105,26 @@ export class QueryArtworkDto extends PaginationDto {
|
||||
@IsEnum(ArtworkStatus)
|
||||
status?: ArtworkStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: '审核状态', enum: AuditStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(AuditStatus)
|
||||
auditStatus?: AuditStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: '模板 ID' })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
templateId?: number;
|
||||
}
|
||||
|
||||
export class AuditArtworkDto {
|
||||
@ApiProperty({ description: '是否通过' })
|
||||
@IsBoolean()
|
||||
approved!: boolean;
|
||||
|
||||
@ApiPropertyOptional({ description: '审核意见(驳回建议填写)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(255)
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
export interface DeviceInfo {
|
||||
deviceType: string; // Mobile | Tablet | PC
|
||||
os: string;
|
||||
browser: string;
|
||||
}
|
||||
|
||||
// 轻量 User-Agent 解析,用于查询日志风控统计。
|
||||
export function parseUserAgent(ua?: string): DeviceInfo {
|
||||
if (!ua) return { deviceType: 'Unknown', os: 'Unknown' };
|
||||
if (!ua) return { deviceType: 'Unknown', os: 'Unknown', browser: 'Unknown' };
|
||||
const s = ua.toLowerCase();
|
||||
let deviceType = 'PC';
|
||||
if (/ipad|tablet/.test(s)) deviceType = 'Tablet';
|
||||
@@ -18,7 +19,16 @@ export function parseUserAgent(ua?: string): DeviceInfo {
|
||||
else if (/mac os|macintosh/.test(s)) os = 'macOS';
|
||||
else if (/linux/.test(s)) os = 'Linux';
|
||||
|
||||
return { deviceType, os };
|
||||
// 浏览器/客户端识别(顺序敏感:微信/Edge 需在通用 Chrome 之前判断)
|
||||
let browser = 'Unknown';
|
||||
if (/micromessenger/.test(s)) browser = 'WeChat';
|
||||
else if (/edg/.test(s)) browser = 'Edge';
|
||||
else if (/opr|opera/.test(s)) browser = 'Opera';
|
||||
else if (/firefox|fxios/.test(s)) browser = 'Firefox';
|
||||
else if (/chrome|crios/.test(s)) browser = 'Chrome';
|
||||
else if (/safari/.test(s)) browser = 'Safari';
|
||||
|
||||
return { deviceType, os, browser };
|
||||
}
|
||||
|
||||
// 从请求中提取真实客户端 IP(兼容反向代理)。
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsDateString, IsOptional, IsString, MaxLength } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDateString, IsInt, IsOptional, IsString, MaxLength, Min } from 'class-validator';
|
||||
|
||||
export class OutboundDto {
|
||||
@ApiPropertyOptional({ description: 'SKU' })
|
||||
@@ -24,6 +25,24 @@ export class OutboundDto {
|
||||
@IsString()
|
||||
outImageKey?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '上链哈希值(填写则记录上链结果)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(255)
|
||||
txHash?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '上链时间' })
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
onchainAt?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '区块高度' })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
blockHeight?: number;
|
||||
|
||||
@ApiPropertyOptional({ description: '备注' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { Job } from 'bullmq';
|
||||
import { createHash } from 'crypto';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { JobStatus, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { JobStatus, OUTBOUND_IMPORT_COLUMNS, ProofStatus, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { JobsService } from '../jobs/jobs.service';
|
||||
|
||||
// 将 ExcelJS 单元格值规整为字符串(兼容 Date / 富文本 / 公式结果 / 超链接 / 数字)
|
||||
function cellToString(v: unknown): string {
|
||||
if (v === null || v === undefined) return '';
|
||||
if (v instanceof Date) return v.toISOString();
|
||||
if (typeof v === 'object') {
|
||||
const o = v as Record<string, unknown>;
|
||||
if (typeof o.text === 'string') return o.text.trim();
|
||||
if (o.result !== undefined && o.result !== null) return String(o.result).trim();
|
||||
if (Array.isArray(o.richText)) return o.richText.map((r: any) => r.text).join('').trim();
|
||||
if (o.hyperlink) return String(o.hyperlink).trim();
|
||||
}
|
||||
return String(v).trim();
|
||||
}
|
||||
|
||||
// 校验并解析日期,非法返回 null(区分 undefined=未填)
|
||||
function parseDate(v?: string): Date | undefined | null {
|
||||
if (!v) return undefined;
|
||||
const d = new Date(v);
|
||||
return isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
|
||||
interface ImportJobData {
|
||||
jobId: string;
|
||||
fileKey: string;
|
||||
@@ -55,8 +77,7 @@ export class ImportProcessor extends WorkerHost {
|
||||
const values: Record<string, string> = {};
|
||||
let empty = true;
|
||||
colToKey.forEach((key, col) => {
|
||||
const v = row.getCell(col).value;
|
||||
const text = v === null || v === undefined ? '' : String(v).trim();
|
||||
const text = cellToString(row.getCell(col).value);
|
||||
if (text) empty = false;
|
||||
values[key] = text;
|
||||
});
|
||||
@@ -74,22 +95,76 @@ export class ImportProcessor extends WorkerHost {
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
const code = await this.prisma.traceCode.findUnique({ where: { shortCode } });
|
||||
const code = await this.prisma.traceCode.findUnique({
|
||||
where: { shortCode },
|
||||
include: { batch: true },
|
||||
});
|
||||
if (!code) {
|
||||
row.reason = '短码不存在';
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
// 批次编号核对:填写则必须与该码实际批次一致
|
||||
if (row.values.batchNo && row.values.batchNo !== (code.batch?.batchNo ?? '')) {
|
||||
row.reason = `批次编号与该码实际批次不符(实际:${code.batch?.batchNo ?? '无'})`;
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
// 字段格式校验
|
||||
const outTime = parseDate(row.values.outTime);
|
||||
if (outTime === null) {
|
||||
row.reason = '出库时间格式不正确(应为 YYYY-MM-DD HH:mm)';
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
const onchainAt = parseDate(row.values.onchainAt);
|
||||
if (onchainAt === null) {
|
||||
row.reason = '上链时间格式不正确(应为 YYYY-MM-DD HH:mm)';
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
let blockHeight: bigint | undefined;
|
||||
if (row.values.blockHeight) {
|
||||
if (!/^\d+$/.test(row.values.blockHeight)) {
|
||||
row.reason = '区块高度应为整数';
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
blockHeight = BigInt(row.values.blockHeight);
|
||||
}
|
||||
try {
|
||||
await this.prisma.traceCode.update({
|
||||
where: { id: code.id },
|
||||
data: {
|
||||
sku: row.values.sku || undefined,
|
||||
archiveNo: row.values.archiveNo || undefined,
|
||||
outTime: row.values.outTime ? new Date(row.values.outTime) : undefined,
|
||||
outTime: outTime ?? undefined,
|
||||
outImage: row.values.outImage || undefined,
|
||||
remark: row.values.remark || undefined,
|
||||
},
|
||||
});
|
||||
// 录入上链哈希则登记一条已上链存证(同码同哈希去重,避免重复导入污染)
|
||||
if (row.values.txHash) {
|
||||
const dup = await this.prisma.blockchainProof.findFirst({
|
||||
where: { traceCodeId: code.id, txHash: row.values.txHash },
|
||||
});
|
||||
if (!dup) {
|
||||
const dataHash =
|
||||
'0x' + createHash('sha256').update(`${code.code}:${row.values.txHash}`).digest('hex');
|
||||
await this.prisma.blockchainProof.create({
|
||||
data: {
|
||||
traceCodeId: code.id,
|
||||
dataHash,
|
||||
txHash: row.values.txHash,
|
||||
blockHeight: blockHeight ?? null,
|
||||
chainName: '手工登记',
|
||||
onchainAt: onchainAt ?? new Date(),
|
||||
status: ProofStatus.ONCHAIN,
|
||||
rawResponse: { source: 'import' },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
row.ok = true;
|
||||
success++;
|
||||
} catch (e) {
|
||||
|
||||
@@ -2,14 +2,27 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectQueue } from '@nestjs/bullmq';
|
||||
import { Queue } from 'bullmq';
|
||||
import { Response } from 'express';
|
||||
import { createHash } from 'crypto';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { ErrorCode, JobType, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
|
||||
import {
|
||||
ErrorCode,
|
||||
JobType,
|
||||
OUTBOUND_IMPORT_COLUMNS,
|
||||
ProofStatus,
|
||||
QUEUE_NAMES,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { JobsService } from '../jobs/jobs.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { OutboundDto } from './dto/outbound.dto';
|
||||
|
||||
const XLSX_MIME_TYPES = [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-excel',
|
||||
'application/octet-stream', // 某些浏览器对 .xlsx 的兜底类型
|
||||
];
|
||||
|
||||
@Injectable()
|
||||
export class OutboundService {
|
||||
constructor(
|
||||
@@ -22,7 +35,7 @@ export class OutboundService {
|
||||
async updateSingle(traceCodeId: bigint, dto: OutboundDto) {
|
||||
const code = await this.prisma.traceCode.findUnique({ where: { id: traceCodeId } });
|
||||
if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '追溯码不存在', 404);
|
||||
return this.prisma.traceCode.update({
|
||||
const updated = await this.prisma.traceCode.update({
|
||||
where: { id: traceCodeId },
|
||||
data: {
|
||||
sku: dto.sku,
|
||||
@@ -32,6 +45,42 @@ export class OutboundService {
|
||||
remark: dto.remark,
|
||||
},
|
||||
});
|
||||
// 录入了上链哈希则记录一条已上链存证(手工登记,不触发 Mock 链)
|
||||
if (dto.txHash) {
|
||||
await this.recordProof(traceCodeId, code.code, {
|
||||
txHash: dto.txHash,
|
||||
onchainAt: dto.onchainAt ? new Date(dto.onchainAt) : new Date(),
|
||||
blockHeight: dto.blockHeight,
|
||||
});
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
// 手工登记上链结果:写入一条 ONCHAIN 存证(数据哈希由 code+txHash 派生)
|
||||
// 同码同哈希去重:重复保存不会产生多条存证
|
||||
private async recordProof(
|
||||
traceCodeId: bigint,
|
||||
code: string,
|
||||
p: { txHash: string; onchainAt: Date; blockHeight?: number },
|
||||
) {
|
||||
const dup = await this.prisma.blockchainProof.findFirst({
|
||||
where: { traceCodeId, txHash: p.txHash },
|
||||
});
|
||||
if (dup) return;
|
||||
const dataHash =
|
||||
'0x' + createHash('sha256').update(`${code}:${p.txHash}`).digest('hex');
|
||||
await this.prisma.blockchainProof.create({
|
||||
data: {
|
||||
traceCodeId,
|
||||
dataHash,
|
||||
txHash: p.txHash,
|
||||
blockHeight: p.blockHeight !== undefined ? BigInt(p.blockHeight) : null,
|
||||
chainName: '手工登记',
|
||||
onchainAt: p.onchainAt,
|
||||
status: ProofStatus.ONCHAIN,
|
||||
rawResponse: { source: 'manual' },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async generateTemplate(res: Response): Promise<void> {
|
||||
@@ -65,6 +114,11 @@ export class OutboundService {
|
||||
|
||||
async startImport(file: Express.Multer.File, userId: number) {
|
||||
if (!file) throw new BusinessException(ErrorCode.BAD_REQUEST, '请上传导入文件');
|
||||
const name = (file.originalname || '').toLowerCase();
|
||||
const okType = XLSX_MIME_TYPES.includes(file.mimetype) || name.endsWith('.xlsx') || name.endsWith('.xls');
|
||||
if (!okType) {
|
||||
throw new BusinessException(ErrorCode.FILE_TYPE_NOT_ALLOWED, '仅支持 Excel(.xlsx/.xls)文件导入');
|
||||
}
|
||||
const saved = await this.storage.save(file.buffer, file.originalname || 'import.xlsx', file.mimetype);
|
||||
const job = await this.jobs.create(JobType.IMPORT_OUTBOUND, 0, userId, { fileKey: saved.key });
|
||||
await this.queue.add('import', { jobId: job.id, fileKey: saved.key });
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||
import type Redis from 'ioredis';
|
||||
import { ArtworkStatus, QueryResult, ProofStatus, TraceCodeStatus } from '@artveris/shared';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ArtworkStatus, AuditStatus, QueryResult, ProofStatus, TraceCodeStatus } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { GeoService } from '../geo/geo.service';
|
||||
import { REDIS_CLIENT } from '../redis/redis.module';
|
||||
import { parseUserAgent } from '../common/utils/ua.util';
|
||||
|
||||
type TraceCodeWithBatch = Prisma.TraceCodeGetPayload<{ include: { batch: true } }>;
|
||||
|
||||
export interface TraceContext {
|
||||
ip: string;
|
||||
userAgent?: string;
|
||||
@@ -52,17 +55,17 @@ export class PublicTraceService {
|
||||
return { status: 'INVALID' as const };
|
||||
}
|
||||
|
||||
const code = await this.prisma.traceCode.findUnique({ where: { id } });
|
||||
const code = await this.prisma.traceCode.findUnique({ where: { id }, include: { batch: true } });
|
||||
if (!code || !code.artworkId || code.status === TraceCodeStatus.UNBOUND) {
|
||||
await this.writeLog(id, null, shortCode, QueryResult.INVALID, ctx);
|
||||
await this.writeLog(id, null, shortCode, QueryResult.INVALID, ctx, code ?? undefined);
|
||||
return { status: 'INVALID' as const };
|
||||
}
|
||||
if (code.status === TraceCodeStatus.DISABLED) {
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.DISABLED, ctx);
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.DISABLED, ctx, code);
|
||||
return { status: 'DISABLED' as const };
|
||||
}
|
||||
if (code.status === TraceCodeStatus.ABNORMAL) {
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.ABNORMAL, ctx);
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.ABNORMAL, ctx, code);
|
||||
return { status: 'ABNORMAL' as const };
|
||||
}
|
||||
|
||||
@@ -74,8 +77,13 @@ export class PublicTraceService {
|
||||
certificates: { orderBy: { id: 'asc' } },
|
||||
},
|
||||
});
|
||||
if (!artwork || artwork.status === ArtworkStatus.DISABLED) {
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.INVALID, ctx);
|
||||
// 仅展示「未停用」且「审核通过」的作品,否则视为无效,避免未审核数据外泄
|
||||
if (
|
||||
!artwork ||
|
||||
artwork.status === ArtworkStatus.DISABLED ||
|
||||
artwork.auditStatus !== AuditStatus.APPROVED
|
||||
) {
|
||||
await this.writeLog(id, code.artworkId, shortCode, QueryResult.INVALID, ctx, code);
|
||||
return { status: 'INVALID' as const };
|
||||
}
|
||||
|
||||
@@ -107,10 +115,12 @@ export class PublicTraceService {
|
||||
});
|
||||
|
||||
const result = firstActivate ? QueryResult.FIRST_ACTIVATE : QueryResult.REPEAT;
|
||||
await this.writeLog(id, artwork.id, shortCode, result, ctx);
|
||||
await this.writeLog(id, artwork.id, shortCode, result, ctx, { ...code, ...updated });
|
||||
|
||||
return {
|
||||
status: 'OK' as const,
|
||||
code: code.code,
|
||||
queriedAt: now,
|
||||
antiCounterfeit: {
|
||||
firstQuery: firstActivate,
|
||||
queryCount: updated.queryCount,
|
||||
@@ -157,7 +167,19 @@ export class PublicTraceService {
|
||||
) {
|
||||
const data = (dynamic as Record<string, unknown>) || {};
|
||||
return fields
|
||||
.map((f) => ({ label: f.label, type: f.type, value: data[f.fieldKey] }))
|
||||
.map((f) => {
|
||||
let value = data[f.fieldKey];
|
||||
// 图片/文件字段:若存的是存储 key(非绝对/Data URL),转为可访问 URL,避免 C 端 404
|
||||
if (
|
||||
(f.type === 'IMAGE' || f.type === 'FILE') &&
|
||||
typeof value === 'string' &&
|
||||
value &&
|
||||
!/^(https?:|data:|\/)/i.test(value)
|
||||
) {
|
||||
value = this.storage.getUrl(value);
|
||||
}
|
||||
return { label: f.label, type: f.type, value };
|
||||
})
|
||||
.filter((f) => f.value !== undefined && f.value !== null && f.value !== '');
|
||||
}
|
||||
|
||||
@@ -167,6 +189,7 @@ export class PublicTraceService {
|
||||
shortCode: string,
|
||||
result: QueryResult,
|
||||
ctx: TraceContext,
|
||||
code?: Partial<TraceCodeWithBatch>,
|
||||
): Promise<void> {
|
||||
try {
|
||||
const device = parseUserAgent(ctx.userAgent);
|
||||
@@ -175,11 +198,19 @@ export class PublicTraceService {
|
||||
traceCodeId: traceCodeId ?? undefined,
|
||||
artworkId: artworkId ?? undefined,
|
||||
shortCode,
|
||||
code: code?.code ?? undefined,
|
||||
sku: code?.sku ?? undefined,
|
||||
archiveNo: code?.archiveNo ?? undefined,
|
||||
batchNo: code?.batch?.batchNo ?? undefined,
|
||||
queryCount: code?.queryCount ?? undefined,
|
||||
firstActivatedAt: code?.firstActivatedAt ?? undefined,
|
||||
queryResult: result,
|
||||
ip: ctx.ip,
|
||||
region: this.geo.resolveRegion(ctx.ip),
|
||||
userAgent: ctx.userAgent,
|
||||
deviceType: device.deviceType,
|
||||
browser: device.browser,
|
||||
os: device.os,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Cron, CronExpression } from '@nestjs/schedule';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
|
||||
// 查询日志保留周期清理:每天凌晨执行,删除超过保留天数的日志。
|
||||
// 保留天数取系统设置 logRetentionDays(后台可配置),<=0 表示长期保留、不清理。
|
||||
@Injectable()
|
||||
export class LogRetentionService {
|
||||
private readonly logger = new Logger(LogRetentionService.name);
|
||||
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly settings: SettingsService,
|
||||
) {}
|
||||
|
||||
@Cron(CronExpression.EVERY_DAY_AT_3AM)
|
||||
async cleanup(): Promise<void> {
|
||||
const days = await this.resolveRetentionDays();
|
||||
if (!days || days <= 0) {
|
||||
this.logger.log('日志保留周期为长期保留,跳过清理');
|
||||
return;
|
||||
}
|
||||
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
|
||||
const { count } = await this.prisma.queryLog.deleteMany({
|
||||
where: { queriedAt: { lt: cutoff } },
|
||||
});
|
||||
this.logger.log(`查询日志清理完成:删除 ${count} 条(保留 ${days} 天,截止 ${cutoff.toISOString()})`);
|
||||
}
|
||||
|
||||
private async resolveRetentionDays(): Promise<number> {
|
||||
const raw = await this.settings.get('logRetentionDays');
|
||||
const n = Number(raw);
|
||||
if (raw !== null && !Number.isNaN(n)) return n;
|
||||
return 365;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,21 @@ import { buildPage } from '../common/utils/pagination.util';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
|
||||
class QueryLogQueryDto extends PaginationDto {
|
||||
@ApiPropertyOptional({ description: '关键词(短码)' })
|
||||
@ApiPropertyOptional({ description: '关键词(短码 / 追溯码 / SKU / 档案编号)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
keyword?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'SKU' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sku?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '批次编号' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
batchNo?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '查询结果', enum: QueryResult })
|
||||
@IsOptional()
|
||||
@IsEnum(QueryResult)
|
||||
@@ -39,7 +49,16 @@ export class QueryLogController {
|
||||
@ApiOperation({ summary: '查询日志列表' })
|
||||
async list(@Query() query: QueryLogQueryDto) {
|
||||
const where: Prisma.QueryLogWhereInput = {};
|
||||
if (query.keyword) where.shortCode = { contains: query.keyword };
|
||||
if (query.keyword) {
|
||||
where.OR = [
|
||||
{ shortCode: { contains: query.keyword } },
|
||||
{ code: { contains: query.keyword } },
|
||||
{ sku: { contains: query.keyword } },
|
||||
{ archiveNo: { contains: query.keyword } },
|
||||
];
|
||||
}
|
||||
if (query.sku) where.sku = { contains: query.sku };
|
||||
if (query.batchNo) where.batchNo = { contains: query.batchNo };
|
||||
if (query.result) where.queryResult = query.result;
|
||||
if (query.startTime || query.endTime) {
|
||||
where.queriedAt = {};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { QueryLogController } from './query-log.controller';
|
||||
import { LogRetentionService } from './log-retention.service';
|
||||
|
||||
@Module({
|
||||
controllers: [QueryLogController],
|
||||
providers: [LogRetentionService],
|
||||
})
|
||||
export class QueryLogModule {}
|
||||
|
||||
@@ -98,6 +98,11 @@ export class BatchStatusDto {
|
||||
@ApiProperty({ description: 'true 停用,false 启用' })
|
||||
@IsBoolean()
|
||||
disabled!: boolean;
|
||||
|
||||
@ApiPropertyOptional({ description: 'true 标记为异常(优先级高于 disabled)' })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
abnormal?: boolean;
|
||||
}
|
||||
|
||||
export class BindArtworkDto {
|
||||
|
||||
@@ -101,7 +101,13 @@ export class TraceCodeService {
|
||||
|
||||
async batchSetStatus(dto: BatchStatusDto) {
|
||||
const ids = dto.ids.map((i) => BigInt(i));
|
||||
if (dto.disabled) {
|
||||
if (dto.abnormal) {
|
||||
// 标记异常:用于运营人为标注疑似被复制/盗用的码
|
||||
await this.prisma.traceCode.updateMany({
|
||||
where: { id: { in: ids } },
|
||||
data: { status: TraceCodeStatus.ABNORMAL },
|
||||
});
|
||||
} else if (dto.disabled) {
|
||||
await this.prisma.traceCode.updateMany({
|
||||
where: { id: { in: ids } },
|
||||
data: { status: TraceCodeStatus.DISABLED },
|
||||
|
||||
@@ -15,9 +15,11 @@ import {
|
||||
MAX_FILE_SIZE,
|
||||
MAX_IMAGE_SIZE,
|
||||
MAX_VIDEO_SIZE,
|
||||
RoleType,
|
||||
} from '@artveris/shared';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
|
||||
type UploadType = 'image' | 'video' | 'file';
|
||||
|
||||
@@ -34,6 +36,7 @@ export class UploadController {
|
||||
constructor(private readonly storage: StorageService) {}
|
||||
|
||||
@Post()
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '上传文件(图片/视频/文档)' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@ApiQuery({ name: 'type', enum: ['image', 'video', 'file'], required: false })
|
||||
|
||||
@@ -7,22 +7,39 @@
|
||||
"firstDesc": "This is the first query of the code. The artwork is genuine.",
|
||||
"repeatDesc": "This code has been activated. Please note the query count.",
|
||||
"queryCount": "Queried {n} times",
|
||||
"firstActivatedAt": "First activated: {t}"
|
||||
"firstActivatedAt": "First activated: {t}",
|
||||
"queriedAt": "This query: {t}",
|
||||
"code": "Trace Code"
|
||||
},
|
||||
"section": {
|
||||
"basic": "Basic Info",
|
||||
"timeline": "Provenance Timeline",
|
||||
"cert": "Certificates",
|
||||
"chain": "Blockchain Attestation"
|
||||
"chain": "Digital Identity & Blockchain"
|
||||
},
|
||||
"chain": {
|
||||
"code": "Trace Code",
|
||||
"hash": "Tx Hash",
|
||||
"dataHash": "Data Hash",
|
||||
"blockHeight": "Block Height",
|
||||
"onchainAt": "On-chain Time",
|
||||
"explorer": "View Proof",
|
||||
"copy": "Copy",
|
||||
"copied": "Copied"
|
||||
"copied": "Copied",
|
||||
"notOnchain": "This artwork has not been recorded on-chain yet."
|
||||
},
|
||||
"cert": {
|
||||
"type": {
|
||||
"PHOTO": "Photo with Author",
|
||||
"CERT": "Certificate",
|
||||
"APPRAISAL": "Appraisal"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"viewFile": "View file"
|
||||
},
|
||||
"privacy": {
|
||||
"note": "Privacy: for anti-counterfeit risk control and query statistics, this visit's necessary info (time, IP, region and device) is recorded."
|
||||
},
|
||||
"state": {
|
||||
"loading": "Loading…",
|
||||
|
||||
@@ -7,22 +7,39 @@
|
||||
"firstDesc": "该防伪码为首次查询,本作品为正品。",
|
||||
"repeatDesc": "该防伪码已激活,请留意查询次数是否异常。",
|
||||
"queryCount": "累计查询 {n} 次",
|
||||
"firstActivatedAt": "首次激活:{t}"
|
||||
"firstActivatedAt": "首次激活:{t}",
|
||||
"queriedAt": "本次查询:{t}",
|
||||
"code": "唯一追溯码"
|
||||
},
|
||||
"section": {
|
||||
"basic": "基础信息",
|
||||
"timeline": "溯源时间轴",
|
||||
"cert": "认证文件",
|
||||
"chain": "区块链存证"
|
||||
"chain": "数字身份与区块链存证"
|
||||
},
|
||||
"chain": {
|
||||
"code": "唯一追溯码",
|
||||
"hash": "交易哈希",
|
||||
"dataHash": "数据哈希",
|
||||
"blockHeight": "区块高度",
|
||||
"onchainAt": "上链时间",
|
||||
"explorer": "查看存证",
|
||||
"copy": "复制",
|
||||
"copied": "已复制"
|
||||
"copied": "已复制",
|
||||
"notOnchain": "该作品暂未上链存证。"
|
||||
},
|
||||
"cert": {
|
||||
"type": {
|
||||
"PHOTO": "作者合照",
|
||||
"CERT": "证书",
|
||||
"APPRAISAL": "鉴定意见"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"viewFile": "查看文件"
|
||||
},
|
||||
"privacy": {
|
||||
"note": "隐私说明:为防伪风控与查询统计,系统会记录本次访问的必要信息(如访问时间、IP、地区与设备信息)。"
|
||||
},
|
||||
"state": {
|
||||
"loading": "正在查询…",
|
||||
|
||||
+99
-19
@@ -33,6 +33,8 @@
|
||||
· {{ t('anti.firstActivatedAt', { t: fmt(data.antiCounterfeit.firstActivatedAt) }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="data.queriedAt" class="anti-meta">{{ t('anti.queriedAt', { t: fmt(data.queriedAt) }) }}</div>
|
||||
<div v-if="data.code" class="anti-code">{{ t('anti.code') }}:<span class="mono">{{ data.code }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -69,7 +71,19 @@
|
||||
<div class="fields">
|
||||
<div v-for="(f, i) in data.artwork.fields" :key="i" class="field">
|
||||
<span class="field-label">{{ f.label }}</span>
|
||||
<span class="field-value">{{ f.value }}</span>
|
||||
<span class="field-value">
|
||||
<img
|
||||
v-if="f.type === 'IMAGE' && f.value"
|
||||
:src="f.value"
|
||||
class="field-img"
|
||||
loading="lazy"
|
||||
@click="openViewer([{ url: f.value, type: 'image', name: f.label }], 0)"
|
||||
/>
|
||||
<a v-else-if="(f.type === 'LINK' || f.type === 'FILE') && safeUrl(f.value)" :href="safeUrl(f.value)" target="_blank" rel="noopener" class="field-link">
|
||||
{{ f.type === 'FILE' ? t('field.viewFile') : f.value }}
|
||||
</a>
|
||||
<template v-else>{{ f.value }}</template>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -108,33 +122,52 @@
|
||||
<div class="cert-grid">
|
||||
<div v-for="(c, i) in data.certificates" :key="i" class="cert">
|
||||
<img v-if="c.url" :src="c.url" loading="lazy" @click="openViewer([{ url: c.url, name: c.name, type: 'image' }], 0)" />
|
||||
<div class="cert-name text-ellipsis">{{ c.name }}</div>
|
||||
<div class="cert-head">
|
||||
<span class="cert-name text-ellipsis">{{ c.name }}</span>
|
||||
<span v-if="c.type" class="cert-type">{{ t(`cert.type.${c.type}`) }}</span>
|
||||
</div>
|
||||
<div v-if="c.issuer" class="muted cert-issuer text-ellipsis">{{ c.issuer }}</div>
|
||||
<div v-if="c.issuedAt" class="muted cert-issuer">{{ fmtDate(c.issuedAt) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 区块链存证 -->
|
||||
<section v-if="data.blockchain" class="card">
|
||||
<!-- 数字身份与区块链存证 -->
|
||||
<section class="card">
|
||||
<h2 class="section-title">{{ t('section.chain') }}</h2>
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.hash') }}</span>
|
||||
<span class="chain-v mono">{{ ellipsis(data.blockchain.txHash) }}</span>
|
||||
<button class="copy" @click="copy(data.blockchain.txHash)">{{ t('chain.copy') }}</button>
|
||||
<span class="chain-k">{{ t('chain.code') }}</span>
|
||||
<span class="chain-v mono">{{ data.code || '-' }}</span>
|
||||
</div>
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.blockHeight') }}</span>
|
||||
<span class="chain-v">{{ data.blockchain.blockHeight }}</span>
|
||||
</div>
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.onchainAt') }}</span>
|
||||
<span class="chain-v">{{ fmt(data.blockchain.onchainAt) }}</span>
|
||||
</div>
|
||||
<a v-if="data.blockchain.explorerUrl" class="chain-link" :href="data.blockchain.explorerUrl" target="_blank">
|
||||
{{ t('chain.explorer') }} →
|
||||
</a>
|
||||
<template v-if="data.blockchain">
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.hash') }}</span>
|
||||
<span class="chain-v mono">{{ ellipsis(data.blockchain.txHash) }}</span>
|
||||
<button class="copy" @click="copy(data.blockchain.txHash)">{{ t('chain.copy') }}</button>
|
||||
</div>
|
||||
<div v-if="data.blockchain.dataHash" class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.dataHash') }}</span>
|
||||
<span class="chain-v mono">{{ ellipsis(data.blockchain.dataHash) }}</span>
|
||||
<button class="copy" @click="copy(data.blockchain.dataHash)">{{ t('chain.copy') }}</button>
|
||||
</div>
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.blockHeight') }}</span>
|
||||
<span class="chain-v">{{ data.blockchain.blockHeight ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="chain-row">
|
||||
<span class="chain-k">{{ t('chain.onchainAt') }}</span>
|
||||
<span class="chain-v">{{ fmt(data.blockchain.onchainAt) }}</span>
|
||||
</div>
|
||||
<a v-if="data.blockchain.explorerUrl" class="chain-link" :href="data.blockchain.explorerUrl" target="_blank">
|
||||
{{ t('chain.explorer') }} →
|
||||
</a>
|
||||
</template>
|
||||
<div v-else class="chain-empty muted">{{ t('chain.notOnchain') }}</div>
|
||||
</section>
|
||||
|
||||
<!-- 隐私说明 -->
|
||||
<p class="privacy muted">{{ t('privacy.note') }}</p>
|
||||
|
||||
<footer class="footer muted">{{ appName }}</footer>
|
||||
</template>
|
||||
|
||||
@@ -190,6 +223,11 @@ function ellipsis(s?: string) {
|
||||
function isVideo(m: { type?: string; url?: string }) {
|
||||
return m.type === 'video' || /\.(mp4|webm|mov|m4v|ogg)$/i.test(m.url || '');
|
||||
}
|
||||
// 仅允许 http(s) 或站内相对路径作为外链,过滤 javascript:/data: 等危险协议
|
||||
function safeUrl(v?: string): string {
|
||||
if (!v) return '';
|
||||
return /^(https?:\/\/|\/)/i.test(v) ? v : '';
|
||||
}
|
||||
function openViewer(items: any[], index: number) {
|
||||
viewerItems.value = items || [];
|
||||
viewerStart.value = index;
|
||||
@@ -340,6 +378,12 @@ watch(
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.anti-code {
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
margin-top: 2px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.carousel {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
@@ -403,6 +447,18 @@ watch(
|
||||
flex: 1;
|
||||
color: var(--text);
|
||||
}
|
||||
.field-img {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
background: #e7ecf3;
|
||||
}
|
||||
.field-link {
|
||||
color: var(--brand-2);
|
||||
word-break: break-all;
|
||||
}
|
||||
.timeline {
|
||||
position: relative;
|
||||
}
|
||||
@@ -472,10 +528,24 @@ watch(
|
||||
border-radius: 10px;
|
||||
background: #e7ecf3;
|
||||
}
|
||||
.cert-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.cert-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin-top: 6px;
|
||||
flex: 1;
|
||||
}
|
||||
.cert-type {
|
||||
font-size: 11px;
|
||||
color: var(--brand-2);
|
||||
background: rgba(19, 138, 114, 0.12);
|
||||
border-radius: 4px;
|
||||
padding: 1px 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.cert-issuer {
|
||||
font-size: 12px;
|
||||
@@ -515,6 +585,16 @@ watch(
|
||||
font-size: 14px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.chain-empty {
|
||||
font-size: 13px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.privacy {
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
padding: 0 16px;
|
||||
margin: 16px 0 0;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
|
||||
Reference in New Issue
Block a user