feat(chat-fixed-assets): 支持资产履历直达预览并优化 Excel 预览体验

This commit is contained in:
runny committed 2026-07-03 18:59:27 +08:00
1 parent 1164ae2e3c
commit 56b6ea06a8
14 files changed
+1051 -48

No files matched your search

@@ -18,11 +18,29 @@ const props = defineProps<{
const emit = defineEmits<{
close: [];
'change-page': [delta: number];
'open-asset-history': [payload: { assetId: string; assetName: string }];
}>();
const totalPages = computed(() =>
Math.max(1, Math.ceil((props.state.total || 0) / (props.state.pageSize || 100))),
);
const assetIdColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产编号'));
const assetNameColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产名称'));
function normalizeCellText(cell: unknown): string {
return String(cell ?? '').trim();
}
function canOpenAssetHistory(row: unknown[], cellIndex: number): boolean {
return cellIndex === assetIdColumnIndex.value && !!normalizeCellText(row[cellIndex]);
}
function emitAssetHistory(row: unknown[]): void {
const assetId = normalizeCellText(row[assetIdColumnIndex.value]);
const assetName = assetNameColumnIndex.value >= 0 ? normalizeCellText(row[assetNameColumnIndex.value]) : '';
if (!assetId) return;
emit('open-asset-history', { assetId, assetName });
}
</script>
<template>
@@ -96,7 +114,15 @@ const totalPages = computed(() =>
:key="`query-preview-cell-${rowIndex}-${cellIndex}`"
class="max-w-[320px] border border-slate-200 px-3 py-2 align-top text-secondary"
>
<div class="whitespace-pre-wrap break-all">{{ cell ?? '-' }}</div>
<button
v-if="canOpenAssetHistory(row, cellIndex)"
type="button"
class="whitespace-pre-wrap break-all text-left font-medium text-brand-600 underline-offset-2 transition hover:underline"
@click="emitAssetHistory(row)"
>
{{ cell ?? '-' }}
</button>
<div v-else class="whitespace-pre-wrap break-all">{{ cell ?? '-' }}</div>
</td>
</tr>
</tbody>