refactor: 按甲方确认重构为一款多码(档案编号标识款、批次码、按款统计)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -185,52 +185,56 @@
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<!-- 追溯码与区块链 -->
|
||||
<!-- 追溯码(一款多码) -->
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.traceCode') + ' / ' + t('pages.blockchain.title')" :bordered="false">
|
||||
<div v-if="artwork?.traceCode">
|
||||
<n-descriptions :column="3" label-placement="left" bordered size="small">
|
||||
<n-descriptions-item :label="t('pages.traceCode.shortCode')">{{ artwork.traceCode.shortCode }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('common.label.status')">
|
||||
<n-tag size="small" :type="statusType(artwork.traceCode.status)">{{ t(`common.status.${artwork.traceCode.status}`) }}</n-tag>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.traceCode.queryCount')">{{ artwork.traceCode.queryCount }}</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
<div style="margin-top:12px; display:flex; gap:8px; flex-wrap:wrap">
|
||||
<n-button v-if="auth.canWrite" size="small" @click="unbind">{{ t('common.action.unbind') }}</n-button>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" :loading="onchainLoading" @click="onchain">
|
||||
<template #icon><n-icon :component="LinkOutline" /></template>
|
||||
{{ t('common.action.onchain') }}
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false">
|
||||
<template #header-extra>
|
||||
<n-space>
|
||||
<n-button v-if="auth.canWrite" size="small" type="primary" @click="genModal = true">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
{{ t('pages.artwork.genCodes') }}
|
||||
</n-button>
|
||||
</div>
|
||||
<n-data-table
|
||||
v-if="artwork.traceCode.proofs?.length"
|
||||
style="margin-top:12px"
|
||||
size="small"
|
||||
:columns="proofColumns"
|
||||
:data="artwork.traceCode.proofs"
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<n-empty :description="t('pages.artwork.noTrace')" />
|
||||
<div v-if="auth.canWrite" style="margin-top:12px; display:flex; gap:8px; align-items:center">
|
||||
<n-select
|
||||
v-model:value="bindCodeId"
|
||||
:options="unboundOptions"
|
||||
filterable
|
||||
:placeholder="t('pages.traceCode.shortCode')"
|
||||
style="width: 240px"
|
||||
@focus="loadUnbound"
|
||||
/>
|
||||
<n-button type="primary" :disabled="!bindCodeId" @click="bind">{{ t('pages.artwork.bindCode') }}</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<n-button size="small" @click="goCodes">{{ t('pages.artwork.viewCodes') }}</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
<n-descriptions :column="4" label-placement="top" bordered size="small">
|
||||
<n-descriptions-item :label="t('pages.artwork.archiveNo')">{{ artwork?.archiveNo || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.artwork.codeCount')">{{ artwork?.codeStats?.total ?? 0 }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.artwork.activeCount')">{{ artwork?.codeStats?.active ?? 0 }}</n-descriptions-item>
|
||||
<n-descriptions-item :label="t('pages.artwork.queryTotal')">{{ artwork?.codeStats?.queryTotal ?? 0 }}</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
<div class="batch-title">{{ t('pages.artwork.batches') }}</div>
|
||||
<n-empty v-if="!artwork?.batches?.length" :description="t('common.msg.noData')" size="small" />
|
||||
<n-data-table
|
||||
v-else
|
||||
size="small"
|
||||
:columns="batchColumns"
|
||||
:data="artwork.batches"
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</template>
|
||||
</n-grid>
|
||||
|
||||
<!-- 生码弹窗 -->
|
||||
<n-modal v-model:show="genModal" preset="card" :title="t('pages.artwork.genCodes')" style="width:420px">
|
||||
<n-form :model="genForm" label-placement="top">
|
||||
<n-form-item :label="t('pages.traceCode.quantity')">
|
||||
<n-input-number v-model:value="genForm.quantity" :min="1" :max="10000" style="width:100%" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.traceCode.batchNo')">
|
||||
<n-input v-model:value="genForm.batchNo" placeholder="(auto)" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align:right">
|
||||
<n-button class="mr8" @click="genModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||
<n-button type="primary" :loading="generating" @click="genCodes">{{ t('common.action.generate') }}</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
|
||||
<!-- 节点弹窗 -->
|
||||
<n-modal v-model:show="nodeModal" preset="card" :title="t('pages.artwork.addNode')" style="width:560px;max-width:94vw">
|
||||
<n-form :model="nodeForm" label-placement="top">
|
||||
@@ -297,9 +301,9 @@ import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||
import { ArrowBackOutline, AddOutline, LinkOutline } from '@vicons/ionicons5';
|
||||
import { ArrowBackOutline, AddOutline } from '@vicons/ionicons5';
|
||||
import { ArtworkStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import { artworkApi, templateApi, traceCodeApi } from '@/api';
|
||||
import { artworkApi, templateApi, traceCodeApi, jobApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import MediaSorter from '@/components/MediaSorter.vue';
|
||||
@@ -334,18 +338,6 @@ const artwork = ref<any>(null);
|
||||
const nodes = ref<any[]>([]);
|
||||
const certs = ref<any[]>([]);
|
||||
|
||||
const proofColumns: DataTableColumns<any> = [
|
||||
{ title: () => t('pages.blockchain.txHash'), key: 'txHash', ellipsis: { tooltip: true }, render: (r) => r.txHash || '-' },
|
||||
{ title: () => t('pages.blockchain.blockHeight'), key: 'blockHeight', width: 120, render: (r) => r.blockHeight || '-' },
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||
},
|
||||
{ title: () => t('pages.blockchain.onchainAt'), key: 'onchainAt', width: 160, render: (r) => fmt(r.onchainAt) },
|
||||
];
|
||||
|
||||
function onTemplateChange() {
|
||||
form.dynamicFields = {};
|
||||
}
|
||||
@@ -515,39 +507,48 @@ function removeCert(c: any) {
|
||||
});
|
||||
}
|
||||
|
||||
/* 追溯码 / 区块链 */
|
||||
const bindCodeId = ref<string | null>(null);
|
||||
const unbound = ref<any[]>([]);
|
||||
const unboundOptions = computed(() => unbound.value.map((c) => ({ label: c.shortCode, value: c.id })));
|
||||
const onchainLoading = ref(false);
|
||||
async function loadUnbound() {
|
||||
const res: any = await traceCodeApi.list({ status: 'UNBOUND', pageSize: 50 });
|
||||
unbound.value = res.list;
|
||||
}
|
||||
async function bind() {
|
||||
if (!bindCodeId.value) return;
|
||||
await traceCodeApi.bind(bindCodeId.value, artworkId.value);
|
||||
message.success(t('common.msg.saved'));
|
||||
bindCodeId.value = null;
|
||||
await loadArtwork();
|
||||
}
|
||||
async function unbind() {
|
||||
if (!artwork.value?.traceCode) return;
|
||||
await traceCodeApi.unbind(String(artwork.value.traceCode.id));
|
||||
message.success(t('common.msg.saved'));
|
||||
await loadArtwork();
|
||||
}
|
||||
async function onchain() {
|
||||
if (!artwork.value?.traceCode) return;
|
||||
onchainLoading.value = true;
|
||||
/* 追溯码(一款多码):生码 + 批次 */
|
||||
const batchColumns: DataTableColumns<any> = [
|
||||
{ title: () => t('pages.traceCode.batchNo'), key: 'batchNo' },
|
||||
{ title: () => t('pages.traceCode.quantity'), key: 'quantity', width: 90 },
|
||||
{ title: () => t('pages.traceCode.generatedCount'), key: 'generatedCount', width: 90 },
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
|
||||
},
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 160, render: (r) => fmt(r.createdAt) },
|
||||
];
|
||||
|
||||
const genModal = ref(false);
|
||||
const generating = ref(false);
|
||||
const genForm = reactive<{ quantity: number; batchNo: string }>({ quantity: 100, batchNo: '' });
|
||||
|
||||
async function genCodes() {
|
||||
generating.value = true;
|
||||
try {
|
||||
await traceCodeApi.onchain(String(artwork.value.traceCode.id));
|
||||
message.success(t('pages.blockchain.triggered'));
|
||||
setTimeout(loadArtwork, 1500);
|
||||
const res: any = await traceCodeApi.generate({
|
||||
artworkId: artworkId.value,
|
||||
quantity: genForm.quantity,
|
||||
batchNo: genForm.batchNo || undefined,
|
||||
});
|
||||
message.success(t('pages.traceCode.genSuccess'));
|
||||
for (let i = 0; i < 30; i++) {
|
||||
await new Promise((r) => setTimeout(r, 700));
|
||||
const job: any = await jobApi.get(res.jobId);
|
||||
if (['SUCCESS', 'FAILED', 'PARTIAL'].includes(job.status)) break;
|
||||
}
|
||||
genModal.value = false;
|
||||
genForm.batchNo = '';
|
||||
await loadArtwork();
|
||||
} finally {
|
||||
onchainLoading.value = false;
|
||||
generating.value = false;
|
||||
}
|
||||
}
|
||||
function goCodes() {
|
||||
router.push({ name: 'traceCodes', query: { artworkId: String(artworkId.value) } });
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadTemplates();
|
||||
@@ -563,6 +564,11 @@ onMounted(async () => {
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.batch-title {
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
margin: 14px 0 8px;
|
||||
}
|
||||
.node-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -75,18 +75,12 @@ const columns: DataTableColumns<any> = [
|
||||
? h(NAvatar, { src: r.images[0].url, size: 44, style: 'border-radius:8px' })
|
||||
: h(NAvatar, { size: 44, style: 'border-radius:8px' }, { default: () => '—' }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.archiveNo'), key: 'archiveNo', width: 140, render: (r) => r.archiveNo || '-' },
|
||||
{ title: () => t('pages.artwork.title'), key: 'title', ellipsis: { tooltip: true } },
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', width: 120, render: (r) => r.artist || '-' },
|
||||
{ title: () => t('pages.artwork.template'), key: 'template', width: 130, render: (r) => r.template?.name || '-' },
|
||||
{
|
||||
title: () => t('pages.artwork.traceCode'),
|
||||
key: 'traceCode',
|
||||
width: 130,
|
||||
render: (r) =>
|
||||
r.traceCode
|
||||
? h(NTag, { size: 'small', type: statusType(r.traceCode.status) }, { default: () => r.traceCode.shortCode })
|
||||
: h(NTag, { size: 'small' }, { default: () => t('pages.artwork.noTrace') }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', width: 110, render: (r) => r.artist || '-' },
|
||||
{ title: () => t('pages.artwork.template'), key: 'template', width: 120, render: (r) => r.template?.name || '-' },
|
||||
{ title: () => t('pages.artwork.codeCount'), key: 'codeCount', width: 80, render: (r) => r.codeCount ?? 0 },
|
||||
{ title: () => t('pages.artwork.queryTotal'), key: 'queryTotal', width: 90, render: (r) => r.queryTotal ?? 0 },
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
key: 'status',
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
<n-list-item v-for="(item, i) in data.topArtworks" :key="i">
|
||||
<div class="top-row">
|
||||
<n-tag :type="i < 3 ? 'warning' : 'default'" size="small" round>{{ i + 1 }}</n-tag>
|
||||
<span class="top-title text-ellipsis">{{ item.title }}</span>
|
||||
<span class="top-title text-ellipsis">
|
||||
<span v-if="item.archiveNo" class="top-archive">{{ item.archiveNo }}</span>{{ item.title }}
|
||||
</span>
|
||||
<span class="top-count">{{ item.queryCount }}</span>
|
||||
</div>
|
||||
</n-list-item>
|
||||
@@ -63,7 +65,7 @@ const data = ref<any>(null);
|
||||
|
||||
const stats = computed(() => [
|
||||
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864' },
|
||||
{ key: 'boundCodes', label: t('pages.dashboard.boundCodes'), icon: QrCodeOutline, color: '#2e5496' },
|
||||
{ key: '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' },
|
||||
@@ -144,6 +146,11 @@ onMounted(async () => {
|
||||
.top-title {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.top-archive {
|
||||
color: var(--brand);
|
||||
font-size: 12px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.top-count {
|
||||
font-weight: 600;
|
||||
color: var(--brand);
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi :label="t('pages.outbound.sku')">
|
||||
<n-input v-model:value="form.sku" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.outbound.archiveNo')">
|
||||
<n-input v-model:value="form.archiveNo" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.outbound.outTime')">
|
||||
<n-date-picker v-model:formatted-value="form.outTime" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
@@ -120,8 +114,6 @@ const codeOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const outImages = ref<any[]>([]);
|
||||
const form = reactive<any>({
|
||||
traceCodeId: null,
|
||||
sku: '',
|
||||
archiveNo: '',
|
||||
outTime: null,
|
||||
remark: '',
|
||||
txHash: '',
|
||||
@@ -137,7 +129,7 @@ function searchCodes(keyword: string) {
|
||||
try {
|
||||
const res: any = await traceCodeApi.list({ keyword: keyword || undefined, pageSize: 20 });
|
||||
codeOptions.value = res.list.map((c: any) => ({
|
||||
label: `${c.shortCode}${c.artwork ? ' · ' + c.artwork.title : ''}${c.sku ? ' · ' + c.sku : ''}`,
|
||||
label: `${c.shortCode}${c.artwork ? ' · ' + (c.artwork.archiveNo || c.artwork.title) : ''}`,
|
||||
value: String(c.id),
|
||||
raw: c,
|
||||
}));
|
||||
@@ -149,8 +141,6 @@ function searchCodes(keyword: string) {
|
||||
function onPickCode(_id: string, opt: any) {
|
||||
const c = opt?.raw;
|
||||
if (!c) return;
|
||||
form.sku = c.sku || '';
|
||||
form.archiveNo = c.archiveNo || '';
|
||||
form.remark = c.remark || '';
|
||||
outImages.value = c.outImage ? [{ key: c.outImage, url: c.outImage, name: c.outImage }] : [];
|
||||
}
|
||||
@@ -159,8 +149,6 @@ async function saveSingle() {
|
||||
saving.value = true;
|
||||
try {
|
||||
await outboundApi.updateSingle(form.traceCodeId, {
|
||||
sku: form.sku || undefined,
|
||||
archiveNo: form.archiveNo || undefined,
|
||||
outTime: form.outTime ? new Date(form.outTime).toISOString() : undefined,
|
||||
outImageKey: outImages.value[0]?.key || undefined,
|
||||
txHash: form.txHash || undefined,
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-input
|
||||
v-model:value="query.sku"
|
||||
placeholder="SKU"
|
||||
v-model:value="query.archiveNo"
|
||||
:placeholder="t('pages.artwork.archiveNo')"
|
||||
clearable
|
||||
style="width: 130px"
|
||||
style="width: 150px"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-input
|
||||
@@ -69,9 +69,9 @@ const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
const query = reactive<{ keyword: string; sku: string; batchNo: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
keyword: '',
|
||||
sku: '',
|
||||
archiveNo: '',
|
||||
batchNo: '',
|
||||
result: null,
|
||||
page: 1,
|
||||
@@ -82,8 +82,7 @@ const resultOptions = Object.values(QueryResult).map((v) => ({ label: t(`common.
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120, render: (r) => r.shortCode || '-' },
|
||||
{ title: 'SKU', key: 'sku', width: 120, render: (r) => r.sku || '-' },
|
||||
{ title: () => t('pages.traceCode.archiveNo'), key: 'archiveNo', width: 110, render: (r) => r.archiveNo || '-' },
|
||||
{ title: () => t('pages.artwork.archiveNo'), key: 'archiveNo', width: 140, render: (r) => r.archiveNo || '-' },
|
||||
{ title: () => t('pages.traceCode.batchNo'), key: 'batchNo', width: 130, render: (r) => r.batchNo || '-' },
|
||||
{
|
||||
title: () => t('pages.queryLog.result'),
|
||||
@@ -113,7 +112,7 @@ async function load() {
|
||||
try {
|
||||
const res: any = await queryLogApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
sku: query.sku || undefined,
|
||||
archiveNo: query.archiveNo || undefined,
|
||||
batchNo: query.batchNo || undefined,
|
||||
result: query.result || undefined,
|
||||
startTime: query.startTime,
|
||||
|
||||
@@ -82,6 +82,18 @@
|
||||
<!-- 生成 -->
|
||||
<n-modal v-model:show="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 440px">
|
||||
<n-form :model="genForm" label-placement="top">
|
||||
<n-form-item :label="t('pages.artwork.selectArtwork')" required>
|
||||
<n-select
|
||||
v-model:value="genForm.artworkId"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:loading="artworkSearching"
|
||||
:options="artworkOptions"
|
||||
:placeholder="t('pages.artwork.selectArtworkTip')"
|
||||
@search="searchArtworks"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.traceCode.quantity')">
|
||||
<n-input-number v-model:value="genForm.quantity" :min="1" :max="10000" style="width: 100%" />
|
||||
</n-form-item>
|
||||
@@ -135,23 +147,26 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NButton, NIcon, NTag, NText, type DataTableColumns } from 'naive-ui';
|
||||
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline } from '@vicons/ionicons5';
|
||||
import { TraceCodeStatus } from '@artveris/shared';
|
||||
import { traceCodeApi, jobApi } from '@/api';
|
||||
import { traceCodeApi, jobApi, artworkApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const auth = useAuthStore();
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
const query = reactive<{ groupId: number | null; batchId: number | null; status: string | null; keyword: string; page: number; pageSize: number }>({
|
||||
const query = reactive<{ artworkId: number | null; groupId: number | null; batchId: number | null; status: string | null; keyword: string; page: number; pageSize: number }>({
|
||||
artworkId: null,
|
||||
groupId: null,
|
||||
batchId: null,
|
||||
status: null,
|
||||
@@ -174,7 +189,26 @@ const groupAssignOptions = computed(() => [
|
||||
|
||||
const genModal = ref(false);
|
||||
const generating = ref(false);
|
||||
const genForm = reactive<{ quantity: number; batchNo: string; groupId: number | null }>({ quantity: 100, batchNo: '', groupId: null });
|
||||
const genForm = reactive<{ artworkId: number | null; quantity: number; batchNo: string; groupId: number | null }>({ artworkId: null, quantity: 100, batchNo: '', groupId: null });
|
||||
|
||||
const artworkSearching = ref(false);
|
||||
const artworkOptions = ref<{ label: string; value: number }[]>([]);
|
||||
let artworkTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
function searchArtworks(keyword: string) {
|
||||
if (artworkTimer) clearTimeout(artworkTimer);
|
||||
artworkTimer = setTimeout(async () => {
|
||||
artworkSearching.value = true;
|
||||
try {
|
||||
const res: any = await artworkApi.list({ keyword: keyword || undefined, pageSize: 20 });
|
||||
artworkOptions.value = res.list.map((a: any) => ({
|
||||
label: `${a.archiveNo || '-'} · ${a.title}`,
|
||||
value: a.id,
|
||||
}));
|
||||
} finally {
|
||||
artworkSearching.value = false;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
const qrModal = ref(false);
|
||||
const qrSrc = ref('');
|
||||
@@ -198,8 +232,9 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
[r.url, h(NIcon, { component: OpenOutline, style: 'vertical-align:-2px;margin-left:4px' })],
|
||||
),
|
||||
},
|
||||
{ title: () => t('pages.traceCode.group'), key: 'group', width: 110, render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }) },
|
||||
{ title: () => t('pages.artwork.title'), key: 'artwork', width: 140, render: (r) => r.artwork?.title || '-' },
|
||||
{ title: () => t('pages.traceCode.group'), key: 'group', width: 100, render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }) },
|
||||
{ title: () => t('pages.artwork.archiveNo'), key: 'archiveNo', width: 130, render: (r) => r.artwork?.archiveNo || '-' },
|
||||
{ title: () => t('pages.artwork.title'), key: 'artwork', width: 130, render: (r) => r.artwork?.title || '-' },
|
||||
{
|
||||
title: () => t('common.label.status'),
|
||||
key: 'status',
|
||||
@@ -230,6 +265,7 @@ async function load() {
|
||||
checkedKeys.value = [];
|
||||
try {
|
||||
const res: any = await traceCodeApi.list({
|
||||
artworkId: query.artworkId || undefined,
|
||||
groupId: query.groupId || undefined,
|
||||
batchId: query.batchId || undefined,
|
||||
status: query.status || undefined,
|
||||
@@ -254,9 +290,14 @@ function onPage(p: number) {
|
||||
}
|
||||
|
||||
async function generate() {
|
||||
if (!genForm.artworkId) {
|
||||
message.error(t('pages.artwork.selectArtworkTip'));
|
||||
return;
|
||||
}
|
||||
generating.value = true;
|
||||
try {
|
||||
const res: any = await traceCodeApi.generate({
|
||||
artworkId: genForm.artworkId,
|
||||
quantity: genForm.quantity,
|
||||
batchNo: genForm.batchNo || undefined,
|
||||
groupId: genForm.groupId || undefined,
|
||||
@@ -300,6 +341,7 @@ async function onExport(key: string) {
|
||||
if (scope === 'selected') {
|
||||
params.ids = checkedKeys.value.map(String).join(',');
|
||||
} else {
|
||||
if (query.artworkId) params.artworkId = query.artworkId;
|
||||
if (query.groupId) params.groupId = query.groupId;
|
||||
if (query.batchId) params.batchId = query.batchId;
|
||||
if (query.status) params.status = query.status;
|
||||
@@ -356,6 +398,9 @@ function removeGroup(g: any) {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 支持从作品详情跳转:?artworkId=xx 直接筛选该款的码
|
||||
const aid = Number(route.query.artworkId);
|
||||
if (aid) query.artworkId = aid;
|
||||
await Promise.all([loadBatches(), loadGroups()]);
|
||||
await load();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user