feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估
- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
1 parent
cef3d5b26a
commit
3a9fbac2fc
226 files changed
+25010
-2098
No files matched your search
@@ -0,0 +1,229 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewDuplicatePanel.vue
|
||||
用途:复核工作台建单前重复订单对比与裁决区。
|
||||
依赖:vue-i18n、shipping.api 重复裁决/刷新、useMessage。
|
||||
逻辑:needs_adjudication 时展示匹配任务与动作;裁决成功后 emit refreshed。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
refreshWorkspaceShippingOrderReviewDuplicate,
|
||||
resolveWorkspaceShippingOrderReviewDuplicate,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type {
|
||||
ShippingDuplicateAction,
|
||||
ShippingOrderReviewDuplicate,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
caseNo: string;
|
||||
duplicate: ShippingOrderReviewDuplicate | null | undefined;
|
||||
editable: boolean;
|
||||
canForceCreate: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
refreshed: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const busy = ref(false);
|
||||
const forceReason = ref('');
|
||||
const selectedAction = ref<ShippingDuplicateAction | ''>('');
|
||||
|
||||
const visible = computed(() => Boolean(props.duplicate?.needs_adjudication || props.duplicate?.blocking));
|
||||
const allowed = computed(() => new Set(props.duplicate?.allowed_actions || []));
|
||||
const primaryMatch = computed(() => props.duplicate?.matches?.[0] || null);
|
||||
const resolved = computed(() => Boolean(props.duplicate?.resolved));
|
||||
|
||||
/**
|
||||
* 重复状态本地化文案。
|
||||
*/
|
||||
const statusLabel = computed(() => {
|
||||
const status = String(props.duplicate?.status || '').trim();
|
||||
const key = `chat.shippingOrderReview.duplicate.status.${status}`;
|
||||
if (status && te(key)) return t(key);
|
||||
if (props.duplicate?.blocking) return t('chat.shippingNoticeDuplicateNeedsResolution');
|
||||
return t('chat.shippingOrderReview.duplicate.status.none');
|
||||
});
|
||||
|
||||
/**
|
||||
* 提交重复裁决。
|
||||
*/
|
||||
async function resolve(action: ShippingDuplicateAction) {
|
||||
if (!props.editable || !props.caseNo || busy.value) return;
|
||||
if (!allowed.value.has(action)) {
|
||||
msg.warning(t('chat.shippingNoticeDuplicateActionUnavailable'));
|
||||
return;
|
||||
}
|
||||
const target = String(primaryMatch.value?.task_no || '').trim();
|
||||
if (!target) {
|
||||
msg.warning(t('chat.shippingNoticeDuplicateActionUnavailable'));
|
||||
return;
|
||||
}
|
||||
if (action === 'force_create') {
|
||||
if (!props.canForceCreate) {
|
||||
msg.warning(t('chat.shippingNoticeDuplicateForceForbidden'));
|
||||
return;
|
||||
}
|
||||
if (!forceReason.value.trim()) {
|
||||
msg.warning(t('chat.shippingNoticeDuplicateReasonRequired'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
busy.value = true;
|
||||
selectedAction.value = action;
|
||||
try {
|
||||
await resolveWorkspaceShippingOrderReviewDuplicate(props.caseNo, {
|
||||
action,
|
||||
target_task_no: target,
|
||||
reason: action === 'force_create' ? forceReason.value.trim() : undefined,
|
||||
});
|
||||
forceReason.value = '';
|
||||
msg.success(t('chat.shippingOrderReview.duplicate.resolveSuccess'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.duplicate.resolveFailed'));
|
||||
msg.warning(message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
selectedAction.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新检测重复(清除陈旧决议)。
|
||||
*/
|
||||
async function onRefresh() {
|
||||
if (!props.editable || !props.caseNo || busy.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await refreshWorkspaceShippingOrderReviewDuplicate(props.caseNo);
|
||||
msg.success(t('chat.shippingOrderReview.duplicate.refreshDone'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.duplicate.refreshFailed'));
|
||||
msg.warning(message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="visible"
|
||||
class="rounded-xl border border-amber-200 bg-amber-50/70 p-3 shadow-sm dark:border-amber-900 dark:bg-amber-950/40"
|
||||
data-testid="review-duplicate-panel"
|
||||
>
|
||||
<header class="flex flex-wrap items-start justify-between gap-2">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold text-amber-950 dark:text-amber-50">
|
||||
{{ t('chat.shippingOrderReview.duplicate.title') }}
|
||||
</h2>
|
||||
<p class="mt-0.5 text-xs text-amber-900 dark:text-amber-200">
|
||||
{{ t('chat.shippingOrderReview.duplicate.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2.5 py-1 text-xs font-medium"
|
||||
:class="resolved
|
||||
? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'
|
||||
: 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'"
|
||||
data-testid="review-duplicate-badge"
|
||||
>
|
||||
{{ resolved ? t('chat.shippingOrderReview.duplicate.resolvedBadge') : statusLabel }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<div
|
||||
v-if="primaryMatch"
|
||||
class="mt-2 rounded-lg border border-amber-200 bg-white/90 px-2.5 py-2 text-xs text-secondary dark:border-amber-900 dark:bg-slate-900"
|
||||
data-testid="review-duplicate-match"
|
||||
>
|
||||
<div class="font-medium text-primary">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchTask', { taskNo: primaryMatch.task_no }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchStatus', { status: primaryMatch.process_status }) }}
|
||||
</div>
|
||||
<div v-if="primaryMatch.matched_fields?.length" class="mt-0.5 text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchFields', { fields: primaryMatch.matched_fields.join(', ') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="duplicate?.resolution?.action" class="mt-2 text-xs text-secondary">
|
||||
{{ t('chat.shippingOrderReview.duplicate.resolutionLabel', { action: duplicate.resolution.action }) }}
|
||||
<span v-if="duplicate.resolution.target_task_no" class="font-mono">
|
||||
→ {{ duplicate.resolution.target_task_no }}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div v-if="editable && duplicate?.needs_adjudication" class="mt-3 space-y-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="allowed.has('open_existing')"
|
||||
type="button"
|
||||
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary hover:bg-surface-soft disabled:opacity-60"
|
||||
data-testid="review-duplicate-open-existing"
|
||||
:disabled="busy"
|
||||
@click="resolve('open_existing')"
|
||||
>
|
||||
{{ t('chat.shippingNoticeDuplicateOpenExisting') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="allowed.has('create_revision')"
|
||||
type="button"
|
||||
class="rounded-xl border border-amber-300 bg-amber-100 px-3 py-1.5 text-sm font-medium text-amber-950 hover:bg-amber-200 disabled:opacity-60 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100"
|
||||
data-testid="review-duplicate-create-revision"
|
||||
:disabled="busy"
|
||||
@click="resolve('create_revision')"
|
||||
>
|
||||
{{ t('chat.shippingNoticeDuplicateCreateRevision') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="allowed.has('force_create') && canForceCreate" class="space-y-1.5">
|
||||
<input
|
||||
v-model="forceReason"
|
||||
type="text"
|
||||
class="w-full rounded border border-default bg-surface px-2 py-1.5 text-xs"
|
||||
data-testid="review-duplicate-force-reason"
|
||||
:placeholder="t('chat.shippingNoticeDuplicateReasonPlaceholder')"
|
||||
:disabled="busy"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-rose-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-rose-700 disabled:opacity-60"
|
||||
data-testid="review-duplicate-force-create"
|
||||
:disabled="busy || !forceReason.trim()"
|
||||
@click="resolve('force_create')"
|
||||
>
|
||||
{{ selectedAction === 'force_create' && busy
|
||||
? t('chat.shippingOrderReview.duplicate.resolving')
|
||||
: t('chat.shippingNoticeDuplicateForceCreate') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="editable" class="mt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="text-[11px] text-secondary underline-offset-2 hover:underline disabled:opacity-60"
|
||||
data-testid="review-duplicate-refresh"
|
||||
:disabled="busy"
|
||||
@click="onRefresh"
|
||||
>
|
||||
{{ busy ? t('chat.shippingOrderReview.duplicate.refreshing') : t('chat.shippingOrderReview.duplicate.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user