fix: 优化后台体验与导出日志交互

This commit is contained in:
Nixevol
2026-07-05 00:04:35 +08:00
parent 935375a904
commit 4122897725
44 changed files with 798 additions and 221 deletions
+18 -2
View File
@@ -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);
+5 -1
View File
@@ -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);
+87 -12
View File
@@ -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;
}
+167 -63
View File
@@ -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>
+10 -12
View File
@@ -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;
+41 -21
View File
@@ -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>
+19 -3
View File
@@ -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>
+1 -1
View File
@@ -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')">
+19 -3
View File
@@ -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);
+9 -4
View File
@@ -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);