feat: 完成 PRD 差距与修复,新增审核流与日志清理功能,支持出库信息与动态字段,优化 C 端用户体验
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('common.label.keyword')"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-select
|
||||
v-model:value="query.auditStatus"
|
||||
:options="auditStatusOptions"
|
||||
clearable
|
||||
:placeholder="t('pages.audit.status')"
|
||||
style="width: 150px"
|
||||
@update:value="onSearch"
|
||||
/>
|
||||
<n-button type="primary" @click="onSearch">
|
||||
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||
{{ t('common.action.search') }}
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="rejectModal" preset="card" :title="t('pages.audit.reject')" style="width: 420px">
|
||||
<n-form label-placement="top">
|
||||
<n-form-item :label="t('pages.audit.remark')">
|
||||
<n-input v-model:value="rejectRemark" type="textarea" :rows="3" :placeholder="t('pages.audit.remarkPlaceholder')" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
<n-button class="mr8" @click="rejectModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||
<n-button type="error" :loading="acting" @click="doReject">{{ t('pages.audit.reject') }}</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NIcon, NTag, NAvatar, type DataTableColumns } from 'naive-ui';
|
||||
import { SearchOutline, EyeOutline, CheckmarkCircleOutline, CloseCircleOutline } from '@vicons/ionicons5';
|
||||
import { AuditStatus } from '@artveris/shared';
|
||||
import { auditApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt } from '@/utils/format';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const acting = ref(false);
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null; page: number; pageSize: number }>({
|
||||
keyword: '',
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
function auditTagType(s: string) {
|
||||
return s === 'APPROVED' ? 'success' : s === 'REJECTED' ? 'error' : 'warning';
|
||||
}
|
||||
|
||||
const rejectModal = ref(false);
|
||||
const rejectRemark = ref('');
|
||||
const rejectId = ref<number | null>(null);
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
{
|
||||
title: () => t('pages.artwork.images'),
|
||||
key: 'cover',
|
||||
width: 70,
|
||||
render: (r) =>
|
||||
r.images?.[0]?.url
|
||||
? h(NAvatar, { src: r.images[0].url, size: 40, style: 'border-radius:8px' })
|
||||
: h(NAvatar, { size: 40, style: 'border-radius:8px' }, { default: () => '—' }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.title'), key: 'title', ellipsis: { tooltip: true } },
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', width: 110, render: (r) => r.artist || '-' },
|
||||
{
|
||||
title: () => t('pages.audit.status'),
|
||||
key: 'auditStatus',
|
||||
width: 100,
|
||||
render: (r) => h(NTag, { size: 'small', type: auditTagType(r.auditStatus) }, { default: () => t(`common.auditStatus.${r.auditStatus}`) }),
|
||||
},
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
{ title: () => t('common.label.updatedAt'), key: 'updatedAt', width: 160, render: (r) => fmt(r.updatedAt) },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
key: 'ops',
|
||||
width: 150,
|
||||
render: (r) =>
|
||||
h('div', { style: 'display:flex;gap:2px' }, [
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', title: t('common.action.detail'), onClick: () => router.push(`/artworks/${r.id}`) }, { icon: () => h(NIcon, null, { default: () => h(EyeOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'success', title: t('pages.audit.approve'), disabled: r.auditStatus === 'APPROVED', onClick: () => approve(r) }, { icon: () => h(NIcon, null, { default: () => h(CheckmarkCircleOutline) }) }),
|
||||
h(NButton, { quaternary: true, circle: true, size: 'small', type: 'error', title: t('pages.audit.reject'), disabled: r.auditStatus === 'REJECTED', onClick: () => openReject(r) }, { icon: () => h(NIcon, null, { default: () => h(CloseCircleOutline) }) }),
|
||||
]),
|
||||
},
|
||||
];
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await auditApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
});
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
load();
|
||||
}
|
||||
function approve(r: any) {
|
||||
dialog.success({
|
||||
title: t('pages.audit.approve'),
|
||||
content: t('pages.audit.approveConfirm', { title: r.title }),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await auditApi.audit(r.id, { approved: true });
|
||||
message.success(t('pages.audit.approved'));
|
||||
load();
|
||||
},
|
||||
});
|
||||
}
|
||||
function openReject(r: any) {
|
||||
rejectId.value = r.id;
|
||||
rejectRemark.value = '';
|
||||
rejectModal.value = true;
|
||||
}
|
||||
async function doReject() {
|
||||
if (rejectId.value === null) return;
|
||||
acting.value = true;
|
||||
try {
|
||||
await auditApi.audit(rejectId.value, { approved: false, remark: rejectRemark.value });
|
||||
message.success(t('pages.audit.rejected'));
|
||||
rejectModal.value = false;
|
||||
load();
|
||||
} finally {
|
||||
acting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user