feat(shipping-notice): 增强发货通知与订单抽取功能,支持多进程处理与紧急停止
- 移除不再使用的 SHIPPING_NOTICE_LAYOUT_PARSER_REVISION 配置 - 在环境配置中新增 SHIPPING_NOTICE_WORKER_CONCURRENCY 和 SHIPPING_NOTICE_JOB_RUNNING_TIMEOUT_SECONDS - 实现发货通知 worker 进程,支持并发处理订单抽取任务 - 引入紧急停止功能,允许管理员在运行中控制订单解析状态 - 更新相关 API,支持读取与设置紧急停止状态 - 增强文档与代码注释,反映新的业务逻辑与功能要求
This commit is contained in:
1 parent
d0fe084999
commit
b352c281d5
149 files changed
+12550
-1874
No files matched your search
@@ -1,11 +1,15 @@
|
||||
<!--
|
||||
用途:提供按 PDF 独立处理的建单前订单人工复核工作台(阶段 3:工作项版本中心)。
|
||||
features/chat/views/ShippingOrderReviewView.vue
|
||||
用途:提供按 PDF 独立处理的建单前订单人工复核工作台(版本中心 + AI 最小证据建议)。
|
||||
依赖:路由参数、复核 composable、ReviewDocumentPreview、ReviewVersionHistoryPanel、ReviewActionConfirmDialog、
|
||||
ReviewLineNoOverrideDialog、ReviewBuildEligibilityPanel、ReviewInventoryCandidatesPanel、
|
||||
ReviewWorkflowProgressPanel。
|
||||
ReviewWorkflowProgressPanel、ReviewLlmSuggestionPanel。
|
||||
逻辑:左 PDF 预览 + 中部订单编辑 + 右侧独立建单资格/库存候选门禁区(sticky);
|
||||
build_eligibility 驱动建单门禁与零候选时已启用库存源选择;破坏性操作二次确认;
|
||||
确认后挂载自动进度面板并轮询 Workflow Item;内部项次 line_no 编辑须经覆盖原因弹窗。
|
||||
底部操作窄屏纵向堆叠(异常操作在上、保存/确认建单在下且确认最后);
|
||||
初始加载失败提供就地重试(再次调用 load);
|
||||
确认后挂载自动进度面板并轮询 Workflow Item;内部项次 line_no 编辑须经覆盖原因弹窗;
|
||||
AI 建议请求/裁决走 useShippingOrderReview.requestSuggestion / decideSuggestion。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
@@ -26,6 +30,7 @@ import ReviewLineNoOverrideDialog, {
|
||||
type LineNoOverridePayload,
|
||||
} from '../components/shipping-review/ReviewLineNoOverrideDialog.vue';
|
||||
import ReviewVersionHistoryPanel from '../components/shipping-review/ReviewVersionHistoryPanel.vue';
|
||||
import ReviewLlmSuggestionPanel from '../components/shipping-review/ReviewLlmSuggestionPanel.vue';
|
||||
import ReviewWorkflowProgressPanel from '../components/shipping-review/ReviewWorkflowProgressPanel.vue';
|
||||
import { REVIEW_BUILD_ELIGIBILITY_BLOCKED, useShippingOrderReview } from '../shipping-review/useShippingOrderReview';
|
||||
import type {
|
||||
@@ -57,6 +62,10 @@ const {
|
||||
saveFailed,
|
||||
versionsLoading,
|
||||
evidence,
|
||||
llmSuggestions,
|
||||
suggestionLoading,
|
||||
focusedFieldId,
|
||||
focusedLineKey,
|
||||
previewUrl,
|
||||
load,
|
||||
selectCase,
|
||||
@@ -77,6 +86,9 @@ const {
|
||||
markQualityIssue,
|
||||
reparseDocument,
|
||||
uploadReplacement,
|
||||
focusSuggestionField,
|
||||
requestSuggestion,
|
||||
decideSuggestion,
|
||||
editable,
|
||||
showWorkflowProgress,
|
||||
workflowProgressPolling,
|
||||
@@ -87,8 +99,23 @@ const runNo = computed(() => String(route.query.run_no || route.params.runNo ||
|
||||
const agentId = computed(() => String(route.params.agentId || ''));
|
||||
const conversationId = computed(() => String(page.conversationId || route.query.conversation_id || ''));
|
||||
const itemNoFromQuery = computed(() => String(route.query.item_no || ''));
|
||||
|
||||
const reviewFocus = computed(() => String(route.query.focus || '').trim());
|
||||
const focusedEvidenceRef = ref<{ fieldId: string; lineIndex?: number } | null>(null);
|
||||
|
||||
watch(
|
||||
() => [evidence.value, reviewFocus.value] as const,
|
||||
([items, focus]) => {
|
||||
if (focus !== 'evidence' || !items?.length) return;
|
||||
const first = items.find((item) => item.bbox) || items[0];
|
||||
if (!first) return;
|
||||
focusedEvidenceRef.value = {
|
||||
fieldId: String(first.field_id || '').trim(),
|
||||
lineIndex: first.line_index == null ? undefined : Number(first.line_index),
|
||||
};
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 当前用于 PDF 证据高亮的条目:明细同时按字段与行号匹配,避免多行同字段定位错位。
|
||||
*/
|
||||
@@ -115,6 +142,8 @@ const findFieldEvidence = (fieldId: string, lineIndex?: number) => (evidence.val
|
||||
const hasFieldEvidence = (fieldId: string, lineIndex?: number) => Boolean(findFieldEvidence(fieldId, lineIndex));
|
||||
/** 聚焦字段证据:有 bbox 时高亮,否则仅切至证据所在页。 */
|
||||
const focusFieldEvidence = (fieldId: string, lineIndex?: number) => {
|
||||
const lineKey = lineIndex != null ? activeCase.value?.draft?.lines?.[lineIndex]?.line_key : undefined;
|
||||
focusSuggestionField(String(fieldId || '').trim(), typeof lineKey === 'string' ? lineKey : null);
|
||||
focusedEvidenceRef.value = findFieldEvidence(fieldId, lineIndex)
|
||||
? { fieldId: String(fieldId || '').trim(), lineIndex }
|
||||
: null;
|
||||
@@ -143,6 +172,24 @@ const draftValue = (container: Record<string, unknown>, fieldId: string) => {
|
||||
return machineValueByIdFor(machine, fieldId);
|
||||
};
|
||||
|
||||
/**
|
||||
* 当前聚焦字段的草稿值,供 LLM 建议面板做三方对比。
|
||||
*/
|
||||
const focusedLlmDraftValue = computed(() => {
|
||||
const fieldId = String(focusedFieldId.value || '');
|
||||
if (!fieldId || !activeCase.value?.draft) return null;
|
||||
const lineKey = focusedLineKey.value;
|
||||
if (lineKey) {
|
||||
const line = (activeCase.value.draft.lines || []).find(
|
||||
(item) => String((item as { line_key?: string }).line_key || '') === String(lineKey),
|
||||
);
|
||||
if (!line) return null;
|
||||
return draftValue(line as Record<string, unknown>, fieldId);
|
||||
}
|
||||
const header = activeCase.value.draft.header_values as Record<string, unknown> | undefined;
|
||||
return header ? draftValue(header, fieldId) : null;
|
||||
});
|
||||
|
||||
/**
|
||||
* 读取投影字段元数据(值来源 / 锁定 / 覆盖原因)。
|
||||
* @param container - 表头或明细草稿容器
|
||||
@@ -543,6 +590,18 @@ const back = () => router.replace({
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* 就地重试加载复核 Run/Case(不依赖整页刷新)。
|
||||
*/
|
||||
function retryLoad() {
|
||||
const nextRun = runNo.value;
|
||||
if (!nextRun) return;
|
||||
void load(nextRun, String(route.query.case || route.query.case_no || '') || undefined, {
|
||||
conversationId: conversationId.value || undefined,
|
||||
itemNo: itemNoFromQuery.value || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
[runNo, () => String(route.query.case || route.query.case_no || ''), conversationId, itemNoFromQuery],
|
||||
([nextRun, nextCase, nextConversationId, nextItemNo]) => {
|
||||
@@ -718,8 +777,21 @@ watch(
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="p-8 text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.loading') }}</div>
|
||||
<div v-else-if="loadFailed" class="m-4 rounded-lg border border-rose-300 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100">
|
||||
{{ t('chat.shippingOrderReview.unavailable') }}
|
||||
<div
|
||||
v-else-if="loadFailed"
|
||||
class="m-4 rounded-lg border border-rose-300 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100"
|
||||
data-testid="shipping-order-review-load-failed"
|
||||
>
|
||||
<p>{{ t('chat.shippingOrderReview.unavailable') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-1 rounded border border-current/30 px-3 py-1.5 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-review-retry-load"
|
||||
@click="retryLoad"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingOrderReview.retryLoad') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1 overflow-y-auto">
|
||||
<section class="p-4 lg:p-5">
|
||||
@@ -794,6 +866,20 @@ watch(
|
||||
<div v-for="issue in activeCase.draft.issues" :key="`${issue.code}-${issue.severity}`" class="mt-1">{{ issue.code }}</div>
|
||||
</div>
|
||||
|
||||
<ReviewLlmSuggestionPanel
|
||||
:active-case="activeCase"
|
||||
:evidence="evidence"
|
||||
:editable="editable"
|
||||
:saving="saving"
|
||||
:suggestions="llmSuggestions"
|
||||
:suggestion-loading="suggestionLoading"
|
||||
:focused-field-id="focusedFieldId"
|
||||
:focused-line-key="focusedLineKey"
|
||||
:draft-value="focusedLlmDraftValue"
|
||||
@request-suggestion="requestSuggestion()"
|
||||
@adjudicate="({ suggestion, body }) => decideSuggestion(suggestion.suggestion_no, body)"
|
||||
/>
|
||||
|
||||
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
@@ -983,35 +1069,68 @@ watch(
|
||||
|
||||
<footer
|
||||
v-if="activeCase?.draft && !isReadOnly"
|
||||
class="flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-slate-200 bg-white p-3 dark:border-slate-800 dark:bg-slate-900"
|
||||
class="flex shrink-0 flex-col gap-3 border-t border-slate-200 bg-white p-3 sm:flex-row sm:items-center sm:justify-between dark:border-slate-800 dark:bg-slate-900"
|
||||
data-testid="review-footer-actions"
|
||||
>
|
||||
<button v-if="activeCase?.available_actions.includes('mark_non_order')" type="button" :disabled="saving" class="rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('non_order')">
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button v-if="activeCase?.available_actions.includes('mark_quality_issue')" type="button" :disabled="saving" class="rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('quality_issue')">
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button v-if="activeCase?.available_actions.includes('reparse')" type="button" :disabled="saving" class="inline-flex items-center gap-1 rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('reparse')">
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label v-if="activeCase?.available_actions.includes('mark_quality_issue')" class="cursor-pointer rounded border px-3 py-2 text-sm">
|
||||
<input class="sr-only" type="file" accept="application/pdf,.pdf" :disabled="saving" @change="selectReplacement">
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
<button v-if="activeCase?.available_actions.includes('validate')" type="button" :disabled="saving" class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50" @click="reportSave(() => validate())">
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('confirm')"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="openActionDialog('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
<!-- 窄屏:异常操作在上;主操作(含确认建单)固定在下且确认按钮为组内最后一项 -->
|
||||
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@click="openActionDialog('non_order')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@click="openActionDialog('quality_issue')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('reparse')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@click="openActionDialog('reparse')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label
|
||||
v-if="activeCase?.available_actions.includes('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<input class="sr-only" type="file" accept="application/pdf,.pdf" :disabled="saving" @change="selectReplacement">
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="order-2 flex flex-wrap items-center justify-end gap-2 sm:order-2">
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('validate')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="reportSave(() => validate())"
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('confirm')"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="openActionDialog('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<ReviewActionConfirmDialog
|
||||
|
||||
Reference in new issue
Block a user