feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估
- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
1 parent
cef3d5b26a
commit
3a9fbac2fc
226 files changed
+25010
-2098
No files matched your search
+146
@@ -0,0 +1,146 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewBuildEligibilitySummary.vue
|
||||
用途:复核摘要侧栏的建单资格压缩卡(可建单状态、门禁清单、首要阻断)。
|
||||
依赖:vue-i18n、ShippingOrderReviewBuildEligibility。
|
||||
逻辑:展示客户确认等关键门禁勾选;「查看完整检查」emit open-details;完整逐行结果不常驻。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewBuildEligibility } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
eligibility: ShippingOrderReviewBuildEligibility | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-details': [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
/** 用户可见的关键建单前门禁(与后端 qualification gates 对齐)。 */
|
||||
const CHECKLIST_GATES = [
|
||||
'customer_confirmed',
|
||||
'required_fields_complete',
|
||||
'evidence_complete',
|
||||
'duplicate_resolved',
|
||||
'field_conflicts_resolved',
|
||||
] as const;
|
||||
|
||||
/** 阻断 issue 数量(优先 blocking severity)。 */
|
||||
const blockingIssueCount = computed(() => {
|
||||
const issues = props.eligibility?.issues || [];
|
||||
const blocking = issues.filter((item) => String(item.severity || '') === 'blocking');
|
||||
return blocking.length || issues.length;
|
||||
});
|
||||
|
||||
/** 首要阻断文案。 */
|
||||
const primaryBlockMessage = computed(() => {
|
||||
const issues = props.eligibility?.issues || [];
|
||||
const primary = issues.find((item) => String(item.severity || '') === 'blocking') || issues[0];
|
||||
if (!primary) {
|
||||
const blockedLines = (props.eligibility?.line_projections || []).filter((line) => line.can_build === false);
|
||||
if (!blockedLines.length) return '';
|
||||
const reason = String(blockedLines[0]?.block_reason || '').trim();
|
||||
const key = `chat.shippingOrderReview.buildEligibility.blockReasons.${reason}`;
|
||||
return reason && te(key) ? t(key) : t('chat.shippingOrderReview.buildEligibility.blockReasons.unknown');
|
||||
}
|
||||
const message = String(primary.explainability?.message || primary.message || '').trim();
|
||||
if (message) return message;
|
||||
const code = String(primary.code || '').trim();
|
||||
const key = `chat.shippingOrderReview.issueCodes.${code}`;
|
||||
return code && te(key) ? t(key) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
});
|
||||
|
||||
/** 不可建单的行数。 */
|
||||
const blockedLineCount = computed(() =>
|
||||
(props.eligibility?.line_projections || []).filter((line) => line.can_build === false).length,
|
||||
);
|
||||
|
||||
/**
|
||||
* 门禁勾选列表:优先 gates 映射;客户未确认时强制展示失败项。
|
||||
*/
|
||||
const gateChecklist = computed(() => {
|
||||
const gates = props.eligibility?.gates || {};
|
||||
const failed = new Set((props.eligibility?.failed_gates || []).map(String));
|
||||
const issues = props.eligibility?.issues || [];
|
||||
const customerIssue = issues.some((item) => String(item.code || '').startsWith('customer_'));
|
||||
return CHECKLIST_GATES.map((gate) => {
|
||||
const known = Object.prototype.hasOwnProperty.call(gates, gate);
|
||||
let passed = known ? Boolean(gates[gate]) : !failed.has(gate);
|
||||
if (gate === 'customer_confirmed' && customerIssue) passed = false;
|
||||
const labelKey = `chat.shippingOrderReview.buildEligibility.gates.${gate}`;
|
||||
return {
|
||||
gate,
|
||||
passed,
|
||||
label: te(labelKey) ? t(labelKey) : gate,
|
||||
};
|
||||
}).filter((item) => Object.keys(gates).length === 0 || Object.prototype.hasOwnProperty.call(gates, item.gate) || item.gate === 'customer_confirmed');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="eligibility"
|
||||
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
||||
data-testid="review-build-eligibility-summary"
|
||||
>
|
||||
<header class="flex flex-wrap items-center justify-between gap-2">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.buildEligibility.title') }}</h2>
|
||||
<span
|
||||
class="rounded-full px-2.5 py-1 text-xs font-medium"
|
||||
:class="eligibility.can_build
|
||||
? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'
|
||||
: 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'"
|
||||
data-testid="review-build-eligibility-badge"
|
||||
>
|
||||
{{
|
||||
eligibility.can_build
|
||||
? t('chat.shippingOrderReview.buildEligibility.canBuildYes')
|
||||
: t('chat.shippingOrderReview.buildEligibility.canBuildNo')
|
||||
}}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<ul
|
||||
v-if="gateChecklist.length"
|
||||
class="mt-2 space-y-1 text-xs"
|
||||
data-testid="review-eligibility-gate-checklist"
|
||||
>
|
||||
<li
|
||||
v-for="item in gateChecklist"
|
||||
:key="item.gate"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
<span :class="item.passed ? 'text-emerald-600' : 'text-rose-600'">{{ item.passed ? '✓' : '×' }}</span>
|
||||
<span :class="item.passed ? 'text-secondary' : 'font-medium text-rose-700 dark:text-rose-300'">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div
|
||||
v-if="!eligibility.can_build && primaryBlockMessage"
|
||||
class="mt-2 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-950 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
|
||||
data-testid="review-eligibility-primary-block"
|
||||
>
|
||||
<div class="font-semibold">{{ t('chat.shippingOrderReview.workbench.primaryBlock') }}</div>
|
||||
<p class="mt-0.5">{{ primaryBlockMessage }}</p>
|
||||
<p v-if="blockingIssueCount || blockedLineCount" class="mt-1 text-[11px] opacity-80">
|
||||
{{ t('chat.shippingOrderReview.workbench.blockCount', {
|
||||
count: Math.max(blockingIssueCount, blockedLineCount),
|
||||
}) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 w-full rounded border border-slate-300 px-2 py-1.5 text-xs hover:bg-slate-50 dark:border-slate-600 dark:hover:bg-slate-800"
|
||||
data-testid="review-open-eligibility-details"
|
||||
@click="emit('open-details')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workbench.viewFullChecks') }}
|
||||
</button>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user