Files
syops/frontend/src/features/chat/components/shipping-review/ReviewIntakeParsePanel.vue
T
hugo 1b6483a4ea feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
2026-08-20 20:23:10 +08:00

147 lines
5.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
features/chat/components/shipping-review/ReviewIntakeParsePanel.vue
用途:在接收解析阶段展示当前 Case 已授权的邮件正文、当前附件及安全预览。
依赖:vue、vue-i18n、ShippingOrderReviewIntakeParseContext。
逻辑:只消费父级按 Case 获取的受控上下文;仅 PDF 可请求/渲染 iframe;处置操作只 emit,
由父页沿用既有确认弹窗和 Case 命令。
-->
<script setup lang="ts">
import { watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewIntakeParseContext } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
context: ShippingOrderReviewIntakeParseContext | null;
loading: boolean;
loadFailed: boolean;
previewUrl: string | null;
previewLoading: boolean;
}>();
const emit = defineEmits<{
'retry-context': [];
'load-preview': [];
}>();
const { t } = useI18n();
/**
* 当前附件为 PDF 且尚无受控 Blob 时,通知父级使用当前 Case 加载预览。
* 仅 Case context 改变时触发,禁止对不受支持文件发起预览请求。
*/
watch(
() => props.context,
(context) => {
if (context?.attachment.preview_kind === 'pdf' && !props.previewUrl) {
emit('load-preview');
}
},
{ immediate: true },
);
</script>
<template>
<section
class="space-y-4"
data-testid="intake-parse-panel"
>
<div
v-if="loading"
class="rounded-xl border border-dashed border-slate-300 bg-slate-50 p-4 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-300"
data-testid="intake-parse-loading"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loading') }}
</div>
<div
v-else-if="loadFailed"
class="rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-100"
data-testid="intake-parse-load-failed"
>
<p>{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loadFailed') }}</p>
<button
type="button"
class="mt-3 rounded border border-rose-300 px-2.5 py-1 text-xs hover:bg-rose-100 dark:border-rose-800 dark:hover:bg-rose-950"
data-testid="intake-parse-retry-context"
@click="emit('retry-context')"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.retry') }}
</button>
</div>
<template v-else-if="context">
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lifecycle.intakeParse.email') }}</h2>
<template v-if="context.email">
<p class="mt-1 text-xs text-slate-500">{{ context.email.filename }}</p>
<iframe
v-if="context.email.render_kind === 'safe_html' && context.email.preview_url"
:src="context.email.preview_url"
sandbox=""
referrerpolicy="no-referrer"
:title="t('chat.shippingOrderReview.lifecycle.intakeParse.emailPreviewTitle')"
class="mt-3 h-72 w-full rounded border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-950"
data-testid="intake-parse-email-html"
/>
<pre
v-else
class="mt-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-slate-50 p-3 text-xs text-slate-700 dark:bg-slate-950/50 dark:text-slate-200"
data-testid="intake-parse-email-body"
>{{ context.email.text }}</pre>
</template>
<p
v-else
class="mt-2 text-sm text-slate-500"
data-testid="intake-parse-no-email"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.noEmail') }}
</p>
</section>
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
<h2 class="text-sm font-semibold" data-testid="intake-parse-attachment-heading">
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.attachment') }} ·
<span class="font-normal text-slate-500 dark:text-slate-400">{{ context.attachment.filename }}</span>
</h2>
<div
v-if="context.attachment.preview_kind === 'pdf'"
class="mt-3"
data-testid="intake-parse-attachment-preview"
>
<p
v-if="previewLoading"
class="mt-2 text-sm text-slate-500"
data-testid="intake-parse-preview-loading"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.previewLoading') }}
</p>
<iframe
v-else-if="previewUrl"
:src="previewUrl"
:title="context.attachment.filename"
class="mt-2 h-[32rem] w-full rounded border border-slate-200 dark:border-slate-700"
/>
<button
v-else
type="button"
class="mt-2 rounded border border-slate-300 px-2.5 py-1 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
data-testid="intake-parse-load-preview"
@click="emit('load-preview')"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.loadPreview') }}
</button>
</div>
<p
v-else
class="mt-4 rounded bg-slate-50 p-3 text-sm text-slate-500 dark:bg-slate-950/50"
data-testid="intake-parse-preview-unsupported"
>
{{ t('chat.shippingOrderReview.lifecycle.intakeParse.previewUnsupported') }}
</p>
</section>
</template>
</section>
</template>