feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
84a881b554
commit
74270adc22
149 files changed
+20111
-3871
No files matched your search
@@ -2,8 +2,8 @@
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办说明(表单/弹窗入口)。
|
||||
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
|
||||
* 逻辑:优先展示 ui_state.process_gate 阻断信息;hidePrimaryActions=true 时不渲染平级主按钮
|
||||
* (由订单处理工作台统一 ActionBar 输出,UI-01 / BE-05);对话框与登记表单仍由此面板承接。
|
||||
* 逻辑:gateCanHandle 控制 Gate 卡写按钮;actionsExecutable 控制 invokeActionByCode / 对话框写;
|
||||
* hidePrimaryActions=true 时不渲染 action_buttons(订单处理工作台写入口仅 Footer)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -17,6 +17,7 @@ import type {
|
||||
ShippingInventorySourceCandidate,
|
||||
ShippingTaskDetail,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
confirmWorkspaceShippingCustomer,
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
matchWorkspaceShippingInventory,
|
||||
retryWorkspaceShippingUpload,
|
||||
submitWorkspaceShippingDecision,
|
||||
type ShippingFulfillmentOwnershipContext,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
@@ -37,11 +39,31 @@ import { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shipp
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
canHandle: boolean;
|
||||
/** 为 true 时隐藏主按钮区与 Gate 卡内主操作(统一进度 ActionBar 已输出)。 */
|
||||
/** 兼容旧调用:未显式传 gate/actions 时两者跟随 canHandle。 */
|
||||
canHandle?: boolean;
|
||||
/** Gate 卡是否允许写(订单处理工作台恒为 false)。 */
|
||||
gateCanHandle?: boolean;
|
||||
/** Footer/Resolver 委托的 invokeActionByCode 是否可执行写。 */
|
||||
actionsExecutable?: boolean;
|
||||
/** 为 true 时隐藏全部 action_buttons(订单处理工作台写入口仅 Footer)。 */
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
|
||||
expectedNoticeTaskNo?: string | null;
|
||||
/** 工作台权威 OT 号,随履约 API 校验归属。 */
|
||||
expectedOrderTaskNo?: string | null;
|
||||
/** 当前 Review Case 号。 */
|
||||
expectedReviewCaseNo?: string | null;
|
||||
/** 当前 Extraction Run 号。 */
|
||||
expectedRunNo?: string | null;
|
||||
}>(), {
|
||||
canHandle: undefined,
|
||||
gateCanHandle: undefined,
|
||||
actionsExecutable: undefined,
|
||||
hidePrimaryActions: false,
|
||||
expectedNoticeTaskNo: null,
|
||||
expectedOrderTaskNo: null,
|
||||
expectedReviewCaseNo: null,
|
||||
expectedRunNo: null,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -173,12 +195,13 @@ const UNIFIED_OWNED_ACTION_IDS = new Set([
|
||||
]);
|
||||
|
||||
const visibleActions = computed(() => {
|
||||
// [STEP] 订单处理工作台:写操作仅 Footer;不渲染 Notice action_buttons(D1)。
|
||||
if (props.hidePrimaryActions) return [];
|
||||
// [STEP] Gate 阻断时后端已清零 action_buttons;前端再兜底隐藏,避免双真相。
|
||||
if (hasBlockingGate.value) return [];
|
||||
return actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
// [UI-01 / BE-05] 统一 ActionBar 已表达的动作不再重复渲染;未映射的履约动作仍由本面板承接。
|
||||
if (props.hidePrimaryActions && UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
if (UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
return false;
|
||||
}
|
||||
if (!allowedIds.value.has(id) || !isActionAllowedForCheckpoint(id, checkpointKind.value)) {
|
||||
@@ -190,8 +213,14 @@ const visibleActions = computed(() => {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
/** Gate 卡在统一进度存在时仍可执行业务恢复(客户确认等),但避免与 ActionBar 重复的 next_action。 */
|
||||
const gateCanHandle = computed(() => props.canHandle);
|
||||
/** Gate 卡写权限;订单处理工作台传入 false 保持只读。 */
|
||||
const resolvedGateCanHandle = computed(() => (
|
||||
props.gateCanHandle !== undefined ? Boolean(props.gateCanHandle) : Boolean(props.canHandle)
|
||||
));
|
||||
/** Footer 委托写权限。 */
|
||||
const resolvedActionsExecutable = computed(() => (
|
||||
props.actionsExecutable !== undefined ? Boolean(props.actionsExecutable) : Boolean(props.canHandle)
|
||||
));
|
||||
/**
|
||||
* 动作成功后刷新详情并更新导航徽标。
|
||||
*/
|
||||
@@ -338,13 +367,44 @@ async function onFreezeConfirm() {
|
||||
pendingFreezeVersion.value = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 组装履约 API 归属上下文(仅非空字段)。
|
||||
*/
|
||||
function ownershipContext(): ShippingFulfillmentOwnershipContext | undefined {
|
||||
const ctx: ShippingFulfillmentOwnershipContext = {};
|
||||
const ot = String(props.expectedOrderTaskNo || '').trim();
|
||||
const caseNo = String(props.expectedReviewCaseNo || '').trim();
|
||||
const run = String(props.expectedRunNo || '').trim();
|
||||
if (ot) ctx.expectedOrderTaskNo = ot;
|
||||
if (caseNo) ctx.expectedReviewCaseNo = caseNo;
|
||||
if (run) ctx.expectedRunNo = run;
|
||||
return (ctx.expectedOrderTaskNo || ctx.expectedReviewCaseNo || ctx.expectedRunNo) ? ctx : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 履约写前校验正式任务号与工作台权威上下文一致。
|
||||
*
|
||||
* @returns 通过为 true;失败已提示并触发 refreshed
|
||||
*/
|
||||
async function assertFulfillmentOwnership(): Promise<boolean> {
|
||||
const expectedNotice = String(props.expectedNoticeTaskNo || '').trim();
|
||||
const actualNotice = String(props.detail.task_no || '').trim();
|
||||
if (expectedNotice && actualNotice && expectedNotice !== actualNotice) {
|
||||
msg.warning(t('errors.codes.SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH'));
|
||||
emit('refreshed');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
*/
|
||||
async function runAction(action: ShippingChatAction) {
|
||||
if (!props.canHandle || busyId.value) return;
|
||||
if (!resolvedActionsExecutable.value || busyId.value) return;
|
||||
const id = String(action.id || '');
|
||||
if (id === 'mark_manual_uploaded') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
manualUploadOpen.value = true;
|
||||
return;
|
||||
}
|
||||
@@ -357,38 +417,47 @@ async function runAction(action: ShippingChatAction) {
|
||||
return;
|
||||
}
|
||||
if (id === 'confirm_inventory_source') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
await runConfirmInventorySource(action);
|
||||
return;
|
||||
}
|
||||
if (id === 'freeze_order') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
openFreezeDialog();
|
||||
return;
|
||||
}
|
||||
busyId.value = id;
|
||||
try {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
const ownership = ownershipContext();
|
||||
if (id === 'download_excel' || id === 'export') {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'generate_excel') {
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no);
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no);
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'retry_upload') {
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no);
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
await submitWorkspaceShippingDecision(props.detail.task_no, id);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof BusinessError && e.code === 'SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH') {
|
||||
msg.warning(t('errors.codes.SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH'));
|
||||
emit('refreshed');
|
||||
return;
|
||||
}
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
@@ -421,7 +490,7 @@ defineExpose({
|
||||
<div class="space-y-3">
|
||||
<ProcessGateRecoveryCard
|
||||
:summary="processGateSummary"
|
||||
:can-handle="gateCanHandle"
|
||||
:can-handle="resolvedGateCanHandle"
|
||||
:navigation-context="{
|
||||
agentId: detail.owner_agent_id != null ? String(detail.owner_agent_id) : undefined,
|
||||
conversationId: detail.conversation_id || undefined,
|
||||
@@ -446,7 +515,7 @@ defineExpose({
|
||||
<p v-if="summary.pause_reason" class="mt-1 text-xs text-amber-700">
|
||||
{{ summary.pause_reason }}
|
||||
</p>
|
||||
<div v-if="!canHandle" class="mt-3 text-xs text-muted">
|
||||
<div v-if="!resolvedActionsExecutable" class="mt-3 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
|
||||
</div>
|
||||
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
@@ -477,7 +546,7 @@ defineExpose({
|
||||
v-model:open="manualUploadOpen"
|
||||
:task-no="detail.task_no"
|
||||
:artifact-id="currentExportArtifactId"
|
||||
:disabled="!canHandle"
|
||||
:disabled="!resolvedActionsExecutable"
|
||||
@success="afterSuccess"
|
||||
/>
|
||||
<ShippingCustomerConfirmDialog
|
||||
|
||||
Reference in new issue
Block a user