feat(in-transit-transfer): 异常恢复一键重建预检并支持按行批量处理

- 新增 resume_service:可恢复阻断行按(来源×收料日期)分组重建范围预检,收料文件不可用自动触发 RPA 重抓,单组失败不影响其余组
- precheck 新增 list_recent_prechecks 最近预检入口:未执行未过期可继续执行,解决预检卡关闭后无处恢复
- manual_close 支持按 item_ids 批量关闭并带审计,retry/backlog 配合按行口径调整
- 前端三区接线换新:首页待办/预检卡/待处理异常接恢复与批量动作,新增 transferDate 日期工具与 e2e 用例
- i18n chat/errors 四语言同步,technical.md 与 funclist 更新,落行归属解耦与 ERP 写路径两份实施计划
This commit is contained in:
hugo committed 2026-09-23 15:30:07 +08:00
1 parent 42b271f92b
commit 556d3fd3db
35 files changed
+2895 -121

No files matched your search

@@ -1,13 +1,15 @@
<!--
features/chat/components/messages/TransferMessageView.vue
用途:在途调拨消息卡片的自驱动挂载视图——按 payload 形态渲染卡片,并把卡片按钮
(直接生成调拨单 / 下载 / 重试 / 关闭)经 useChatTransfer 真实调用 API。
(生成调拨单 / 下载 / 重查 / 恢复 / 关闭)经 useChatTransfer 真实调用 API。
依赖:Transfer*Card、useChatTransfer、i18n chat.transfer.*。
逻辑:payload 作为初始状态(ChatLog 回放);执行后切换为结果卡;下载走 requestBlob;
逻辑:payload 作为初始状态(ChatLog 回放);仅携带 precheck_id 时按 ID 恢复预检卡
(最近预检入口);执行后切换为结果卡;下载走 requestBlob;
不展示执行审计入口(决策 19)。
-->
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import TransferPrecheckCard from './TransferPrecheckCard.vue';
import TransferFileProgressCard from './TransferFileProgressCard.vue';
import TransferProgressCard from './TransferProgressCard.vue';
@@ -32,7 +34,8 @@ const props = defineProps<{
payload?: Record<string, unknown> | null;
}>();
const { error: notifyError } = useMessage();
const { t } = useI18n();
const { error: notifyError, success: notifySuccess, warning: notifyWarning } = useMessage();
/** 统一错误提示:BusinessError 带本地化 message,其余回退到 String(e)。 */
function reportError(e: unknown) {
@@ -41,6 +44,12 @@ function reportError(e: unknown) {
const kind = computed(() => String(props.payload?.kind ?? 'precheck'));
const mode = ref(kind.value);
/** backlog 初始筛选(首页计数卡切片进入:recoverable/closed/unknown;白名单外回落 all)。 */
const backlogInitialFilter = computed<'all' | 'recoverable' | 'closed' | 'unknown'>(() => {
const value = String(props.payload?.filter ?? 'all');
const allowed = ['all', 'recoverable', 'closed', 'unknown'] as const;
return (allowed as readonly string[]).includes(value) ? (value as (typeof allowed)[number]) : 'all';
});
const summaryRef = ref<TransferPrecheckSummary | null>((props.payload?.summary as TransferPrecheckSummary) ?? null);
const items = ref<TransferPrecheckItem[]>((props.payload?.items as TransferPrecheckItem[]) ?? []);
const runNo = ref(String(props.payload?.run_no ?? ''));
@@ -48,6 +57,8 @@ const status = ref(String(props.payload?.status ?? 'executing'));
const run = ref<TransferRunResult | null>((props.payload?.run as TransferRunResult) ?? null);
const busy = ref(false);
const closeTarget = ref<TransferBacklogItem | null>(null);
/** 批量标记无需处理的明细 id 集合(与单行关闭共用同一弹窗)。 */
const batchCloseIds = ref<number[]>([]);
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
const retryingSource = ref<Set<string>>(new Set());
@@ -61,8 +72,27 @@ onMounted(() => {
if (kind.value === 'source-select') {
void transfer.loadSources();
}
// 最近预检入口:仅携带 precheck_id 无 summary,按 ID 恢复预检进度与明细。
if (kind.value === 'precheck' && !summaryRef.value && props.payload?.precheck_id) {
void restoreById(String(props.payload.precheck_id));
}
});
/** 按预检号恢复预检卡(GET /prechecks/{id},页面刷新/最近预检入口共用)。 */
async function restoreById(precheckId: string) {
busy.value = true;
try {
const detail = await transfer.restorePrecheckById(precheckId);
mode.value = 'precheck';
summaryRef.value = detail.summary;
items.value = detail.items;
} catch (e) {
reportError(e);
} finally {
busy.value = false;
}
}
/** payload 更新时重置本地状态(历史回放/刷新);初始化组合式函数上下文 */
function applyPayload(payload?: Record<string, unknown> | null) {
if (!payload) return;
@@ -178,16 +208,87 @@ async function onBacklogRetry(itemId: number) {
}
}
/** 批量重查(待处理池多选):逐行隔离,完成后刷新列表并弹汇总。 */
async function onBacklogRequery(itemIds: number[]) {
busy.value = true;
try {
const result = await transfer.batchRequery(itemIds);
const ok = result.results.filter((entry) => entry.ok).length;
notifySuccess(t('chat.transfer.toastRequeryDone', { ok, failed: result.total - ok }));
await transfer.loadBacklog();
} catch (e) {
reportError(e);
} finally {
busy.value = false;
}
}
/** 恢复处理(行级/多选):按(来源, 收料日期)分组重建预检。仅当重建预检
* 含可执行行才切换预检卡(其余份数引导到「最近预检」);全部仍阻断(ERP
* 未修正)不跳转,留在待处理池并明确提示;文件不可用的来源已触发重抓。 */
async function onBacklogResume(itemIds: number[]) {
busy.value = true;
try {
const result = await transfer.batchResume(itemIds);
await transfer.loadBacklog();
const actionable = result.prechecks.filter((entry) => entry.executable_count > 0);
const firstActionable = actionable[0];
if (firstActionable) {
const detail = await transfer.restorePrecheckById(firstActionable.precheck_no);
mode.value = 'precheck';
summaryRef.value = detail.summary;
items.value = detail.items;
if (actionable.length > 1) {
notifySuccess(t('chat.transfer.toastResumeOpened', { count: actionable.length }));
}
}
const stillBlockedCount = result.prechecks
.filter((entry) => entry.executable_count === 0)
.reduce((sum, entry) => sum + entry.selected_item_count, 0);
if (stillBlockedCount) {
notifyWarning(t('chat.transfer.toastResumeStillBlocked', { count: stillBlockedCount }));
}
const refetching = result.file_fetching.filter((entry) => entry.ok).map((entry) => entry.source_code);
if (refetching.length) {
notifyWarning(t('chat.transfer.toastResumeRefetching', { sources: refetching.join('、') }));
}
const failedCount = result.file_fetching.filter((entry) => !entry.ok).length + result.skipped.length;
if (failedCount) {
notifyWarning(t('chat.transfer.toastResumeSkipped', { count: failedCount }));
}
} catch (e) {
reportError(e);
} finally {
busy.value = false;
}
}
function onBacklogClose(item: TransferBacklogItem) {
closeTarget.value = item;
}
/** 批量标记无需处理:复用关闭弹窗(批量文案)。 */
function onBacklogBatchClose(itemIds: number[]) {
batchCloseIds.value = itemIds;
}
function onCancelClose() {
closeTarget.value = null;
batchCloseIds.value = [];
}
async function onCloseConfirm(reason: string) {
if (!closeTarget.value) return;
busy.value = true;
try {
await transfer.manualClose(closeTarget.value.item_id, reason);
closeTarget.value = null;
if (batchCloseIds.value.length) {
const result = await transfer.batchManualClose(batchCloseIds.value, reason);
const ok = result.results.filter((entry) => entry.ok).length;
notifySuccess(t('chat.transfer.toastCloseDone', { ok, failed: result.total - ok }));
batchCloseIds.value = [];
} else if (closeTarget.value) {
await transfer.manualClose(closeTarget.value.item_id, reason);
closeTarget.value = null;
}
await transfer.loadBacklog();
} catch (e) {
reportError(e);
@@ -274,16 +375,22 @@ async function onSourceRetry(sourceCodes: string[]) {
<TransferBacklogSummaryCard
v-else-if="mode === 'backlog'"
:items="transfer.backlog.value"
:busy="busy"
:initial-filter="backlogInitialFilter"
@retry="onBacklogRetry"
@requery="onBacklogRequery"
@resume="onBacklogResume"
@close="onBacklogClose"
@batch-close="onBacklogBatchClose"
@refresh="() => transfer.loadBacklog()"
/>
<TransferManualCloseDialog
v-if="closeTarget"
:open="Boolean(closeTarget)"
:invoice-no="closeTarget.invoice_no"
v-if="closeTarget || batchCloseIds.length"
:open="Boolean(closeTarget || batchCloseIds.length)"
:invoice-no="closeTarget?.invoice_no ?? ''"
:count="batchCloseIds.length"
@confirm="onCloseConfirm"
@cancel="closeTarget = null"
@cancel="onCancelClose"
/>
</div>
</template>