fix: 完善平台国际化覆盖

This commit is contained in:
Nixevol
2026-07-05 00:53:03 +08:00
parent 66d16a6524
commit 4d32a117e2
16 changed files with 295 additions and 111 deletions
+33 -23
View File
@@ -1,11 +1,11 @@
<template>
<div class="page table-page outbound-page">
<div class="page-toolbar outbound-toolbar">
<div class="section-title">出库批量导入</div>
<div class="section-title">{{ t('pages.outbound.batchImportTitle') }}</div>
<div class="spacer" />
<n-button :title="'下载模板包'" @click="downloadTemplate">
<n-button :title="t('pages.outbound.downloadZipTemplate')" @click="downloadTemplate">
<template #icon><n-icon :component="DownloadOutline" /></template>
下载模板包
{{ t('pages.outbound.downloadZipTemplate') }}
</n-button>
<n-upload
:show-file-list="false"
@@ -15,21 +15,21 @@
>
<n-button type="primary" :loading="previewing">
<template #icon><n-icon :component="CloudUploadOutline" /></template>
上传并预览
{{ t('pages.outbound.uploadZipPreview') }}
</n-button>
</n-upload>
</div>
<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" />
<n-statistic label="有效行">
<n-statistic :label="t('pages.outbound.totalRows')" :value="session.total || 0" />
<n-statistic :label="t('pages.outbound.validRows')">
<span class="success-text">{{ session.validCount || 0 }}</span>
</n-statistic>
<n-statistic label="错误行">
<n-statistic :label="t('pages.outbound.invalidRows')">
<span class="danger-text">{{ session.invalidCount || 0 }}</span>
</n-statistic>
<n-tag :type="statusType(session.status)">{{ session.status }}</n-tag>
<n-tag :type="statusType(session.status)">{{ sessionStatusLabel(session.status) }}</n-tag>
<n-progress
v-if="busy"
type="line"
@@ -44,11 +44,11 @@
:loading="committing"
@click="commitImport"
>
确认导入
{{ t('pages.outbound.confirmImport') }}
</n-button>
<n-button v-if="result?.resultFileUrl" tag="a" :href="result.resultFileUrl" target="_blank">
<template #icon><n-icon :component="DownloadOutline" /></template>
下载导入结果
{{ t('pages.outbound.downloadResult') }}
</n-button>
</n-space>
<n-text v-if="session.error" type="error" class="session-error">{{ session.error }}</n-text>
@@ -74,6 +74,7 @@
<script setup lang="ts">
import { computed, h, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import type { UploadCustomRequestOptions } from 'naive-ui';
import { NButton, NIcon, NImage, NTag, NText, type DataTableColumns } from 'naive-ui';
import { CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5';
@@ -86,6 +87,7 @@ import { useTablePage } from '@/composables/useTablePage';
import { openMediaViewer } from '@/composables/openMediaViewer';
import { useRemoteSort } from '@/utils/tableSort';
const { t } = useI18n();
const auth = useAuthStore();
const rows = ref<any[]>([]);
const session = ref<any>(null);
@@ -105,28 +107,28 @@ const { sortProps, onSorterChange, sortParams } = useRemoteSort(() => {
});
const columns = computed<DataTableColumns<any>>(() => [
{ title: '行号', key: 'rowNo', width: 80, align: 'center' },
{ title: t('pages.outbound.rowNo'), key: 'rowNo', width: 80, align: 'center' },
{
title: '状态',
title: t('common.label.status'),
key: 'status',
width: 110,
align: 'center',
render: (row) => h(NTag, { size: 'small', type: row.status === 'VALID' || row.status === 'IMPORTED' ? 'success' : 'error' }, { default: () => row.status }),
render: (row) => h(NTag, { size: 'small', type: row.status === 'VALID' || row.status === 'IMPORTED' ? 'success' : 'error' }, { default: () => statusLabel(row.status) }),
},
{ 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), ...sortProps('outTime') },
{ title: t('pages.traceCode.shortCode'), key: 'shortCode', minWidth: 150, align: 'center', ellipsis: { tooltip: true } },
{ title: t('pages.traceCode.batchNo'), key: 'batchNo', minWidth: 180, align: 'center', ellipsis: { tooltip: true } },
{ title: t('pages.outbound.outTime'), key: 'outTime', width: 170, align: 'center', render: (row) => fmt(row.outTime || row.preview?.outTime), ...sortProps('outTime') },
{
title: '出库实况图',
title: t('pages.outbound.outImage'),
key: 'images',
width: 240,
align: 'center',
render: (row) => renderImages(row),
},
{ title: '上链哈希', key: 'txHash', minWidth: 260, ellipsis: { tooltip: true } },
{ title: '备注', key: 'remark', minWidth: 220, ellipsis: { tooltip: true } },
{ title: t('pages.blockchain.txHash'), key: 'txHash', minWidth: 260, ellipsis: { tooltip: true } },
{ title: t('common.label.remark'), key: 'remark', minWidth: 220, ellipsis: { tooltip: true } },
{
title: '错误原因',
title: t('pages.outbound.errorReason'),
key: 'reason',
minWidth: 300,
ellipsis: { tooltip: true },
@@ -188,10 +190,10 @@ async function uploadPreview({ file, onFinish, onError }: UploadCustomRequestOpt
await refreshSession();
resetPage();
await loadRows();
message.success('预览解析完成');
message.success(t('pages.outbound.previewReady'));
onFinish();
} catch (e) {
message.error((e as Error)?.message || '上传失败');
message.error(t('pages.outbound.uploadFailed'));
onError();
} finally {
previewing.value = false;
@@ -210,7 +212,7 @@ async function commitImport() {
result.value = job;
await refreshSession();
await loadRows();
message.success('导入完成');
message.success(t('pages.outbound.importDone'));
} finally {
committing.value = false;
progressPercent.value = 0;
@@ -261,6 +263,14 @@ async function loadRows() {
loading.value = false;
}
}
function statusLabel(value?: string) {
return value ? t(`pages.outbound.rowStatus.${value}`) : '-';
}
function sessionStatusLabel(value?: string) {
return value ? t(`pages.outbound.sessionStatus.${value}`) : '-';
}
</script>
<style scoped>