fix: 优化后台体验与导出日志交互
This commit is contained in:
@@ -14,7 +14,7 @@ export const authApi = {
|
||||
};
|
||||
|
||||
export const dashboardApi = {
|
||||
overview: () => get('/dashboard/overview'),
|
||||
overview: (params?: object) => get('/dashboard/overview', params),
|
||||
};
|
||||
|
||||
export const templateApi = {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
remote
|
||||
:scroll-x="1320"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -44,6 +45,7 @@ import { dialog, message } from '@/utils/feedback';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
@@ -52,12 +54,16 @@ const restoring = ref(false);
|
||||
const restorePreviewResult = ref<any>(null);
|
||||
const query = reactive({ status: null as string | null, mode: null as string | null });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, 20);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(() => {
|
||||
resetPage();
|
||||
return load();
|
||||
});
|
||||
|
||||
const statusOptions = ['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED'].map((value) => ({ label: value, value }));
|
||||
const modeOptions = ['BACKUP', 'RESTORE', 'SCHEDULED', 'AUTO_BEFORE_RESTORE'].map((value) => ({ label: value, value }));
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '创建时间', key: 'createdAt', width: 170, align: 'center', render: (row) => fmt(row.createdAt) },
|
||||
{ title: '创建时间', key: 'createdAt', width: 170, align: 'center', render: (row) => fmt(row.createdAt), ...sortProps('createdAt') },
|
||||
{ title: '文件名', key: 'fileName', minWidth: 360, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: () => renderFilterTitle('类型', query.mode, modeOptions, (value) => setFilter('mode', value)),
|
||||
@@ -143,6 +149,7 @@ async function load() {
|
||||
mode: query.mode || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<n-dropdown trigger="click" :options="options" @select="onSelect">
|
||||
<n-button quaternary :title="t('common.lang.zh')">
|
||||
<n-button quaternary :title="marker">
|
||||
<template #icon><n-icon :component="LanguageOutline" /></template>
|
||||
{{ marker }}
|
||||
</n-button>
|
||||
@@ -13,9 +13,9 @@ import { useI18n } from 'vue-i18n';
|
||||
import { LanguageOutline } from '@vicons/ionicons5';
|
||||
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const marker = computed(() => locale.value);
|
||||
const options = SUPPORTED_LOCALES.map((l) => ({ label: `${l.label}(${l.value})`, key: l.value }));
|
||||
const { locale } = useI18n();
|
||||
const marker = computed(() => SUPPORTED_LOCALES.find((l) => l.value === locale.value)?.label || locale.value);
|
||||
const options = SUPPORTED_LOCALES.map((l) => ({ label: l.label, key: l.value }));
|
||||
function onSelect(key: string) {
|
||||
setLocale(key);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="panel-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('pages.traceCode.shortCode')"
|
||||
:placeholder="t('pages.traceCode.keywordPlaceholder')"
|
||||
clearable
|
||||
class="toolbar-control"
|
||||
@keyup.enter="onSearch"
|
||||
@@ -56,6 +56,7 @@
|
||||
:scroll-x="1780"
|
||||
:row-key="(r) => r.id"
|
||||
v-model:checked-row-keys="checkedKeys"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -201,6 +202,7 @@ import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -237,6 +239,7 @@ const query = reactive<{
|
||||
keyword: '',
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, embedded.value ? 20 : 20);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
const statusOptions = Object.values(TraceCodeStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
const outboundStatusOptions = computed(() => [
|
||||
{ label: t('pages.traceCode.outRegistered'), value: 'OUTBOUND' },
|
||||
@@ -317,7 +320,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
? h(NTag, { size: 'small', type: 'success' }, { default: () => t('pages.traceCode.outRegistered') })
|
||||
: h(NText, { depth: 3 }, { default: () => t('pages.traceCode.notOutbound') }),
|
||||
},
|
||||
{ title: () => t('pages.outbound.outTime'), key: 'outTime', width: 150, align: 'center', render: (r) => fmt(r.outTime) },
|
||||
{ title: () => t('pages.outbound.outTime'), key: 'outTime', width: 150, align: 'center', render: (r) => fmt(r.outTime), ...sortProps('outTime') },
|
||||
{
|
||||
title: () => t('pages.traceCode.onchainStatus'),
|
||||
key: 'onchainStatus',
|
||||
@@ -328,8 +331,8 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
? h(NTag, { size: 'small', type: statusType(r.latestAnyProof.status) }, { default: () => t(`common.status.${r.latestAnyProof.status}`) })
|
||||
: h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noOnchain') }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120, align: 'center' },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, align: 'center', render: (r) => fmt(r.createdAt) },
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, align: 'center', render: (r) => fmt(r.createdAt), ...sortProps('createdAt') },
|
||||
{
|
||||
title: () => t('pages.traceCode.url'),
|
||||
key: 'url',
|
||||
@@ -357,7 +360,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 100, align: 'center' },
|
||||
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 150, align: 'center', render: (r) => fmt(r.firstActivatedAt) },
|
||||
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 150, align: 'center', render: (r) => fmt(r.firstActivatedAt), ...sortProps('firstActivatedAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
@@ -366,7 +369,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
align: 'center',
|
||||
render: (r) =>
|
||||
h('div', { class: 'row-actions' }, [
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', onClick: () => showQr(r) }, { icon: () => h(NIcon, null, { default: () => h(QrCodeOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('pages.traceCode.qrPreview'), onClick: () => showQr(r) }, { icon: () => h(NIcon, null, { default: () => h(QrCodeOutline) }) }),
|
||||
auth.canWrite
|
||||
? h(
|
||||
NDropdown,
|
||||
@@ -375,7 +378,7 @@ const columns = computed<DataTableColumns<any>>(() => {
|
||||
default: () =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small' },
|
||||
{ quaternary: true, circle: true, size: 'small', title: t('common.label.operation') },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(EllipsisHorizontalOutline) }) },
|
||||
),
|
||||
},
|
||||
@@ -476,6 +479,7 @@ async function load() {
|
||||
keyword: query.keyword || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
@@ -552,11 +556,11 @@ async function showQr(r: any) {
|
||||
const exportOptions = computed(() => {
|
||||
const cur = t('pages.traceCode.exportCurrent');
|
||||
const opts: Array<{ label: string; key: string }> = [
|
||||
{ label: `Excel - ${cur}`, key: 'filter' },
|
||||
{ label: cur, key: 'filter' },
|
||||
];
|
||||
if (checkedKeys.value.length) {
|
||||
const sel = t('pages.traceCode.selected', { n: checkedKeys.value.length });
|
||||
opts.push({ label: `Excel - ${sel}`, key: 'selected' });
|
||||
opts.push({ label: sel, key: 'selected' });
|
||||
}
|
||||
return opts;
|
||||
});
|
||||
@@ -575,7 +579,7 @@ async function onExport(key: string) {
|
||||
if (query.outboundStatus) params.outboundStatus = query.outboundStatus;
|
||||
if (query.keyword) params.keyword = query.keyword;
|
||||
}
|
||||
await downloadFile('/trace-codes/export', 'trace-codes.xlsx', params);
|
||||
await downloadFile('/trace-codes/export', 'trace-codes.zip', params);
|
||||
}
|
||||
|
||||
async function batchAssignGroup(key: string) {
|
||||
@@ -819,6 +823,7 @@ onMounted(async () => {
|
||||
query.artworkId = aid;
|
||||
genForm.artworkId = aid;
|
||||
}
|
||||
if (typeof route.query.status === 'string') query.status = route.query.status;
|
||||
}
|
||||
await Promise.all([loadBatches(), loadGroups()]);
|
||||
await load();
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"noData": "No data",
|
||||
"maxReached": "Up to {n} files"
|
||||
},
|
||||
"lang": { "zh": "中文", "en": "English" }
|
||||
"lang": { "zh": "Simplified Chinese", "en": "English" }
|
||||
},
|
||||
"menu": {
|
||||
"dashboard": "Dashboard",
|
||||
@@ -133,11 +133,11 @@
|
||||
"operationLogs": "Operation Logs",
|
||||
"users": "Users",
|
||||
"settings": "Settings",
|
||||
"profile": "Profile"
|
||||
"profile": "Personal Info"
|
||||
},
|
||||
"pages": {
|
||||
"login": {
|
||||
"title": "Artwork Traceability & Authentication",
|
||||
"title": "Artwork Traceability Platform",
|
||||
"subtitle": "Management Console",
|
||||
"username": "Username",
|
||||
"password": "Password",
|
||||
@@ -153,10 +153,11 @@
|
||||
"totalQueries": "Total Queries",
|
||||
"todayQueries": "Today",
|
||||
"abnormalQueries": "Abnormal",
|
||||
"trendTitle": "Queries (Last 7 Days)",
|
||||
"trendTitle": "Query Trend",
|
||||
"topTitle": "Top Queried Artworks",
|
||||
"queryCount": "Queries",
|
||||
"rank": "Rank"
|
||||
"rank": "Rank",
|
||||
"daysSuffix": "days"
|
||||
},
|
||||
"template": {
|
||||
"name": "Template Name",
|
||||
@@ -244,9 +245,10 @@
|
||||
"quantity": "Quantity",
|
||||
"generate": "Generate Trace Codes",
|
||||
"generatedCount": "Generated",
|
||||
"shortCode": "Short Code",
|
||||
"shortCode": "Trace Code",
|
||||
"code": "Trace Code",
|
||||
"url": "Short URL",
|
||||
"url": "Link",
|
||||
"keywordPlaceholder": "Trace code / link / archive no. / name",
|
||||
"queryCount": "Queries",
|
||||
"firstActivatedAt": "First Activated",
|
||||
"exportBatch": "Export Batch",
|
||||
@@ -301,7 +303,18 @@
|
||||
"successCount": "Success",
|
||||
"failCount": "Failed",
|
||||
"downloadResult": "Download Details",
|
||||
"tip": "Download the template first, fill it in and upload (xlsx). Includes outbound photo, on-chain hash/time/block height."
|
||||
"tip": "Download the template first, fill it in and upload (xlsx). Includes outbound photo, on-chain hash/time/block height.",
|
||||
"downloadZipTemplate": "Download Template ZIP",
|
||||
"uploadZipPreview": "Upload & Preview",
|
||||
"totalRows": "Rows",
|
||||
"validRows": "Valid",
|
||||
"invalidRows": "Invalid",
|
||||
"confirmImport": "Confirm Import",
|
||||
"rowNo": "Row",
|
||||
"errorReason": "Error",
|
||||
"previewReady": "Preview parsed",
|
||||
"uploadFailed": "Upload failed",
|
||||
"importDone": "Import completed"
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "Blockchain Attestation",
|
||||
@@ -320,7 +333,7 @@
|
||||
"queriedAt": "Time",
|
||||
"startTime": "Start",
|
||||
"endTime": "End",
|
||||
"keywordPlaceholder": "Short code / trace code / archive no."
|
||||
"keywordPlaceholder": "Trace code / archive no."
|
||||
},
|
||||
"user": {
|
||||
"username": "Username",
|
||||
@@ -334,19 +347,59 @@
|
||||
},
|
||||
"settings": {
|
||||
"appName": "Platform Name",
|
||||
"logRetentionDays": "Log Retention (days)",
|
||||
"logRetentionDays": "Query Log Retention (days)",
|
||||
"operationLogRetentionDays": "Operation Log Retention (days)",
|
||||
"watermarkText": "Certificate Watermark",
|
||||
"carouselInterval": "Client Carousel Interval (s)",
|
||||
"carouselIntervalHint": "Seconds each media stays; decimals allowed. 0 disables auto-advance (manual loop still works).",
|
||||
"saved": "Settings saved"
|
||||
},
|
||||
"profile": {
|
||||
"title": "Profile",
|
||||
"title": "Personal Info",
|
||||
"oldPassword": "Current Password",
|
||||
"newPassword": "New Password",
|
||||
"confirmPassword": "Confirm Password",
|
||||
"passwordMismatch": "Passwords do not match",
|
||||
"changed": "Password changed, please log in again"
|
||||
},
|
||||
"operationLog": {
|
||||
"keywordPlaceholder": "Account / summary / path / target ID",
|
||||
"module": "Module",
|
||||
"action": "Action",
|
||||
"result": "Result",
|
||||
"summary": "Summary",
|
||||
"duration": "Duration",
|
||||
"message": "Message",
|
||||
"rawTargetId": "Raw Target ID",
|
||||
"rawPath": "Raw Path",
|
||||
"requestSummary": "Request Summary",
|
||||
"modules": {
|
||||
"auth": "Auth",
|
||||
"artworks": "Artwork Files",
|
||||
"templates": "Templates",
|
||||
"traceCodes": "Trace Codes",
|
||||
"traceCodeGroups": "Trace Code Groups",
|
||||
"outbound": "Outbound Import",
|
||||
"backups": "Backup & Restore",
|
||||
"settings": "Settings",
|
||||
"users": "Users",
|
||||
"upload": "Upload",
|
||||
"download": "Download",
|
||||
"export": "Export"
|
||||
},
|
||||
"actions": {
|
||||
"login": "Sign in",
|
||||
"backup": "Create Backup",
|
||||
"restore": "Restore"
|
||||
},
|
||||
"paths": {
|
||||
"outboundPreview": "Outbound import preview",
|
||||
"outboundCommit": "Confirm outbound import",
|
||||
"traceExport": "Export trace codes and QR images",
|
||||
"backup": "Backup management",
|
||||
"restore": "Restore backup",
|
||||
"upload": "Upload file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import enUS from './en-US.json';
|
||||
|
||||
// 新增语言:在本目录添加 <locale>.json(与 zh-CN.json 同构),并在此注册即可。
|
||||
export const SUPPORTED_LOCALES = [
|
||||
{ value: 'zh-CN', label: '中文' },
|
||||
{ value: 'zh-CN', label: '简体中文' },
|
||||
{ value: 'en-US', label: 'English' },
|
||||
];
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"noData": "暂无数据",
|
||||
"maxReached": "最多上传 {n} 个"
|
||||
},
|
||||
"lang": { "zh": "中文", "en": "English" }
|
||||
"lang": { "zh": "简体中文", "en": "English" }
|
||||
},
|
||||
"menu": {
|
||||
"dashboard": "数据看板",
|
||||
@@ -133,11 +133,11 @@
|
||||
"operationLogs": "操作日志",
|
||||
"users": "用户管理",
|
||||
"settings": "系统设置",
|
||||
"profile": "个人中心"
|
||||
"profile": "个人信息"
|
||||
},
|
||||
"pages": {
|
||||
"login": {
|
||||
"title": "艺术品可信溯源与认证平台",
|
||||
"title": "艺术品溯源平台",
|
||||
"subtitle": "运营管理后台",
|
||||
"username": "用户名",
|
||||
"password": "密码",
|
||||
@@ -153,10 +153,11 @@
|
||||
"totalQueries": "总查询次数",
|
||||
"todayQueries": "今日查询",
|
||||
"abnormalQueries": "异常查询",
|
||||
"trendTitle": "近 7 日查询趋势",
|
||||
"trendTitle": "查询趋势",
|
||||
"topTitle": "高频查询作品榜",
|
||||
"queryCount": "查询次数",
|
||||
"rank": "排名"
|
||||
"rank": "排名",
|
||||
"daysSuffix": "日"
|
||||
},
|
||||
"template": {
|
||||
"name": "模板名称",
|
||||
@@ -244,9 +245,10 @@
|
||||
"quantity": "数量",
|
||||
"generate": "生成追溯码",
|
||||
"generatedCount": "已生成",
|
||||
"shortCode": "短码",
|
||||
"shortCode": "追溯码",
|
||||
"code": "追溯码",
|
||||
"url": "短链",
|
||||
"url": "链接",
|
||||
"keywordPlaceholder": "追溯码 / 链接 / 档案编号 / 名称",
|
||||
"queryCount": "查询次数",
|
||||
"firstActivatedAt": "首次激活时间",
|
||||
"exportBatch": "导出本批",
|
||||
@@ -301,7 +303,18 @@
|
||||
"successCount": "成功",
|
||||
"failCount": "失败",
|
||||
"downloadResult": "下载结果明细",
|
||||
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)。模板含出库实况图、上链哈希/时间/区块高度等字段。"
|
||||
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)。模板含出库实况图、上链哈希/时间/区块高度等字段。",
|
||||
"downloadZipTemplate": "下载模板包",
|
||||
"uploadZipPreview": "上传并预览",
|
||||
"totalRows": "总行数",
|
||||
"validRows": "有效行",
|
||||
"invalidRows": "错误行",
|
||||
"confirmImport": "确认导入",
|
||||
"rowNo": "行号",
|
||||
"errorReason": "错误原因",
|
||||
"previewReady": "预览解析完成",
|
||||
"uploadFailed": "上传失败",
|
||||
"importDone": "导入完成"
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "区块链存证",
|
||||
@@ -320,7 +333,7 @@
|
||||
"queriedAt": "查询时间",
|
||||
"startTime": "开始时间",
|
||||
"endTime": "结束时间",
|
||||
"keywordPlaceholder": "短码 / 追溯码 / 档案号"
|
||||
"keywordPlaceholder": "追溯码 / 档案号"
|
||||
},
|
||||
"user": {
|
||||
"username": "用户名",
|
||||
@@ -334,19 +347,59 @@
|
||||
},
|
||||
"settings": {
|
||||
"appName": "平台名称",
|
||||
"logRetentionDays": "日志保留天数",
|
||||
"logRetentionDays": "查询日志保留天数",
|
||||
"operationLogRetentionDays": "操作日志保留天数",
|
||||
"watermarkText": "证书水印文案",
|
||||
"carouselInterval": "客户端轮播间隔(秒)",
|
||||
"carouselIntervalHint": "每张媒体停留秒数,支持小数;填 0 则不自动切换(仍可手动循环切换)",
|
||||
"saved": "设置已保存"
|
||||
},
|
||||
"profile": {
|
||||
"title": "个人中心",
|
||||
"title": "个人信息",
|
||||
"oldPassword": "原密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmPassword": "确认新密码",
|
||||
"passwordMismatch": "两次密码不一致",
|
||||
"changed": "密码修改成功,请重新登录"
|
||||
},
|
||||
"operationLog": {
|
||||
"keywordPlaceholder": "账号 / 摘要 / 路径 / 目标 ID",
|
||||
"module": "模块",
|
||||
"action": "操作",
|
||||
"result": "结果",
|
||||
"summary": "操作摘要",
|
||||
"duration": "耗时",
|
||||
"message": "消息",
|
||||
"rawTargetId": "原始目标 ID",
|
||||
"rawPath": "原始路径",
|
||||
"requestSummary": "请求摘要",
|
||||
"modules": {
|
||||
"auth": "登录认证",
|
||||
"artworks": "艺术品档案",
|
||||
"templates": "溯源模板",
|
||||
"traceCodes": "追溯码管理",
|
||||
"traceCodeGroups": "追溯码分组",
|
||||
"outbound": "出库导入",
|
||||
"backups": "备份恢复",
|
||||
"settings": "系统设置",
|
||||
"users": "用户管理",
|
||||
"upload": "文件上传",
|
||||
"download": "文件下载",
|
||||
"export": "数据导出"
|
||||
},
|
||||
"actions": {
|
||||
"login": "登录",
|
||||
"backup": "创建备份",
|
||||
"restore": "恢复"
|
||||
},
|
||||
"paths": {
|
||||
"outboundPreview": "出库批量导入预览",
|
||||
"outboundCommit": "确认出库批量导入",
|
||||
"traceExport": "导出追溯码与二维码",
|
||||
"backup": "备份管理",
|
||||
"restore": "恢复备份",
|
||||
"upload": "上传文件"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { reactive } from 'vue';
|
||||
|
||||
export type RemoteSortOrder = 'ascend' | 'descend' | false;
|
||||
|
||||
export interface RemoteSortState {
|
||||
sortField?: string;
|
||||
sortOrder: RemoteSortOrder;
|
||||
}
|
||||
|
||||
export function useRemoteSort(onChange: () => void | Promise<void>) {
|
||||
const sortState = reactive<RemoteSortState>({ sortField: undefined, sortOrder: false });
|
||||
|
||||
function sortProps(key: string) {
|
||||
return {
|
||||
sorter: true,
|
||||
sortOrder: sortState.sortField === key ? sortState.sortOrder : false,
|
||||
};
|
||||
}
|
||||
|
||||
function onSorterChange(sorter: { columnKey?: string | number; order?: RemoteSortOrder } | null) {
|
||||
sortState.sortField = sorter?.order && sorter.columnKey ? String(sorter.columnKey) : undefined;
|
||||
sortState.sortOrder = sorter?.order || false;
|
||||
void onChange();
|
||||
}
|
||||
|
||||
function sortParams() {
|
||||
return sortState.sortField && sortState.sortOrder
|
||||
? { sortField: sortState.sortField, sortOrder: sortState.sortOrder }
|
||||
: {};
|
||||
}
|
||||
|
||||
return { sortState, sortProps, onSorterChange, sortParams };
|
||||
}
|
||||
@@ -29,6 +29,7 @@
|
||||
remote
|
||||
:scroll-x="1400"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -50,6 +51,7 @@ import { useTablePage } from '@/composables/useTablePage';
|
||||
import { dialog, message } from '@/utils/feedback';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -63,6 +65,7 @@ const query = reactive<{ keyword: string; status: string | null; auditStatus: st
|
||||
auditStatus: null,
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
const statusOptions = Object.values(ArtworkStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
@@ -82,7 +85,19 @@ const columns: DataTableColumns<any> = [
|
||||
})
|
||||
: h(NAvatar, { size: 44, style: 'border-radius:8px' }, { default: () => '—' }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.archiveNo'), key: 'archiveNo', width: 170, align: 'center', ellipsis: { tooltip: true }, render: (r) => r.archiveNo || '-' },
|
||||
{
|
||||
title: () => t('pages.artwork.archiveNo'),
|
||||
key: 'archiveNo',
|
||||
width: 170,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
render: (r) =>
|
||||
h(
|
||||
NButton,
|
||||
{ text: true, type: 'primary', title: t('pages.artwork.traceCodeManage'), onClick: () => router.push(`/artworks/${r.id}/trace-codes`) },
|
||||
{ default: () => r.archiveNo || '-' },
|
||||
),
|
||||
},
|
||||
{ title: () => t('pages.artwork.title'), key: 'title', minWidth: 220, ellipsis: { tooltip: true } },
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', minWidth: 130, ellipsis: { tooltip: true }, render: (r) => r.artist || '-' },
|
||||
{ title: () => t('pages.artwork.template'), key: 'template', minWidth: 150, ellipsis: { tooltip: true }, render: (r) => r.template?.name || '-' },
|
||||
@@ -107,7 +122,7 @@ const columns: DataTableColumns<any> = [
|
||||
{ default: () => t(`common.auditStatus.${r.auditStatus || 'PENDING'}`) },
|
||||
),
|
||||
},
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, align: 'center', ellipsis: { tooltip: true }, render: (r) => fmt(r.createdAt) },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, align: 'center', ellipsis: { tooltip: true }, render: (r) => fmt(r.createdAt), ...sortProps('createdAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
@@ -166,6 +181,7 @@ async function load() {
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
remote
|
||||
:scroll-x="1180"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -58,6 +59,7 @@ import { fmt } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -70,6 +72,7 @@ const query = reactive<{ keyword: string; auditStatus: string | null }>({
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
function auditTagType(s: string) {
|
||||
@@ -106,7 +109,7 @@ const columns: DataTableColumns<any> = [
|
||||
render: (r) => h(NTag, { size: 'small', type: auditTagType(r.auditStatus) }, { default: () => t(`common.auditStatus.${r.auditStatus}`) }),
|
||||
},
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', minWidth: 280, ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
{ title: () => t('common.label.updatedAt'), key: 'updatedAt', width: 160, align: 'center', render: (r) => fmt(r.updatedAt) },
|
||||
{ title: () => t('common.label.updatedAt'), key: 'updatedAt', width: 160, align: 'center', render: (r) => fmt(r.updatedAt), ...sortProps('updatedAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
@@ -130,6 +133,7 @@ async function load() {
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="stat-grid">
|
||||
<n-card v-for="s in stats" :key="s.key" class="stat-card" :bordered="false">
|
||||
<n-card v-for="s in stats" :key="s.key" class="stat-card clickable-card" :bordered="false" @click="s.open">
|
||||
<div class="stat-inner">
|
||||
<div class="stat-icon" :style="{ background: s.color }">
|
||||
<n-icon :component="s.icon" />
|
||||
@@ -16,7 +16,17 @@
|
||||
|
||||
<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">
|
||||
<n-card :bordered="false">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>{{ t('pages.dashboard.trendTitle') }}</span>
|
||||
<div class="range-tools">
|
||||
<n-input-number v-model:value="days" :min="1" :max="365" size="small" class="days-input" @update:value="onDaysChange" />
|
||||
<span class="range-label">{{ t('pages.dashboard.daysSuffix') }}</span>
|
||||
<n-date-picker v-model:value="range" type="datetimerange" clearable size="small" class="range-picker" @update:value="onRangeChange" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<v-chart class="chart" :option="trendOption" autoresize />
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
@@ -25,7 +35,7 @@
|
||||
<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">
|
||||
<div class="top-row top-clickable" @click="openArtworkCodes(item.artworkId)">
|
||||
<n-tag :type="i < 3 ? 'warning' : 'default'" size="small" round>{{ i + 1 }}</n-tag>
|
||||
<span class="top-title text-ellipsis">
|
||||
<span v-if="item.archiveNo" class="top-archive">{{ item.archiveNo }}</span>{{ item.title }}
|
||||
@@ -42,12 +52,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
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 dayjs from 'dayjs';
|
||||
import {
|
||||
ImagesOutline,
|
||||
QrCodeOutline,
|
||||
@@ -61,15 +73,18 @@ import { dashboardApi } from '@/api';
|
||||
use([LineChart, GridComponent, TooltipComponent, CanvasRenderer]);
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const data = ref<any>(null);
|
||||
const days = ref(7);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
|
||||
const stats = computed(() => [
|
||||
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864' },
|
||||
{ key: 'totalCodes', label: t('pages.dashboard.totalCodes'), 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' },
|
||||
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864', open: () => router.push('/artworks') },
|
||||
{ key: 'totalCodes', label: t('pages.dashboard.totalCodes'), icon: QrCodeOutline, color: '#2e5496', open: () => router.push('/trace-codes') },
|
||||
{ key: 'activatedCodes', label: t('pages.dashboard.activatedCodes'), icon: CheckmarkCircleOutline, color: '#138a72', open: () => router.push({ path: '/trace-codes', query: { status: 'ACTIVE' } }) },
|
||||
{ key: 'totalQueries', label: t('pages.dashboard.totalQueries'), icon: SearchOutline, color: '#3a7bd5', open: () => router.push('/query-logs') },
|
||||
{ key: 'todayQueries', label: t('pages.dashboard.todayQueries'), icon: TodayOutline, color: '#b9851f', open: () => router.push({ path: '/query-logs', query: { quickRange: 'today' } }) },
|
||||
{ key: 'abnormalQueries', label: t('pages.dashboard.abnormalQueries'), icon: WarningOutline, color: '#c0392b', open: () => router.push({ path: '/query-logs', query: { result: 'ABNORMAL' } }) },
|
||||
]);
|
||||
|
||||
const trendOption = computed(() => ({
|
||||
@@ -93,9 +108,31 @@ const trendOption = computed(() => ({
|
||||
],
|
||||
}));
|
||||
|
||||
onMounted(async () => {
|
||||
data.value = await dashboardApi.overview();
|
||||
});
|
||||
async function load() {
|
||||
const params: Record<string, unknown> = {};
|
||||
if (range.value) {
|
||||
params.startTime = dayjs(range.value[0]).toISOString();
|
||||
params.endTime = dayjs(range.value[1]).toISOString();
|
||||
} else {
|
||||
params.days = days.value;
|
||||
}
|
||||
data.value = await dashboardApi.overview(params);
|
||||
}
|
||||
|
||||
function onDaysChange() {
|
||||
range.value = null;
|
||||
void load();
|
||||
}
|
||||
|
||||
function onRangeChange() {
|
||||
void load();
|
||||
}
|
||||
|
||||
function openArtworkCodes(id?: number) {
|
||||
if (id) void router.push(`/artworks/${id}/trace-codes`);
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -107,6 +144,14 @@ onMounted(async () => {
|
||||
.stat-card {
|
||||
border-radius: 12px;
|
||||
}
|
||||
.clickable-card {
|
||||
cursor: pointer;
|
||||
transition: transform 0.16s ease, box-shadow 0.16s ease;
|
||||
}
|
||||
.clickable-card:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
.stat-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -137,12 +182,42 @@ onMounted(async () => {
|
||||
.chart {
|
||||
height: 320px;
|
||||
}
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.range-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.days-input {
|
||||
width: 92px;
|
||||
}
|
||||
.range-label {
|
||||
font-size: 13px;
|
||||
opacity: 0.72;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.range-picker {
|
||||
width: 310px;
|
||||
}
|
||||
.top-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
.top-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.top-clickable:hover .top-title {
|
||||
color: var(--brand);
|
||||
}
|
||||
.top-title {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input v-model:value="query.keyword" clearable placeholder="账号 / 路径 / 目标 ID" style="width: 240px" @keyup.enter="onSearch" />
|
||||
<n-input v-model:value="query.keyword" clearable :placeholder="t('pages.operationLog.keywordPlaceholder')" style="width: 260px" @keyup.enter="onSearch" />
|
||||
<n-date-picker v-model:value="range" type="datetimerange" clearable style="width: 360px" />
|
||||
<n-button type="primary" @click="onSearch">查询</n-button>
|
||||
<n-button type="primary" @click="onSearch">{{ t('common.action.search') }}</n-button>
|
||||
</div>
|
||||
|
||||
<n-data-table
|
||||
@@ -14,104 +14,189 @@
|
||||
class="table-fill operation-log-table"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1860"
|
||||
:scroll-x="1620"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
|
||||
<n-modal v-model:show="detailModal" preset="card" :title="t('common.action.detail')" style="width: 720px">
|
||||
<n-descriptions v-if="detail" :column="1" bordered label-placement="left">
|
||||
<n-descriptions-item :label="t('common.label.createdAt')">{{ fmt(detail.createdAt) }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.user.username')">{{ detail.username || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.user.role')">{{ roleLabel(detail.role) }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.operationLog.summary')">{{ operationSummary(detail) }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.operationLog.rawTargetId')">{{ detail.targetId || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.operationLog.rawPath')">{{ detail.path || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.operationLog.requestSummary')">
|
||||
<pre class="detail-json">{{ formatJson(detail.requestSummary) }}</pre>
|
||||
</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { NButton, NDropdown, NIcon, NTag, type DataTableColumns, type DropdownOption } from 'naive-ui';
|
||||
import { FilterOutline } from '@vicons/ionicons5';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NIcon, NTag, type DataTableColumns } from 'naive-ui';
|
||||
import { EyeOutline } from '@vicons/ionicons5';
|
||||
import { RoleType } from '@artveris/shared';
|
||||
import { operationLogApi } from '@/api';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
const query = reactive({ keyword: '', module: null as string | null, action: null as string | null, status: null as string | null });
|
||||
const detailModal = ref(false);
|
||||
const detail = ref<any>(null);
|
||||
const query = reactive({
|
||||
keyword: '',
|
||||
role: null as string | null,
|
||||
module: null as string | null,
|
||||
action: null as string | null,
|
||||
status: null as string | null,
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, 20);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
|
||||
const moduleOptions = [
|
||||
{ label: 'auth', value: 'auth' },
|
||||
{ label: 'artworks', value: 'artworks' },
|
||||
{ label: 'trace-codes', value: 'trace-codes' },
|
||||
{ label: 'outbound', value: 'outbound' },
|
||||
{ label: 'backups', value: 'backups' },
|
||||
{ label: 'settings', value: 'settings' },
|
||||
{ label: 'users', value: 'users' },
|
||||
];
|
||||
const actionOptions = [
|
||||
{ label: 'POST', value: 'POST' },
|
||||
{ label: 'PUT', value: 'PUT' },
|
||||
{ label: 'PATCH', value: 'PATCH' },
|
||||
{ label: 'DELETE', value: 'DELETE' },
|
||||
{ label: 'download', value: 'download' },
|
||||
{ label: 'export', value: 'export' },
|
||||
];
|
||||
const resultOptions = [
|
||||
{ label: 'SUCCESS', value: 'SUCCESS' },
|
||||
{ label: 'FAILED', value: 'FAILED' },
|
||||
];
|
||||
'auth',
|
||||
'artworks',
|
||||
'templates',
|
||||
'trace-codes',
|
||||
'trace-code-groups',
|
||||
'outbound',
|
||||
'backups',
|
||||
'settings',
|
||||
'users',
|
||||
'upload',
|
||||
'download',
|
||||
'export',
|
||||
].map((value) => ({ label: moduleLabel(value), value }));
|
||||
const actionOptions = ['login', 'create', 'update', 'delete', 'upload', 'audit', 'onchain', 'backup', 'restore', 'download', 'export'].map((value) => ({
|
||||
label: actionLabel(value),
|
||||
value,
|
||||
}));
|
||||
const resultOptions = ['SUCCESS', 'FAILED'].map((value) => ({ label: t(`common.status.${value}`), value }));
|
||||
const roleOptions = Object.values(RoleType).map((value) => ({ label: t(`common.role.${value}`), value }));
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '时间', key: 'createdAt', width: 155, align: 'center', ellipsis: { tooltip: true }, render: (row) => fmt(row.createdAt) },
|
||||
{ title: '账号', key: 'username', width: 120, ellipsis: { tooltip: true }, render: (row) => row.username || '-' },
|
||||
{ title: '角色', key: 'role', width: 130, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: t('common.label.createdAt'), key: 'createdAt', width: 160, align: 'center', ellipsis: { tooltip: true }, render: (row) => fmt(row.createdAt), ...sortProps('createdAt') },
|
||||
{ title: t('pages.user.username'), key: 'username', width: 130, ellipsis: { tooltip: true }, render: (row) => row.username || '-' },
|
||||
{
|
||||
title: () => renderFilterTitle('模块', query.module, moduleOptions, (value) => setFilter('module', value)),
|
||||
title: () => renderTableFilterTitle(t('pages.user.role'), query.role, roleOptions, (value) => setFilter('role', value)),
|
||||
key: 'role',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
render: (row) => roleLabel(row.role),
|
||||
},
|
||||
{
|
||||
title: () => renderTableFilterTitle(t('pages.operationLog.module'), query.module, moduleOptions, (value) => setFilter('module', value)),
|
||||
key: 'module',
|
||||
width: 140,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
render: (row) => moduleLabel(row.module),
|
||||
},
|
||||
{
|
||||
title: () => renderTableFilterTitle(t('pages.operationLog.action'), query.action, actionOptions, (value) => setFilter('action', value)),
|
||||
key: 'action',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
render: (row) => actionLabel(row.action),
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('操作', query.action, actionOptions, (value) => setFilter('action', value)),
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('结果', query.status, resultOptions, (value) => setFilter('status', value)),
|
||||
title: () => renderTableFilterTitle(t('pages.operationLog.result'), query.status, resultOptions, (value) => setFilter('status', value)),
|
||||
key: 'status',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
render: (row) => h(NTag, { size: 'small', type: statusType(row.status) }, { default: () => row.status }),
|
||||
render: (row) => h(NTag, { size: 'small', type: statusType(row.status) }, { default: () => t(`common.status.${row.status}`) }),
|
||||
},
|
||||
{ title: t('pages.operationLog.summary'), key: 'summary', minWidth: 360, ellipsis: { tooltip: true }, render: (row) => operationSummary(row) },
|
||||
{ title: 'IP', key: 'ip', width: 120, align: 'center', ellipsis: { tooltip: true }, render: (row) => row.ip || '-' },
|
||||
{ title: t('pages.operationLog.duration'), key: 'durationMs', width: 90, align: 'center', render: (row) => `${row.durationMs || 0}ms` },
|
||||
{ title: t('pages.operationLog.message'), key: 'message', minWidth: 260, ellipsis: { tooltip: true }, render: (row) => row.message || '-' },
|
||||
{
|
||||
title: t('common.label.operation'),
|
||||
key: 'ops',
|
||||
width: 80,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
render: (row) =>
|
||||
h('div', { class: 'row-actions' }, [
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('common.action.detail'), onClick: () => openDetail(row) }, { icon: () => h(NIcon, null, { default: () => h(EyeOutline) }) }),
|
||||
]),
|
||||
},
|
||||
{ title: '目标 ID', key: 'targetId', minWidth: 180, align: 'center', ellipsis: { tooltip: true }, render: (row) => row.targetId || '-' },
|
||||
{ title: '路径', key: 'path', minWidth: 430, ellipsis: { tooltip: true } },
|
||||
{ title: 'IP', key: 'ip', width: 100, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '耗时', key: 'durationMs', width: 90, align: 'center', ellipsis: { tooltip: true }, render: (row) => `${row.durationMs || 0}ms` },
|
||||
{ title: '消息', key: 'message', minWidth: 420, ellipsis: { tooltip: true }, render: (row) => row.message || '-' },
|
||||
]);
|
||||
|
||||
function renderFilterTitle(label: string, value: string | null, options: { label: string; value: string }[], onSelect: (value: string | null) => void) {
|
||||
const dropdownOptions: DropdownOption[] = [{ label: '全部', key: '__all__' }, ...options.map((item) => ({ label: item.label, key: item.value }))];
|
||||
return h('div', { class: 'filter-title' }, [
|
||||
h('span', { class: 'filter-title-text' }, label),
|
||||
h(
|
||||
NDropdown,
|
||||
{ trigger: 'click', options: dropdownOptions, onSelect: (key) => onSelect(key === '__all__' ? null : String(key)) },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'tiny', class: ['filter-trigger', { active: !!value }], title: '筛选' },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
|
||||
),
|
||||
},
|
||||
),
|
||||
]);
|
||||
function moduleLabel(value?: string) {
|
||||
const map: Record<string, string> = {
|
||||
auth: t('pages.operationLog.modules.auth'),
|
||||
artworks: t('pages.operationLog.modules.artworks'),
|
||||
templates: t('pages.operationLog.modules.templates'),
|
||||
'trace-codes': t('pages.operationLog.modules.traceCodes'),
|
||||
'trace-code-groups': t('pages.operationLog.modules.traceCodeGroups'),
|
||||
outbound: t('pages.operationLog.modules.outbound'),
|
||||
backups: t('pages.operationLog.modules.backups'),
|
||||
settings: t('pages.operationLog.modules.settings'),
|
||||
users: t('pages.operationLog.modules.users'),
|
||||
upload: t('pages.operationLog.modules.upload'),
|
||||
download: t('pages.operationLog.modules.download'),
|
||||
export: t('pages.operationLog.modules.export'),
|
||||
};
|
||||
return value ? map[value] || value : '-';
|
||||
}
|
||||
|
||||
function setFilter(field: 'module' | 'action' | 'status', value: string | null) {
|
||||
query[field] = value;
|
||||
function actionLabel(value?: string) {
|
||||
const map: Record<string, string> = {
|
||||
login: t('pages.operationLog.actions.login'),
|
||||
create: t('common.action.add'),
|
||||
update: t('common.action.edit'),
|
||||
delete: t('common.action.delete'),
|
||||
upload: t('common.action.upload'),
|
||||
audit: t('menu.audit'),
|
||||
onchain: t('common.action.onchain'),
|
||||
backup: t('pages.operationLog.actions.backup'),
|
||||
restore: t('pages.operationLog.actions.restore'),
|
||||
download: t('common.action.download'),
|
||||
export: t('common.action.export'),
|
||||
};
|
||||
return value ? map[value] || value : '-';
|
||||
}
|
||||
|
||||
function roleLabel(value?: string) {
|
||||
return value ? t(`common.role.${value}`) : '-';
|
||||
}
|
||||
|
||||
function pathLabel(path?: string) {
|
||||
if (!path) return '';
|
||||
if (path.includes('/outbound/import/preview')) return t('pages.operationLog.paths.outboundPreview');
|
||||
if (path.includes('/outbound/import-sessions') && path.includes('/commit')) return t('pages.operationLog.paths.outboundCommit');
|
||||
if (path.includes('/trace-codes/export')) return t('pages.operationLog.paths.traceExport');
|
||||
if (path.includes('/backups/restore')) return t('pages.operationLog.paths.restore');
|
||||
if (path.includes('/backups')) return t('pages.operationLog.paths.backup');
|
||||
if (path.includes('/upload')) return t('pages.operationLog.paths.upload');
|
||||
return '';
|
||||
}
|
||||
|
||||
function operationSummary(row: any) {
|
||||
const readablePath = pathLabel(row.path);
|
||||
if (readablePath) return readablePath;
|
||||
const target = row.targetId ? ` #${row.targetId}` : '';
|
||||
return `${actionLabel(row.action)}${moduleLabel(row.module)}${target}`;
|
||||
}
|
||||
|
||||
function setFilter(field: 'role' | 'module' | 'action' | 'status', value: string | number | null) {
|
||||
query[field] = value ? String(value) : null;
|
||||
onSearch();
|
||||
}
|
||||
|
||||
@@ -120,11 +205,13 @@ async function load() {
|
||||
try {
|
||||
const params: Record<string, unknown> = {
|
||||
keyword: query.keyword || undefined,
|
||||
role: query.role || undefined,
|
||||
module: query.module || undefined,
|
||||
action: query.action || undefined,
|
||||
status: query.status || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
};
|
||||
if (range.value) {
|
||||
params.startTime = new Date(range.value[0]).toISOString();
|
||||
@@ -143,6 +230,16 @@ function onSearch() {
|
||||
void load();
|
||||
}
|
||||
|
||||
function openDetail(row: any) {
|
||||
detail.value = row;
|
||||
detailModal.value = true;
|
||||
}
|
||||
|
||||
function formatJson(value: unknown) {
|
||||
if (!value) return '-';
|
||||
return JSON.stringify(value, null, 2);
|
||||
}
|
||||
|
||||
watch(range, onSearch);
|
||||
onMounted(load);
|
||||
</script>
|
||||
@@ -151,4 +248,11 @@ onMounted(load);
|
||||
.operation-log-table :deep(.n-data-table-td) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.detail-json {
|
||||
max-height: 260px;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="page-toolbar outbound-toolbar">
|
||||
<div class="section-title">出库批量导入</div>
|
||||
<div class="spacer" />
|
||||
<n-button @click="downloadTemplate">
|
||||
<n-button :title="'下载模板包'" @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载模板包
|
||||
</n-button>
|
||||
@@ -20,10 +20,6 @@
|
||||
</n-upload>
|
||||
</div>
|
||||
|
||||
<n-alert type="info" :show-icon="true" class="section-alert">
|
||||
ZIP 内需要包含 1 个 xlsx 文件和 images 文件夹;xlsx 中出库实况图路径填写 images/xxx.jpg,多张用英文分号分隔。
|
||||
</n-alert>
|
||||
|
||||
<n-card v-if="session" embedded class="summary-card" :bordered="false">
|
||||
<n-space align="center" size="large" wrap>
|
||||
<n-statistic label="总行数" :value="session.total || 0" />
|
||||
@@ -68,6 +64,7 @@
|
||||
remote
|
||||
:scroll-x="1480"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -87,6 +84,7 @@ import { downloadFile } from '@/utils/download';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const auth = useAuthStore();
|
||||
const rows = ref<any[]>([]);
|
||||
@@ -101,6 +99,10 @@ const progressPercent = ref(0);
|
||||
const busy = computed(() => previewing.value || committing.value);
|
||||
const canCommit = computed(() => session.value?.status === 'READY' && Number(session.value?.invalidCount || 0) === 0);
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(loadRows, 20);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(() => {
|
||||
resetPage();
|
||||
return loadRows();
|
||||
});
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '行号', key: 'rowNo', width: 80, align: 'center' },
|
||||
@@ -111,9 +113,9 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
align: 'center',
|
||||
render: (row) => h(NTag, { size: 'small', type: row.status === 'VALID' || row.status === 'IMPORTED' ? 'success' : 'error' }, { default: () => row.status }),
|
||||
},
|
||||
{ title: '追溯短码', key: 'shortCode', minWidth: 150, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '追溯码', key: 'shortCode', minWidth: 150, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '批次编号', key: 'batchNo', minWidth: 180, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '出库时间', key: 'outTime', width: 170, align: 'center', render: (row) => fmt(row.outTime || row.preview?.outTime) },
|
||||
{ title: '出库时间', key: 'outTime', width: 170, align: 'center', render: (row) => fmt(row.outTime || row.preview?.outTime), ...sortProps('outTime') },
|
||||
{
|
||||
title: '出库实况图',
|
||||
key: 'images',
|
||||
@@ -252,7 +254,7 @@ async function loadRows() {
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await outboundApi.rows(sessionId.value, { page: page.value, pageSize: pageSize.value });
|
||||
const res: any = await outboundApi.rows(sessionId.value, { page: page.value, pageSize: pageSize.value, ...sortParams() });
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
@@ -276,10 +278,6 @@ async function loadRows() {
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.section-alert {
|
||||
margin-bottom: 12px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.summary-card {
|
||||
margin-bottom: 12px;
|
||||
flex: 0 0 auto;
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<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>
|
||||
<div class="page profile-page">
|
||||
<div class="profile-grid">
|
||||
<n-card :title="t('pages.profile.title')" :bordered="false">
|
||||
<n-descriptions :column="1" label-placement="left" bordered>
|
||||
<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-card>
|
||||
|
||||
<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>
|
||||
<n-card :title="t('common.action.changePassword')" :bordered="false">
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -66,3 +69,20 @@ async function submit() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.profile-page {
|
||||
overflow: auto;
|
||||
}
|
||||
.profile-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(320px, 440px) minmax(360px, 520px);
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.profile-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
remote
|
||||
:scroll-x="1420"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -54,6 +55,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NTag, type DataTableColumns } from 'naive-ui';
|
||||
import { SearchOutline } from '@vicons/ionicons5';
|
||||
@@ -63,8 +65,10 @@ import { queryLogApi } from '@/api';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
@@ -75,6 +79,7 @@ const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; re
|
||||
result: null,
|
||||
});
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
const resultOptions = Object.values(QueryResult).map((v) => ({ label: t(`common.queryResult.${v}`), value: v }));
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
@@ -89,7 +94,7 @@ const columns: DataTableColumns<any> = [
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.queryResult) }, { default: () => t(`common.queryResult.${r.queryResult}`) }),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 100, align: 'center', render: (r) => (r.queryCount ?? '-') },
|
||||
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 160, align: 'center', render: (r) => fmt(r.firstActivatedAt) },
|
||||
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 160, align: 'center', render: (r) => fmt(r.firstActivatedAt), ...sortProps('firstActivatedAt') },
|
||||
{
|
||||
title: () => t('pages.queryLog.ip'),
|
||||
key: 'ip',
|
||||
@@ -106,7 +111,7 @@ const columns: DataTableColumns<any> = [
|
||||
ellipsis: { tooltip: true },
|
||||
render: (r) => [r.deviceType, r.os, r.browser].filter(Boolean).join(' / ') || '-',
|
||||
},
|
||||
{ title: () => t('pages.queryLog.queriedAt'), key: 'queriedAt', width: 160, align: 'center', render: (r) => fmt(r.queriedAt) },
|
||||
{ title: () => t('pages.queryLog.queriedAt'), key: 'queriedAt', width: 160, align: 'center', render: (r) => fmt(r.queriedAt), ...sortProps('queriedAt') },
|
||||
];
|
||||
|
||||
async function load() {
|
||||
@@ -121,6 +126,7 @@ async function load() {
|
||||
endTime: query.endTime,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
@@ -147,5 +153,15 @@ function setResultFilter(value: string | number | null) {
|
||||
onSearch();
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
onMounted(() => {
|
||||
if (typeof route.query.result === 'string') query.result = route.query.result;
|
||||
if (route.query.quickRange === 'today') {
|
||||
const start = dayjs().startOf('day');
|
||||
const end = dayjs().endOf('day');
|
||||
range.value = [start.valueOf(), end.valueOf()];
|
||||
query.startTime = start.toISOString();
|
||||
query.endTime = end.toISOString();
|
||||
}
|
||||
load();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<n-form-item :label="t('pages.settings.logRetentionDays')">
|
||||
<n-input-number v-model:value="form.logRetentionDays" :min="1" class="control-short" />
|
||||
</n-form-item>
|
||||
<n-form-item label="操作日志保留天数">
|
||||
<n-form-item :label="t('pages.settings.operationLogRetentionDays')">
|
||||
<n-input-number v-model:value="form.operationLogRetentionDays" :min="1" class="control-short" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.settings.carouselInterval')">
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
remote
|
||||
:scroll-x="1120"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -111,6 +112,7 @@ import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
@@ -119,6 +121,7 @@ const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive<{ keyword: string; status: string | null }>({ keyword: '', status: null });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
|
||||
const fieldTypeOptions = Object.values(FieldType).map((v) => ({ label: t(`common.fieldType.${v}`), value: v }));
|
||||
const statusOptions = Object.values(TemplateStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
@@ -131,8 +134,20 @@ const form = reactive<{ name: string; remark: string; status: string; fields: an
|
||||
const rules: FormRules = { name: { required: true, message: () => t('pages.template.namePlaceholder'), trigger: 'blur' } };
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
{ title: 'ID', key: 'id', width: 70, align: 'center' },
|
||||
{ title: () => t('pages.template.name'), key: 'name', minWidth: 220, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: 'ID',
|
||||
key: 'id',
|
||||
width: 70,
|
||||
align: 'center',
|
||||
render: (r) => h(NButton, { text: true, type: 'primary', title: t('pages.template.edit'), onClick: () => openEdit(r) }, { default: () => String(r.id) }),
|
||||
},
|
||||
{
|
||||
title: () => t('pages.template.name'),
|
||||
key: 'name',
|
||||
minWidth: 220,
|
||||
ellipsis: { tooltip: true },
|
||||
render: (r) => h(NButton, { text: true, type: 'primary', title: t('pages.template.edit'), onClick: () => openEdit(r) }, { default: () => r.name || '-' }),
|
||||
},
|
||||
{
|
||||
title: () => t('pages.template.fields'),
|
||||
key: 'fields',
|
||||
@@ -148,7 +163,7 @@ const columns: DataTableColumns<any> = [
|
||||
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, align: 'center', render: (r) => r._count?.artworks ?? 0 },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, align: 'center', render: (r) => fmt(r.createdAt) },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, align: 'center', render: (r) => fmt(r.createdAt), ...sortProps('createdAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
@@ -200,6 +215,7 @@ async function load() {
|
||||
status: query.status || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
remote
|
||||
:scroll-x="1040"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
@@ -77,12 +78,14 @@ import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive<{ keyword: string; role: string | null; status: string | null }>({ keyword: '', role: null, status: null });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const { sortProps, onSorterChange, sortParams } = useRemoteSort(onSearch);
|
||||
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 }));
|
||||
|
||||
@@ -118,7 +121,8 @@ const columns: DataTableColumns<any> = [
|
||||
align: 'center',
|
||||
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, align: 'center', render: (r) => fmt(r.lastLoginAt) },
|
||||
{ title: () => t('pages.user.lastLoginAt'), key: 'lastLoginAt', width: 160, align: 'center', render: (r) => fmt(r.lastLoginAt), ...sortProps('lastLoginAt') },
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, align: 'center', render: (r) => fmt(r.createdAt), ...sortProps('createdAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
@@ -127,9 +131,9 @@ const columns: DataTableColumns<any> = [
|
||||
align: 'center',
|
||||
render: (r) =>
|
||||
h('div', { class: 'row-actions' }, [
|
||||
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) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('common.action.edit'), onClick: () => openEdit(r) }, { icon: () => h(NIcon, null, { default: () => h(CreateOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('pages.user.resetPassword'), onClick: () => openReset(r) }, { icon: () => h(NIcon, null, { default: () => h(KeyOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'error', title: t('common.action.delete'), onClick: () => remove(r) }, { icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) }),
|
||||
]),
|
||||
},
|
||||
];
|
||||
@@ -143,6 +147,7 @@ async function load() {
|
||||
status: query.status || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
|
||||
Reference in New Issue
Block a user