fix: 优化后台体验与导出日志交互
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user