feat(shipping-notice): 实现对话级批量重试自动推进功能,优化库存与PDF匹配逻辑
- 新增对话级批量重试自动推进的完整链路:后端服务、API、数据投影逻辑 - 前端新增对话级重试按钮、多语言国际化支持与API类型定义 - 优化行级库存重试控制,新增retryable字段统一管控重试按钮展示,清理废弃的view_fulfillment_detail动作,标准化前端动作码排序逻辑 - 修复PDF坐标匹配的fail-close防护逻辑,避免生成伪精确匹配分数 - 调整订单确认后流程,提前进入库存获取阶段,移除冗余的确认建单按钮,优化用户流转体验 - 新增对应单元测试用例覆盖核心业务逻辑
This commit is contained in:
1 parent
fd6a23f870
commit
1008911a7e
41 files changed
+3956
-1256
No files matched your search
+36
-76
@@ -265,26 +265,28 @@ function primaryActionItem(task: ConversationProcessingUserTask): ActionPresenta
|
||||
return taskActionPresentation(task).primary;
|
||||
}
|
||||
|
||||
/** needs_action 的用户语义提示:不重复主按钮文案。 */
|
||||
function currentNeedLabel(task: ConversationProcessingUserTask): string {
|
||||
if (task.group !== 'needs_action') return '';
|
||||
const action = String(task.primary_action || task.available_actions?.[0] || '').trim().toLowerCase();
|
||||
const labels: Record<string, string> = {
|
||||
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
|
||||
resolve_field_conflicts: 'chat.shippingProcessing.currentNeed.resolveFieldConflicts',
|
||||
open_inventory_match_review: 'chat.shippingProcessing.currentNeed.inventoryMatch',
|
||||
open_order_processing: 'chat.shippingProcessing.currentNeed.orderDraft',
|
||||
retry: 'chat.shippingProcessing.currentNeed.retry',
|
||||
retry_parse: 'chat.shippingProcessing.currentNeed.retry',
|
||||
};
|
||||
const key = labels[action];
|
||||
return key && te(key) ? t(key) : t('chat.shippingProcessing.currentNeed.generic');
|
||||
}
|
||||
|
||||
/**
|
||||
* 次要文字链:有文件对象时可展开 → 不返回 view_details(改由展开文件入口承载);
|
||||
* 无文件对象时优先 view_details,否则取非 cancel 的 presentation.secondary。
|
||||
*/
|
||||
function secondaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
if (canExpandFileDetails(task)) return null;
|
||||
const presentation = taskActionPresentation(task);
|
||||
const candidates = [
|
||||
presentation.secondary,
|
||||
...presentation.overflow,
|
||||
].filter((item): item is ActionPresentationItem => Boolean(item));
|
||||
const viewDetails = candidates.find(
|
||||
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
|
||||
);
|
||||
if (viewDetails) return viewDetails;
|
||||
const secondary = presentation.secondary;
|
||||
if (!secondary) return null;
|
||||
const code = String(secondary.actionCode || '').trim().toLowerCase();
|
||||
if (code === 'cancel_task' || code === 'cancel_run' || code === 'view_details') return null;
|
||||
return secondary;
|
||||
function secondaryActionItem(_task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,11 +312,8 @@ function overflowActionItems(task: ConversationProcessingUserTask): ActionPresen
|
||||
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
|
||||
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
|
||||
*/
|
||||
function shouldShowOverflowActions(task: ConversationProcessingUserTask): boolean {
|
||||
if (projectionForTask(task)) return false;
|
||||
if (!overflowActionItems(task).length) return false;
|
||||
if (canExpandFileDetails(task)) return isDetailsExpanded(task);
|
||||
return true;
|
||||
function shouldShowOverflowActions(_task: ConversationProcessingUserTask): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,15 +328,19 @@ function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boole
|
||||
* 处理记录只读卡:仅保留 view_details 文字链(无主 CTA / 取消 / 重解析)。
|
||||
*/
|
||||
function recordViewDetailsItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
if (String(task.status_label || '').trim().toLowerCase() === 'cancelled') return null;
|
||||
const presentation = taskActionPresentation(task);
|
||||
const candidates = [
|
||||
presentation.primary,
|
||||
presentation.secondary,
|
||||
...presentation.overflow,
|
||||
].filter((item): item is ActionPresentationItem => Boolean(item));
|
||||
return candidates.find(
|
||||
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
|
||||
) || null;
|
||||
return candidates.find((item) => {
|
||||
const code = String(item.actionCode || '').trim().toLowerCase();
|
||||
return code === 'view_details' || code === 'view_result';
|
||||
}) || (String(task.group || '') === 'completed'
|
||||
? { intent: 'view_result', actionCode: 'view_result', labelKey: 'chat.shippingProcessing.action.view_result' }
|
||||
: null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,8 +594,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="task.group === 'needs_action' && currentNeedLabel(task)"
|
||||
class="mt-1 text-[11px] text-secondary"
|
||||
data-testid="shipping-processing-current-need"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeedLabel(task) }}
|
||||
</div>
|
||||
<SidebarProgressInline
|
||||
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
v-if="task.group === 'processing' && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="progressModeForTask(task) === 'compact'"
|
||||
@@ -612,57 +622,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
>
|
||||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
<ChevronRight v-else class="h-3 w-3" />
|
||||
{{ isDetailsExpanded(task)
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="secondaryActionItem(task)"
|
||||
type="button"
|
||||
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-else-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
<ChevronRight v-else class="h-3 w-3" />
|
||||
{{ isDetailsExpanded(task)
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<div
|
||||
v-if="shouldShowOverflowActions(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-overflow-actions"
|
||||
>
|
||||
<button
|
||||
v-for="item in overflowActionItems(task)"
|
||||
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
|
||||
type="button"
|
||||
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${item.actionCode}`"
|
||||
@click="onTaskAction(task, item.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, item) }}
|
||||
</button>
|
||||
<span v-if="task.group === 'needs_action'" class="sr-only">{{ currentNeedLabel(task) }}</span>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user