feat(i18n): 将前端用户可见中文硬编码改为四语言
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dce915ea30
commit
ac7b53a523
105 files changed
+2928
-647
No files matched your search
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Copy, Download, Edit2, Eye, LayoutGrid, MessageSquareText, RotateCw, X } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBlock.vue';
|
||||
@@ -85,6 +86,7 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const { t } = useI18n();
|
||||
const INLINE_DOWNLOAD_ALLOWED_EMPLOYEE_ID = '17070141';
|
||||
const RESTRICTED_INLINE_DOWNLOAD_FILE_NAME = '资产明细全量导出表.csv';
|
||||
|
||||
@@ -149,56 +151,57 @@ interface InlineFileEntry {
|
||||
table: InlinePreviewTable;
|
||||
}
|
||||
|
||||
const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
id: '序号',
|
||||
asset_id: '资产编号',
|
||||
asset_no: '资产编号',
|
||||
asset_name: '资产名称',
|
||||
currency_amount: '本币金额(元)',
|
||||
specification: '规格型号',
|
||||
account_period: '账套',
|
||||
operating_center_code: '账套',
|
||||
custodian_person: '保管人',
|
||||
custodian_name: '保管人',
|
||||
custodian_dept: '保管部门',
|
||||
department_name: '保管部门',
|
||||
image: '图片',
|
||||
picture: '图片',
|
||||
storage_location: '存放位置名称',
|
||||
location_name: '存放位置名称',
|
||||
asset_status: '资产状态',
|
||||
reserved_field: '预留残值',
|
||||
residual_value: '预留残值',
|
||||
supplier: '供应商',
|
||||
vendor_name: '供应商',
|
||||
asset_nature: '资产性质',
|
||||
nature: '资产性质',
|
||||
amount_local: '本币金额(元)',
|
||||
unit_price: '本币金额(元)',
|
||||
quantity: '数量',
|
||||
unit: '计量单位',
|
||||
unit_of_measurement: '计量单位',
|
||||
acquisition_date: '取得时间',
|
||||
acquired_date: '取得时间',
|
||||
accounting_date: '入账日期',
|
||||
recorded_date: '入账日期',
|
||||
created_at: '创建时间',
|
||||
created_time: '创建时间',
|
||||
updated_at: '更新时间',
|
||||
snapshot_time: '快照时间',
|
||||
/** 英文字段名 → chat.assetColumns.* key(展示用;匹配仍用 aliases 中的中英文别名) */
|
||||
const FIXED_ASSET_HEADER_KEYS: Record<string, string> = {
|
||||
id: 'chat.assetColumns.id',
|
||||
asset_id: 'chat.assetColumns.assetId',
|
||||
asset_no: 'chat.assetColumns.assetId',
|
||||
asset_name: 'chat.assetColumns.assetName',
|
||||
currency_amount: 'chat.assetColumns.currencyAmount',
|
||||
specification: 'chat.assetColumns.specification',
|
||||
account_period: 'chat.assetColumns.accountPeriod',
|
||||
operating_center_code: 'chat.assetColumns.accountPeriod',
|
||||
custodian_person: 'chat.assetColumns.custodianPerson',
|
||||
custodian_name: 'chat.assetColumns.custodianPerson',
|
||||
custodian_dept: 'chat.assetColumns.custodianDept',
|
||||
department_name: 'chat.assetColumns.custodianDept',
|
||||
image: 'chat.assetColumns.image',
|
||||
picture: 'chat.assetColumns.image',
|
||||
storage_location: 'chat.assetColumns.storageLocation',
|
||||
location_name: 'chat.assetColumns.storageLocation',
|
||||
asset_status: 'chat.assetColumns.assetStatus',
|
||||
reserved_field: 'chat.assetColumns.residualValue',
|
||||
residual_value: 'chat.assetColumns.residualValue',
|
||||
supplier: 'chat.assetColumns.supplier',
|
||||
vendor_name: 'chat.assetColumns.supplier',
|
||||
asset_nature: 'chat.assetColumns.assetNature',
|
||||
nature: 'chat.assetColumns.assetNature',
|
||||
amount_local: 'chat.assetColumns.currencyAmount',
|
||||
unit_price: 'chat.assetColumns.currencyAmount',
|
||||
quantity: 'chat.assetColumns.quantity',
|
||||
unit: 'chat.assetColumns.unit',
|
||||
unit_of_measurement: 'chat.assetColumns.unit',
|
||||
acquisition_date: 'chat.assetColumns.acquisitionDate',
|
||||
acquired_date: 'chat.assetColumns.acquisitionDate',
|
||||
accounting_date: 'chat.assetColumns.accountingDate',
|
||||
recorded_date: 'chat.assetColumns.accountingDate',
|
||||
created_at: 'chat.assetColumns.createdAt',
|
||||
created_time: 'chat.assetColumns.createdAt',
|
||||
updated_at: 'chat.assetColumns.updatedAt',
|
||||
snapshot_time: 'chat.assetColumns.snapshotTime',
|
||||
};
|
||||
const FIXED_ASSET_CANONICAL_COLUMNS = [
|
||||
{ key: 'id', label: '序号', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', label: '资产编号', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', label: '资产名称', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', label: '保管人', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', label: '保管部门', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', label: '图片', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', label: '账套', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', label: '供应商', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', label: '资产状态', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', label: '数量', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', label: '取得时间', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
{ key: 'id', labelKey: 'chat.assetColumns.id', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', labelKey: 'chat.assetColumns.assetId', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', labelKey: 'chat.assetColumns.assetName', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', labelKey: 'chat.assetColumns.custodianPerson', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', labelKey: 'chat.assetColumns.custodianDept', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', labelKey: 'chat.assetColumns.image', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', labelKey: 'chat.assetColumns.accountPeriod', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', labelKey: 'chat.assetColumns.supplier', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', labelKey: 'chat.assetColumns.assetStatus', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', labelKey: 'chat.assetColumns.quantity', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', labelKey: 'chat.assetColumns.acquisitionDate', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
] as const;
|
||||
const INLINE_DIALOG_PAGE_SIZE = 15;
|
||||
|
||||
@@ -238,14 +241,15 @@ function parseCsvLine(line: string): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的中文列名。
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的本地化列名。
|
||||
* 核心逻辑:优先命中已知字段映射;未知字段保留原值,避免误伤其他 Agent 的文件。
|
||||
* @param header - CSV 原始表头。
|
||||
* @returns 中文表头或原始表头。
|
||||
* @returns 本地化表头或原始表头。
|
||||
*/
|
||||
function localizeInlineTableHeader(header: string): string {
|
||||
const normalizedHeader = String(header || '').trim().toLowerCase();
|
||||
return FIXED_ASSET_HEADER_LABELS[normalizedHeader] || header || '-';
|
||||
const key = FIXED_ASSET_HEADER_KEYS[normalizedHeader];
|
||||
return key ? t(key) : (header || '-');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,14 +272,14 @@ function formatInlineDateOnly(value: string): string {
|
||||
|
||||
/**
|
||||
* 统一表格中的空值展示。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示“无”,但保留数字 0 与正常文本。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示本地化“无”,但保留数字 0 与正常文本。
|
||||
* @param value - 原始单元格值。
|
||||
* @returns 归一化后的展示值。
|
||||
*/
|
||||
function normalizeInlineTableCell(value: string): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
if (!normalized) return '无';
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return '无';
|
||||
if (!normalized) return t('chat.assetColumns.empty');
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return t('chat.assetColumns.empty');
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -338,7 +342,7 @@ function serializeCsvRows(rows: string[][]): string {
|
||||
* @returns 规范化后的表头与数据行。
|
||||
*/
|
||||
function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]): InlinePreviewTable {
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.label);
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => t(column.labelKey));
|
||||
const canonicalHeaders = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.key);
|
||||
const allRows = dataRows.map((row, rowIndex) => FIXED_ASSET_CANONICAL_COLUMNS.map((column) => {
|
||||
if (column.key === 'id') return String(rowIndex + 1);
|
||||
@@ -352,7 +356,7 @@ function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]):
|
||||
if (normalizedImageValue) {
|
||||
return normalizeInlineTableCell(normalizedImageValue);
|
||||
}
|
||||
return normalizedAssetId ? '查看' : '无';
|
||||
return normalizedAssetId ? t('chat.assetColumns.view') : t('chat.assetColumns.empty');
|
||||
}
|
||||
const columnIndex = findInlineTableHeaderIndex(rawHeaders, [...column.aliases]);
|
||||
const rawValue = columnIndex >= 0 ? row[columnIndex] ?? '' : '';
|
||||
@@ -573,7 +577,10 @@ function canOpenInlineAssetHistory(cellIndex: number, cellValue: string): boolea
|
||||
}
|
||||
|
||||
function isInlineHighlightHeader(header: string): boolean {
|
||||
return header === '资产编号' || header === '图片';
|
||||
return header === t('chat.assetColumns.assetId')
|
||||
|| header === t('chat.assetColumns.image')
|
||||
|| header === '资产编号'
|
||||
|| header === '图片';
|
||||
}
|
||||
|
||||
async function openInlineAssetHistory(row: string[], cellIndex: number): Promise<void> {
|
||||
@@ -911,7 +918,7 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.inlineFile.download') }}
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="closeInlinePreviewDialog">
|
||||
<button type="button" class="btn-icon-ds" :aria-label="$t('common.close')" @click="closeInlinePreviewDialog">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user