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
+200
@@ -0,0 +1,200 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewCustomerResolutionPanel.vue
|
||||
用途:复核工作台固定「建单前客户确认」区域(与重新识别 PDF 分层)。
|
||||
依赖:vue-i18n、ShippingCustomerConfirmDialog、shipping.api 客户确认/重识别接口。
|
||||
逻辑:始终展示客户识别状态;选择标准客户 / 重新识别客户;成功后 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 ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
|
||||
import {
|
||||
confirmWorkspaceShippingOrderReviewCustomer,
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
retryWorkspaceShippingOrderReviewCustomerResolution,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type {
|
||||
ShippingCustomerOption,
|
||||
ShippingOrderReviewCustomerResolution,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
caseNo: string;
|
||||
resolution: ShippingOrderReviewCustomerResolution | null | undefined;
|
||||
editable: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
refreshed: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const busy = ref(false);
|
||||
const dialogOpen = ref(false);
|
||||
const options = ref<ShippingCustomerOption[]>([]);
|
||||
const loadingOptions = ref(false);
|
||||
|
||||
const resolved = computed(() => Boolean(props.resolution?.resolved));
|
||||
const statusLabel = computed(() => {
|
||||
const status = String(props.resolution?.status || '').trim();
|
||||
if (!status) {
|
||||
return resolved.value
|
||||
? t('chat.shippingOrderReview.customerResolution.status.confirmed')
|
||||
: t('chat.shippingOrderReview.customerResolution.status.unmatched');
|
||||
}
|
||||
const key = `chat.shippingOrderReview.customerResolution.status.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
});
|
||||
|
||||
const displayName = computed(() => {
|
||||
const name = String(props.resolution?.standard_name || '').trim();
|
||||
const code = String(props.resolution?.short_code || '').trim();
|
||||
if (name && code) return `${name} (${code})`;
|
||||
return name || code || String(props.resolution?.raw_name || '').trim() || '—';
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开标准客户选择弹窗并加载选项。
|
||||
*/
|
||||
async function openSelectDialog() {
|
||||
if (!props.editable || busy.value) return;
|
||||
dialogOpen.value = true;
|
||||
loadingOptions.value = true;
|
||||
try {
|
||||
options.value = await listWorkspaceShippingCustomerOptions();
|
||||
} catch (error: unknown) {
|
||||
options.value = [];
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingCustomer.loadFailed'));
|
||||
} finally {
|
||||
loadingOptions.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按关键词搜索标准客户。
|
||||
*/
|
||||
async function searchCustomers(query: string) {
|
||||
loadingOptions.value = true;
|
||||
try {
|
||||
options.value = await listWorkspaceShippingCustomerOptions(query.trim());
|
||||
} catch (error: unknown) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingCustomer.loadFailed'));
|
||||
} finally {
|
||||
loadingOptions.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认标准客户并通知父级刷新 Case / 建单资格。
|
||||
*/
|
||||
async function onConfirm(customerId: number) {
|
||||
if (!props.caseNo || busy.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await confirmWorkspaceShippingOrderReviewCustomer(props.caseNo, {
|
||||
customer_id: customerId,
|
||||
reason: t('chat.shippingOrderReview.customerResolution.confirmReason'),
|
||||
});
|
||||
dialogOpen.value = false;
|
||||
msg.success(t('chat.shippingOrderReview.customerResolution.confirmed'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingCustomer.confirmFailed'));
|
||||
msg.warning(message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新识别客户(不触发 PDF 重识别)。
|
||||
*/
|
||||
async function onRetry() {
|
||||
if (!props.caseNo || !props.editable || busy.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await retryWorkspaceShippingOrderReviewCustomerResolution(props.caseNo);
|
||||
msg.success(t('chat.shippingOrderReview.customerResolution.retryDone'));
|
||||
emit('refreshed');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: (error instanceof Error ? error.message : t('chat.shippingOrderReview.customerResolution.retryFailed'));
|
||||
msg.warning(message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
||||
data-testid="review-customer-resolution-panel"
|
||||
>
|
||||
<header class="flex flex-wrap items-start justify-between gap-2">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.customerResolution.title') }}</h2>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ t('chat.shippingOrderReview.customerResolution.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-customer-resolution-badge"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<dl class="mt-2 space-y-1 text-xs text-secondary">
|
||||
<div class="flex flex-wrap gap-x-2">
|
||||
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.recognizedAs') }}</dt>
|
||||
<dd class="font-medium text-primary">{{ displayName }}</dd>
|
||||
</div>
|
||||
<div v-if="resolution?.raw_name && resolution.raw_name !== displayName" class="flex flex-wrap gap-x-2">
|
||||
<dt class="text-muted">{{ t('chat.shippingOrderReview.customerResolution.rawName') }}</dt>
|
||||
<dd>{{ resolution.raw_name }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div v-if="editable" class="mt-3 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-primary px-3 py-1.5 text-sm font-medium text-on-primary disabled:opacity-60"
|
||||
data-testid="review-select-customer"
|
||||
:disabled="busy"
|
||||
@click="openSelectDialog"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.customerResolution.selectCustomer') }}
|
||||
</button>
|
||||
<button
|
||||
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-retry-customer"
|
||||
:disabled="busy"
|
||||
@click="onRetry"
|
||||
>
|
||||
{{ busy ? t('chat.shippingOrderReview.customerResolution.retrying') : t('chat.shippingOrderReview.customerResolution.retryCustomer') }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-2 text-[11px] text-muted">
|
||||
{{ t('chat.shippingOrderReview.customerResolution.pdfReparseHint') }}
|
||||
</p>
|
||||
|
||||
<ShippingCustomerConfirmDialog
|
||||
:open="dialogOpen"
|
||||
:options="options"
|
||||
:loading="loadingOptions || busy"
|
||||
@close="dialogOpen = false"
|
||||
@search="searchCustomers"
|
||||
@confirm="onConfirm"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user