44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
/**
|
|
* features/chat/shipping-review/showReviewResumeOutcome.ts
|
|
* 用途:复核写操作后统一展示 resume_outcome 提示(与 Customer 面板一致)。
|
|
* 依赖:vue-i18n、ShippingOrderReviewResumeOutcome。
|
|
* 逻辑:各 Reservation / 冲突 / 重复 / 履约面板在 API 成功后调用本 helper。
|
|
*/
|
|
import type { ComposerTranslation } from 'vue-i18n';
|
|
import type { ShippingOrderReviewResumeOutcome } from '../types/shipping.api.types';
|
|
|
|
type ToastApi = {
|
|
success: (message: string) => void;
|
|
};
|
|
|
|
/**
|
|
* 按 resume_outcome 展示成功提示;无 outcome 时使用 fallbackSuccess。
|
|
* 核心逻辑:auto_created/idempotent_replay → 自动建单;waiting_manual_confirm → 待人工确认。
|
|
* @param resume - 后端统一恢复协调结果
|
|
* @param msg - useMessage 实例
|
|
* @param t - vue-i18n translate
|
|
* @param fallbackSuccess - 无特殊 outcome 时的默认成功文案
|
|
* @returns 是否已展示 resume 专用提示(调用方可跳过 fallback)
|
|
*/
|
|
export function showReviewResumeOutcome(
|
|
resume: ShippingOrderReviewResumeOutcome | null | undefined,
|
|
msg: ToastApi,
|
|
t: ComposerTranslation,
|
|
fallbackSuccess?: string,
|
|
): void {
|
|
const outcome = String(resume?.outcome || '').trim();
|
|
if (outcome === 'auto_created' || outcome === 'idempotent_replay') {
|
|
msg.success(t('chat.shippingOrderReview.resume.autoCreated', {
|
|
taskNo: resume?.task_no || '',
|
|
}));
|
|
return;
|
|
}
|
|
if (outcome === 'waiting_manual_confirm') {
|
|
msg.success(t('chat.shippingOrderReview.resume.waitingManualConfirm'));
|
|
return;
|
|
}
|
|
if (fallbackSuccess) {
|
|
msg.success(fallbackSuccess);
|
|
}
|
|
}
|