feat(shipping-notice): 增强发货通知与审计功能,支持敏感数据控制与哈希链校验
- 更新发货通知工具 API,剥离不可信的操作人身份字段,确保审计安全 - 引入审计事件的哈希链校验机制,支持数据完整性验证 - 增强订单抽取与审计功能,支持敏感快照的访问控制 - 更新相关模型与服务,确保新功能的完整性与可追溯性 - 完善文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
1 parent
95cdfe66b0
commit
d0fe084999
225 files changed
+25923
-6653
No files matched your search
@@ -1,131 +1,91 @@
|
||||
/**
|
||||
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
|
||||
* 用途:仅渲染后端 ui_state.action_buttons / summary.allowed_actions 对应的当前待办动作。
|
||||
|
||||
* 依赖:shipping.api 履约写接口、shipping-tasks.api 下载/人工上传、各确认对话框。
|
||||
|
||||
* 逻辑:禁止按 process_status 二次推导按钮;管理员 can_handle=false 时只读。
|
||||
|
||||
* 依赖:shipping.api 履约写接口、shipping-tasks.api 下载/人工上传、ManualUploadEvidenceDialog、各确认对话框。
|
||||
* 逻辑:禁止按 process_status 二次推导按钮;管理员 can_handle=false 时只读;
|
||||
* wait_manual_upload 允许下载 Excel + 登记人工上传凭据(禁 RPA);
|
||||
* 多源阻断时对话框候选强制取 stp_facts.recovery_source_codes,禁止展示冻结全集。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
|
||||
import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
|
||||
|
||||
import type {
|
||||
|
||||
ShippingChatAction,
|
||||
|
||||
ShippingCustomerOption,
|
||||
|
||||
ShippingInventorySourceCandidate,
|
||||
|
||||
ShippingTaskDetail,
|
||||
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
import {
|
||||
|
||||
confirmWorkspaceShippingCustomer,
|
||||
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
|
||||
freezeWorkspaceShippingOrder,
|
||||
|
||||
generateWorkspaceShippingExcel,
|
||||
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
|
||||
matchWorkspaceShippingInventory,
|
||||
|
||||
retryWorkspaceShippingUpload,
|
||||
|
||||
submitWorkspaceShippingDecision,
|
||||
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
|
||||
import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
|
||||
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
|
||||
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
detail: ShippingTaskDetail;
|
||||
|
||||
canHandle: boolean;
|
||||
|
||||
}>();
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
refreshed: [];
|
||||
|
||||
}>();
|
||||
|
||||
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const msg = useMessage();
|
||||
|
||||
const busyId = ref<string | null>(null);
|
||||
|
||||
const manualUploadOpen = ref(false);
|
||||
|
||||
|
||||
|
||||
const customerDialogOpen = ref(false);
|
||||
|
||||
const customerOptions = ref<ShippingCustomerOption[]>([]);
|
||||
|
||||
const customerLoading = ref(false);
|
||||
|
||||
|
||||
|
||||
const freezeDialogOpen = ref(false);
|
||||
|
||||
const pendingFreezeVersion = ref<number | null>(null);
|
||||
|
||||
|
||||
|
||||
const inventorySourceDialogOpen = ref(false);
|
||||
|
||||
const inventorySourceCandidates = ref<ShippingInventorySourceCandidate[]>([]);
|
||||
|
||||
const inventorySourceInitialCode = ref('');
|
||||
|
||||
|
||||
|
||||
const summary = computed(() => props.detail.ui_state?.summary || {});
|
||||
|
||||
const actionButtons = computed(() => props.detail.ui_state?.action_buttons || []);
|
||||
|
||||
const checkpointKind = computed(() => String(props.detail.ui_state?.checkpoint_kind || ''));
|
||||
const checkpoint = computed(() => String(props.detail.ui_state?.checkpoint || ''));
|
||||
|
||||
/**
|
||||
* 是否展示「待人工上传登记」提示。
|
||||
* 核心逻辑:wait_manual_upload,或 export_ready/export_generated 且已有导出文件名/工件。
|
||||
*/
|
||||
const showWaitingManualUploadNote = computed(() => {
|
||||
if (checkpointKind.value === 'wait_manual_upload') return true;
|
||||
if (checkpoint.value === 'export_ready' || checkpoint.value === 'export_generated') {
|
||||
return Boolean(
|
||||
props.detail.export_file_name
|
||||
|| (Array.isArray(props.detail.export_artifacts) && props.detail.export_artifacts.length > 0),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/** 当前导出工件 id,供人工上传登记对话框绑定。 */
|
||||
const currentExportArtifactId = computed(() => {
|
||||
const artifacts = props.detail.export_artifacts;
|
||||
if (!Array.isArray(artifacts) || !artifacts.length) return null;
|
||||
const id = Number(artifacts[0]?.id);
|
||||
return Number.isFinite(id) ? id : null;
|
||||
});
|
||||
/** auto_continue 仅保留刷新;正常 STP 由后台自动推进。 */
|
||||
const AUTO_CONTINUE_ACTIONS = new Set(['refresh']);
|
||||
|
||||
/** wait_manual_upload 仅允许下载/导出/人工上传确认。 */
|
||||
const WAIT_MANUAL_UPLOAD_ACTIONS = new Set(['download_excel', 'export', 'mark_manual_uploaded', 'refresh']);
|
||||
|
||||
/** must_human 保留例外处理动作,禁止 Chat 侧履约写路径。 */
|
||||
const MUST_HUMAN_ACTIONS = new Set([
|
||||
'confirm',
|
||||
@@ -142,7 +102,6 @@ const MUST_HUMAN_ACTIONS = new Set([
|
||||
'match_inventory',
|
||||
'refresh',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 按 STP checkpoint_kind 过滤工作台动作,避免 auto_continue 误点写操作。
|
||||
*/
|
||||
@@ -153,601 +112,291 @@ function isActionAllowedForCheckpoint(actionId: string, kind: string): boolean {
|
||||
if (kind === 'must_human') return MUST_HUMAN_ACTIONS.has(actionId);
|
||||
return true;
|
||||
}
|
||||
|
||||
const allowedIds = computed(() => {
|
||||
|
||||
const fromSummary = summary.value.allowed_actions;
|
||||
|
||||
if (Array.isArray(fromSummary) && fromSummary.length) return new Set(fromSummary.map(String));
|
||||
|
||||
return new Set(actionButtons.value.map((item) => item.id));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const visibleActions = computed(() =>
|
||||
|
||||
actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
return allowedIds.value.has(id) && isActionAllowedForCheckpoint(id, checkpointKind.value);
|
||||
}),
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 动作成功后刷新详情并更新导航徽标。
|
||||
|
||||
*/
|
||||
|
||||
async function afterSuccess() {
|
||||
|
||||
await refreshShippingTodoBadge(true);
|
||||
|
||||
emit('refreshed');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 从任务上下文解析唯一库存源编码;多候选或无候选时返回空字符串。
|
||||
|
||||
*/
|
||||
|
||||
function resolveSingleInventorySourceCode(action: ShippingChatAction): string {
|
||||
|
||||
const fromAction = String(action.source_code || '').trim().toUpperCase();
|
||||
|
||||
if (fromAction) return fromAction;
|
||||
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
|
||||
const candidates = resolution && typeof resolution === 'object'
|
||||
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
|
||||
: null;
|
||||
|
||||
if (Array.isArray(candidates) && candidates.length === 1) {
|
||||
|
||||
const only = candidates[0];
|
||||
|
||||
if (only && typeof only === 'object') {
|
||||
|
||||
return String((only as { source_code?: unknown }).source_code || '').trim().toUpperCase();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 打开库存源选择对话框;若已能唯一解析则直接提交。
|
||||
|
||||
*/
|
||||
|
||||
async function runConfirmInventorySource(action: ShippingChatAction) {
|
||||
|
||||
const directCode = resolveSingleInventorySourceCode(action);
|
||||
|
||||
if (directCode) {
|
||||
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, directCode);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
|
||||
const raw = resolution && typeof resolution === 'object'
|
||||
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
|
||||
: null;
|
||||
|
||||
inventorySourceCandidates.value = Array.isArray(raw)
|
||||
|
||||
? raw.filter((item): item is ShippingInventorySourceCandidate =>
|
||||
|
||||
Boolean(item && typeof item === 'object' && (item as ShippingInventorySourceCandidate).source_code))
|
||||
|
||||
: [];
|
||||
|
||||
inventorySourceInitialCode.value = String(action.source_code || '').trim().toUpperCase();
|
||||
|
||||
inventorySourceDialogOpen.value = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 对话框确认库存源后提交后端。
|
||||
|
||||
*/
|
||||
|
||||
async function onInventorySourceConfirm(sourceCode: string) {
|
||||
|
||||
if (!sourceCode.trim()) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.inventorySourcePrompt'));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, sourceCode.trim().toUpperCase());
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 打开客户确认对话框并加载启用标准客户。
|
||||
|
||||
*/
|
||||
|
||||
async function openCustomerDialog() {
|
||||
|
||||
customerDialogOpen.value = true;
|
||||
|
||||
customerLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
customerOptions.value = await listWorkspaceShippingCustomerOptions();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
customerOptions.value = [];
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
} finally {
|
||||
|
||||
customerLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 按关键词刷新客户选项。
|
||||
|
||||
*/
|
||||
|
||||
async function searchCustomers(query: string) {
|
||||
|
||||
customerLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
customerOptions.value = await listWorkspaceShippingCustomerOptions(query.trim());
|
||||
|
||||
if (!customerOptions.value.length) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
}
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
} finally {
|
||||
|
||||
customerLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 确认客户后刷新任务详情。
|
||||
|
||||
*/
|
||||
|
||||
async function onCustomerConfirm(customerId: number) {
|
||||
|
||||
busyId.value = 'confirm_customer';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingCustomer(props.detail.task_no, customerId);
|
||||
|
||||
customerDialogOpen.value = false;
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 校验版本并打开冻结确认对话框。
|
||||
|
||||
*/
|
||||
|
||||
function openFreezeDialog() {
|
||||
|
||||
const version = Number(props.detail.order_data_version);
|
||||
|
||||
if (!Number.isInteger(version) || version < 1) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.freezeFailed'));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
pendingFreezeVersion.value = version;
|
||||
|
||||
freezeDialogOpen.value = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 确认冻结后提交后端。
|
||||
|
||||
*/
|
||||
|
||||
async function onFreezeConfirm() {
|
||||
|
||||
const version = pendingFreezeVersion.value;
|
||||
|
||||
if (version == null) return;
|
||||
|
||||
busyId.value = 'freeze_order';
|
||||
|
||||
try {
|
||||
|
||||
await freezeWorkspaceShippingOrder(props.detail.task_no, version);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
pendingFreezeVersion.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
|
||||
*/
|
||||
|
||||
async function runAction(action: ShippingChatAction) {
|
||||
|
||||
if (!props.canHandle || busyId.value) return;
|
||||
|
||||
const id = String(action.id || '');
|
||||
|
||||
|
||||
|
||||
if (id === 'mark_manual_uploaded') {
|
||||
|
||||
manualUploadOpen.value = true;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'refresh') {
|
||||
|
||||
emit('refreshed');
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'confirm_customer') {
|
||||
|
||||
await openCustomerDialog();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'confirm_inventory_source') {
|
||||
|
||||
await runConfirmInventorySource(action);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'freeze_order') {
|
||||
|
||||
openFreezeDialog();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
busyId.value = id;
|
||||
|
||||
try {
|
||||
|
||||
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 afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'retry_upload') {
|
||||
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
await submitWorkspaceShippingDecision(props.detail.task_no, id);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<section class="rounded-2xl border border-brand-200/80 bg-brand-50/40 px-4 py-3">
|
||||
|
||||
<div class="mb-1 text-xs font-semibold uppercase tracking-wide text-brand-700">
|
||||
|
||||
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
|
||||
|
||||
</div>
|
||||
|
||||
<h3 class="text-sm font-semibold text-primary">
|
||||
|
||||
{{ summary.current_todo || summary.title || $t('workspace.shippingNotice.todo.noActionTitle') }}
|
||||
|
||||
</h3>
|
||||
|
||||
<p class="mt-1 text-sm text-secondary">
|
||||
|
||||
{{ summary.message || $t('workspace.shippingNotice.todo.noActionMessage') }}
|
||||
|
||||
</p>
|
||||
|
||||
<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">
|
||||
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
|
||||
<button
|
||||
|
||||
v-for="action in visibleActions"
|
||||
|
||||
:key="action.id"
|
||||
|
||||
type="button"
|
||||
|
||||
class="rounded-xl px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50"
|
||||
|
||||
:class="action.variant === 'danger'
|
||||
|
||||
? 'bg-rose-600 text-white hover:bg-rose-700'
|
||||
|
||||
: action.variant === 'secondary'
|
||||
|
||||
? 'border border-default bg-surface text-secondary hover:bg-surface-soft'
|
||||
|
||||
: 'bg-brand-600 text-white hover:bg-brand-700'"
|
||||
|
||||
:disabled="busyId === action.id"
|
||||
|
||||
@click="runAction(action)"
|
||||
|
||||
>
|
||||
|
||||
{{ action.label }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<p
|
||||
v-if="showWaitingManualUploadNote"
|
||||
class="mt-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
data-testid="manual-upload-end-note"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.waitingManualUploadNote') }}
|
||||
</p>
|
||||
<ManualUploadEvidenceDialog
|
||||
|
||||
v-model:open="manualUploadOpen"
|
||||
|
||||
:task-no="detail.task_no"
|
||||
|
||||
:artifact-id="detail.export_artifacts?.[0]?.id"
|
||||
|
||||
:artifact-id="currentExportArtifactId"
|
||||
:disabled="!canHandle"
|
||||
|
||||
@success="afterSuccess"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ShippingCustomerConfirmDialog
|
||||
|
||||
:open="customerDialogOpen"
|
||||
|
||||
:options="customerOptions"
|
||||
|
||||
:loading="customerLoading"
|
||||
|
||||
@close="customerDialogOpen = false"
|
||||
|
||||
@search="searchCustomers"
|
||||
|
||||
@confirm="onCustomerConfirm"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<InventorySourceSelectDialog
|
||||
|
||||
v-model:open="inventorySourceDialogOpen"
|
||||
|
||||
:candidates="inventorySourceCandidates"
|
||||
|
||||
:initial-code="inventorySourceInitialCode"
|
||||
|
||||
@confirm="onInventorySourceConfirm"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<DeleteConfirmDialog
|
||||
|
||||
v-model="freezeDialogOpen"
|
||||
|
||||
confirm-tone="primary"
|
||||
|
||||
:title="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
|
||||
:message="$t('workspace.shippingNotice.actions.freezeConfirm')"
|
||||
|
||||
:confirm-text="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
|
||||
:confirm-loading="busyId === 'freeze_order'"
|
||||
|
||||
@confirm="onFreezeConfirm"
|
||||
|
||||
/>
|
||||
|
||||
</section>
|
||||
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user