!13 feat(shipping-freight-auto-upload): 新增货代发货Excel连接级自动上传全链路功能

Merge pull request !13 from 曹惠鹏/hugo-shipping-notice
This commit is contained in:
sophie authored and Gitee committed 2026-08-27 07:51:42 +00:00
commit 2921c8d90f
93 files changed
+4867 -601

No files matched your search

@@ -2,7 +2,8 @@
* features/chat/components/shipping-review/ReviewCurrentProcessingCard.spec.ts
* 用途:验证工作台右侧当前任务卡只在需要人工处理时渲染业务动作。
* 依赖:Vitest、Vue Test Utils、Vue I18n、ReviewCurrentProcessingCard。
* 逻辑:库存自动处理中即使遗留 primary_action,也不得显示编辑正式任务;可重试状态仍保留重试入口。
* 逻辑:库存自动处理中即使遗留 primary_action,也不得显示编辑正式任务;可重试状态仍保留重试入口;
* loading 是「权威投影读取中」占位:已知阶段照常展示,状态/下一步给中性加载文案(非系统处理中)。
*/
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
@@ -38,9 +39,25 @@ const i18n = createI18n({
saveOrderAndValidate: '提交订单',
currentProcessing: {
waitingStart: '等待系统启动',
stageLoading: '正在获取最新状态…',
statusIdle: '待机',
status: '状态',
stages: {
excel_generating: 'Excel 生成',
},
},
currentTask: {
title: '当前任务',
labelStage: '当前门禁',
statusRunning: '系统处理中',
statusWaitingHuman: '待人工处理',
statusRetryable: '可重试',
statusFailed: '自动处理失败',
statusCompleted: '已完成',
statusCancelled: '已取消',
nextStepTitle: '下一步',
nextStepRunning: '系统正在处理,暂不需要人工操作',
nextStepUnknown: '状态待确认',
nextStepWaitingExternal: '等待外部系统回执,暂不需要人工操作',
},
},
@@ -180,6 +197,23 @@ describe('ReviewCurrentProcessingCard', () => {
expect(wrapper.text()).not.toContain('edit_draft');
});
it('hides an unlabeled primary action instead of rendering an icon-only ghost button', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
stageCode: 'fulfillment_prep',
userStatus: 'waiting_human',
// 后端下发了动作码,但前端无受控文案(缺失 i18n 映射 / 未登记),
// 必须整体隐藏按钮,不能渲染成只有 Bot/RefreshCw 图标的“幽灵按钮”。
primaryAction: { code: 'unknown_system_action', i18nKey: 'workspace.shippingNotice.processGate.actionCodes.unknown_system_action' },
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-current-task-actions"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
expect(wrapper.text()).not.toContain('unknown_system_action');
});
it('renders a localized reason instead of an internal blocking code in the next step', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
@@ -233,4 +267,46 @@ describe('ReviewCurrentProcessingCard', () => {
['retry_inventory_preparation', {}],
]);
});
it('keeps the known stage and status while the authoritative projection is still loading', () => {
// Case 先到、Projection 后到的过渡窗口:阶段与投影同源(project_stage_for_task),
// status 也来自后端 automation 运行态,必须照常展示,不能退回骨架/「正在更新状态」占位。
const wrapper = mount(ReviewCurrentProcessingCard, {
props: {
loading: true,
stageCode: 'excel_generating',
stageLabelKey: 'excel_generating',
userStatus: 'running',
},
global: { plugins: [i18n] },
});
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('Excel 生成');
// loading 只抑制动作,不掩盖真值:运行态照常显示「系统处理中」。
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('系统处理中');
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text())
.toBe('系统正在处理,暂不需要人工操作');
});
it('shows the neutral idle value instead of a skeleton when nothing is actionable yet', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: { loading: true, stageCode: 'excel_generating', stageLabelKey: 'excel_generating' },
global: { plugins: [i18n] },
});
// 空用户态自然落到「待机 / 状态待确认」,与投影稳态一致——不做骨架→真值的二次刷新。
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('Excel 生成');
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('待机');
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('状态待确认');
});
it('falls back to a neutral stage placeholder only when no stage is known', () => {
const wrapper = mount(ReviewCurrentProcessingCard, {
props: { loading: true },
global: { plugins: [i18n] },
});
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('正在获取最新状态…');
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('待机');
});
});
@@ -4,6 +4,11 @@
依赖:vue-i18n、ShippingProcessingBlockingReason/PrimaryAction 类型、resolveShippingProcessingStageLabel。
逻辑:主卡内部 section = 「当前阶段/状态/正式OT → 下一步 → 动作区」;
状态文案严格绑定 user_status;blocking_reason 只作下一步问题说明;按钮显隐由后端 retryable + primary_action.parameters 决定;
主动作按钮文案 fail-closed:后端下发动作码但无受控 i18n 文案时整体隐藏该按钮(含图标),禁止渲染无文字裸按钮;
loading 仅代表「权威投影读取中」而非系统运行态:已知阶段/状态/阻断仍照常展示
(与投影同源或后端 automation 运行态),空态自然落到「待机/状态待确认」,
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
loading 仅在挂载期抑制可执行动作,等权威投影到达后再放行(fail-closed);
由 ShippingOrderReviewView 在 mountCurrentProcessingCard 时挂载。
-->
<script setup lang="ts">
@@ -24,9 +29,6 @@ const props = defineProps<{
stageLabelKey?: string | null;
stageInconsistent?: boolean;
hasFormalOt?: boolean;
shippingNoticeNo?: string | null;
userStatus?:
| 'running'
| 'waiting_human'
@@ -70,10 +72,16 @@ const { t, te } = useI18n();
/**
* 当前阶段展示文案:优先消费 stage_label_key,禁止直接展示 stage 码。
* 核心逻辑:loading 是「权威投影读取中」占位,不是业务运行态——只要已有可展示的
* 阶段(Case 快照 current_stage 与投影同源,见 currentProcessingStageDisplay),
* 照常展示真实阶段;仅在连降级阶段都没有时才回退 stageLoading 占位文案。
*/
const stageLabel = computed(() => {
if (props.loading) {
return t('chat.shippingOrderReview.caseSwitchLoading');
const hasKnownStage = Boolean(
String(props.stageCode || '').trim() || String(props.stageLabelKey || '').trim(),
);
if (props.loading && !hasKnownStage) {
return t('chat.shippingOrderReview.currentProcessing.stageLoading');
}
if (props.stageInconsistent) {
return t('chat.shippingOrderReview.currentProcessing.stateInconsistent');
@@ -88,11 +96,11 @@ const stageLabel = computed(() => {
/**
* 「状态」行用户态文案:严格绑定 user_status,不再由前端推断。
* loading 只是「权威投影读取中」:只要已有后端下发的 user_status(如 Case automation
* 运行态)就照常展示真实/待机文案,禁止再退回「正在获取最新状态」骨架造成二次刷新
* (状态空时 statusIdle 即中性「待机」,与投影稳态一致)。
*/
const statusLabel = computed(() => {
if (props.loading) {
return t('chat.shippingOrderReview.currentTask.statusRunning');
}
const s = String(props.userStatus || '').trim() as ReviewCurrentUserStatus | '';
const map: Record<ReviewCurrentUserStatus, string> = {
running: t('chat.shippingOrderReview.currentTask.statusRunning'),
@@ -132,9 +140,10 @@ const nextStepText = computed(() => {
}
return raw;
};
if (props.loading) {
return safeMessage(props.automation?.message) || t('chat.shippingOrderReview.currentTask.nextStepRunning');
}
// 加载占位不等于系统运行态:只透传后端 automation.message(若有);
// 其余按 user_status/blocking_reason 照常渲染,空态自然落在「状态待确认」,不做骨架二次刷新。
const automationMessage = props.loading ? safeMessage(props.automation?.message) : '';
if (automationMessage) return automationMessage;
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
const br = props.blockingReason;
if (br) {
@@ -219,6 +228,10 @@ function isNonTaskCapabilityAction(code: string): boolean {
/**
* 业务动作按钮只消费 primary_action;retryable 是状态,不是授权。
*
* 核心逻辑:除既有授权过滤外,文案必须是后端下发且经受控映射解析出的非空文案
* (businessActionLabel 已 fail-closed 为 '');无文案时整体隐藏按钮,防止
* 渲染成只有图标/空壳的“幽灵按钮”误导用户以为是开关或其他控件。
*/
const showBusinessAction = computed(() => {
if (props.loading) return false;
@@ -233,6 +246,8 @@ const showBusinessAction = computed(() => {
if (isHiddenWorkbenchNavigationAction(code)) return false;
// 无对象边界的泛化 retry 永不展示。
if (code === 'retry') return false;
// [AUTHORITY] 无受控文案的动作码 fail-closed:连图标一起隐藏,不渲染空壳按钮。
if (!businessActionLabel.value) return false;
return true;
});
@@ -365,16 +380,6 @@ type ReviewCurrentUserStatus =
{{ statusLabel }}
</dd>
</div>
<div
v-if="hasFormalOt && shippingNoticeNo"
class="flex flex-wrap gap-x-2"
>
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentTask.labelFormalSn') }}</dt>
<dd
class="font-mono"
data-testid="review-current-processing-ot"
>{{ shippingNoticeNo }}</dd>
</div>
</dl>
<p
@@ -168,8 +168,11 @@ function drawEvidenceHighlight(
context.strokeStyle = 'rgba(202, 138, 4, 0.95)';
context.setLineDash([]);
} else {
context.fillStyle = 'rgba(244, 63, 94, 0.18)';
context.strokeStyle = 'rgba(225, 29, 72, 0.95)';
// unavailable / invalid 证据高亮统一使用品牌色(对齐编辑画布匹配锚点的 sky/brand 蓝),
// 避免在纯文档预览上出现刺眼的红色,导致「模板预览图标颜色不一致」的观感。
// 说明:质量仅影响可信度提示,不改变「该处确有取值位置」的语义,故不再用警示红。
context.fillStyle = 'rgba(14, 165, 233, 0.22)';
context.strokeStyle = 'rgba(2, 132, 199, 0.95)';
context.setLineDash([3, 3]);
}
context.lineWidth = 2;