feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估

- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。
- 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。
- 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。
- 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。
- 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
hugo committed 2026-08-02 19:26:35 +08:00
1 parent cef3d5b26a
commit 3a9fbac2fc
226 files changed
+25010 -2098

No files matched your search

@@ -0,0 +1,225 @@
<!--
features/chat/components/shipping-review/ReviewFieldConflictPanel.vue
用途:复核工作台建单前字段冲突集中裁决区(采用候选值 / 手工值)。
依赖:vue-i18n、shipping.api.resolveWorkspaceShippingOrderReviewFieldConflict、useMessage。
逻辑:展示 Case.field_conflicts;裁决成功后 emit refreshed;可 emit focus-conflict 定位证据。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import { resolveWorkspaceShippingOrderReviewFieldConflict } from '@/features/chat/api/shipping.api';
import type { ShippingOrderReviewFieldConflict } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
caseNo: string;
draftVersion: number | null | undefined;
conflicts: ShippingOrderReviewFieldConflict[] | null | undefined;
editable: boolean;
}>();
const emit = defineEmits<{
refreshed: [];
'focus-conflict': [payload: { fieldCode: string; lineIndex: number | null; lineKey: string | null }];
}>();
const { t, te } = useI18n();
const msg = useMessage();
const resolvingKey = ref<string | null>(null);
const customOpenKey = ref<string | null>(null);
const customValue = ref('');
const openConflicts = computed(() => props.conflicts || []);
/**
* 字段编码本地化标签(无文案时回退 field_code)。
*/
function fieldLabel(fieldCode: string): string {
const key = `chat.shippingOrderReview.fieldConflict.fields.${fieldCode}`;
return te(key) ? t(key) : fieldCode;
}
/**
* 冲突原因本地化。
*/
function reasonLabel(reason: string): string {
const key = `chat.shippingOrderReview.fieldConflict.reasons.${reason}`;
return te(key) ? t(key) : reason;
}
/**
* 定位冲突字段到草稿/证据区。
*/
function onFocus(conflict: ShippingOrderReviewFieldConflict) {
emit('focus-conflict', {
fieldCode: conflict.field_code,
lineIndex: conflict.line_index ?? null,
lineKey: conflict.line_key ?? null,
});
}
/**
* 采用某一候选值。
*/
async function adoptOption(conflict: ShippingOrderReviewFieldConflict, optionIndex: number) {
if (!props.editable || !props.caseNo || props.draftVersion == null || resolvingKey.value) return;
resolvingKey.value = conflict.conflict_key;
try {
await resolveWorkspaceShippingOrderReviewFieldConflict(props.caseNo, conflict.conflict_key, {
resolution: 'adopt_option',
option_index: optionIndex,
expected_draft_version: props.draftVersion,
reason: t('chat.shippingOrderReview.fieldConflict.resolveReason'),
});
msg.success(t('chat.shippingOrderReview.fieldConflict.resolveSuccess'));
emit('refreshed');
} catch (error: unknown) {
const message = error instanceof BusinessError
? resolveLocalizedErrorMessage(error.code, error.message)
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fieldConflict.resolveFailed'));
msg.warning(message);
} finally {
resolvingKey.value = null;
}
}
/**
* 展开/收起手工值输入。
*/
function toggleCustom(conflictKey: string) {
if (customOpenKey.value === conflictKey) {
customOpenKey.value = null;
customValue.value = '';
return;
}
customOpenKey.value = conflictKey;
customValue.value = '';
}
/**
* 提交手工值裁决。
*/
async function submitCustom(conflict: ShippingOrderReviewFieldConflict) {
const value = customValue.value.trim();
if (!value || !props.editable || props.draftVersion == null || resolvingKey.value) return;
resolvingKey.value = conflict.conflict_key;
try {
await resolveWorkspaceShippingOrderReviewFieldConflict(props.caseNo, conflict.conflict_key, {
resolution: 'custom',
custom_value: value,
expected_draft_version: props.draftVersion,
reason: t('chat.shippingOrderReview.fieldConflict.resolveReason'),
});
customOpenKey.value = null;
customValue.value = '';
msg.success(t('chat.shippingOrderReview.fieldConflict.resolveSuccess'));
emit('refreshed');
} catch (error: unknown) {
const message = error instanceof BusinessError
? resolveLocalizedErrorMessage(error.code, error.message)
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.fieldConflict.resolveFailed'));
msg.warning(message);
} finally {
resolvingKey.value = null;
}
}
</script>
<template>
<section
v-if="openConflicts.length"
class="rounded-xl border border-rose-200 bg-rose-50/70 p-3 shadow-sm dark:border-rose-900 dark:bg-rose-950/40"
data-testid="review-field-conflict-panel"
>
<header class="flex flex-wrap items-start justify-between gap-2">
<div>
<h2 class="text-sm font-semibold text-rose-950 dark:text-rose-50">
{{ t('chat.shippingOrderReview.fieldConflict.title', { count: openConflicts.length }) }}
</h2>
<p class="mt-0.5 text-xs text-rose-800 dark:text-rose-200">
{{ t('chat.shippingOrderReview.fieldConflict.subtitle') }}
</p>
</div>
</header>
<ul class="mt-3 space-y-2">
<li
v-for="conflict in openConflicts"
:key="conflict.conflict_key"
class="rounded-lg border border-rose-200 bg-white/95 px-2.5 py-2 dark:border-rose-900 dark:bg-slate-900"
:data-testid="`review-field-conflict-${conflict.conflict_key}`"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="text-xs font-medium text-rose-950 dark:text-rose-50">
<span v-if="conflict.line_index != null">#{{ conflict.line_index + 1 }} · </span>
<span class="font-mono">{{ fieldLabel(conflict.field_code) }}</span>
</div>
<button
type="button"
class="text-[11px] text-primary underline-offset-2 hover:underline"
data-testid="review-field-conflict-focus"
@click="onFocus(conflict)"
>
{{ t('chat.shippingOrderReview.fieldConflict.focusEvidence') }}
</button>
</div>
<p class="mt-1 text-[11px] text-muted">{{ reasonLabel(conflict.reason) }}</p>
<div class="mt-2 grid gap-1 text-[11px] text-secondary sm:grid-cols-2">
<div
v-for="(option, idx) in conflict.options"
:key="`${conflict.conflict_key}-${idx}`"
class="rounded border border-default bg-surface-soft px-2 py-1.5"
>
<div class="text-muted">
{{ t('chat.shippingOrderReview.fieldConflict.optionLabel', { index: idx + 1 }) }}
<span v-if="option.sources?.length" class="ml-1">({{ option.sources.join(', ') }})</span>
</div>
<div class="mt-0.5 font-mono text-primary">{{ option.display_value || option.value_key || '—' }}</div>
<button
v-if="editable"
type="button"
class="mt-1.5 rounded border border-rose-300 bg-rose-100 px-2 py-0.5 text-[11px] font-medium text-rose-900 hover:bg-rose-200 disabled:opacity-50 dark:border-rose-800 dark:bg-rose-950 dark:text-rose-100"
:disabled="resolvingKey != null"
:data-testid="`review-field-conflict-adopt-${idx}`"
@click="adoptOption(conflict, idx)"
>
{{ t('chat.shippingOrderReview.fieldConflict.adoptOption') }}
</button>
</div>
</div>
<div v-if="editable" class="mt-2">
<button
type="button"
class="text-[11px] text-secondary underline-offset-2 hover:underline"
:disabled="resolvingKey != null"
data-testid="review-field-conflict-custom-toggle"
@click="toggleCustom(conflict.conflict_key)"
>
{{ t('chat.shippingOrderReview.fieldConflict.customValue') }}
</button>
<div v-if="customOpenKey === conflict.conflict_key" class="mt-1.5 flex flex-wrap gap-2">
<input
v-model="customValue"
type="text"
class="min-w-[10rem] flex-1 rounded border border-default bg-surface px-2 py-1 text-xs"
data-testid="review-field-conflict-custom-input"
:placeholder="t('chat.shippingOrderReview.fieldConflict.customPlaceholder')"
>
<button
type="button"
class="rounded bg-primary px-2.5 py-1 text-xs font-medium text-on-primary disabled:opacity-50"
:disabled="!customValue.trim() || resolvingKey != null"
data-testid="review-field-conflict-custom-submit"
@click="submitCustom(conflict)"
>
{{ t('chat.shippingOrderReview.fieldConflict.submitCustom') }}
</button>
</div>
</div>
</li>
</ul>
</section>
</template>