feat: 实现后台管理前端全部页面与登录布局
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,4 +57,6 @@
|
|||||||
- 阶段 5(生码与公开溯源)已完成:批量生码(GEN_CODE 队列异步,nanoid 短码 10 位/追溯码 18 位,url=`BASE_URL/t/{shortCode}`,分块 createMany,回写 batch/job 进度);批次/追溯码列表、二维码 PNG(qrcode)、Excel 导出(exceljs 含二维码 DataURL)、绑定/解绑作品(UNBOUND→INACTIVE);public-trace 公开匿名:短码经 Redis 映射缓存解析→校验→未激活则激活计数=1+首次激活时间、已激活则原子 increment→聚合作品(动态字段映射label)/时间轴/证书(仅水印图)/链上凭证→写查询日志(IP/地区/设备/结果);`/t/:shortCode` 302 跳转 C 端。已验证生码→绑定→首扫激活→复扫+1→无效码 INVALID。
|
- 阶段 5(生码与公开溯源)已完成:批量生码(GEN_CODE 队列异步,nanoid 短码 10 位/追溯码 18 位,url=`BASE_URL/t/{shortCode}`,分块 createMany,回写 batch/job 进度);批次/追溯码列表、二维码 PNG(qrcode)、Excel 导出(exceljs 含二维码 DataURL)、绑定/解绑作品(UNBOUND→INACTIVE);public-trace 公开匿名:短码经 Redis 映射缓存解析→校验→未激活则激活计数=1+首次激活时间、已激活则原子 increment→聚合作品(动态字段映射label)/时间轴/证书(仅水印图)/链上凭证→写查询日志(IP/地区/设备/结果);`/t/:shortCode` 302 跳转 C 端。已验证生码→绑定→首扫激活→复扫+1→无效码 INVALID。
|
||||||
- 阶段 6(出库/上链/日志/看板/设置)已完成:出库单条录入 + 批量导入(IMPORT_OUTBOUND 队列异步,按 OUTBOUND_IMPORT_COLUMNS 解析、逐行校验、生成成功/失败明细 xlsx 至存储并回写 job.resultFileUrl)+ 导入模板下载(含字段说明);区块链存证触发 `POST /trace-codes/:id/onchain`(建 PENDING 证据 + ONCHAIN 队列 Mock 上链回写 txHash/blockHash/blockHeight/explorerUrl)+ 重试;查询日志检索(短码/结果/时间);数据看板总览(计数+近7天趋势+高频榜);系统设置(appName/logRetentionDays/watermarkText,超管可改,app-info/settings/public 公开读)。已端到端验证看板/上链/日志/模板/导入(PARTIAL 成功失败明细)。后端功能已全部完成。
|
- 阶段 6(出库/上链/日志/看板/设置)已完成:出库单条录入 + 批量导入(IMPORT_OUTBOUND 队列异步,按 OUTBOUND_IMPORT_COLUMNS 解析、逐行校验、生成成功/失败明细 xlsx 至存储并回写 job.resultFileUrl)+ 导入模板下载(含字段说明);区块链存证触发 `POST /trace-codes/:id/onchain`(建 PENDING 证据 + ONCHAIN 队列 Mock 上链回写 txHash/blockHash/blockHeight/explorerUrl)+ 重试;查询日志检索(短码/结果/时间);数据看板总览(计数+近7天趋势+高频榜);系统设置(appName/logRetentionDays/watermarkText,超管可改,app-info/settings/public 公开读)。已端到端验证看板/上链/日志/模板/导入(PARTIAL 成功失败明细)。后端功能已全部完成。
|
||||||
- 阶段 7(种子+测试)已完成:seed 创建 4 个角色账号(admin/Admin@12345、operator/Operator@123、auditor/Auditor@123、viewer/Viewer@123)、系统设置、1 模板、3 件示例作品(sharp 生成占位图写入 storage/seed、动态字段、4 节点、带水印证书、追溯码,其中 2 件已激活并含查询日志与 Mock 存证);`db:reset` 一键重置+种子。单元测试 9 个通过(hashData 确定性/mock attest、水印输出 JPEG、UA/IP 解析)。已验证看板与公开溯源完整渲染、图片与水印可访问。
|
- 阶段 7(种子+测试)已完成:seed 创建 4 个角色账号(admin/Admin@12345、operator/Operator@123、auditor/Auditor@123、viewer/Viewer@123)、系统设置、1 模板、3 件示例作品(sharp 生成占位图写入 storage/seed、动态字段、4 节点、带水印证书、追溯码,其中 2 件已激活并含查询日志与 Mock 存证);`db:reset` 一键重置+种子。单元测试 9 个通过(hashData 确定性/mock attest、水印输出 JPEG、UA/IP 解析)。已验证看板与公开溯源完整渲染、图片与水印可访问。
|
||||||
|
- 阶段 8-10(后台前端)已完成:`apps/admin`(Vue3 + Vite + Naive UI + Pinia + vue-router hash + axios 封装 + vue-i18n 中英 + ECharts)。商务深蓝主题与设计令牌;登录页、自适应布局(侧栏折叠 + 顶栏语言切换/用户菜单);看板(6 指标卡 + 趋势折线 + 高频榜)、模板管理(动态字段编辑)、艺术品建档(动态表单/多图/时间轴节点/证书/追溯码绑定/上链)、追溯码(生成轮询/筛选/二维码预览/导出)、出库导入(下载模板+上传+进度+结果明细)、查询日志(筛选)、用户管理(CRUD/重置密码)、系统设置、个人改密。
|
||||||
|
- 前端约定:`@artveris/shared` 在 Vite 用 alias 指向 src(避免 rollup 读 CJS 命名导出失败);媒体上传走 `MediaUpload` 组件→/upload 返回 key,提交时存 key;二维码接口设为 @Public 供 img 直接加载;文件下载用 axios blob + saveBlob。`vite dev` 代理 `/api` 到 3000,端口 5173。
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>艺术品可信溯源与认证平台</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "@artveris/admin",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"lint": "echo \"(admin) lint skipped\""
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@artveris/shared": "workspace:*",
|
||||||
|
"@vicons/ionicons5": "^0.13.0",
|
||||||
|
"axios": "^1.7.9",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
|
"echarts": "^5.5.1",
|
||||||
|
"naive-ui": "^2.40.3",
|
||||||
|
"pinia": "^2.3.0",
|
||||||
|
"vue": "^3.5.13",
|
||||||
|
"vue-echarts": "^7.0.3",
|
||||||
|
"vue-i18n": "^9.14.2",
|
||||||
|
"vue-router": "^4.5.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
|
"typescript": "^5.6.3",
|
||||||
|
"vite": "^5.4.11"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<n-config-provider :theme-overrides="themeOverrides" :locale="naiveLocale" :date-locale="naiveDateLocale">
|
||||||
|
<router-view />
|
||||||
|
</n-config-provider>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { zhCN, dateZhCN, enUS, dateEnUS } from 'naive-ui';
|
||||||
|
import { themeOverrides } from '@/theme';
|
||||||
|
|
||||||
|
const { locale } = useI18n();
|
||||||
|
const naiveLocale = computed(() => (locale.value === 'en-US' ? enUS : zhCN));
|
||||||
|
const naiveDateLocale = computed(() => (locale.value === 'en-US' ? dateEnUS : dateZhCN));
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { get, post, put, del, download } from './request';
|
||||||
|
import type { PageResult } from '@artveris/shared';
|
||||||
|
|
||||||
|
export interface LoginResult {
|
||||||
|
token: string;
|
||||||
|
user: { id: number; username: string; realName?: string; role: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const authApi = {
|
||||||
|
login: (data: { username: string; password: string }) => post<LoginResult>('/auth/login', data),
|
||||||
|
profile: () => get('/auth/profile'),
|
||||||
|
changePassword: (data: { oldPassword: string; newPassword: string }) =>
|
||||||
|
post('/auth/change-password', data),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const dashboardApi = {
|
||||||
|
overview: () => get('/dashboard/overview'),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const templateApi = {
|
||||||
|
list: (params: object) => get<PageResult<any>>('/templates', params),
|
||||||
|
options: () => get<any[]>('/templates/options'),
|
||||||
|
get: (id: number) => get(`/templates/${id}`),
|
||||||
|
create: (data: object) => post('/templates', data),
|
||||||
|
update: (id: number, data: object) => put(`/templates/${id}`, data),
|
||||||
|
remove: (id: number) => del(`/templates/${id}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const artworkApi = {
|
||||||
|
list: (params: object) => get<PageResult<any>>('/artworks', params),
|
||||||
|
get: (id: number) => get(`/artworks/${id}`),
|
||||||
|
create: (data: object) => post('/artworks', data),
|
||||||
|
update: (id: number, data: object) => put(`/artworks/${id}`, data),
|
||||||
|
remove: (id: number) => del(`/artworks/${id}`),
|
||||||
|
// nodes
|
||||||
|
listNodes: (artworkId: number) => get<any[]>(`/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<any[]>(`/artworks/${artworkId}/certificates`),
|
||||||
|
createCert: (artworkId: number, data: object) => post(`/artworks/${artworkId}/certificates`, data),
|
||||||
|
removeCert: (id: number) => del(`/certificates/${id}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const traceCodeApi = {
|
||||||
|
generate: (data: { quantity: number; batchNo?: string }) => post('/trace-codes/batch', data),
|
||||||
|
batches: (params: object) => get<PageResult<any>>('/batches', params),
|
||||||
|
list: (params: object) => get<PageResult<any>>('/trace-codes', params),
|
||||||
|
bind: (id: string, artworkId: number) => put(`/trace-codes/${id}/bind`, { artworkId }),
|
||||||
|
unbind: (id: string) => put(`/trace-codes/${id}/unbind`, {}),
|
||||||
|
qrUrl: (id: string) => `/api/trace-codes/${id}/qrcode`,
|
||||||
|
onchain: (id: string) => post(`/trace-codes/${id}/onchain`, {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const outboundApi = {
|
||||||
|
updateSingle: (id: string, data: object) => put(`/outbound/trace-codes/${id}`, data),
|
||||||
|
templateUrl: '/api/outbound/import/template',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const jobApi = {
|
||||||
|
get: (id: string) => get(`/jobs/${id}`),
|
||||||
|
list: (params: object) => get<PageResult<any>>('/jobs', params),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const queryLogApi = {
|
||||||
|
list: (params: object) => get<PageResult<any>>('/query-logs', params),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const userApi = {
|
||||||
|
list: (params: object) => get<PageResult<any>>('/users', params),
|
||||||
|
create: (data: object) => post('/users', data),
|
||||||
|
update: (id: number, data: object) => put(`/users/${id}`, data),
|
||||||
|
resetPassword: (id: number, newPassword: string) => put(`/users/${id}/password`, { newPassword }),
|
||||||
|
remove: (id: number) => del(`/users/${id}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const settingsApi = {
|
||||||
|
getAll: () => get<Record<string, string>>('/settings'),
|
||||||
|
update: (data: object) => put('/settings', data),
|
||||||
|
};
|
||||||
|
|
||||||
|
export { download, get, post, put, del };
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
import { i18n } from '@/locales';
|
||||||
|
|
||||||
|
const TOKEN_KEY = 'artveris_token';
|
||||||
|
|
||||||
|
export function getToken(): string | null {
|
||||||
|
return localStorage.getItem(TOKEN_KEY);
|
||||||
|
}
|
||||||
|
export function setToken(token: string): void {
|
||||||
|
localStorage.setItem(TOKEN_KEY, token);
|
||||||
|
}
|
||||||
|
export function clearToken(): void {
|
||||||
|
localStorage.removeItem(TOKEN_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
const instance: AxiosInstance = axios.create({
|
||||||
|
baseURL: '/api',
|
||||||
|
timeout: 30000,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.interceptors.request.use((config) => {
|
||||||
|
const token = getToken();
|
||||||
|
if (token) {
|
||||||
|
config.headers = config.headers ?? {};
|
||||||
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.interceptors.response.use(
|
||||||
|
(response) => {
|
||||||
|
// blob(下载)直接返回
|
||||||
|
if (response.config.responseType === 'blob') {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
const body = response.data;
|
||||||
|
if (body && typeof body === 'object' && 'code' in body) {
|
||||||
|
if (body.code === 0) {
|
||||||
|
return body.data;
|
||||||
|
}
|
||||||
|
message.error(body.message || i18n.global.t('common.msg.networkError'));
|
||||||
|
return Promise.reject(body);
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
const status = error?.response?.status;
|
||||||
|
const body = error?.response?.data;
|
||||||
|
if (status === 401) {
|
||||||
|
clearToken();
|
||||||
|
message.error(body?.message || i18n.global.t('common.msg.loginExpired'));
|
||||||
|
if (location.hash.indexOf('/login') === -1) {
|
||||||
|
location.hash = '#/login';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message.error(body?.message || i18n.global.t('common.msg.networkError'));
|
||||||
|
}
|
||||||
|
return Promise.reject(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export function get<T = unknown>(url: string, params?: object): Promise<T> {
|
||||||
|
return instance.get(url, { params }) as unknown as Promise<T>;
|
||||||
|
}
|
||||||
|
export function post<T = unknown>(url: string, data?: object, config?: AxiosRequestConfig): Promise<T> {
|
||||||
|
return instance.post(url, data, config) as unknown as Promise<T>;
|
||||||
|
}
|
||||||
|
export function put<T = unknown>(url: string, data?: object): Promise<T> {
|
||||||
|
return instance.put(url, data) as unknown as Promise<T>;
|
||||||
|
}
|
||||||
|
export function del<T = unknown>(url: string): Promise<T> {
|
||||||
|
return instance.delete(url) as unknown as Promise<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function download(url: string, params?: object): Promise<{ data: Blob; headers: Record<string, string> }> {
|
||||||
|
return instance.get(url, { params, responseType: 'blob' }) as unknown as Promise<{
|
||||||
|
data: Blob;
|
||||||
|
headers: Record<string, string>;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default instance;
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<template>
|
||||||
|
<n-upload
|
||||||
|
:list-type="listType"
|
||||||
|
:file-list="fileList"
|
||||||
|
:max="max"
|
||||||
|
:accept="accept"
|
||||||
|
:custom-request="doUpload"
|
||||||
|
@remove="onRemove"
|
||||||
|
>
|
||||||
|
<template v-if="listType === 'image-card'">
|
||||||
|
<div class="upd-trigger">
|
||||||
|
<n-icon :component="AddOutline" :size="22" />
|
||||||
|
<span>{{ t('common.action.upload') }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<n-button v-else>
|
||||||
|
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||||
|
{{ t('common.action.upload') }}
|
||||||
|
</n-button>
|
||||||
|
</n-upload>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import type { UploadCustomRequestOptions, UploadFileInfo } from 'naive-ui';
|
||||||
|
import { AddOutline, CloudUploadOutline } from '@vicons/ionicons5';
|
||||||
|
import { post } from '@/api/request';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
|
||||||
|
interface MediaItem {
|
||||||
|
key: string;
|
||||||
|
url?: string;
|
||||||
|
name?: string;
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{ modelValue: MediaItem[]; type?: 'image' | 'video' | 'file'; max?: number }>(),
|
||||||
|
{ type: 'image', max: 8 },
|
||||||
|
);
|
||||||
|
const emit = defineEmits<{ (e: 'update:modelValue', v: MediaItem[]): void }>();
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const listType = computed(() => (props.type === 'image' ? 'image-card' : 'text'));
|
||||||
|
const accept = computed(() =>
|
||||||
|
props.type === 'image' ? 'image/*' : props.type === 'video' ? 'video/*' : 'application/pdf,image/*',
|
||||||
|
);
|
||||||
|
|
||||||
|
const fileList = computed<UploadFileInfo[]>(() =>
|
||||||
|
(props.modelValue || []).map((m) => ({
|
||||||
|
id: m.key,
|
||||||
|
name: m.name || m.key,
|
||||||
|
status: 'finished',
|
||||||
|
url: m.url,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
async function doUpload({ file, onFinish, onError }: UploadCustomRequestOptions) {
|
||||||
|
try {
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('file', file.file as File);
|
||||||
|
const res: any = await post(`/upload?type=${props.type}`, fd, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
});
|
||||||
|
emit('update:modelValue', [
|
||||||
|
...(props.modelValue || []),
|
||||||
|
{ key: res.key, url: res.url, name: res.name, type: props.type },
|
||||||
|
]);
|
||||||
|
onFinish();
|
||||||
|
} catch (e) {
|
||||||
|
message.error((e as Error)?.message || 'upload failed');
|
||||||
|
onError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRemove({ file }: { file: UploadFileInfo }) {
|
||||||
|
emit('update:modelValue', (props.modelValue || []).filter((m) => m.key !== file.id));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.upd-trigger {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare module '*.vue' {
|
||||||
|
import type { DefineComponent } from 'vue';
|
||||||
|
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
|
||||||
|
export default component;
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
<template>
|
||||||
|
<n-layout has-sider position="absolute">
|
||||||
|
<n-layout-sider
|
||||||
|
bordered
|
||||||
|
:collapsed="collapsed"
|
||||||
|
collapse-mode="width"
|
||||||
|
:collapsed-width="64"
|
||||||
|
:width="224"
|
||||||
|
:native-scrollbar="false"
|
||||||
|
:inverted="true"
|
||||||
|
show-trigger="bar"
|
||||||
|
@collapse="collapsed = true"
|
||||||
|
@expand="collapsed = false"
|
||||||
|
>
|
||||||
|
<div class="brand">
|
||||||
|
<span class="brand-logo">艺</span>
|
||||||
|
<span v-show="!collapsed" class="brand-name text-ellipsis">{{ appName }}</span>
|
||||||
|
</div>
|
||||||
|
<n-menu
|
||||||
|
:inverted="true"
|
||||||
|
:collapsed="collapsed"
|
||||||
|
:collapsed-width="64"
|
||||||
|
:value="activeKey"
|
||||||
|
:options="menuOptions"
|
||||||
|
@update:value="onMenu"
|
||||||
|
/>
|
||||||
|
</n-layout-sider>
|
||||||
|
|
||||||
|
<n-layout>
|
||||||
|
<n-layout-header bordered class="header">
|
||||||
|
<n-button quaternary circle @click="collapsed = !collapsed">
|
||||||
|
<template #icon><n-icon :component="MenuOutline" /></template>
|
||||||
|
</n-button>
|
||||||
|
<div class="header-title text-ellipsis">{{ currentTitle }}</div>
|
||||||
|
<div class="spacer" />
|
||||||
|
<n-select
|
||||||
|
v-model:value="currentLocale"
|
||||||
|
:options="localeOptions"
|
||||||
|
size="small"
|
||||||
|
style="width: 110px"
|
||||||
|
@update:value="changeLocale"
|
||||||
|
/>
|
||||||
|
<n-dropdown :options="userOptions" @select="onUser">
|
||||||
|
<n-button quaternary>
|
||||||
|
<template #icon><n-icon :component="PersonCircleOutline" /></template>
|
||||||
|
{{ auth.user?.realName || auth.user?.username }}
|
||||||
|
</n-button>
|
||||||
|
</n-dropdown>
|
||||||
|
</n-layout-header>
|
||||||
|
|
||||||
|
<n-layout-content class="content" :native-scrollbar="false">
|
||||||
|
<router-view v-slot="{ Component }">
|
||||||
|
<transition name="fade" mode="out-in">
|
||||||
|
<component :is="Component" />
|
||||||
|
</transition>
|
||||||
|
</router-view>
|
||||||
|
</n-layout-content>
|
||||||
|
</n-layout>
|
||||||
|
</n-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, h, onMounted, onUnmounted, ref } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { NIcon } from 'naive-ui';
|
||||||
|
import type { MenuOption } from 'naive-ui';
|
||||||
|
import {
|
||||||
|
GridOutline,
|
||||||
|
DocumentTextOutline,
|
||||||
|
ImagesOutline,
|
||||||
|
QrCodeOutline,
|
||||||
|
CubeOutline,
|
||||||
|
ListOutline,
|
||||||
|
PeopleOutline,
|
||||||
|
SettingsOutline,
|
||||||
|
MenuOutline,
|
||||||
|
PersonCircleOutline,
|
||||||
|
LogOutOutline,
|
||||||
|
KeyOutline,
|
||||||
|
} from '@vicons/ionicons5';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { settingsApi } from '@/api';
|
||||||
|
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
|
||||||
|
import { dialog } from '@/utils/feedback';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
const { t, locale } = useI18n();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const collapsed = ref(window.innerWidth < 900);
|
||||||
|
const appName = ref(t('pages.login.title'));
|
||||||
|
const currentLocale = ref(locale.value);
|
||||||
|
|
||||||
|
const localeOptions = SUPPORTED_LOCALES.map((l) => ({ label: l.label, value: l.value }));
|
||||||
|
|
||||||
|
function renderIcon(icon: unknown) {
|
||||||
|
return () => h(NIcon, null, { default: () => h(icon as never) });
|
||||||
|
}
|
||||||
|
|
||||||
|
const menuOptions = computed<MenuOption[]>(() => {
|
||||||
|
const items: Array<MenuOption & { superOnly?: 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.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);
|
||||||
|
});
|
||||||
|
|
||||||
|
const activeKey = computed(() => {
|
||||||
|
if (route.name === 'artwork-detail') return 'artworks';
|
||||||
|
return route.name as string;
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentTitle = computed(() => {
|
||||||
|
const key = activeKey.value;
|
||||||
|
return key ? t(`menu.${key}`) : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
const userOptions = computed(() => [
|
||||||
|
{ label: t('menu.profile'), key: 'profile', icon: renderIcon(KeyOutline) },
|
||||||
|
{ label: t('common.action.logout'), key: 'logout', icon: renderIcon(LogOutOutline) },
|
||||||
|
]);
|
||||||
|
|
||||||
|
function onMenu(key: string) {
|
||||||
|
router.push({ name: key });
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeLocale(val: string) {
|
||||||
|
setLocale(val);
|
||||||
|
currentLocale.value = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUser(key: string) {
|
||||||
|
if (key === 'profile') {
|
||||||
|
router.push({ name: 'profile' });
|
||||||
|
} else if (key === 'logout') {
|
||||||
|
dialog.warning({
|
||||||
|
title: t('common.action.logout'),
|
||||||
|
content: '确定退出登录?',
|
||||||
|
positiveText: t('common.action.confirm'),
|
||||||
|
negativeText: t('common.action.cancel'),
|
||||||
|
onPositiveClick: () => {
|
||||||
|
auth.logout();
|
||||||
|
router.push({ name: 'login' });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let resizeHandler: () => void;
|
||||||
|
onMounted(async () => {
|
||||||
|
resizeHandler = () => {
|
||||||
|
collapsed.value = window.innerWidth < 900;
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', resizeHandler);
|
||||||
|
try {
|
||||||
|
const s = await settingsApi.getAll();
|
||||||
|
if (s.appName) appName.value = s.appName;
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onUnmounted(() => window.removeEventListener('resize', resizeHandler));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.brand {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
height: 56px;
|
||||||
|
padding: 0 16px;
|
||||||
|
color: #fff;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
.brand-logo {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #2e5496;
|
||||||
|
font-weight: 700;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.brand-name {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
height: 56px;
|
||||||
|
padding: 0 16px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.header-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
max-width: 40vw;
|
||||||
|
}
|
||||||
|
.spacer {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
height: calc(100vh - 56px);
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
.fade-enter-active,
|
||||||
|
.fade-leave-active {
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
.fade-enter-from,
|
||||||
|
.fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"add": "Add",
|
||||||
|
"edit": "Edit",
|
||||||
|
"delete": "Delete",
|
||||||
|
"save": "Save",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"confirm": "OK",
|
||||||
|
"search": "Search",
|
||||||
|
"reset": "Reset",
|
||||||
|
"export": "Export",
|
||||||
|
"download": "Download",
|
||||||
|
"downloadTemplate": "Template",
|
||||||
|
"upload": "Upload",
|
||||||
|
"view": "View",
|
||||||
|
"detail": "Detail",
|
||||||
|
"back": "Back",
|
||||||
|
"submit": "Submit",
|
||||||
|
"refresh": "Refresh",
|
||||||
|
"generate": "Generate",
|
||||||
|
"bind": "Bind",
|
||||||
|
"unbind": "Unbind",
|
||||||
|
"retry": "Retry",
|
||||||
|
"copy": "Copy",
|
||||||
|
"onchain": "On-chain",
|
||||||
|
"qrcode": "QR Code",
|
||||||
|
"changePassword": "Change Password",
|
||||||
|
"logout": "Logout"
|
||||||
|
},
|
||||||
|
"label": {
|
||||||
|
"keyword": "Keyword",
|
||||||
|
"status": "Status",
|
||||||
|
"type": "Type",
|
||||||
|
"createdAt": "Created",
|
||||||
|
"updatedAt": "Updated",
|
||||||
|
"operation": "Actions",
|
||||||
|
"all": "All",
|
||||||
|
"remark": "Remark",
|
||||||
|
"total": "{n} items",
|
||||||
|
"yes": "Yes",
|
||||||
|
"no": "No"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"ENABLED": "Enabled",
|
||||||
|
"DISABLED": "Disabled",
|
||||||
|
"DRAFT": "Draft",
|
||||||
|
"ACTIVE": "Activated",
|
||||||
|
"ABNORMAL": "Abnormal",
|
||||||
|
"UNBOUND": "Unbound",
|
||||||
|
"INACTIVE": "Inactive",
|
||||||
|
"PENDING": "Pending",
|
||||||
|
"PROCESSING": "Processing",
|
||||||
|
"SUCCESS": "Success",
|
||||||
|
"PARTIAL": "Partial",
|
||||||
|
"FAILED": "Failed",
|
||||||
|
"ONCHAIN": "On-chain",
|
||||||
|
"GENERATING": "Generating",
|
||||||
|
"DONE": "Done"
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"SUPER_ADMIN": "Super Admin",
|
||||||
|
"OPERATOR": "Operator",
|
||||||
|
"AUDITOR": "Auditor",
|
||||||
|
"VIEWER": "Viewer"
|
||||||
|
},
|
||||||
|
"queryResult": {
|
||||||
|
"FIRST_ACTIVATE": "First Activation",
|
||||||
|
"REPEAT": "Repeat",
|
||||||
|
"INVALID": "Invalid",
|
||||||
|
"DISABLED": "Disabled",
|
||||||
|
"ABNORMAL": "Abnormal"
|
||||||
|
},
|
||||||
|
"fieldType": {
|
||||||
|
"TEXT": "Text",
|
||||||
|
"NUMBER": "Number",
|
||||||
|
"DATE": "Date",
|
||||||
|
"IMAGE": "Image",
|
||||||
|
"FILE": "File",
|
||||||
|
"LINK": "Link",
|
||||||
|
"TEXTAREA": "Textarea"
|
||||||
|
},
|
||||||
|
"nodeType": {
|
||||||
|
"CREATE": "Creation",
|
||||||
|
"PRODUCE": "Production",
|
||||||
|
"STORAGE": "Storage",
|
||||||
|
"OUTBOUND": "Outbound",
|
||||||
|
"OTHER": "Other"
|
||||||
|
},
|
||||||
|
"msg": {
|
||||||
|
"confirmDelete": "Delete this record?",
|
||||||
|
"deleted": "Deleted",
|
||||||
|
"saved": "Saved",
|
||||||
|
"created": "Created",
|
||||||
|
"updated": "Updated",
|
||||||
|
"copied": "Copied",
|
||||||
|
"operationSuccess": "Success",
|
||||||
|
"loginExpired": "Session expired, please log in again",
|
||||||
|
"networkError": "Network error, please try again",
|
||||||
|
"noData": "No data"
|
||||||
|
},
|
||||||
|
"lang": {
|
||||||
|
"zh": "中文",
|
||||||
|
"en": "English"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"dashboard": "Dashboard",
|
||||||
|
"templates": "Templates",
|
||||||
|
"artworks": "Artworks",
|
||||||
|
"traceCodes": "Trace Codes",
|
||||||
|
"outbound": "Outbound & Chain",
|
||||||
|
"queryLogs": "Query Logs",
|
||||||
|
"users": "Users",
|
||||||
|
"settings": "Settings",
|
||||||
|
"profile": "Profile"
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"login": {
|
||||||
|
"title": "Artwork Traceability & Authentication",
|
||||||
|
"subtitle": "Management Console",
|
||||||
|
"username": "Username",
|
||||||
|
"password": "Password",
|
||||||
|
"submit": "Sign In",
|
||||||
|
"placeholderUser": "Enter username",
|
||||||
|
"placeholderPass": "Enter password",
|
||||||
|
"success": "Signed in"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"totalArtworks": "Artworks",
|
||||||
|
"boundCodes": "Bound Codes",
|
||||||
|
"activatedCodes": "Activated Codes",
|
||||||
|
"totalQueries": "Total Queries",
|
||||||
|
"todayQueries": "Today",
|
||||||
|
"abnormalQueries": "Abnormal",
|
||||||
|
"trendTitle": "Queries (Last 7 Days)",
|
||||||
|
"topTitle": "Top Queried Artworks",
|
||||||
|
"queryCount": "Queries",
|
||||||
|
"rank": "Rank"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"name": "Template Name",
|
||||||
|
"fields": "Fields",
|
||||||
|
"fieldKey": "Field Key",
|
||||||
|
"fieldLabel": "Label",
|
||||||
|
"fieldType": "Type",
|
||||||
|
"required": "Required",
|
||||||
|
"sortOrder": "Order",
|
||||||
|
"addField": "Add Field",
|
||||||
|
"useCount": "Used By",
|
||||||
|
"create": "New Template",
|
||||||
|
"edit": "Edit Template",
|
||||||
|
"namePlaceholder": "Enter template name",
|
||||||
|
"fieldKeyTip": "Unique key, e.g. craft"
|
||||||
|
},
|
||||||
|
"artwork": {
|
||||||
|
"title": "Title",
|
||||||
|
"artist": "Artist",
|
||||||
|
"template": "Template",
|
||||||
|
"images": "Images",
|
||||||
|
"basicInfo": "Basic Info",
|
||||||
|
"dynamicFields": "Fields",
|
||||||
|
"nodes": "Timeline",
|
||||||
|
"certificates": "Certificates",
|
||||||
|
"traceCode": "Trace Code",
|
||||||
|
"status": "Status",
|
||||||
|
"create": "New Artwork",
|
||||||
|
"edit": "Edit Artwork",
|
||||||
|
"detail": "Artwork Detail",
|
||||||
|
"addNode": "Add Node",
|
||||||
|
"nodeTitle": "Node Title",
|
||||||
|
"nodeLocation": "Location",
|
||||||
|
"nodeTime": "Time",
|
||||||
|
"nodeDesc": "Description",
|
||||||
|
"addCert": "Add Certificate",
|
||||||
|
"certName": "Certificate Name",
|
||||||
|
"certIssuer": "Issuer",
|
||||||
|
"certType": "Type",
|
||||||
|
"originFile": "Original File",
|
||||||
|
"watermarkPreview": "Watermark",
|
||||||
|
"watermarkPending": "Generating watermark…",
|
||||||
|
"bindCode": "Bind Trace Code",
|
||||||
|
"noTrace": "No trace code bound"
|
||||||
|
},
|
||||||
|
"traceCode": {
|
||||||
|
"batches": "Batches",
|
||||||
|
"codes": "Trace Codes",
|
||||||
|
"batchNo": "Batch No.",
|
||||||
|
"quantity": "Quantity",
|
||||||
|
"generate": "Generate",
|
||||||
|
"generatedCount": "Generated",
|
||||||
|
"shortCode": "Short Code",
|
||||||
|
"code": "Trace Code",
|
||||||
|
"url": "Short URL",
|
||||||
|
"queryCount": "Queries",
|
||||||
|
"firstActivatedAt": "First Activated",
|
||||||
|
"exportBatch": "Export Batch",
|
||||||
|
"bindArtwork": "Bind Artwork",
|
||||||
|
"selectArtwork": "Select artwork",
|
||||||
|
"qrPreview": "QR Preview",
|
||||||
|
"generating": "Generating, please wait…",
|
||||||
|
"genSuccess": "Generation task submitted"
|
||||||
|
},
|
||||||
|
"outbound": {
|
||||||
|
"single": "Single Entry",
|
||||||
|
"import": "Batch Import",
|
||||||
|
"sku": "SKU",
|
||||||
|
"archiveNo": "Archive No.",
|
||||||
|
"outTime": "Outbound Time",
|
||||||
|
"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)"
|
||||||
|
},
|
||||||
|
"blockchain": {
|
||||||
|
"title": "Blockchain Attestation",
|
||||||
|
"dataHash": "Data Hash",
|
||||||
|
"txHash": "Tx Hash",
|
||||||
|
"blockHeight": "Block Height",
|
||||||
|
"onchainAt": "On-chain Time",
|
||||||
|
"explorer": "Explorer",
|
||||||
|
"trigger": "Trigger On-chain",
|
||||||
|
"triggered": "On-chain task submitted"
|
||||||
|
},
|
||||||
|
"queryLog": {
|
||||||
|
"result": "Result",
|
||||||
|
"ip": "IP / Region",
|
||||||
|
"device": "Device",
|
||||||
|
"queriedAt": "Time",
|
||||||
|
"startTime": "Start",
|
||||||
|
"endTime": "End"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"username": "Username",
|
||||||
|
"realName": "Name",
|
||||||
|
"role": "Role",
|
||||||
|
"create": "New User",
|
||||||
|
"edit": "Edit User",
|
||||||
|
"resetPassword": "Reset Password",
|
||||||
|
"newPassword": "New Password",
|
||||||
|
"lastLoginAt": "Last Login"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"appName": "Platform Name",
|
||||||
|
"logRetentionDays": "Log Retention (days)",
|
||||||
|
"watermarkText": "Certificate Watermark",
|
||||||
|
"saved": "Settings saved"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "Profile",
|
||||||
|
"oldPassword": "Current Password",
|
||||||
|
"newPassword": "New Password",
|
||||||
|
"confirmPassword": "Confirm Password",
|
||||||
|
"passwordMismatch": "Passwords do not match",
|
||||||
|
"changed": "Password changed, please log in again"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { createI18n } from 'vue-i18n';
|
||||||
|
import zhCommon from './zh-CN/common.json';
|
||||||
|
import zhMenu from './zh-CN/menu.json';
|
||||||
|
import zhPages from './zh-CN/pages.json';
|
||||||
|
import enCommon from './en-US/common.json';
|
||||||
|
import enMenu from './en-US/menu.json';
|
||||||
|
import enPages from './en-US/pages.json';
|
||||||
|
|
||||||
|
export const SUPPORTED_LOCALES = [
|
||||||
|
{ value: 'zh-CN', label: '中文' },
|
||||||
|
{ value: 'en-US', label: 'English' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'artveris_locale';
|
||||||
|
|
||||||
|
export function getInitialLocale(): string {
|
||||||
|
const saved = localStorage.getItem(STORAGE_KEY);
|
||||||
|
if (saved && SUPPORTED_LOCALES.some((l) => l.value === saved)) return saved;
|
||||||
|
return navigator.language.startsWith('en') ? 'en-US' : 'zh-CN';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setLocale(locale: string): void {
|
||||||
|
localStorage.setItem(STORAGE_KEY, locale);
|
||||||
|
i18n.global.locale.value = locale as 'zh-CN' | 'en-US';
|
||||||
|
document.querySelector('html')?.setAttribute('lang', locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const i18n = createI18n({
|
||||||
|
legacy: false,
|
||||||
|
locale: getInitialLocale(),
|
||||||
|
fallbackLocale: 'zh-CN',
|
||||||
|
messages: {
|
||||||
|
'zh-CN': { common: zhCommon, menu: zhMenu, pages: zhPages },
|
||||||
|
'en-US': { common: enCommon, menu: enMenu, pages: enPages },
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"add": "新增",
|
||||||
|
"edit": "编辑",
|
||||||
|
"delete": "删除",
|
||||||
|
"save": "保存",
|
||||||
|
"cancel": "取消",
|
||||||
|
"confirm": "确定",
|
||||||
|
"search": "查询",
|
||||||
|
"reset": "重置",
|
||||||
|
"export": "导出",
|
||||||
|
"download": "下载",
|
||||||
|
"downloadTemplate": "下载模板",
|
||||||
|
"upload": "上传",
|
||||||
|
"view": "查看",
|
||||||
|
"detail": "详情",
|
||||||
|
"back": "返回",
|
||||||
|
"submit": "提交",
|
||||||
|
"refresh": "刷新",
|
||||||
|
"generate": "生成",
|
||||||
|
"bind": "绑定",
|
||||||
|
"unbind": "解绑",
|
||||||
|
"retry": "重试",
|
||||||
|
"copy": "复制",
|
||||||
|
"onchain": "上链存证",
|
||||||
|
"qrcode": "二维码",
|
||||||
|
"changePassword": "修改密码",
|
||||||
|
"logout": "退出登录"
|
||||||
|
},
|
||||||
|
"label": {
|
||||||
|
"keyword": "关键词",
|
||||||
|
"status": "状态",
|
||||||
|
"type": "类型",
|
||||||
|
"createdAt": "创建时间",
|
||||||
|
"updatedAt": "更新时间",
|
||||||
|
"operation": "操作",
|
||||||
|
"all": "全部",
|
||||||
|
"remark": "备注",
|
||||||
|
"total": "共 {n} 条",
|
||||||
|
"yes": "是",
|
||||||
|
"no": "否"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"ENABLED": "启用",
|
||||||
|
"DISABLED": "停用",
|
||||||
|
"DRAFT": "草稿",
|
||||||
|
"ACTIVE": "已激活",
|
||||||
|
"ABNORMAL": "异常",
|
||||||
|
"UNBOUND": "未绑定",
|
||||||
|
"INACTIVE": "未激活",
|
||||||
|
"PENDING": "等待中",
|
||||||
|
"PROCESSING": "处理中",
|
||||||
|
"SUCCESS": "成功",
|
||||||
|
"PARTIAL": "部分成功",
|
||||||
|
"FAILED": "失败",
|
||||||
|
"ONCHAIN": "已上链",
|
||||||
|
"GENERATING": "生成中",
|
||||||
|
"DONE": "已完成"
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"SUPER_ADMIN": "超级管理员",
|
||||||
|
"OPERATOR": "平台运营",
|
||||||
|
"AUDITOR": "审核员",
|
||||||
|
"VIEWER": "只读监管"
|
||||||
|
},
|
||||||
|
"queryResult": {
|
||||||
|
"FIRST_ACTIVATE": "首次激活",
|
||||||
|
"REPEAT": "重复查询",
|
||||||
|
"INVALID": "无效",
|
||||||
|
"DISABLED": "停用",
|
||||||
|
"ABNORMAL": "异常"
|
||||||
|
},
|
||||||
|
"fieldType": {
|
||||||
|
"TEXT": "文本",
|
||||||
|
"NUMBER": "数字",
|
||||||
|
"DATE": "日期",
|
||||||
|
"IMAGE": "图片",
|
||||||
|
"FILE": "文件",
|
||||||
|
"LINK": "链接",
|
||||||
|
"TEXTAREA": "多行文本"
|
||||||
|
},
|
||||||
|
"nodeType": {
|
||||||
|
"CREATE": "创作",
|
||||||
|
"PRODUCE": "制作",
|
||||||
|
"STORAGE": "仓储",
|
||||||
|
"OUTBOUND": "出库",
|
||||||
|
"OTHER": "其他"
|
||||||
|
},
|
||||||
|
"msg": {
|
||||||
|
"confirmDelete": "确认删除该条数据?",
|
||||||
|
"deleted": "删除成功",
|
||||||
|
"saved": "保存成功",
|
||||||
|
"created": "创建成功",
|
||||||
|
"updated": "更新成功",
|
||||||
|
"copied": "已复制",
|
||||||
|
"operationSuccess": "操作成功",
|
||||||
|
"loginExpired": "登录已过期,请重新登录",
|
||||||
|
"networkError": "网络异常,请稍后再试",
|
||||||
|
"noData": "暂无数据"
|
||||||
|
},
|
||||||
|
"lang": {
|
||||||
|
"zh": "中文",
|
||||||
|
"en": "English"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"dashboard": "数据看板",
|
||||||
|
"templates": "溯源模板",
|
||||||
|
"artworks": "艺术品建档",
|
||||||
|
"traceCodes": "追溯码管理",
|
||||||
|
"outbound": "出库与上链",
|
||||||
|
"queryLogs": "查询日志",
|
||||||
|
"users": "用户管理",
|
||||||
|
"settings": "系统设置",
|
||||||
|
"profile": "个人中心"
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"login": {
|
||||||
|
"title": "艺术品可信溯源与认证平台",
|
||||||
|
"subtitle": "运营管理后台",
|
||||||
|
"username": "用户名",
|
||||||
|
"password": "密码",
|
||||||
|
"submit": "登 录",
|
||||||
|
"placeholderUser": "请输入用户名",
|
||||||
|
"placeholderPass": "请输入密码",
|
||||||
|
"success": "登录成功"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"totalArtworks": "作品总数",
|
||||||
|
"boundCodes": "已绑定追溯码",
|
||||||
|
"activatedCodes": "已激活追溯码",
|
||||||
|
"totalQueries": "总查询次数",
|
||||||
|
"todayQueries": "今日查询",
|
||||||
|
"abnormalQueries": "异常查询",
|
||||||
|
"trendTitle": "近 7 日查询趋势",
|
||||||
|
"topTitle": "高频查询作品榜",
|
||||||
|
"queryCount": "查询次数",
|
||||||
|
"rank": "排名"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"name": "模板名称",
|
||||||
|
"fields": "字段配置",
|
||||||
|
"fieldKey": "字段键",
|
||||||
|
"fieldLabel": "字段名称",
|
||||||
|
"fieldType": "字段类型",
|
||||||
|
"required": "必填",
|
||||||
|
"sortOrder": "排序",
|
||||||
|
"addField": "添加字段",
|
||||||
|
"useCount": "使用作品数",
|
||||||
|
"create": "新建模板",
|
||||||
|
"edit": "编辑模板",
|
||||||
|
"namePlaceholder": "请输入模板名称",
|
||||||
|
"fieldKeyTip": "英文唯一标识,如 craft"
|
||||||
|
},
|
||||||
|
"artwork": {
|
||||||
|
"title": "作品名称",
|
||||||
|
"artist": "艺术家",
|
||||||
|
"template": "所属模板",
|
||||||
|
"images": "作品图片",
|
||||||
|
"basicInfo": "基础信息",
|
||||||
|
"dynamicFields": "动态字段",
|
||||||
|
"nodes": "溯源时间轴",
|
||||||
|
"certificates": "认证文件",
|
||||||
|
"traceCode": "追溯码",
|
||||||
|
"status": "状态",
|
||||||
|
"create": "新建作品",
|
||||||
|
"edit": "编辑作品",
|
||||||
|
"detail": "作品详情",
|
||||||
|
"addNode": "添加节点",
|
||||||
|
"nodeTitle": "节点标题",
|
||||||
|
"nodeLocation": "地点",
|
||||||
|
"nodeTime": "发生时间",
|
||||||
|
"nodeDesc": "说明",
|
||||||
|
"addCert": "添加认证文件",
|
||||||
|
"certName": "证书名称",
|
||||||
|
"certIssuer": "颁发机构",
|
||||||
|
"certType": "类型",
|
||||||
|
"originFile": "原始文件",
|
||||||
|
"watermarkPreview": "水印预览",
|
||||||
|
"watermarkPending": "水印生成中…",
|
||||||
|
"bindCode": "绑定追溯码",
|
||||||
|
"noTrace": "未绑定追溯码"
|
||||||
|
},
|
||||||
|
"traceCode": {
|
||||||
|
"batches": "批次列表",
|
||||||
|
"codes": "追溯码列表",
|
||||||
|
"batchNo": "批次编号",
|
||||||
|
"quantity": "数量",
|
||||||
|
"generate": "生成追溯码",
|
||||||
|
"generatedCount": "已生成",
|
||||||
|
"shortCode": "短码",
|
||||||
|
"code": "追溯码",
|
||||||
|
"url": "短链",
|
||||||
|
"queryCount": "查询次数",
|
||||||
|
"firstActivatedAt": "首次激活时间",
|
||||||
|
"exportBatch": "导出本批",
|
||||||
|
"bindArtwork": "绑定作品",
|
||||||
|
"selectArtwork": "选择作品",
|
||||||
|
"qrPreview": "二维码预览",
|
||||||
|
"generating": "正在生成,请稍候…",
|
||||||
|
"genSuccess": "生码任务已提交"
|
||||||
|
},
|
||||||
|
"outbound": {
|
||||||
|
"single": "单条录入",
|
||||||
|
"import": "批量导入",
|
||||||
|
"sku": "SKU",
|
||||||
|
"archiveNo": "档案编号",
|
||||||
|
"outTime": "出库时间",
|
||||||
|
"selectFile": "选择文件",
|
||||||
|
"importing": "导入中…",
|
||||||
|
"importResult": "导入结果",
|
||||||
|
"successCount": "成功",
|
||||||
|
"failCount": "失败",
|
||||||
|
"downloadResult": "下载结果明细",
|
||||||
|
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)"
|
||||||
|
},
|
||||||
|
"blockchain": {
|
||||||
|
"title": "区块链存证",
|
||||||
|
"dataHash": "数据哈希",
|
||||||
|
"txHash": "交易哈希",
|
||||||
|
"blockHeight": "区块高度",
|
||||||
|
"onchainAt": "上链时间",
|
||||||
|
"explorer": "存证查询",
|
||||||
|
"trigger": "触发上链",
|
||||||
|
"triggered": "已提交上链任务"
|
||||||
|
},
|
||||||
|
"queryLog": {
|
||||||
|
"result": "查询结果",
|
||||||
|
"ip": "IP / 地区",
|
||||||
|
"device": "设备信息",
|
||||||
|
"queriedAt": "查询时间",
|
||||||
|
"startTime": "开始时间",
|
||||||
|
"endTime": "结束时间"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"username": "用户名",
|
||||||
|
"realName": "姓名",
|
||||||
|
"role": "角色",
|
||||||
|
"create": "新建用户",
|
||||||
|
"edit": "编辑用户",
|
||||||
|
"resetPassword": "重置密码",
|
||||||
|
"newPassword": "新密码",
|
||||||
|
"lastLoginAt": "最近登录"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"appName": "平台名称",
|
||||||
|
"logRetentionDays": "日志保留天数",
|
||||||
|
"watermarkText": "证书水印文案",
|
||||||
|
"saved": "设置已保存"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "个人中心",
|
||||||
|
"oldPassword": "原密码",
|
||||||
|
"newPassword": "新密码",
|
||||||
|
"confirmPassword": "确认新密码",
|
||||||
|
"passwordMismatch": "两次密码不一致",
|
||||||
|
"changed": "密码修改成功,请重新登录"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { createApp } from 'vue';
|
||||||
|
import { createPinia } from 'pinia';
|
||||||
|
import naive from 'naive-ui';
|
||||||
|
import App from './App.vue';
|
||||||
|
import router from './router';
|
||||||
|
import { i18n } from './locales';
|
||||||
|
import './styles.css';
|
||||||
|
|
||||||
|
const app = createApp(App);
|
||||||
|
app.use(createPinia());
|
||||||
|
app.use(router);
|
||||||
|
app.use(i18n);
|
||||||
|
app.use(naive);
|
||||||
|
app.mount('#app');
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { loadingBar } from '@/utils/feedback';
|
||||||
|
import MainLayout from '@/layouts/MainLayout.vue';
|
||||||
|
|
||||||
|
export const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/login',
|
||||||
|
name: 'login',
|
||||||
|
component: () => import('@/views/Login.vue'),
|
||||||
|
meta: { public: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
component: MainLayout,
|
||||||
|
redirect: '/dashboard',
|
||||||
|
children: [
|
||||||
|
{ path: 'dashboard', name: 'dashboard', component: () => import('@/views/Dashboard.vue') },
|
||||||
|
{ path: 'templates', name: 'templates', component: () => import('@/views/Templates.vue') },
|
||||||
|
{ path: 'artworks', name: 'artworks', component: () => import('@/views/Artworks.vue') },
|
||||||
|
{ 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: '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: 'profile', name: 'profile', component: () => import('@/views/Profile.vue') },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ path: '/:pathMatch(.*)*', redirect: '/dashboard' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHashHistory(),
|
||||||
|
routes,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.beforeEach(async (to) => {
|
||||||
|
loadingBar.start();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
if (to.meta.public) {
|
||||||
|
if (auth.isLoggedIn && to.name === 'login') return { name: 'dashboard' };
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!auth.isLoggedIn) {
|
||||||
|
return { name: 'login' };
|
||||||
|
}
|
||||||
|
if (!auth.user) {
|
||||||
|
try {
|
||||||
|
await auth.fetchProfile();
|
||||||
|
} catch {
|
||||||
|
auth.logout();
|
||||||
|
return { name: 'login' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
router.afterEach(() => loadingBar.finish());
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { authApi } from '@/api';
|
||||||
|
import { setToken, clearToken, getToken } from '@/api/request';
|
||||||
|
|
||||||
|
interface AuthUser {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
realName?: string;
|
||||||
|
role: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useAuthStore = defineStore('auth', {
|
||||||
|
state: () => ({
|
||||||
|
token: getToken() || '',
|
||||||
|
user: null as AuthUser | null,
|
||||||
|
}),
|
||||||
|
getters: {
|
||||||
|
isLoggedIn: (state) => !!state.token,
|
||||||
|
isSuperAdmin: (state) => state.user?.role === 'SUPER_ADMIN',
|
||||||
|
canWrite: (state) => state.user?.role === 'SUPER_ADMIN' || state.user?.role === 'OPERATOR',
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
async login(username: string, password: string) {
|
||||||
|
const res = await authApi.login({ username, password });
|
||||||
|
this.token = res.token;
|
||||||
|
this.user = res.user;
|
||||||
|
setToken(res.token);
|
||||||
|
},
|
||||||
|
async fetchProfile() {
|
||||||
|
this.user = (await authApi.profile()) as AuthUser;
|
||||||
|
},
|
||||||
|
logout() {
|
||||||
|
this.token = '';
|
||||||
|
this.user = null;
|
||||||
|
clearToken();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
||||||
|
Roboto, sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
.page {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.page-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.page-toolbar .spacer {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
.text-ellipsis {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import type { GlobalThemeOverrides } from 'naive-ui';
|
||||||
|
|
||||||
|
// 商务深蓝主色 + 统一设计令牌
|
||||||
|
export const BRAND = {
|
||||||
|
primary: '#1f3864',
|
||||||
|
primaryHover: '#2e5496',
|
||||||
|
primaryPressed: '#162a4d',
|
||||||
|
primarySuppl: '#2e5496',
|
||||||
|
radius: '8px',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const themeOverrides: GlobalThemeOverrides = {
|
||||||
|
common: {
|
||||||
|
primaryColor: BRAND.primary,
|
||||||
|
primaryColorHover: BRAND.primaryHover,
|
||||||
|
primaryColorPressed: BRAND.primaryPressed,
|
||||||
|
primaryColorSuppl: BRAND.primarySuppl,
|
||||||
|
infoColor: BRAND.primaryHover,
|
||||||
|
borderRadius: BRAND.radius,
|
||||||
|
borderRadiusSmall: '6px',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeightStrong: '600',
|
||||||
|
},
|
||||||
|
Card: {
|
||||||
|
borderRadius: '12px',
|
||||||
|
},
|
||||||
|
Button: {
|
||||||
|
borderRadiusMedium: BRAND.radius,
|
||||||
|
},
|
||||||
|
DataTable: {
|
||||||
|
thColor: '#f4f7fc',
|
||||||
|
thTextColor: '#1f2937',
|
||||||
|
borderRadius: BRAND.radius,
|
||||||
|
},
|
||||||
|
Layout: {
|
||||||
|
siderColor: '#1f2a44',
|
||||||
|
},
|
||||||
|
Menu: {
|
||||||
|
itemTextColorInverted: 'rgba(255,255,255,0.82)',
|
||||||
|
itemIconColorInverted: 'rgba(255,255,255,0.82)',
|
||||||
|
itemTextColorHoverInverted: '#ffffff',
|
||||||
|
itemIconColorHoverInverted: '#ffffff',
|
||||||
|
itemColorActiveInverted: BRAND.primaryHover,
|
||||||
|
itemColorActiveHoverInverted: BRAND.primaryHover,
|
||||||
|
itemTextColorActiveInverted: '#ffffff',
|
||||||
|
itemIconColorActiveInverted: '#ffffff',
|
||||||
|
itemTextColorChildActiveInverted: '#ffffff',
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { download } from '@/api/request';
|
||||||
|
|
||||||
|
export function saveBlob(blob: Blob, filename: string): void {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadFile(url: string, filename: string, params?: object): Promise<void> {
|
||||||
|
const res = await download(url, params);
|
||||||
|
saveBlob(res.data, filename);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { createDiscreteApi } from 'naive-ui';
|
||||||
|
import { themeOverrides } from '@/theme';
|
||||||
|
|
||||||
|
// 全局可用的消息/对话框/加载条(含在 setup 之外,如 axios 拦截器)
|
||||||
|
const { message, dialog, loadingBar } = createDiscreteApi(['message', 'dialog', 'loadingBar'], {
|
||||||
|
configProviderProps: { themeOverrides },
|
||||||
|
});
|
||||||
|
|
||||||
|
export { message, dialog, loadingBar };
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
export function fmt(d?: string | Date | null): string {
|
||||||
|
return d ? dayjs(d).format('YYYY-MM-DD HH:mm') : '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fmtDate(d?: string | Date | null): string {
|
||||||
|
return d ? dayjs(d).format('YYYY-MM-DD') : '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_TYPE: Record<string, 'default' | 'success' | 'warning' | 'error' | 'info'> = {
|
||||||
|
ENABLED: 'success',
|
||||||
|
ACTIVE: 'success',
|
||||||
|
ONCHAIN: 'success',
|
||||||
|
SUCCESS: 'success',
|
||||||
|
DONE: 'success',
|
||||||
|
DRAFT: 'default',
|
||||||
|
UNBOUND: 'default',
|
||||||
|
INACTIVE: 'info',
|
||||||
|
PENDING: 'info',
|
||||||
|
PROCESSING: 'info',
|
||||||
|
GENERATING: 'info',
|
||||||
|
PARTIAL: 'warning',
|
||||||
|
DISABLED: 'warning',
|
||||||
|
ABNORMAL: 'error',
|
||||||
|
FAILED: 'error',
|
||||||
|
FIRST_ACTIVATE: 'success',
|
||||||
|
REPEAT: 'info',
|
||||||
|
INVALID: 'error',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function statusType(s?: string): 'default' | 'success' | 'warning' | 'error' | 'info' {
|
||||||
|
return (s && STATUS_TYPE[s]) || 'default';
|
||||||
|
}
|
||||||
@@ -0,0 +1,511 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<div class="page-toolbar">
|
||||||
|
<n-button quaternary @click="router.back()">
|
||||||
|
<template #icon><n-icon :component="ArrowBackOutline" /></template>
|
||||||
|
{{ t('common.action.back') }}
|
||||||
|
</n-button>
|
||||||
|
<div class="page-title">{{ isNew ? t('pages.artwork.create') : t('pages.artwork.detail') }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-grid :cols="1" :y-gap="16">
|
||||||
|
<!-- 基础信息 -->
|
||||||
|
<n-grid-item>
|
||||||
|
<n-card :title="t('pages.artwork.basicInfo')" :bordered="false">
|
||||||
|
<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')">
|
||||||
|
<n-select
|
||||||
|
v-model:value="form.templateId"
|
||||||
|
:options="templateOptions"
|
||||||
|
:disabled="!isNew"
|
||||||
|
@update:value="onTemplateChange"
|
||||||
|
/>
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi span="2 m:1" path="title" :label="t('pages.artwork.title')">
|
||||||
|
<n-input v-model:value="form.title" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi span="2 m:1" :label="t('pages.artwork.artist')">
|
||||||
|
<n-input v-model:value="form.artist" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi v-if="!isNew" span="2 m:1" :label="t('common.label.status')">
|
||||||
|
<n-select v-model:value="form.status" :options="statusOptions" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
<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-date-picker
|
||||||
|
v-if="f.type === 'DATE'"
|
||||||
|
v-model:formatted-value="form.dynamicFields[f.fieldKey]"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="date"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
<n-input
|
||||||
|
v-else-if="f.type === 'TEXTAREA'"
|
||||||
|
v-model:value="form.dynamicFields[f.fieldKey]"
|
||||||
|
type="textarea"
|
||||||
|
:rows="2"
|
||||||
|
/>
|
||||||
|
<n-input v-else v-model:value="form.dynamicFields[f.fieldKey]" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.images') }}</n-divider>
|
||||||
|
<media-upload v-model="form.images" type="image" :max="8" />
|
||||||
|
</n-form>
|
||||||
|
<div style="text-align: right; margin-top: 16px">
|
||||||
|
<n-button type="primary" :loading="saving" :disabled="!auth.canWrite" @click="saveBasic">
|
||||||
|
{{ t('common.action.save') }}
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
|
||||||
|
<template v-if="!isNew">
|
||||||
|
<!-- 溯源时间轴 -->
|
||||||
|
<n-grid-item>
|
||||||
|
<n-card :title="t('pages.artwork.nodes')" :bordered="false">
|
||||||
|
<template #header-extra>
|
||||||
|
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openNode()">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.artwork.addNode') }}
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
<n-empty v-if="!nodes.length" :description="t('common.msg.noData')" />
|
||||||
|
<n-timeline v-else>
|
||||||
|
<n-timeline-item v-for="n in nodes" :key="n.id" type="info" :title="n.title">
|
||||||
|
<template #header>
|
||||||
|
<div class="node-head">
|
||||||
|
<span>{{ t(`common.nodeType.${n.nodeType}`) }} · {{ n.title }}</span>
|
||||||
|
<span v-if="auth.canWrite" class="node-ops">
|
||||||
|
<n-button text size="tiny" @click="openNode(n)">{{ t('common.action.edit') }}</n-button>
|
||||||
|
<n-button text size="tiny" type="error" @click="removeNode(n)">{{ t('common.action.delete') }}</n-button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="node-meta">{{ [fmtDate(n.occurredAt), n.location].filter(Boolean).join(' · ') }}</div>
|
||||||
|
<div>{{ n.description }}</div>
|
||||||
|
<div class="node-media">
|
||||||
|
<n-image v-for="m in n.media" :key="m.url" :src="m.url" width="64" height="64" object-fit="cover" style="border-radius:6px" />
|
||||||
|
</div>
|
||||||
|
</n-timeline-item>
|
||||||
|
</n-timeline>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
|
||||||
|
<!-- 认证文件 -->
|
||||||
|
<n-grid-item>
|
||||||
|
<n-card :title="t('pages.artwork.certificates')" :bordered="false">
|
||||||
|
<template #header-extra>
|
||||||
|
<n-button v-if="auth.canWrite" size="small" type="primary" @click="openCert()">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.artwork.addCert') }}
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
<n-empty v-if="!certs.length" :description="t('common.msg.noData')" />
|
||||||
|
<n-grid v-else :cols="4" :x-gap="12" :y-gap="12" item-responsive responsive="screen">
|
||||||
|
<n-grid-item v-for="c in certs" :key="c.id" span="2 m:1">
|
||||||
|
<n-card size="small" :title="c.name">
|
||||||
|
<template #cover>
|
||||||
|
<n-image v-if="c.watermarkUrl" :src="c.watermarkUrl" object-fit="cover" style="height:140px;width:100%" />
|
||||||
|
<div v-else class="cert-pending">{{ t('pages.artwork.watermarkPending') }}</div>
|
||||||
|
</template>
|
||||||
|
<div class="cert-meta">{{ c.issuer || '-' }}</div>
|
||||||
|
<template #footer>
|
||||||
|
<n-button v-if="auth.canWrite" text size="tiny" type="error" @click="removeCert(c)">
|
||||||
|
{{ t('common.action.delete') }}
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
</n-grid>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
|
||||||
|
<!-- 追溯码与区块链 -->
|
||||||
|
<n-grid-item>
|
||||||
|
<n-card :title="t('pages.artwork.traceCode') + ' / ' + t('pages.blockchain.title')" :bordered="false">
|
||||||
|
<div v-if="artwork?.traceCode">
|
||||||
|
<n-descriptions :column="3" label-placement="left" bordered size="small">
|
||||||
|
<n-descriptions-item :label="t('pages.traceCode.shortCode')">{{ artwork.traceCode.shortCode }}</n-descriptions-item>
|
||||||
|
<n-descriptions-item :label="t('common.label.status')">
|
||||||
|
<n-tag size="small" :type="statusType(artwork.traceCode.status)">{{ t(`common.status.${artwork.traceCode.status}`) }}</n-tag>
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item :label="t('pages.traceCode.queryCount')">{{ artwork.traceCode.queryCount }}</n-descriptions-item>
|
||||||
|
</n-descriptions>
|
||||||
|
<div style="margin-top:12px; display:flex; gap:8px; flex-wrap:wrap">
|
||||||
|
<n-button v-if="auth.canWrite" size="small" @click="unbind">{{ t('common.action.unbind') }}</n-button>
|
||||||
|
<n-button v-if="auth.canWrite" size="small" type="primary" :loading="onchainLoading" @click="onchain">
|
||||||
|
<template #icon><n-icon :component="LinkOutline" /></template>
|
||||||
|
{{ t('common.action.onchain') }}
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
<n-data-table
|
||||||
|
v-if="artwork.traceCode.proofs?.length"
|
||||||
|
style="margin-top:12px"
|
||||||
|
size="small"
|
||||||
|
:columns="proofColumns"
|
||||||
|
:data="artwork.traceCode.proofs"
|
||||||
|
:row-key="(r) => r.id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<n-empty :description="t('pages.artwork.noTrace')" />
|
||||||
|
<div v-if="auth.canWrite" style="margin-top:12px; display:flex; gap:8px; align-items:center">
|
||||||
|
<n-select
|
||||||
|
v-model:value="bindCodeId"
|
||||||
|
:options="unboundOptions"
|
||||||
|
filterable
|
||||||
|
:placeholder="t('pages.traceCode.shortCode')"
|
||||||
|
style="width: 240px"
|
||||||
|
@focus="loadUnbound"
|
||||||
|
/>
|
||||||
|
<n-button type="primary" :disabled="!bindCodeId" @click="bind">{{ t('pages.artwork.bindCode') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
</template>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
<!-- 节点弹窗 -->
|
||||||
|
<n-modal v-model:show="nodeModal" preset="card" :title="t('pages.artwork.addNode')" style="width:560px;max-width:94vw">
|
||||||
|
<n-form :model="nodeForm" label-placement="top">
|
||||||
|
<n-grid :cols="2" :x-gap="12">
|
||||||
|
<n-form-item-gi :label="t('common.label.type')">
|
||||||
|
<n-select v-model:value="nodeForm.nodeType" :options="nodeTypeOptions" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi :label="t('pages.artwork.nodeTitle')">
|
||||||
|
<n-input v-model:value="nodeForm.title" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi :label="t('pages.artwork.nodeTime')">
|
||||||
|
<n-date-picker v-model:formatted-value="nodeForm.occurredAt" value-format="yyyy-MM-dd" type="date" style="width:100%" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi :label="t('pages.artwork.nodeLocation')">
|
||||||
|
<n-input v-model:value="nodeForm.location" />
|
||||||
|
</n-form-item-gi>
|
||||||
|
</n-grid>
|
||||||
|
<n-form-item :label="t('pages.artwork.nodeDesc')">
|
||||||
|
<n-input v-model:value="nodeForm.description" type="textarea" :rows="2" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.artwork.images')">
|
||||||
|
<media-upload v-model="nodeForm.mediaFiles" type="image" :max="6" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align:right">
|
||||||
|
<n-button class="mr8" @click="nodeModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" :loading="nodeSaving" @click="saveNode">{{ t('common.action.save') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<!-- 证书弹窗 -->
|
||||||
|
<n-modal v-model:show="certModal" preset="card" :title="t('pages.artwork.addCert')" style="width:480px;max-width:94vw">
|
||||||
|
<n-form :model="certForm" label-placement="top">
|
||||||
|
<n-form-item :label="t('pages.artwork.certName')">
|
||||||
|
<n-input v-model:value="certForm.name" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.artwork.certIssuer')">
|
||||||
|
<n-input v-model:value="certForm.issuer" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.artwork.certType')">
|
||||||
|
<n-select v-model:value="certForm.type" :options="certTypeOptions" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.artwork.originFile')">
|
||||||
|
<media-upload v-model="certForm.files" type="image" :max="1" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align:right">
|
||||||
|
<n-button class="mr8" @click="certModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" :loading="certSaving" @click="saveCert">{{ t('common.action.save') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||||
|
import { ArrowBackOutline, AddOutline, LinkOutline } from '@vicons/ionicons5';
|
||||||
|
import { ArtworkStatus, CertType, NodeType } from '@artveris/shared';
|
||||||
|
import { artworkApi, templateApi, traceCodeApi } from '@/api';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import MediaUpload from '@/components/MediaUpload.vue';
|
||||||
|
import { message, dialog } from '@/utils/feedback';
|
||||||
|
import { fmt, fmtDate, statusType } from '@/utils/format';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const isNew = computed(() => route.params.id === 'new');
|
||||||
|
const artworkId = computed(() => Number(route.params.id));
|
||||||
|
|
||||||
|
const formRef = ref<FormInst | null>(null);
|
||||||
|
const form = reactive<any>({ templateId: null, title: '', artist: '', status: ArtworkStatus.DRAFT, dynamicFields: {}, images: [] });
|
||||||
|
const rules: FormRules = {
|
||||||
|
templateId: { required: true, type: 'number', message: () => t('pages.artwork.template'), trigger: 'change' },
|
||||||
|
title: { required: true, message: () => t('pages.artwork.title'), trigger: 'blur' },
|
||||||
|
};
|
||||||
|
const saving = ref(false);
|
||||||
|
|
||||||
|
const templates = ref<any[]>([]);
|
||||||
|
const templateOptions = computed(() => templates.value.map((x) => ({ label: x.name, value: x.id })));
|
||||||
|
const statusOptions = Object.values(ArtworkStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||||
|
const nodeTypeOptions = Object.values(NodeType).map((v) => ({ label: t(`common.nodeType.${v}`), value: v }));
|
||||||
|
const certTypeOptions = Object.values(CertType).map((v) => ({ label: v, value: v }));
|
||||||
|
|
||||||
|
const currentFields = computed(() => templates.value.find((x) => x.id === form.templateId)?.fields ?? []);
|
||||||
|
|
||||||
|
const artwork = ref<any>(null);
|
||||||
|
const nodes = ref<any[]>([]);
|
||||||
|
const certs = ref<any[]>([]);
|
||||||
|
|
||||||
|
const proofColumns: DataTableColumns<any> = [
|
||||||
|
{ title: () => t('pages.blockchain.txHash'), key: 'txHash', ellipsis: { tooltip: true }, render: (r) => r.txHash || '-' },
|
||||||
|
{ title: () => t('pages.blockchain.blockHeight'), key: 'blockHeight', width: 120, render: (r) => r.blockHeight || '-' },
|
||||||
|
{
|
||||||
|
title: () => t('common.label.status'),
|
||||||
|
key: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||||
|
},
|
||||||
|
{ title: () => t('pages.blockchain.onchainAt'), key: 'onchainAt', width: 160, render: (r) => fmt(r.onchainAt) },
|
||||||
|
];
|
||||||
|
|
||||||
|
function onTemplateChange() {
|
||||||
|
form.dynamicFields = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadTemplates() {
|
||||||
|
templates.value = await templateApi.options();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadArtwork() {
|
||||||
|
const a: any = await artworkApi.get(artworkId.value);
|
||||||
|
artwork.value = a;
|
||||||
|
form.templateId = a.templateId;
|
||||||
|
form.title = a.title;
|
||||||
|
form.artist = a.artist;
|
||||||
|
form.status = a.status;
|
||||||
|
form.dynamicFields = a.dynamicFields || {};
|
||||||
|
form.images = a.images || [];
|
||||||
|
nodes.value = a.traceNodes || [];
|
||||||
|
certs.value = a.certificates || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveBasic() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
templateId: form.templateId,
|
||||||
|
title: form.title,
|
||||||
|
artist: form.artist,
|
||||||
|
status: form.status,
|
||||||
|
dynamicFields: form.dynamicFields,
|
||||||
|
images: form.images.map((m: any) => ({ key: m.key, name: m.name })),
|
||||||
|
};
|
||||||
|
if (isNew.value) {
|
||||||
|
const created: any = await artworkApi.create(payload);
|
||||||
|
message.success(t('common.msg.created'));
|
||||||
|
router.replace(`/artworks/${created.id}`);
|
||||||
|
} else {
|
||||||
|
await artworkApi.update(artworkId.value, payload);
|
||||||
|
message.success(t('common.msg.saved'));
|
||||||
|
await loadArtwork();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 节点 */
|
||||||
|
const nodeModal = ref(false);
|
||||||
|
const nodeSaving = ref(false);
|
||||||
|
const editingNode = ref<number | null>(null);
|
||||||
|
const nodeForm = reactive<any>({ nodeType: NodeType.CREATE, title: '', occurredAt: null, location: '', description: '', mediaFiles: [] });
|
||||||
|
function openNode(n?: any) {
|
||||||
|
editingNode.value = n?.id ?? null;
|
||||||
|
Object.assign(nodeForm, {
|
||||||
|
nodeType: n?.nodeType ?? NodeType.CREATE,
|
||||||
|
title: n?.title ?? '',
|
||||||
|
occurredAt: n?.occurredAt ? fmtDate(n.occurredAt) : null,
|
||||||
|
location: n?.location ?? '',
|
||||||
|
description: n?.description ?? '',
|
||||||
|
mediaFiles: n?.media ? n.media.map((m: any) => ({ key: m.key || m.url, url: m.url, name: m.name })) : [],
|
||||||
|
});
|
||||||
|
nodeModal.value = true;
|
||||||
|
}
|
||||||
|
async function saveNode() {
|
||||||
|
if (!nodeForm.title) {
|
||||||
|
message.error(t('pages.artwork.nodeTitle'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodeSaving.value = true;
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
nodeType: nodeForm.nodeType,
|
||||||
|
title: nodeForm.title,
|
||||||
|
occurredAt: nodeForm.occurredAt || undefined,
|
||||||
|
location: nodeForm.location,
|
||||||
|
description: nodeForm.description,
|
||||||
|
mediaFiles: nodeForm.mediaFiles.map((m: any) => ({ key: m.key, name: m.name, type: 'image' })),
|
||||||
|
};
|
||||||
|
if (editingNode.value) await artworkApi.updateNode(editingNode.value, payload);
|
||||||
|
else await artworkApi.createNode(artworkId.value, payload);
|
||||||
|
message.success(t('common.msg.saved'));
|
||||||
|
nodeModal.value = false;
|
||||||
|
nodes.value = await artworkApi.listNodes(artworkId.value);
|
||||||
|
} finally {
|
||||||
|
nodeSaving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function removeNode(n: any) {
|
||||||
|
dialog.warning({
|
||||||
|
title: t('common.action.delete'),
|
||||||
|
content: t('common.msg.confirmDelete'),
|
||||||
|
positiveText: t('common.action.confirm'),
|
||||||
|
negativeText: t('common.action.cancel'),
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
await artworkApi.removeNode(n.id);
|
||||||
|
nodes.value = await artworkApi.listNodes(artworkId.value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 证书 */
|
||||||
|
const certModal = ref(false);
|
||||||
|
const certSaving = ref(false);
|
||||||
|
const certForm = reactive<any>({ name: '', issuer: '', type: CertType.CERT, files: [] });
|
||||||
|
function openCert() {
|
||||||
|
Object.assign(certForm, { name: '', issuer: '', type: CertType.CERT, files: [] });
|
||||||
|
certModal.value = true;
|
||||||
|
}
|
||||||
|
async function saveCert() {
|
||||||
|
if (!certForm.name || !certForm.files.length) {
|
||||||
|
message.error(t('pages.artwork.certName'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
certSaving.value = true;
|
||||||
|
try {
|
||||||
|
await artworkApi.createCert(artworkId.value, {
|
||||||
|
name: certForm.name,
|
||||||
|
issuer: certForm.issuer,
|
||||||
|
type: certForm.type,
|
||||||
|
originKey: certForm.files[0].key,
|
||||||
|
});
|
||||||
|
message.success(t('common.msg.created'));
|
||||||
|
certModal.value = false;
|
||||||
|
certs.value = await artworkApi.listCerts(artworkId.value);
|
||||||
|
} finally {
|
||||||
|
certSaving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function removeCert(c: any) {
|
||||||
|
dialog.warning({
|
||||||
|
title: t('common.action.delete'),
|
||||||
|
content: t('common.msg.confirmDelete'),
|
||||||
|
positiveText: t('common.action.confirm'),
|
||||||
|
negativeText: t('common.action.cancel'),
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
await artworkApi.removeCert(c.id);
|
||||||
|
certs.value = await artworkApi.listCerts(artworkId.value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 追溯码 / 区块链 */
|
||||||
|
const bindCodeId = ref<string | null>(null);
|
||||||
|
const unbound = ref<any[]>([]);
|
||||||
|
const unboundOptions = computed(() => unbound.value.map((c) => ({ label: c.shortCode, value: c.id })));
|
||||||
|
const onchainLoading = ref(false);
|
||||||
|
async function loadUnbound() {
|
||||||
|
const res: any = await traceCodeApi.list({ status: 'UNBOUND', pageSize: 50 });
|
||||||
|
unbound.value = res.list;
|
||||||
|
}
|
||||||
|
async function bind() {
|
||||||
|
if (!bindCodeId.value) return;
|
||||||
|
await traceCodeApi.bind(bindCodeId.value, artworkId.value);
|
||||||
|
message.success(t('common.msg.saved'));
|
||||||
|
bindCodeId.value = null;
|
||||||
|
await loadArtwork();
|
||||||
|
}
|
||||||
|
async function unbind() {
|
||||||
|
if (!artwork.value?.traceCode) return;
|
||||||
|
await traceCodeApi.unbind(String(artwork.value.traceCode.id));
|
||||||
|
message.success(t('common.msg.saved'));
|
||||||
|
await loadArtwork();
|
||||||
|
}
|
||||||
|
async function onchain() {
|
||||||
|
if (!artwork.value?.traceCode) return;
|
||||||
|
onchainLoading.value = true;
|
||||||
|
try {
|
||||||
|
await traceCodeApi.onchain(String(artwork.value.traceCode.id));
|
||||||
|
message.success(t('pages.blockchain.triggered'));
|
||||||
|
setTimeout(loadArtwork, 1500);
|
||||||
|
} finally {
|
||||||
|
onchainLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadTemplates();
|
||||||
|
if (!isNew.value) await loadArtwork();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.mr8 {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
.node-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.node-ops {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.node-meta {
|
||||||
|
color: #8a8a8a;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
|
.node-media {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 6px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.cert-meta {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
.cert-pending {
|
||||||
|
height: 140px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #9ca3af;
|
||||||
|
background: #f4f7fc;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
<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.status"
|
||||||
|
:options="statusOptions"
|
||||||
|
clearable
|
||||||
|
:placeholder="t('common.label.status')"
|
||||||
|
style="width: 140px"
|
||||||
|
@update:value="onSearch"
|
||||||
|
/>
|
||||||
|
<n-button type="primary" @click="onSearch">
|
||||||
|
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||||
|
{{ t('common.action.search') }}
|
||||||
|
</n-button>
|
||||||
|
<div class="spacer" />
|
||||||
|
<n-button v-if="auth.canWrite" type="primary" @click="goCreate">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.artwork.create') }}
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-data-table
|
||||||
|
:columns="columns"
|
||||||
|
:data="rows"
|
||||||
|
:loading="loading"
|
||||||
|
:pagination="pagination"
|
||||||
|
remote
|
||||||
|
:row-key="(r) => r.id"
|
||||||
|
@update:page="onPage"
|
||||||
|
/>
|
||||||
|
</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, AddOutline, CreateOutline } from '@vicons/ionicons5';
|
||||||
|
import { ArtworkStatus } from '@artveris/shared';
|
||||||
|
import { artworkApi } from '@/api';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { fmt, statusType } from '@/utils/format';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const rows = ref<any[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const query = reactive<{ keyword: string; status: string | null; page: number; pageSize: number }>({
|
||||||
|
keyword: '',
|
||||||
|
status: null,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||||
|
const statusOptions = Object.values(ArtworkStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||||
|
|
||||||
|
const columns: DataTableColumns<any> = [
|
||||||
|
{
|
||||||
|
title: () => t('pages.artwork.images'),
|
||||||
|
key: 'cover',
|
||||||
|
width: 76,
|
||||||
|
render: (r) =>
|
||||||
|
r.images?.[0]?.url
|
||||||
|
? h(NAvatar, { src: r.images[0].url, size: 44, style: 'border-radius:8px' })
|
||||||
|
: h(NAvatar, { size: 44, style: 'border-radius:8px' }, { default: () => '—' }),
|
||||||
|
},
|
||||||
|
{ title: () => t('pages.artwork.title'), key: 'title', ellipsis: { tooltip: true } },
|
||||||
|
{ title: () => t('pages.artwork.artist'), key: 'artist', width: 120, render: (r) => r.artist || '-' },
|
||||||
|
{ title: () => t('pages.artwork.template'), key: 'template', width: 130, render: (r) => r.template?.name || '-' },
|
||||||
|
{
|
||||||
|
title: () => t('pages.artwork.traceCode'),
|
||||||
|
key: 'traceCode',
|
||||||
|
width: 130,
|
||||||
|
render: (r) =>
|
||||||
|
r.traceCode
|
||||||
|
? h(NTag, { size: 'small', type: statusType(r.traceCode.status) }, { default: () => r.traceCode.shortCode })
|
||||||
|
: h(NTag, { size: 'small' }, { default: () => t('pages.artwork.noTrace') }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: () => t('common.label.status'),
|
||||||
|
key: 'status',
|
||||||
|
width: 90,
|
||||||
|
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('common.label.operation'),
|
||||||
|
key: 'ops',
|
||||||
|
width: 90,
|
||||||
|
render: (r) =>
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ quaternary: true, circle: true, size: 'small', onClick: () => router.push(`/artworks/${r.id}`) },
|
||||||
|
{ icon: () => h(NIcon, null, { default: () => h(CreateOutline) }) },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await artworkApi.list({
|
||||||
|
keyword: query.keyword,
|
||||||
|
status: query.status || 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 goCreate() {
|
||||||
|
router.push('/artworks/new');
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<div class="stat-grid">
|
||||||
|
<n-card v-for="s in stats" :key="s.key" class="stat-card" :bordered="false">
|
||||||
|
<div class="stat-inner">
|
||||||
|
<div class="stat-icon" :style="{ background: s.color }">
|
||||||
|
<n-icon :component="s.icon" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="stat-value">{{ data?.[s.key] ?? 0 }}</div>
|
||||||
|
<div class="stat-label">{{ s.label }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</n-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-grid :cols="3" :x-gap="16" :y-gap="16" item-responsive responsive="screen" class="mt16">
|
||||||
|
<n-grid-item span="3 m:2">
|
||||||
|
<n-card :title="t('pages.dashboard.trendTitle')" :bordered="false">
|
||||||
|
<v-chart class="chart" :option="trendOption" autoresize />
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
<n-grid-item span="3 m:1">
|
||||||
|
<n-card :title="t('pages.dashboard.topTitle')" :bordered="false">
|
||||||
|
<n-empty v-if="!data?.topArtworks?.length" :description="t('common.msg.noData')" />
|
||||||
|
<n-list v-else>
|
||||||
|
<n-list-item v-for="(item, i) in data.topArtworks" :key="i">
|
||||||
|
<div class="top-row">
|
||||||
|
<n-tag :type="i < 3 ? 'warning' : 'default'" size="small" round>{{ i + 1 }}</n-tag>
|
||||||
|
<span class="top-title text-ellipsis">{{ item.title }}</span>
|
||||||
|
<span class="top-count">{{ item.queryCount }}</span>
|
||||||
|
</div>
|
||||||
|
</n-list-item>
|
||||||
|
</n-list>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
</n-grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { use } from 'echarts/core';
|
||||||
|
import { LineChart } from 'echarts/charts';
|
||||||
|
import { GridComponent, TooltipComponent } from 'echarts/components';
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers';
|
||||||
|
import VChart from 'vue-echarts';
|
||||||
|
import {
|
||||||
|
ImagesOutline,
|
||||||
|
QrCodeOutline,
|
||||||
|
CheckmarkCircleOutline,
|
||||||
|
SearchOutline,
|
||||||
|
TodayOutline,
|
||||||
|
WarningOutline,
|
||||||
|
} from '@vicons/ionicons5';
|
||||||
|
import { dashboardApi } from '@/api';
|
||||||
|
|
||||||
|
use([LineChart, GridComponent, TooltipComponent, CanvasRenderer]);
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const data = ref<any>(null);
|
||||||
|
|
||||||
|
const stats = computed(() => [
|
||||||
|
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864' },
|
||||||
|
{ key: 'boundCodes', label: t('pages.dashboard.boundCodes'), icon: QrCodeOutline, color: '#2e5496' },
|
||||||
|
{ key: 'activatedCodes', label: t('pages.dashboard.activatedCodes'), icon: CheckmarkCircleOutline, color: '#138a72' },
|
||||||
|
{ key: 'totalQueries', label: t('pages.dashboard.totalQueries'), icon: SearchOutline, color: '#3a7bd5' },
|
||||||
|
{ key: 'todayQueries', label: t('pages.dashboard.todayQueries'), icon: TodayOutline, color: '#b9851f' },
|
||||||
|
{ key: 'abnormalQueries', label: t('pages.dashboard.abnormalQueries'), icon: WarningOutline, color: '#c0392b' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const trendOption = computed(() => ({
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
grid: { left: 40, right: 16, top: 24, bottom: 28 },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: (data.value?.trend ?? []).map((d: any) => d.date),
|
||||||
|
},
|
||||||
|
yAxis: { type: 'value', minInterval: 1 },
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: t('pages.dashboard.queryCount'),
|
||||||
|
type: 'line',
|
||||||
|
smooth: true,
|
||||||
|
areaStyle: { opacity: 0.12 },
|
||||||
|
itemStyle: { color: '#2e5496' },
|
||||||
|
data: (data.value?.trend ?? []).map((d: any) => d.count),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}));
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
data.value = await dashboardApi.overview();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.stat-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
.stat-card {
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
.stat-inner {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
.stat-icon {
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
|
.stat-value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
.stat-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
.mt16 {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
.chart {
|
||||||
|
height: 320px;
|
||||||
|
}
|
||||||
|
.top-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.top-title {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
.top-count {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #2e5496;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<template>
|
||||||
|
<div class="login-wrap">
|
||||||
|
<div class="login-lang">
|
||||||
|
<n-select
|
||||||
|
v-model:value="currentLocale"
|
||||||
|
:options="localeOptions"
|
||||||
|
size="small"
|
||||||
|
style="width: 120px"
|
||||||
|
@update:value="changeLocale"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="login-left">
|
||||||
|
<div class="login-left-inner">
|
||||||
|
<div class="logo">艺</div>
|
||||||
|
<h1>{{ t('pages.login.title') }}</h1>
|
||||||
|
<p>{{ t('pages.login.subtitle') }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="login-right">
|
||||||
|
<n-card class="login-card" :bordered="false">
|
||||||
|
<h2 class="login-card-title">{{ t('pages.login.subtitle') }}</h2>
|
||||||
|
<n-form ref="formRef" :model="form" :rules="rules" @keyup.enter="onSubmit">
|
||||||
|
<n-form-item path="username" :label="t('pages.login.username')">
|
||||||
|
<n-input
|
||||||
|
v-model:value="form.username"
|
||||||
|
:placeholder="t('pages.login.placeholderUser')"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<template #prefix><n-icon :component="PersonOutline" /></template>
|
||||||
|
</n-input>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item path="password" :label="t('pages.login.password')">
|
||||||
|
<n-input
|
||||||
|
v-model:value="form.password"
|
||||||
|
type="password"
|
||||||
|
show-password-on="click"
|
||||||
|
:placeholder="t('pages.login.placeholderPass')"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<template #prefix><n-icon :component="LockClosedOutline" /></template>
|
||||||
|
</n-input>
|
||||||
|
</n-form-item>
|
||||||
|
<n-button type="primary" size="large" block :loading="loading" @click="onSubmit">
|
||||||
|
{{ t('pages.login.submit') }}
|
||||||
|
</n-button>
|
||||||
|
</n-form>
|
||||||
|
</n-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import type { FormInst, FormRules } from 'naive-ui';
|
||||||
|
import { PersonOutline, LockClosedOutline } from '@vicons/ionicons5';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
|
||||||
|
const { t, locale } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const formRef = ref<FormInst | null>(null);
|
||||||
|
const form = ref({ username: '', password: '' });
|
||||||
|
const loading = ref(false);
|
||||||
|
const currentLocale = ref(locale.value);
|
||||||
|
const localeOptions = SUPPORTED_LOCALES.map((l) => ({ label: l.label, value: l.value }));
|
||||||
|
|
||||||
|
const rules: FormRules = {
|
||||||
|
username: { required: true, message: () => t('pages.login.placeholderUser'), trigger: 'blur' },
|
||||||
|
password: { required: true, message: () => t('pages.login.placeholderPass'), trigger: 'blur' },
|
||||||
|
};
|
||||||
|
|
||||||
|
function changeLocale(val: string) {
|
||||||
|
setLocale(val);
|
||||||
|
currentLocale.value = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSubmit() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
await auth.login(form.value.username, form.value.password);
|
||||||
|
message.success(t('pages.login.success'));
|
||||||
|
router.push({ name: 'dashboard' });
|
||||||
|
} catch {
|
||||||
|
/* 错误已由拦截器提示 */
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.login-wrap {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
height: 100vh;
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
.login-lang {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 24px;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.login-left {
|
||||||
|
flex: 1 1 55%;
|
||||||
|
background: linear-gradient(135deg, #1f3864 0%, #2e5496 100%);
|
||||||
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.login-left-inner {
|
||||||
|
text-align: center;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
.login-left-inner .logo {
|
||||||
|
width: 72px;
|
||||||
|
height: 72px;
|
||||||
|
margin: 0 auto 24px;
|
||||||
|
border-radius: 18px;
|
||||||
|
background: rgba(255, 255, 255, 0.16);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 38px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.login-left-inner h1 {
|
||||||
|
font-size: 28px;
|
||||||
|
margin: 0 0 12px;
|
||||||
|
}
|
||||||
|
.login-left-inner p {
|
||||||
|
font-size: 16px;
|
||||||
|
opacity: 0.85;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.login-right {
|
||||||
|
flex: 1 1 45%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
.login-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 380px;
|
||||||
|
}
|
||||||
|
.login-card-title {
|
||||||
|
margin: 0 0 24px;
|
||||||
|
font-size: 22px;
|
||||||
|
color: #1f2937;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.login-left {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<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 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-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { 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 { useAuthStore } from '@/stores/auth';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
import { statusType } from '@/utils/format';
|
||||||
|
import { downloadFile } from '@/utils/download';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
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;
|
||||||
|
try {
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('file', file.file as File);
|
||||||
|
const res: any = await post('/outbound/import', fd, { headers: { 'Content-Type': 'multipart/form-data' } });
|
||||||
|
const jobId = res.jobId;
|
||||||
|
let job: any = null;
|
||||||
|
for (let i = 0; i < 40; i++) {
|
||||||
|
await new Promise((r) => setTimeout(r, 700));
|
||||||
|
job = await jobApi.get(jobId);
|
||||||
|
if (['SUCCESS', 'FAILED', 'PARTIAL'].includes(job.status)) break;
|
||||||
|
}
|
||||||
|
result.value = job;
|
||||||
|
message.success(t('common.msg.operationSuccess'));
|
||||||
|
onFinish();
|
||||||
|
} catch (e) {
|
||||||
|
message.error((e as Error)?.message || 'import failed');
|
||||||
|
onError();
|
||||||
|
} finally {
|
||||||
|
importing.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<n-card :title="t('pages.profile.title')" :bordered="false" style="max-width: 520px">
|
||||||
|
<n-descriptions :column="1" label-placement="left" bordered style="margin-bottom: 20px">
|
||||||
|
<n-descriptions-item :label="t('pages.user.username')">{{ auth.user?.username }}</n-descriptions-item>
|
||||||
|
<n-descriptions-item :label="t('pages.user.realName')">{{ auth.user?.realName || '-' }}</n-descriptions-item>
|
||||||
|
<n-descriptions-item :label="t('pages.user.role')">{{ t(`common.role.${auth.user?.role}`) }}</n-descriptions-item>
|
||||||
|
</n-descriptions>
|
||||||
|
|
||||||
|
<n-divider>{{ t('common.action.changePassword') }}</n-divider>
|
||||||
|
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||||
|
<n-form-item path="oldPassword" :label="t('pages.profile.oldPassword')">
|
||||||
|
<n-input v-model:value="form.oldPassword" type="password" show-password-on="click" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item path="newPassword" :label="t('pages.profile.newPassword')">
|
||||||
|
<n-input v-model:value="form.newPassword" type="password" show-password-on="click" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item path="confirmPassword" :label="t('pages.profile.confirmPassword')">
|
||||||
|
<n-input v-model:value="form.confirmPassword" type="password" show-password-on="click" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-button type="primary" :loading="saving" @click="submit">{{ t('common.action.changePassword') }}</n-button>
|
||||||
|
</n-form>
|
||||||
|
</n-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import type { FormInst, FormRules } from 'naive-ui';
|
||||||
|
import { authApi } from '@/api';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
const formRef = ref<FormInst | null>(null);
|
||||||
|
const saving = ref(false);
|
||||||
|
const form = reactive({ oldPassword: '', newPassword: '', confirmPassword: '' });
|
||||||
|
const rules: FormRules = {
|
||||||
|
oldPassword: { required: true, message: () => t('pages.profile.oldPassword'), trigger: 'blur' },
|
||||||
|
newPassword: { required: true, min: 6, message: () => t('pages.profile.newPassword'), trigger: 'blur' },
|
||||||
|
confirmPassword: {
|
||||||
|
validator: (_r, v) => v === form.newPassword,
|
||||||
|
message: () => t('pages.profile.passwordMismatch'),
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await authApi.changePassword({ oldPassword: form.oldPassword, newPassword: form.newPassword });
|
||||||
|
message.success(t('pages.profile.changed'));
|
||||||
|
auth.logout();
|
||||||
|
router.push({ name: 'login' });
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<div class="page-toolbar">
|
||||||
|
<n-input
|
||||||
|
v-model:value="query.keyword"
|
||||||
|
:placeholder="t('pages.traceCode.shortCode')"
|
||||||
|
clearable
|
||||||
|
style="width: 180px"
|
||||||
|
@keyup.enter="onSearch"
|
||||||
|
/>
|
||||||
|
<n-select
|
||||||
|
v-model:value="query.result"
|
||||||
|
:options="resultOptions"
|
||||||
|
clearable
|
||||||
|
:placeholder="t('pages.queryLog.result')"
|
||||||
|
style="width: 150px"
|
||||||
|
@update:value="onSearch"
|
||||||
|
/>
|
||||||
|
<n-date-picker
|
||||||
|
v-model:value="range"
|
||||||
|
type="datetimerange"
|
||||||
|
clearable
|
||||||
|
style="width: 360px"
|
||||||
|
@update:value="onRange"
|
||||||
|
/>
|
||||||
|
<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"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { h, onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { NTag, type DataTableColumns } from 'naive-ui';
|
||||||
|
import { SearchOutline } from '@vicons/ionicons5';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { QueryResult } from '@artveris/shared';
|
||||||
|
import { queryLogApi } from '@/api';
|
||||||
|
import { fmt, statusType } from '@/utils/format';
|
||||||
|
|
||||||
|
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 }>({
|
||||||
|
keyword: '',
|
||||||
|
result: null,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
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.queryLog.result'),
|
||||||
|
key: 'queryResult',
|
||||||
|
width: 110,
|
||||||
|
render: (r) => h(NTag, { size: 'small', type: statusType(r.queryResult) }, { default: () => t(`common.queryResult.${r.queryResult}`) }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: () => t('pages.queryLog.ip'),
|
||||||
|
key: 'ip',
|
||||||
|
width: 200,
|
||||||
|
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) },
|
||||||
|
];
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await queryLogApi.list({
|
||||||
|
keyword: query.keyword || undefined,
|
||||||
|
result: query.result || undefined,
|
||||||
|
startTime: query.startTime,
|
||||||
|
endTime: query.endTime,
|
||||||
|
page: query.page,
|
||||||
|
pageSize: query.pageSize,
|
||||||
|
});
|
||||||
|
rows.value = res.list;
|
||||||
|
pagination.itemCount = res.total;
|
||||||
|
pagination.page = res.page;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function onRange(val: [number, number] | null) {
|
||||||
|
if (val) {
|
||||||
|
query.startTime = dayjs(val[0]).toISOString();
|
||||||
|
query.endTime = dayjs(val[1]).toISOString();
|
||||||
|
} else {
|
||||||
|
query.startTime = undefined;
|
||||||
|
query.endTime = undefined;
|
||||||
|
}
|
||||||
|
onSearch();
|
||||||
|
}
|
||||||
|
function onSearch() {
|
||||||
|
query.page = 1;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
function onPage(p: number) {
|
||||||
|
query.page = p;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<n-card :title="t('menu.settings')" :bordered="false" style="max-width: 640px">
|
||||||
|
<n-form label-placement="top">
|
||||||
|
<n-form-item :label="t('pages.settings.appName')">
|
||||||
|
<n-input v-model:value="form.appName" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.settings.logRetentionDays')">
|
||||||
|
<n-input-number v-model:value="form.logRetentionDays" :min="1" style="width: 220px" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.settings.watermarkText')">
|
||||||
|
<n-input v-model:value="form.watermarkText" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-button type="primary" :loading="saving" @click="save">{{ t('common.action.save') }}</n-button>
|
||||||
|
</n-form>
|
||||||
|
</n-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { settingsApi } from '@/api';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const saving = ref(false);
|
||||||
|
const form = reactive<{ appName: string; logRetentionDays: number; watermarkText: string }>({
|
||||||
|
appName: '',
|
||||||
|
logRetentionDays: 365,
|
||||||
|
watermarkText: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
const s = await settingsApi.getAll();
|
||||||
|
form.appName = s.appName || '';
|
||||||
|
form.logRetentionDays = Number(s.logRetentionDays || 365);
|
||||||
|
form.watermarkText = s.watermarkText || '';
|
||||||
|
}
|
||||||
|
async function save() {
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
await settingsApi.update({
|
||||||
|
appName: form.appName,
|
||||||
|
logRetentionDays: String(form.logRetentionDays),
|
||||||
|
watermarkText: form.watermarkText,
|
||||||
|
});
|
||||||
|
message.success(t('pages.settings.saved'));
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,226 @@
|
|||||||
|
<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="load"
|
||||||
|
/>
|
||||||
|
<n-button type="primary" @click="load">
|
||||||
|
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||||
|
{{ t('common.action.search') }}
|
||||||
|
</n-button>
|
||||||
|
<div class="spacer" />
|
||||||
|
<n-button v-if="auth.canWrite" type="primary" @click="openCreate">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.template.create') }}
|
||||||
|
</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="showModal"
|
||||||
|
preset="card"
|
||||||
|
:title="editing ? t('pages.template.edit') : t('pages.template.create')"
|
||||||
|
style="width: 720px; max-width: 94vw"
|
||||||
|
>
|
||||||
|
<n-form ref="formRef" :model="form" :rules="rules">
|
||||||
|
<n-form-item path="name" :label="t('pages.template.name')">
|
||||||
|
<n-input v-model:value="form.name" :placeholder="t('pages.template.namePlaceholder')" />
|
||||||
|
</n-form-item>
|
||||||
|
<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 :label="t('pages.template.fields')">
|
||||||
|
<div style="width: 100%">
|
||||||
|
<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" />
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<n-button dashed block @click="addField">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.template.addField') }}
|
||||||
|
</n-button>
|
||||||
|
</div>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<n-button class="mr8" @click="showModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" :loading="saving" @click="save">{{ t('common.action.save') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
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 { templateApi } from '@/api';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { message, dialog } from '@/utils/feedback';
|
||||||
|
import { fmt, statusType } from '@/utils/format';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const rows = ref<any[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
|
||||||
|
const pagination = reactive({ page: 1, pageCount: 1, pageSize: 10, itemCount: 0 });
|
||||||
|
|
||||||
|
const fieldTypeOptions = Object.values(FieldType).map((v) => ({ label: t(`common.fieldType.${v}`), value: v }));
|
||||||
|
|
||||||
|
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 rules: FormRules = { name: { required: true, message: () => t('pages.template.namePlaceholder'), trigger: 'blur' } };
|
||||||
|
|
||||||
|
const columns: DataTableColumns<any> = [
|
||||||
|
{ title: 'ID', key: 'id', width: 70 },
|
||||||
|
{ title: () => t('pages.template.name'), key: 'name' },
|
||||||
|
{
|
||||||
|
title: () => t('pages.template.fields'),
|
||||||
|
key: 'fields',
|
||||||
|
render: (r) => (r.fields || []).map((f: any) => f.label).join('、') || '-',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: () => t('common.label.status'),
|
||||||
|
key: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (r) => h(NTag, { type: statusType(r.status), size: 'small' }, { default: () => t(`common.status.${r.status}`) }),
|
||||||
|
},
|
||||||
|
{ title: () => t('pages.template.useCount'), key: 'useCount', width: 100, render: (r) => r._count?.artworks ?? 0 },
|
||||||
|
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, render: (r) => fmt(r.createdAt) },
|
||||||
|
{
|
||||||
|
title: () => t('common.label.operation'),
|
||||||
|
key: 'ops',
|
||||||
|
width: 130,
|
||||||
|
render: (r) =>
|
||||||
|
auth.canWrite
|
||||||
|
? h('div', { style: 'display:flex;gap:4px' }, [
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ quaternary: true, circle: true, size: 'small', onClick: () => openEdit(r) },
|
||||||
|
{ icon: () => h(NIcon, null, { default: () => h(CreateOutline) }) },
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ quaternary: true, circle: true, size: 'small', type: 'error', onClick: () => remove(r) },
|
||||||
|
{ icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) },
|
||||||
|
),
|
||||||
|
])
|
||||||
|
: '-',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await templateApi.list({ keyword: query.keyword, page: query.page, pageSize: query.pageSize });
|
||||||
|
rows.value = res.list;
|
||||||
|
pagination.itemCount = res.total;
|
||||||
|
pagination.page = res.page;
|
||||||
|
pagination.pageSize = res.pageSize;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function onPage(p: number) {
|
||||||
|
query.page = p;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addField() {
|
||||||
|
form.fields.push({ fieldKey: '', label: '', type: FieldType.TEXT, required: false });
|
||||||
|
}
|
||||||
|
function openCreate() {
|
||||||
|
editing.value = null;
|
||||||
|
form.name = '';
|
||||||
|
form.remark = '';
|
||||||
|
form.fields = [{ fieldKey: '', label: '', type: FieldType.TEXT, required: false }];
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
function openEdit(r: any) {
|
||||||
|
editing.value = r.id;
|
||||||
|
form.name = r.name;
|
||||||
|
form.remark = r.remark || '';
|
||||||
|
form.fields = (r.fields || []).map((f: any) => ({ ...f }));
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
async function save() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!form.fields.length || form.fields.some((f) => !f.fieldKey || !f.label)) {
|
||||||
|
message.error(t('pages.template.fields') + ' ✕');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
const payload = { name: form.name, remark: form.remark, fields: form.fields };
|
||||||
|
if (editing.value) {
|
||||||
|
await templateApi.update(editing.value, payload);
|
||||||
|
message.success(t('common.msg.updated'));
|
||||||
|
} else {
|
||||||
|
await templateApi.create(payload);
|
||||||
|
message.success(t('common.msg.created'));
|
||||||
|
}
|
||||||
|
showModal.value = false;
|
||||||
|
load();
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function remove(r: any) {
|
||||||
|
dialog.warning({
|
||||||
|
title: t('common.action.delete'),
|
||||||
|
content: t('common.msg.confirmDelete'),
|
||||||
|
positiveText: t('common.action.confirm'),
|
||||||
|
negativeText: t('common.action.cancel'),
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
await templateApi.remove(r.id);
|
||||||
|
message.success(t('common.msg.deleted'));
|
||||||
|
load();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.field-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.mr8 {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<div class="page-toolbar">
|
||||||
|
<n-select
|
||||||
|
v-model:value="query.batchId"
|
||||||
|
:options="batchOptions"
|
||||||
|
clearable
|
||||||
|
:placeholder="t('pages.traceCode.batchNo')"
|
||||||
|
style="width: 200px"
|
||||||
|
@update:value="onSearch"
|
||||||
|
/>
|
||||||
|
<n-select
|
||||||
|
v-model:value="query.status"
|
||||||
|
:options="statusOptions"
|
||||||
|
clearable
|
||||||
|
:placeholder="t('common.label.status')"
|
||||||
|
style="width: 140px"
|
||||||
|
@update:value="onSearch"
|
||||||
|
/>
|
||||||
|
<n-input
|
||||||
|
v-model:value="query.keyword"
|
||||||
|
:placeholder="t('pages.traceCode.shortCode')"
|
||||||
|
clearable
|
||||||
|
style="width: 180px"
|
||||||
|
@keyup.enter="onSearch"
|
||||||
|
/>
|
||||||
|
<n-button type="primary" @click="onSearch">
|
||||||
|
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||||
|
{{ t('common.action.search') }}
|
||||||
|
</n-button>
|
||||||
|
<div class="spacer" />
|
||||||
|
<n-button v-if="auth.canWrite && query.batchId" @click="exportBatch">
|
||||||
|
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||||
|
{{ t('pages.traceCode.exportBatch') }}
|
||||||
|
</n-button>
|
||||||
|
<n-button v-if="auth.canWrite" type="primary" @click="genModal = true">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.traceCode.generate') }}
|
||||||
|
</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="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 420px">
|
||||||
|
<n-form :model="genForm" label-placement="top">
|
||||||
|
<n-form-item :label="t('pages.traceCode.quantity')">
|
||||||
|
<n-input-number v-model:value="genForm.quantity" :min="1" :max="10000" style="width: 100%" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.traceCode.batchNo')">
|
||||||
|
<n-input v-model:value="genForm.batchNo" placeholder="(auto)" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<n-text v-if="generating" depth="3">{{ t('pages.traceCode.generating') }}</n-text>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<n-button class="mr8" @click="genModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" :loading="generating" @click="generate">{{ t('common.action.generate') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<n-modal v-model:show="qrModal" preset="card" :title="t('pages.traceCode.qrPreview')" style="width: 360px">
|
||||||
|
<div style="text-align: center">
|
||||||
|
<img :src="qrSrc" alt="qrcode" style="width: 280px; height: 280px" />
|
||||||
|
<div style="margin-top: 8px; color: #6b7280; word-break: break-all">{{ qrUrl }}</div>
|
||||||
|
</div>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { h, onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { NButton, NIcon, NTag, NText, type DataTableColumns } from 'naive-ui';
|
||||||
|
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline } from '@vicons/ionicons5';
|
||||||
|
import { TraceCodeStatus } from '@artveris/shared';
|
||||||
|
import { traceCodeApi, jobApi } from '@/api';
|
||||||
|
import { useAuthStore } from '@/stores/auth';
|
||||||
|
import { message } from '@/utils/feedback';
|
||||||
|
import { fmt, statusType } from '@/utils/format';
|
||||||
|
import { downloadFile } from '@/utils/download';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
|
const rows = ref<any[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const query = reactive<{ batchId: number | null; status: string | null; keyword: string; page: number; pageSize: number }>({
|
||||||
|
batchId: null,
|
||||||
|
status: null,
|
||||||
|
keyword: '',
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||||
|
const statusOptions = Object.values(TraceCodeStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||||
|
const batches = ref<any[]>([]);
|
||||||
|
const batchOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
|
const genModal = ref(false);
|
||||||
|
const generating = ref(false);
|
||||||
|
const genForm = reactive<{ quantity: number; batchNo: string }>({ quantity: 100, batchNo: '' });
|
||||||
|
|
||||||
|
const qrModal = ref(false);
|
||||||
|
const qrSrc = ref('');
|
||||||
|
const qrUrl = ref('');
|
||||||
|
|
||||||
|
const columns: DataTableColumns<any> = [
|
||||||
|
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 130 },
|
||||||
|
{ title: () => t('pages.traceCode.url'), key: 'url', ellipsis: { tooltip: true } },
|
||||||
|
{
|
||||||
|
title: () => t('pages.artwork.title'),
|
||||||
|
key: 'artwork',
|
||||||
|
width: 150,
|
||||||
|
render: (r) => r.artwork?.title || '-',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: () => t('common.label.status'),
|
||||||
|
key: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||||
|
},
|
||||||
|
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 90 },
|
||||||
|
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 160, render: (r) => fmt(r.firstActivatedAt) },
|
||||||
|
{
|
||||||
|
title: () => t('common.label.operation'),
|
||||||
|
key: 'ops',
|
||||||
|
width: 80,
|
||||||
|
render: (r) =>
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ quaternary: true, circle: true, size: 'small', onClick: () => showQr(r) },
|
||||||
|
{ icon: () => h(NIcon, null, { default: () => h(QrCodeOutline) }) },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function loadBatches() {
|
||||||
|
const res: any = await traceCodeApi.batches({ pageSize: 100 });
|
||||||
|
batches.value = res.list;
|
||||||
|
batchOptions.value = res.list.map((b: any) => ({ label: `${b.batchNo} (${b.generatedCount}/${b.quantity})`, value: b.id }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await traceCodeApi.list({
|
||||||
|
batchId: query.batchId || undefined,
|
||||||
|
status: query.status || undefined,
|
||||||
|
keyword: query.keyword || 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generate() {
|
||||||
|
generating.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await traceCodeApi.generate({ quantity: genForm.quantity, batchNo: genForm.batchNo || undefined });
|
||||||
|
message.success(t('pages.traceCode.genSuccess'));
|
||||||
|
// 轮询任务
|
||||||
|
const jobId = res.jobId;
|
||||||
|
for (let i = 0; i < 30; i++) {
|
||||||
|
await new Promise((r) => setTimeout(r, 700));
|
||||||
|
const job: any = await jobApi.get(jobId);
|
||||||
|
if (job.status === 'SUCCESS' || job.status === 'FAILED' || job.status === 'PARTIAL') break;
|
||||||
|
}
|
||||||
|
genModal.value = false;
|
||||||
|
await loadBatches();
|
||||||
|
await load();
|
||||||
|
} finally {
|
||||||
|
generating.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showQr(r: any) {
|
||||||
|
qrSrc.value = traceCodeApi.qrUrl(r.id);
|
||||||
|
qrUrl.value = r.url;
|
||||||
|
qrModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function exportBatch() {
|
||||||
|
if (!query.batchId) return;
|
||||||
|
await downloadFile('/trace-codes/export', `trace-codes-${query.batchId}.xlsx`, { batchId: query.batchId });
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadBatches();
|
||||||
|
await load();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.mr8 {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page">
|
||||||
|
<div class="page-toolbar">
|
||||||
|
<n-input v-model:value="query.keyword" :placeholder="t('common.label.keyword')" clearable style="width: 200px" @keyup.enter="onSearch" />
|
||||||
|
<n-button type="primary" @click="onSearch">
|
||||||
|
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||||
|
{{ t('common.action.search') }}
|
||||||
|
</n-button>
|
||||||
|
<div class="spacer" />
|
||||||
|
<n-button type="primary" @click="openCreate">
|
||||||
|
<template #icon><n-icon :component="AddOutline" /></template>
|
||||||
|
{{ t('pages.user.create') }}
|
||||||
|
</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="showModal" preset="card" :title="editing ? t('pages.user.edit') : t('pages.user.create')" style="width: 460px">
|
||||||
|
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||||
|
<n-form-item path="username" :label="t('pages.user.username')">
|
||||||
|
<n-input v-model:value="form.username" :disabled="!!editing" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item v-if="!editing" path="password" :label="t('pages.login.password')">
|
||||||
|
<n-input v-model:value="form.password" type="password" show-password-on="click" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.user.realName')">
|
||||||
|
<n-input v-model:value="form.realName" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="t('pages.user.role')">
|
||||||
|
<n-select v-model:value="form.role" :options="roleOptions" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item v-if="editing" :label="t('common.label.status')">
|
||||||
|
<n-select v-model:value="form.status" :options="statusOptions" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<n-button class="mr8" @click="showModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" :loading="saving" @click="save">{{ t('common.action.save') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<n-modal v-model:show="pwdModal" preset="card" :title="t('pages.user.resetPassword')" style="width: 380px">
|
||||||
|
<n-input v-model:value="newPwd" type="password" show-password-on="click" :placeholder="t('pages.user.newPassword')" />
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<n-button class="mr8" @click="pwdModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||||
|
<n-button type="primary" @click="doReset">{{ t('common.action.confirm') }}</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
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, CreateOutline, KeyOutline, TrashOutline } from '@vicons/ionicons5';
|
||||||
|
import { RoleType, UserStatus } from '@artveris/shared';
|
||||||
|
import { userApi } from '@/api';
|
||||||
|
import { message, dialog } from '@/utils/feedback';
|
||||||
|
import { fmt, statusType } from '@/utils/format';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const rows = ref<any[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
|
||||||
|
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||||
|
const roleOptions = Object.values(RoleType).map((v) => ({ label: t(`common.role.${v}`), value: v }));
|
||||||
|
const statusOptions = Object.values(UserStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const editing = ref<number | null>(null);
|
||||||
|
const saving = ref(false);
|
||||||
|
const formRef = ref<FormInst | null>(null);
|
||||||
|
const form = reactive<any>({ username: '', password: '', realName: '', role: RoleType.OPERATOR, status: UserStatus.ACTIVE });
|
||||||
|
const rules: FormRules = {
|
||||||
|
username: { required: true, message: () => t('pages.user.username'), trigger: 'blur' },
|
||||||
|
password: { required: true, message: () => t('pages.login.password'), trigger: 'blur' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const pwdModal = ref(false);
|
||||||
|
const newPwd = ref('');
|
||||||
|
const pwdUserId = ref<number | null>(null);
|
||||||
|
|
||||||
|
const columns: DataTableColumns<any> = [
|
||||||
|
{ title: 'ID', key: 'id', width: 64 },
|
||||||
|
{ title: () => t('pages.user.username'), key: 'username' },
|
||||||
|
{ title: () => t('pages.user.realName'), key: 'realName', render: (r) => r.realName || '-' },
|
||||||
|
{ title: () => t('pages.user.role'), key: 'role', width: 120, render: (r) => t(`common.role.${r.role}`) },
|
||||||
|
{
|
||||||
|
title: () => t('common.label.status'),
|
||||||
|
key: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||||
|
},
|
||||||
|
{ title: () => t('pages.user.lastLoginAt'), key: 'lastLoginAt', width: 160, render: (r) => fmt(r.lastLoginAt) },
|
||||||
|
{
|
||||||
|
title: () => t('common.label.operation'),
|
||||||
|
key: 'ops',
|
||||||
|
width: 140,
|
||||||
|
render: (r) =>
|
||||||
|
h('div', { style: 'display:flex;gap:2px' }, [
|
||||||
|
h(NButton, { quaternary: true, circle: true, size: 'small', onClick: () => openEdit(r) }, { icon: () => h(NIcon, null, { default: () => h(CreateOutline) }) }),
|
||||||
|
h(NButton, { quaternary: true, circle: true, size: 'small', onClick: () => openReset(r) }, { icon: () => h(NIcon, null, { default: () => h(KeyOutline) }) }),
|
||||||
|
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'error', onClick: () => remove(r) }, { icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) }),
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await userApi.list({ keyword: query.keyword, 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 openCreate() {
|
||||||
|
editing.value = null;
|
||||||
|
Object.assign(form, { username: '', password: '', realName: '', role: RoleType.OPERATOR, status: UserStatus.ACTIVE });
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
function openEdit(r: any) {
|
||||||
|
editing.value = r.id;
|
||||||
|
Object.assign(form, { username: r.username, realName: r.realName || '', role: r.role, status: r.status });
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
async function save() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
if (editing.value) {
|
||||||
|
await userApi.update(editing.value, { realName: form.realName, role: form.role, status: form.status });
|
||||||
|
message.success(t('common.msg.updated'));
|
||||||
|
} else {
|
||||||
|
await userApi.create({ username: form.username, password: form.password, realName: form.realName, role: form.role });
|
||||||
|
message.success(t('common.msg.created'));
|
||||||
|
}
|
||||||
|
showModal.value = false;
|
||||||
|
load();
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function openReset(r: any) {
|
||||||
|
pwdUserId.value = r.id;
|
||||||
|
newPwd.value = '';
|
||||||
|
pwdModal.value = true;
|
||||||
|
}
|
||||||
|
async function doReset() {
|
||||||
|
if (!pwdUserId.value || newPwd.value.length < 6) {
|
||||||
|
message.error(t('pages.user.newPassword'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await userApi.resetPassword(pwdUserId.value, newPwd.value);
|
||||||
|
message.success(t('common.msg.updated'));
|
||||||
|
pwdModal.value = false;
|
||||||
|
}
|
||||||
|
function remove(r: any) {
|
||||||
|
dialog.warning({
|
||||||
|
title: t('common.action.delete'),
|
||||||
|
content: t('common.msg.confirmDelete'),
|
||||||
|
positiveText: t('common.action.confirm'),
|
||||||
|
negativeText: t('common.action.cancel'),
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
await userApi.remove(r.id);
|
||||||
|
message.success(t('common.msg.deleted'));
|
||||||
|
load();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.mr8 {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2021",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"strict": true,
|
||||||
|
"jsx": "preserve",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"lib": ["ES2021", "DOM", "DOM.Iterable"],
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue", "vite.config.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { fileURLToPath, URL } from 'node:url';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
'@artveris/shared': fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
port: 5173,
|
||||||
|
host: true,
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:3000',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
QueryTraceCodeDto,
|
QueryTraceCodeDto,
|
||||||
} from './dto/trace-code.dto';
|
} from './dto/trace-code.dto';
|
||||||
import { Roles } from '../common/decorators/roles.decorator';
|
import { Roles } from '../common/decorators/roles.decorator';
|
||||||
|
import { Public } from '../common/decorators/public.decorator';
|
||||||
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
|
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
|
||||||
|
|
||||||
@ApiTags('批量生码')
|
@ApiTags('批量生码')
|
||||||
@@ -53,6 +54,7 @@ export class TraceCodeController {
|
|||||||
return this.service.exportExcel(batchId ? Number(batchId) : undefined, res);
|
return this.service.exportExcel(batchId ? Number(batchId) : undefined, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Public()
|
||||||
@Get('trace-codes/:id/qrcode')
|
@Get('trace-codes/:id/qrcode')
|
||||||
@ApiOperation({ summary: '获取追溯码二维码 PNG' })
|
@ApiOperation({ summary: '获取追溯码二维码 PNG' })
|
||||||
async qrcode(@Param('id') id: string, @Res() res: Response) {
|
async qrcode(@Param('id') id: string, @Res() res: Response) {
|
||||||
|
|||||||
+3
-1
@@ -27,7 +27,9 @@
|
|||||||
"@nestjs/core",
|
"@nestjs/core",
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"@scarf/scarf",
|
"@scarf/scarf",
|
||||||
"msgpackr-extract"
|
"msgpackr-extract",
|
||||||
|
"vue-demi",
|
||||||
|
"esbuild"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1123
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user