Merge branch 'dev' into runny827

feat(training): 新增精益培训视频与周任务管理

# Conflicts:
#	backend/app/models/__init__.py
This commit is contained in:
runny committed 2026-09-08 18:30:09 +08:00
1 parent 85d27e9ffa
commit 91b7233872
812 files changed
+73763 -18908

No files matched your search

@@ -0,0 +1,131 @@
<!--
features/chat/components/messages/TransferResultCard.vue
用途:结果卡——按 ERP 单号聚合(决策 20)、可展开物料明细、未生成单据异常区、
下载收料来源文件 / ERP 库存表(决策 21)。不展示执行审计入口(决策 19)。
依赖:props.run、i18n chat.transfer.*。
逻辑:<details> 展开/收起物料行;异常单独分区;两个下载按钮 + 异常 Excel。
-->
<script setup lang="ts">
import type { TransferRunResult } from '../../types/transfer.types';
defineProps<{
run: TransferRunResult;
}>();
const emit = defineEmits<{
downloadReceipt: [];
downloadErp: [];
downloadExceptions: [];
}>();
function reasonLabel(reason: string): string {
const map: Record<string, string> = {
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
business_failed: 'chat.transfer.exceptionBusinessFailed',
technical_failed: 'chat.transfer.exceptionTechnicalFailed',
result_unknown: 'chat.transfer.resultUnknown',
precheck_expired: 'chat.transfer.exceptionPrecheckExpired',
};
return map[reason] ?? 'chat.transfer.resultBlocked';
}
</script>
<template>
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-result-card">
<div class="mb-3 flex items-center justify-between">
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.resultTitle') }}</h3>
<span class="text-xs text-muted">{{ run.run_no }}</span>
</div>
<!-- 已生成 ERP 单据:按单号聚合 + 可展开物料明细 -->
<div v-if="run.result.erp_documents.length" class="flex flex-col gap-2">
<details
v-for="doc in run.result.erp_documents"
:key="doc.document_no"
class="rounded-lg border border-default"
data-testid="transfer-erp-document"
>
<summary class="flex cursor-pointer flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
<span class="font-bold text-brand-700">{{ doc.document_no }}</span>
<span class="text-secondary">{{ doc.from_warehouse }} → {{ doc.to_warehouse }}</span>
<span class="text-muted">{{ $t('chat.transfer.materialCount', { count: doc.material_count }) }}</span>
<span class="font-bold text-secondary">{{ doc.total_quantity }}</span>
<span class="rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700">
{{ $t('chat.transfer.posted') }}
</span>
</summary>
<div class="border-t border-subtle px-3 py-2">
<table class="w-full text-xs" data-testid="transfer-erp-document-lines">
<thead>
<tr class="text-left text-[11px] text-muted">
<th class="p-1">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
<th class="p-1">{{ $t('chat.transfer.colSpec') }}</th>
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="line in doc.lines" :key="line.invoice_no" class="border-t border-subtle">
<td class="p-1">{{ line.material_no }}</td>
<td class="p-1">{{ line.material_name }}</td>
<td class="p-1">{{ line.specification }}</td>
<td class="p-1">{{ line.invoice_no }}</td>
<td class="p-1">{{ line.quantity }}</td>
</tr>
</tbody>
</table>
</div>
</details>
</div>
<div v-else class="mb-3 rounded-lg bg-surface-soft p-3 text-xs text-muted">
{{ $t('chat.transfer.noDocuments') }}
</div>
<!-- 未生成 ERP 单据的异常区(决策 20 单独展示) -->
<div v-if="run.result.exceptions.length" class="mt-3" data-testid="transfer-exceptions-area">
<h4 class="mb-1 text-xs font-bold text-secondary">{{ $t('chat.transfer.exceptionsTitle') }}</h4>
<ul class="flex flex-col gap-1">
<li
v-for="exc in run.result.exceptions"
:key="exc.invoice_no"
class="rounded-lg bg-red-50 px-3 py-1.5 text-xs text-red-700"
data-testid="transfer-exception-item"
>
<span class="font-bold">{{ exc.invoice_no }}</span>
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ $t(reasonLabel(exc.reason)) }}
<div class="text-[11px] text-red-500">{{ exc.facts }}</div>
</li>
</ul>
</div>
<!-- 下载:收料来源文件 + ERP 库存表(决策 21);无审计入口(决策 19) -->
<div class="mt-3 flex flex-wrap gap-2 border-t border-subtle pt-3" data-testid="transfer-result-downloads">
<button
type="button"
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50"
data-testid="transfer-download-receipt"
@click="emit('downloadReceipt')"
>
{{ $t('chat.transfer.downloadReceiptFiles') }}
</button>
<button
type="button"
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50"
data-testid="transfer-download-erp"
@click="emit('downloadErp')"
>
{{ $t('chat.transfer.downloadErpInventory') }}
</button>
<button
type="button"
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft"
data-testid="transfer-download-exceptions"
@click="emit('downloadExceptions')"
>
{{ $t('chat.transfer.downloadExceptions') }}
</button>
</div>
</div>
</template>