feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
+184
-12
@@ -2,19 +2,34 @@
|
||||
features/chat/components/shipping-review/ReviewBuildEligibilitySummary.vue
|
||||
用途:复核摘要侧栏的建单资格压缩卡(可建单状态、门禁清单、首要阻断)。
|
||||
依赖:vue-i18n、ShippingOrderReviewBuildEligibility。
|
||||
逻辑:展示客户确认等关键门禁勾选;「查看完整检查」emit open-details;完整逐行结果不常驻。
|
||||
逻辑:只展示业务结论、具体字段/明细问题与异常导航;隐藏 Gate code、
|
||||
can_build/can_auto_create 等实现标识;「查看完整检查」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';
|
||||
import type { ShippingOrderReviewFieldConflict } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
eligibility: ShippingOrderReviewBuildEligibility | null;
|
||||
fieldConflicts?: ShippingOrderReviewFieldConflict[] | null;
|
||||
fieldLabels?: Record<string, string>;
|
||||
customerResolved?: boolean;
|
||||
/** 可定位异常总数;由工作台统一收集草稿与门禁问题。 */
|
||||
exceptionCount?: number;
|
||||
/** 当前定位异常序号;未定位时为 0。 */
|
||||
exceptionOrdinal?: number;
|
||||
/**
|
||||
* 为 true 时只展示能否建单/自动建单与异常导航,隐藏门禁清单与首要阻断文案,
|
||||
* 避免与 ProcessGateRecoveryCard 重复表达同一业务阻断。
|
||||
*/
|
||||
focusBuildability?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-details': [];
|
||||
'navigate-exception': [delta: -1 | 1];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -29,28 +44,84 @@ const CHECKLIST_GATES = [
|
||||
] as const;
|
||||
|
||||
/** 阻断 issue 数量(优先 blocking severity)。 */
|
||||
const blockingIssueCount = computed(() => {
|
||||
const effectiveIssues = computed(() => {
|
||||
const issues = props.eligibility?.issues || [];
|
||||
if (props.customerResolved !== true) return issues;
|
||||
return issues.filter((item) => {
|
||||
const code = String(item.code || '').trim().toLowerCase();
|
||||
const reason = String(item.reason_code || '').trim().toLowerCase();
|
||||
const gate = String(item.owning_gate_code || '').trim().toLowerCase();
|
||||
return !(
|
||||
code.startsWith('customer_')
|
||||
|| reason.startsWith('customer_')
|
||||
|| gate === 'customer_resolution'
|
||||
|| gate === 'customer_confirmed'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const blockingIssueCount = computed(() => {
|
||||
const issues = effectiveIssues.value;
|
||||
const blocking = issues.filter((item) => String(item.severity || '') === 'blocking');
|
||||
return blocking.length || issues.length;
|
||||
});
|
||||
|
||||
/** 首要阻断文案。 */
|
||||
const primaryBlockMessage = computed(() => {
|
||||
const issues = props.eligibility?.issues || [];
|
||||
const issues = effectiveIssues.value;
|
||||
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 blockedLines = (props.eligibility?.line_projections || []).filter((line) => {
|
||||
if (line.can_build !== false) return false;
|
||||
if (props.customerResolved !== true) return true;
|
||||
const reason = String(line.block_reason || '').trim().toLowerCase();
|
||||
return !reason.startsWith('customer_');
|
||||
});
|
||||
if (!blockedLines.length) {
|
||||
const failedGate = (props.eligibility?.failed_gates || [])[0];
|
||||
if (!failedGate) return '';
|
||||
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
|
||||
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
}
|
||||
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 code = String(primary.code || '').trim().toLowerCase();
|
||||
// Draft 基础校验按冻结 Schema 返回 field_id,资格评估返回 field_code;两者都要映射,
|
||||
// 否则会丢失“究竟哪个字段没有值”的事实,只剩笼统的不可建单。
|
||||
const field = String(primary.field_code || primary.field_id || '').trim();
|
||||
const lineIndex = Number.isFinite(Number(primary.line_index)) ? Number(primary.line_index) : null;
|
||||
const candidates = Array.isArray(primary.candidate_inventory_source_codes)
|
||||
? primary.candidate_inventory_source_codes.map((item) => {
|
||||
const sourceCode = String(item || '').trim();
|
||||
return props.eligibility?.inventory_source_labels?.[sourceCode] || sourceCode;
|
||||
}).filter(Boolean)
|
||||
: [];
|
||||
if (code === 'customer_unresolved') {
|
||||
return t('chat.shippingOrderReview.workbench.manualReview.customer');
|
||||
}
|
||||
if (field) {
|
||||
return t('chat.shippingOrderReview.workbench.manualReview.field', {
|
||||
field: props.fieldLabels?.[field] || field,
|
||||
});
|
||||
}
|
||||
if (lineIndex !== null && (candidates.length || code === 'require_manual_review' || code.includes('inventory_source'))) {
|
||||
return t('chat.shippingOrderReview.workbench.manualReview.lineInventory', {
|
||||
line: lineIndex + 1,
|
||||
candidates: candidates.length ? candidates.join('、') : t('chat.shippingOrderReview.workbench.manualReview.noCandidates'),
|
||||
});
|
||||
}
|
||||
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');
|
||||
if (code && te(key)) return t(key);
|
||||
const failedGate = (props.eligibility?.failed_gates || [])[0];
|
||||
if (failedGate) {
|
||||
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
|
||||
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
}
|
||||
return t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
});
|
||||
|
||||
/** 不可建单的行数。 */
|
||||
@@ -58,6 +129,25 @@ const blockedLineCount = computed(() =>
|
||||
(props.eligibility?.line_projections || []).filter((line) => line.can_build === false).length,
|
||||
);
|
||||
|
||||
const missingRequiredFields = computed(() => (props.eligibility?.assessment?.missing_required_fields || [])
|
||||
.map((code) => props.fieldLabels?.[String(code)] || String(code)));
|
||||
const conflictFields = computed(() => (props.fieldConflicts || []).map((item) => props.fieldLabels?.[String(item.field_code || '').trim()] || String(item.field_code || '').trim())
|
||||
.filter(Boolean));
|
||||
const lowConfidenceFields = computed(() => props.eligibility?.issues?.flatMap((issue) =>
|
||||
(issue.low_confidence_fields || []).map((item) => ({
|
||||
...item,
|
||||
label: props.fieldLabels?.[item.field_code] || item.field_code,
|
||||
})),
|
||||
) || []);
|
||||
const unexplainedBlocked = computed(() => Boolean(
|
||||
props.eligibility
|
||||
&& props.eligibility.can_build === false
|
||||
&& !props.eligibility.issues?.length
|
||||
&& !props.eligibility.failed_gates?.length
|
||||
&& !props.eligibility.assessment?.missing_required_fields?.length
|
||||
&& !(props.eligibility.line_projections || []).some((line) => line.can_build === false),
|
||||
));
|
||||
|
||||
/**
|
||||
* 门禁勾选列表:优先 gates 映射;客户未确认时强制展示失败项。
|
||||
*/
|
||||
@@ -66,17 +156,37 @@ const gateChecklist = computed(() => {
|
||||
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 checks = 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;
|
||||
if (gate === 'customer_confirmed') {
|
||||
passed = props.customerResolved === true ? true : (customerIssue ? false : passed);
|
||||
}
|
||||
if (gate === 'field_conflicts_resolved' && props.fieldConflicts) {
|
||||
passed = props.fieldConflicts.length === 0;
|
||||
}
|
||||
if (gate === 'required_fields_complete' && props.eligibility?.assessment) {
|
||||
const missing = props.eligibility.assessment.missing_required_fields || [];
|
||||
const invalid = props.eligibility.assessment.invalid_lines || [];
|
||||
passed = missing.length === 0 && invalid.length === 0;
|
||||
}
|
||||
const labelKey = `chat.shippingOrderReview.buildEligibility.gates.${gate}`;
|
||||
return {
|
||||
gate,
|
||||
passed,
|
||||
label: te(labelKey) ? t(labelKey) : gate,
|
||||
label: te(labelKey) ? t(labelKey) : t('chat.shippingOrderReview.issueCodes.unknown'),
|
||||
};
|
||||
}).filter((item) => Object.keys(gates).length === 0 || Object.prototype.hasOwnProperty.call(gates, item.gate) || item.gate === 'customer_confirmed');
|
||||
return [
|
||||
{
|
||||
gate: 'overall_build_result',
|
||||
passed: props.eligibility?.can_build === true,
|
||||
label: props.eligibility?.can_build === true
|
||||
? t('chat.shippingOrderReview.buildEligibility.overallPass')
|
||||
: t('chat.shippingOrderReview.buildEligibility.overallBlocked'),
|
||||
},
|
||||
...checks,
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -103,8 +213,15 @@ const gateChecklist = computed(() => {
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<p
|
||||
v-if="eligibility.can_build && eligibility.can_auto_create === false"
|
||||
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-auto-create-blocked"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.buildEligibility.manualConfirmOnly') }}
|
||||
</p>
|
||||
<ul
|
||||
v-if="gateChecklist.length"
|
||||
v-if="!focusBuildability && gateChecklist.length"
|
||||
class="mt-2 space-y-1 text-xs"
|
||||
data-testid="review-eligibility-gate-checklist"
|
||||
>
|
||||
@@ -119,9 +236,57 @@ const gateChecklist = computed(() => {
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div
|
||||
v-if="exceptionCount"
|
||||
class="mt-2 flex flex-wrap items-center justify-between gap-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-exception-nav"
|
||||
>
|
||||
<span>
|
||||
{{ t('chat.shippingOrderReview.issues') }}
|
||||
<span class="ml-1 text-muted">
|
||||
{{ exceptionOrdinal ? `${exceptionOrdinal}/${exceptionCount}` : `0/${exceptionCount}` }}
|
||||
</span>
|
||||
</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-1 text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-950"
|
||||
data-testid="review-exception-prev"
|
||||
:title="t('chat.shippingOrderReview.exceptionNav.prevHint')"
|
||||
@click="emit('navigate-exception', -1)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.exceptionNav.prev') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-1 text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-950"
|
||||
data-testid="review-exception-next"
|
||||
:title="t('chat.shippingOrderReview.exceptionNav.nextHint')"
|
||||
@click="emit('navigate-exception', 1)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.exceptionNav.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="missingRequiredFields.length || conflictFields.length" class="mt-2 space-y-1 rounded-lg border border-rose-200 bg-rose-50 px-2.5 py-2 text-xs text-rose-900 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-100">
|
||||
<p v-if="missingRequiredFields.length"><span class="font-semibold">{{ t('chat.shippingOrderReview.workbench.missingRequiredFields') }}:</span>{{ missingRequiredFields.join('、') }}</p>
|
||||
<p v-if="conflictFields.length"><span class="font-semibold">{{ t('chat.shippingOrderReview.workbench.conflictFields') }}:</span>{{ [...new Set(conflictFields)].join('、') }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="!focusBuildability && lowConfidenceFields.length"
|
||||
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-low-confidence-fields"
|
||||
>
|
||||
<p class="font-semibold">{{ t('chat.shippingOrderReview.workbench.lowConfidenceFields') }}:</p>
|
||||
<ul class="mt-1 list-disc pl-4">
|
||||
<li v-for="item in lowConfidenceFields" :key="item.field_code">
|
||||
{{ item.label }}({{ item.confidence == null ? '—' : `${Math.round(item.confidence * 100)}%` }},{{ t('chat.shippingOrderReview.workbench.confidenceThreshold', { threshold: Math.round(Number(item.minimum_confidence || 0) * 100) }) }})
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!eligibility.can_build && primaryBlockMessage"
|
||||
v-if="!focusBuildability && !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"
|
||||
>
|
||||
@@ -133,6 +298,13 @@ const gateChecklist = computed(() => {
|
||||
}) }}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="unexplainedBlocked"
|
||||
class="mt-2 rounded-lg border border-rose-200 bg-rose-50 px-2.5 py-2 text-xs text-rose-900 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-100"
|
||||
data-testid="review-eligibility-unexplained-block"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.buildEligibility.unexplainedBlocked') }}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user