feat: 完成 PRD 差距与修复,新增审核流与日志清理功能,支持出库信息与动态字段,优化 C 端用户体验
This commit is contained in:
@@ -1,65 +1,186 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<n-card :title="t('pages.outbound.import')" :bordered="false">
|
||||
<n-alert type="info" :show-icon="true" style="margin-bottom: 16px">{{ t('pages.outbound.tip') }}</n-alert>
|
||||
<n-space>
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('common.action.downloadTemplate') }}
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.xls"
|
||||
:custom-request="doImport"
|
||||
:disabled="importing || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="importing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
{{ t('pages.outbound.selectFile') }}
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
<n-card :bordered="false">
|
||||
<n-tabs type="line" animated>
|
||||
<!-- 单条录入 -->
|
||||
<n-tab-pane name="single" :tab="t('pages.outbound.single')">
|
||||
<n-form label-placement="top" style="max-width: 560px">
|
||||
<n-form-item :label="t('pages.outbound.selectCode')" required>
|
||||
<n-select
|
||||
v-model:value="form.traceCodeId"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:loading="searching"
|
||||
:options="codeOptions"
|
||||
:placeholder="t('pages.outbound.selectCodePlaceholder')"
|
||||
@search="searchCodes"
|
||||
@update:value="onPickCode"
|
||||
/>
|
||||
</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>
|
||||
<n-form-item-gi :label="t('common.label.remark')">
|
||||
<n-input v-model:value="form.remark" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
<n-form-item :label="t('pages.outbound.outImage')">
|
||||
<media-upload v-model="outImages" type="image" :max="1" />
|
||||
</n-form-item>
|
||||
|
||||
<n-card v-if="result" embedded :title="t('pages.outbound.importResult')" style="margin-top: 16px">
|
||||
<n-space align="center" size="large">
|
||||
<n-statistic :label="t('common.label.total')" :value="result.total" />
|
||||
<n-statistic :label="t('pages.outbound.successCount')">
|
||||
<span style="color: #138a72">{{ result.successCount }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic :label="t('pages.outbound.failCount')">
|
||||
<span style="color: #c0392b">{{ result.failCount }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(result.status)">{{ t(`common.status.${result.status}`) }}</n-tag>
|
||||
<n-button v-if="result.resultFileUrl" text tag="a" :href="result.resultFileUrl" target="_blank" type="primary">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('pages.outbound.downloadResult') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
<n-divider style="margin: 4px 0 14px">{{ t('pages.outbound.onchainSection') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi span="2" :label="t('pages.blockchain.txHash')">
|
||||
<n-input v-model:value="form.txHash" :placeholder="t('pages.outbound.txHashTip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.blockchain.onchainAt')">
|
||||
<n-date-picker v-model:formatted-value="form.onchainAt" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.blockchain.blockHeight')">
|
||||
<n-input-number v-model:value="form.blockHeight" :min="0" style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
||||
<n-button type="primary" :loading="saving" :disabled="!auth.canWrite || !form.traceCodeId" @click="saveSingle">
|
||||
{{ t('common.action.save') }}
|
||||
</n-button>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
|
||||
<!-- 批量导入 -->
|
||||
<n-tab-pane name="import" :tab="t('pages.outbound.import')">
|
||||
<n-alert type="info" :show-icon="true" style="margin-bottom: 16px">{{ t('pages.outbound.tip') }}</n-alert>
|
||||
<n-space>
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('common.action.downloadTemplate') }}
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.xls"
|
||||
:custom-request="doImport"
|
||||
:disabled="importing || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="importing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
{{ t('pages.outbound.selectFile') }}
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
|
||||
<n-card v-if="result" embedded :title="t('pages.outbound.importResult')" style="margin-top: 16px">
|
||||
<n-space align="center" size="large">
|
||||
<n-statistic :label="t('common.label.total', { n: result.total })" :value="result.total" />
|
||||
<n-statistic :label="t('pages.outbound.successCount')">
|
||||
<span style="color: #138a72">{{ result.successCount }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic :label="t('pages.outbound.failCount')">
|
||||
<span style="color: #c0392b">{{ result.failCount }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(result.status)">{{ t(`common.status.${result.status}`) }}</n-tag>
|
||||
<n-button v-if="result.resultFileUrl" text tag="a" :href="result.resultFileUrl" target="_blank" type="primary">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ t('pages.outbound.downloadResult') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { UploadCustomRequestOptions } from 'naive-ui';
|
||||
import { DownloadOutline, CloudUploadOutline } from '@vicons/ionicons5';
|
||||
import { jobApi, outboundApi, post } from '@/api';
|
||||
import { jobApi, outboundApi, traceCodeApi, post } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import { message } from '@/utils/feedback';
|
||||
import { statusType } from '@/utils/format';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
|
||||
/* 单条录入 */
|
||||
const saving = ref(false);
|
||||
const searching = ref(false);
|
||||
const codeOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const outImages = ref<any[]>([]);
|
||||
const form = reactive<any>({
|
||||
traceCodeId: null,
|
||||
sku: '',
|
||||
archiveNo: '',
|
||||
outTime: null,
|
||||
remark: '',
|
||||
txHash: '',
|
||||
onchainAt: null,
|
||||
blockHeight: null,
|
||||
});
|
||||
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
function searchCodes(keyword: string) {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(async () => {
|
||||
searching.value = true;
|
||||
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 : ''}`,
|
||||
value: String(c.id),
|
||||
raw: c,
|
||||
}));
|
||||
} finally {
|
||||
searching.value = false;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
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 }] : [];
|
||||
}
|
||||
async function saveSingle() {
|
||||
if (!form.traceCodeId) return;
|
||||
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,
|
||||
onchainAt: form.onchainAt ? new Date(form.onchainAt).toISOString() : undefined,
|
||||
blockHeight: form.blockHeight ?? undefined,
|
||||
remark: form.remark || undefined,
|
||||
});
|
||||
message.success(t('common.msg.saved'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* 批量导入 */
|
||||
const importing = ref(false);
|
||||
const result = ref<any>(null);
|
||||
|
||||
async function downloadTemplate() {
|
||||
await downloadFile('/outbound/import/template', 'outbound-import-template.xlsx');
|
||||
}
|
||||
|
||||
async function doImport({ file, onFinish, onError }: UploadCustomRequestOptions) {
|
||||
importing.value = true;
|
||||
result.value = null;
|
||||
|
||||
Reference in New Issue
Block a user