feat(shipping-notice): 添加识别定义和规则集管理功能,支持客户和站点的可配置识别规则
This commit is contained in:
1 parent
88408490d7
commit
34d489a2d1
167 files changed
+10365
-7978
No files matched your search
@@ -23,7 +23,7 @@ const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getA
|
||||
|
||||
export type ShippingInventoryReadinessCheck = {
|
||||
code: string;
|
||||
status: 'passed' | 'pending' | 'failed' | 'stale';
|
||||
status: 'passed' | 'pending' | 'failed' | 'stale' | 'empty';
|
||||
blocking: boolean;
|
||||
action: 'configure_connection' | 'configure_parsing_profile' | 'configure_excel_template' | 'configure_warehouse_mapping' | 'run_configuration_test';
|
||||
evidence: Record<string, unknown>;
|
||||
@@ -37,9 +37,10 @@ export type ShippingInventoryReadiness = {
|
||||
|
||||
export type ShippingInventoryConfigurationTest = {
|
||||
run_no: string;
|
||||
inventory_source_id: number;
|
||||
source_config_version: number;
|
||||
rpa_profile_config_version: number;
|
||||
status: 'awaiting_rpa' | 'processing' | 'completed' | 'failed';
|
||||
status: 'awaiting_rpa' | 'processing' | 'completed' | 'completed_empty' | 'failed';
|
||||
stage: string;
|
||||
error_message?: string | null;
|
||||
created_at?: string | null;
|
||||
@@ -50,9 +51,23 @@ export type ShippingInventoryConfigurationTest = {
|
||||
candidates?: Array<{ profile_id: number; display_name: string; version: number; level: string }>;
|
||||
};
|
||||
};
|
||||
current_profile_verified?: boolean;
|
||||
profile_match_level?: 'exact' | 'compatible';
|
||||
};
|
||||
};
|
||||
|
||||
export type ShippingInventoryValidationBatch = {
|
||||
id: number;
|
||||
batch_no: string;
|
||||
status: 'queued' | 'running' | 'completed' | 'partial_failed' | 'failed';
|
||||
total_count: number;
|
||||
success_count: number;
|
||||
empty_count: number;
|
||||
failed_count: number;
|
||||
stale_count: number;
|
||||
runs: ShippingInventoryConfigurationTest[];
|
||||
};
|
||||
|
||||
/** 下载管理员可访问的库存快照,并保留服务端指定的原始文件名。 */
|
||||
export const downloadShippingInventorySnapshot = async (snapshotId: number, fallbackName: string): Promise<void> => {
|
||||
const response = await fetch(`/api/admin/shipping-notice/snapshots/${snapshotId}/download`, { headers: getAuthHeaders() });
|
||||
@@ -120,6 +135,9 @@ export const getShippingExcelTemplateLayout = (id: number) => requestJson<{ temp
|
||||
export const createShippingExcelTemplateVersion = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/excel-templates/${id}/new-version`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const cloneShippingExcelTemplate = (id: number, payload: { template_code: string; display_name: string }) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/excel-templates/${id}/clone`, { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const publishShippingExcelTemplate = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/excel-templates/${id}/publish`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
@@ -130,17 +148,15 @@ export const deleteShippingExcelTemplate = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/excel-templates/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
|
||||
/** 读取库存路由可选的 published 订单字段和受控系统事实。 */
|
||||
/** 读取库存路由可选的已发布订单字段。 */
|
||||
export const getShippingInventoryRoutingFields = () => requestJson<{
|
||||
order_fields: Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>;
|
||||
system_facts: string[];
|
||||
order_schema_published: boolean;
|
||||
}>('/api/admin/shipping-notice/routing-fields', auth());
|
||||
|
||||
export type ShippingInventoryConfigurationCatalog = {
|
||||
order_fields: Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>;
|
||||
order_schema_published: boolean;
|
||||
routing_system_facts: string[];
|
||||
inventory_fields: ShippingInventoryField[];
|
||||
template_system_facts: string[];
|
||||
template_source_kinds: Array<'order_field' | 'inventory_field' | 'system_fact' | 'constant'>;
|
||||
@@ -216,6 +232,18 @@ export const saveShippingInventorySource = (payload: Record<string, unknown>, id
|
||||
`/api/admin/shipping-notice/sources${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 直接绑定停用库存站点到已发布解析方案;服务端自动写入操作审计。 */
|
||||
export const bindShippingInventorySourceParsingProfile = (id: number, payload: { parsing_profile_id: number }) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/sources/${id}/bind-parsing-profile`, { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 原子批量绑定已发布解析方案;任一站点不合格时整批拒绝,避免部分更新。 */
|
||||
export const bulkBindShippingInventorySourceParsingProfile = (payload: { source_ids: number[]; parsing_profile_id: number }) => requestJson<unknown[]>(
|
||||
'/api/admin/shipping-notice/sources/bulk-bind-parsing-profile', { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取站点解析方案绑定的可追溯审计记录。 */
|
||||
export const getShippingInventorySourceParsingBindingAudits = (id: number) => requestJson<unknown[]>(
|
||||
`/api/admin/shipping-notice/sources/${id}/parsing-binding-audits`, auth(),
|
||||
);
|
||||
export const deleteShippingInventorySource = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/sources/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
@@ -244,6 +272,22 @@ export const confirmShippingInventoryConfigurationTestProfile = (id: number, run
|
||||
`/api/admin/shipping-notice/sources/${id}/test-export/${encodeURIComponent(runNo)}/confirm-profile`,
|
||||
{ method: 'POST', body: JSON.stringify({ profile_id: profileId }), ...jsonAuth() },
|
||||
);
|
||||
/** 对已绑定发布解析方案的多个停用站点发起受控批量测试。 */
|
||||
export const startShippingInventoryValidationBatch = (sourceIds: number[]) => requestJson<ShippingInventoryValidationBatch>(
|
||||
'/api/admin/shipping-notice/source-validation-batches', { method: 'POST', body: JSON.stringify({ source_ids: sourceIds }), ...jsonAuth() },
|
||||
);
|
||||
/** 读取批量测试进度和逐站点独立结果。 */
|
||||
export const getShippingInventoryValidationBatch = (batchId: number) => requestJson<ShippingInventoryValidationBatch>(
|
||||
`/api/admin/shipping-notice/source-validation-batches/${batchId}`, auth(),
|
||||
);
|
||||
/** 恢复最近尚未结束的批量测试,供刷新页面后继续展示进度。 */
|
||||
export const getLatestActiveShippingInventoryValidationBatch = () => requestJson<ShippingInventoryValidationBatch | null>(
|
||||
'/api/admin/shipping-notice/source-validation-batches/latest-active', auth(),
|
||||
);
|
||||
/** 仅重试批次内失败或已过期的站点。 */
|
||||
export const retryFailedShippingInventoryValidationBatch = (batchId: number) => requestJson<ShippingInventoryValidationBatch>(
|
||||
`/api/admin/shipping-notice/source-validation-batches/${batchId}/retry-failed`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 保存路由规则草稿;规则发布需调用独立接口以生成审计快照。 */
|
||||
export const saveShippingInventoryRule = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* features/admin/api/shipping-identity-rules.api.ts
|
||||
* 用途:调用货代可配置客户识别定义和规则集管理 API。
|
||||
* 依赖:requestJson、认证请求头、规则 DTO。
|
||||
* 逻辑:所有写入由后端校验来源适配器、版本锁和自动化风险上限。
|
||||
*/
|
||||
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { ShippingIdentityDefinition, ShippingIdentityRuleCatalog, ShippingIdentityRuleSet } from '../types/shipping-identity-rules.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export const getShippingIdentityRuleCatalog = () =>
|
||||
requestJson<ShippingIdentityRuleCatalog>('/api/admin/shipping-identity-rules/definitions', auth());
|
||||
|
||||
export const saveShippingIdentityDefinition = (payload: Record<string, unknown>, id?: string) =>
|
||||
requestJson<ShippingIdentityDefinition>(`/api/admin/shipping-identity-rules/definitions${id ? `/${id}` : ''}`, {
|
||||
method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth(),
|
||||
});
|
||||
|
||||
export const retireShippingIdentityDefinition = (id: string) =>
|
||||
requestJson<ShippingIdentityDefinition>(`/api/admin/shipping-identity-rules/definitions/${id}/retire`, {
|
||||
method: 'POST', ...jsonAuth(),
|
||||
});
|
||||
|
||||
export const listShippingIdentityRuleSets = () =>
|
||||
requestJson<{ items: ShippingIdentityRuleSet[] }>('/api/admin/shipping-identity-rules/rule-sets', auth());
|
||||
|
||||
export const createShippingIdentityRuleSet = (payload: { copy_from_rule_set_id?: number; change_note?: string }) =>
|
||||
requestJson<ShippingIdentityRuleSet>('/api/admin/shipping-identity-rules/rule-sets', {
|
||||
method: 'POST', body: JSON.stringify(payload), ...jsonAuth(),
|
||||
});
|
||||
|
||||
export const saveShippingIdentityRuleSet = (id: number, payload: { definition_ids: string[]; expected_lock_version: number; change_note?: string }) =>
|
||||
requestJson<ShippingIdentityRuleSet>(`/api/admin/shipping-identity-rules/rule-sets/${id}`, {
|
||||
method: 'PUT', body: JSON.stringify(payload), ...jsonAuth(),
|
||||
});
|
||||
|
||||
export const publishShippingIdentityRuleSet = (id: number, expectedLockVersion: number) =>
|
||||
requestJson<ShippingIdentityRuleSet>(`/api/admin/shipping-identity-rules/rule-sets/${id}/publish`, {
|
||||
method: 'POST', body: JSON.stringify({ expected_lock_version: expectedLockVersion }), ...jsonAuth(),
|
||||
});
|
||||
@@ -14,9 +14,9 @@ import {
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
import { config } from '@/config';
|
||||
import { ADMIN_MODULE_METAS, ADMIN_REPORT_TABLES } from '../constants/modules';
|
||||
import { ADMIN_MODULE_METAS, ADMIN_REPORT_TABLES, SHIPPING_CONFIG_SUB_MODULE_METAS } from '../constants/modules';
|
||||
import { useAdminNavStore } from '../stores/admin-nav.store';
|
||||
import type { AdminModuleId } from '../types/admin.types';
|
||||
import type { AdminModuleId, ShippingConfigSubModuleId } from '../types/admin.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
@@ -46,7 +46,7 @@ const visibleModules = computed(() =>
|
||||
);
|
||||
|
||||
const standardModules = computed(() =>
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom'),
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom' && item.id !== 'shipping_inventory'),
|
||||
);
|
||||
|
||||
const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
@@ -54,6 +54,9 @@ const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
|
||||
const isReportsActive = computed(() => route.meta.adminModule === 'reports');
|
||||
const isWecomActive = computed(() => route.meta.adminModule === 'wecom');
|
||||
const isShippingConfigActive = computed(() => route.meta.adminModule === 'shipping_inventory');
|
||||
const isShippingConfigSubModuleActive = (subModule: ShippingConfigSubModuleId): boolean =>
|
||||
route.meta.adminSubModule === subModule;
|
||||
|
||||
const wecomSubRoutes = [
|
||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||
@@ -65,6 +68,10 @@ const navigateWecom = (routeName: string): void => {
|
||||
router.push({ name: routeName });
|
||||
};
|
||||
|
||||
const navigateShippingConfig = (routeName: string): void => {
|
||||
router.push({ name: routeName });
|
||||
};
|
||||
|
||||
const getReportTableLabel = (table: string): string => {
|
||||
const i18nKey = `admin.report.tables.${table}`;
|
||||
const translated = t(i18nKey);
|
||||
@@ -98,6 +105,14 @@ watch(
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
isShippingConfigActive,
|
||||
(active) => {
|
||||
if (active) navStore.shippingConfigExpanded = true;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -162,6 +177,36 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="config.admin.modules.shipping_inventory !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
:class="{ 'admin-nav-btn--active': isShippingConfigActive }"
|
||||
:title="navStore.sidebarCollapsed ? t('admin.nav.shippingConfig') : ''"
|
||||
@click="navStore.shippingConfigExpanded = !navStore.shippingConfigExpanded"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<Warehouse class="w-5 h-5 flex-shrink-0" :class="isShippingConfigActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.shippingConfig') }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="navStore.shippingConfigExpanded && !navStore.sidebarCollapsed"
|
||||
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
||||
>
|
||||
<button
|
||||
v-for="sub in SHIPPING_CONFIG_SUB_MODULE_METAS"
|
||||
:key="sub.id"
|
||||
type="button"
|
||||
class="admin-nav-subitem"
|
||||
:class="{ 'admin-nav-subitem--active': isShippingConfigSubModuleActive(sub.id) }"
|
||||
@click="navigateShippingConfig(sub.routeName)"
|
||||
>
|
||||
{{ t(sub.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="config.admin.modules.reports !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 管理后台模块元数据,AdminNav 与子路由共用。
|
||||
*/
|
||||
|
||||
import type { AdminModuleId, AdminReportTableId } from '../types/admin.types';
|
||||
import type { AdminModuleId, AdminReportTableId, ShippingConfigSubModuleId } from '../types/admin.types';
|
||||
|
||||
export interface AdminModuleMeta {
|
||||
id: AdminModuleId;
|
||||
@@ -13,6 +13,13 @@ export interface AdminModuleMeta {
|
||||
configKey: keyof typeof import('@/config').config.admin.modules;
|
||||
}
|
||||
|
||||
export interface ShippingConfigSubModuleMeta {
|
||||
id: ShippingConfigSubModuleId;
|
||||
routeName: 'AdminShippingInventory' | 'AdminShippingIdentityRules';
|
||||
path: 'shipping-notice' | 'shipping-identity-rules';
|
||||
labelKey: string;
|
||||
}
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'platform_apps', 'shipping_inventory', 'reports',
|
||||
@@ -35,6 +42,12 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'requests', routeName: 'AdminRequests', path: 'requests', labelKey: 'admin.nav.requests', configKey: 'requests' },
|
||||
];
|
||||
|
||||
/** 货代配置的二级导航唯一真相源;两个页面共用父模块权限与可见性开关。 */
|
||||
export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
{ id: 'inventory', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.nav.shippingInventory' },
|
||||
{ id: 'identity_rules', routeName: 'AdminShippingIdentityRules', path: 'shipping-identity-rules', labelKey: 'admin.nav.shippingIdentityRules' },
|
||||
];
|
||||
|
||||
export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
'usage_analysis',
|
||||
'chat_logs',
|
||||
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-identity-rules/ShippingIdentityRulesPage.vue
|
||||
用途:维护来源适配器绑定的客户/送货站点业务识别定义,并发布不可变规则集。
|
||||
依赖:规则 API、Vue Composition API、Vue I18n。
|
||||
逻辑:平台只提供来源适配器目录;管理员创建业务定义,订单字段仅能选择服务端提供的已发布 Header 字段。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ArrowUpRight, Check, CircleDotDashed, FileCheck2, Layers3, Plus, Send, Tags, Workflow } from 'lucide-vue-next';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
createShippingIdentityRuleSet,
|
||||
getShippingIdentityRuleCatalog,
|
||||
listShippingIdentityRuleSets,
|
||||
publishShippingIdentityRuleSet,
|
||||
saveShippingIdentityDefinition,
|
||||
saveShippingIdentityRuleSet,
|
||||
} from '@/features/admin/api/shipping-identity-rules.api';
|
||||
import type { ShippingIdentityRuleCatalog, ShippingIdentityRuleSet } from '@/features/admin/types/shipping-identity-rules.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const catalog = ref<ShippingIdentityRuleCatalog | null>(null);
|
||||
const ruleSets = ref<ShippingIdentityRuleSet[]>([]);
|
||||
const selectedRuleSet = ref<ShippingIdentityRuleSet | null>(null);
|
||||
const selectedDefinitionIds = ref<string[]>([]);
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const form = reactive({
|
||||
display_name: '', description: '', evidence_label: '', target_type: 'customer', order_field_id: '',
|
||||
source_adapter_key: 'email_metadata', source_projection: 'email', default_weight: 100,
|
||||
});
|
||||
|
||||
const selectedDefinitionCount = computed(() => selectedDefinitionIds.value.length);
|
||||
const activeDefinitions = computed(() => catalog.value?.definitions.filter((item) => item.status === 'active') || []);
|
||||
const publishedRuleSet = computed(() => ruleSets.value.find((item) => item.status === 'published') || null);
|
||||
const isOrderFieldSource = computed(() => form.source_adapter_key === 'order_field');
|
||||
const isEmailSource = computed(() => form.source_adapter_key === 'email_metadata');
|
||||
const isTemplateSource = computed(() => form.source_adapter_key === 'document_template');
|
||||
const selectedAutomation = computed(() => {
|
||||
const adapter = catalog.value?.catalog.source_adapters.find((item) => item.key === form.source_adapter_key);
|
||||
const option = isEmailSource.value ? form.source_projection : isTemplateSource.value ? 'template' : '';
|
||||
return option ? adapter?.options[option]?.max_automation || 'none' : 'none';
|
||||
});
|
||||
|
||||
/** 说明当前来源实际从何处取值和自动化边界,帮助管理员在提交前理解选择结果。 */
|
||||
const selectedSourceHint = computed(() => {
|
||||
const adapter = catalog.value?.catalog.source_adapters.find((item) => item.key === form.source_adapter_key);
|
||||
return adapter?.description || '';
|
||||
});
|
||||
|
||||
const sourceDisplay = (definition: { source_adapter_key: string; source_selector: Record<string, unknown>; order_field?: { field_code: string; display_name?: string } | null }): string => {
|
||||
const adapter = catalog.value?.catalog.source_adapters.find((item) => item.key === definition.source_adapter_key);
|
||||
if (definition.source_adapter_key === 'order_field') return definition.order_field?.display_name || definition.order_field?.field_code || adapter?.display_name || '';
|
||||
if (definition.source_adapter_key === 'email_metadata') {
|
||||
const option = adapter?.options[String(definition.source_selector.projection)];
|
||||
return option?.display_name || adapter?.display_name || '';
|
||||
}
|
||||
return adapter?.options.template?.display_name || adapter?.display_name || '';
|
||||
};
|
||||
|
||||
watch(() => form.source_adapter_key, (adapter) => {
|
||||
if (adapter === 'email_metadata') Object.assign(form, { target_type: 'customer', source_projection: 'email', order_field_id: '' });
|
||||
if (adapter === 'document_template') Object.assign(form, { target_type: 'customer', order_field_id: '' });
|
||||
if (adapter === 'order_field') Object.assign(form, { target_type: 'site' });
|
||||
});
|
||||
|
||||
watch(selectedRuleSet, (ruleSet) => {
|
||||
selectedDefinitionIds.value = ruleSet?.definition?.definitions.map((item) => item.id) || [];
|
||||
}, { immediate: true });
|
||||
|
||||
const showError = (error: unknown): void => {
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingIdentityRules.operationFailed'));
|
||||
};
|
||||
|
||||
const load = async (): Promise<void> => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const [nextCatalog, nextRuleSets] = await Promise.all([getShippingIdentityRuleCatalog(), listShippingIdentityRuleSets()]);
|
||||
catalog.value = nextCatalog;
|
||||
ruleSets.value = nextRuleSets.items;
|
||||
selectedRuleSet.value = nextRuleSets.items.find((item) => item.status === 'draft') || nextRuleSets.items.find((item) => item.status === 'published') || null;
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const saveDefinition = async (): Promise<void> => {
|
||||
saving.value = true;
|
||||
try {
|
||||
const source_selector = isOrderFieldSource.value
|
||||
? { order_field_id: form.order_field_id }
|
||||
: isEmailSource.value
|
||||
? { attribute: 'email.from', projection: form.source_projection }
|
||||
: { document: 'primary' };
|
||||
await saveShippingIdentityDefinition({ ...form, source_selector });
|
||||
Object.assign(form, { display_name: '', description: '', evidence_label: '' });
|
||||
await load();
|
||||
message.success(t('admin.shippingIdentityRules.definitionSaved'));
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const createDraft = async (): Promise<void> => {
|
||||
saving.value = true;
|
||||
try {
|
||||
const draft = await createShippingIdentityRuleSet({
|
||||
copy_from_rule_set_id: ruleSets.value.find((item) => item.status === 'published')?.id,
|
||||
});
|
||||
selectedRuleSet.value = draft;
|
||||
await load();
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const saveDraft = async (): Promise<void> => {
|
||||
if (!selectedRuleSet.value || selectedRuleSet.value.status !== 'draft' || !catalog.value) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
const saved = await saveShippingIdentityRuleSet(selectedRuleSet.value.id, {
|
||||
expected_lock_version: selectedRuleSet.value.lock_version,
|
||||
definition_ids: selectedDefinitionIds.value,
|
||||
});
|
||||
selectedRuleSet.value = saved;
|
||||
await load();
|
||||
message.success(t('admin.shippingIdentityRules.ruleSetSaved'));
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const publishDraft = async (): Promise<void> => {
|
||||
if (!selectedRuleSet.value || selectedRuleSet.value.status !== 'draft') return;
|
||||
saving.value = true;
|
||||
try {
|
||||
await publishShippingIdentityRuleSet(selectedRuleSet.value.id, selectedRuleSet.value.lock_version);
|
||||
await load();
|
||||
message.success(t('admin.shippingIdentityRules.ruleSetPublished'));
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 发布规则集后才可维护证据,跳转保留既有工作台管理员入口。 */
|
||||
const openCustomerMaster = (): void => {
|
||||
router.push({ name: 'workspace-shipping-customers' });
|
||||
};
|
||||
|
||||
onMounted(() => { void load(); });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="identity-rules-page">
|
||||
<header class="identity-hero">
|
||||
<div>
|
||||
<p class="identity-kicker"><Workflow class="h-4 w-4" />{{ t('admin.shippingIdentityRules.eyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingIdentityRules.title') }}</h2>
|
||||
<p>{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="identity-hero__meta">
|
||||
<div class="identity-hero__status">
|
||||
<span class="identity-pulse" :class="{ 'identity-pulse--draft': !publishedRuleSet }" />
|
||||
<span v-if="publishedRuleSet">V{{ publishedRuleSet.version }} · {{ t('admin.shippingIdentityRules.status.published') }}</span>
|
||||
<span v-else>{{ t('admin.shippingIdentityRules.status.draft') }}</span>
|
||||
</div>
|
||||
<button type="button" class="btn-ghost identity-hero__link" @click="openCustomerMaster">
|
||||
{{ t('admin.shippingIdentityRules.openCustomerMaster') }}<ArrowUpRight class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="identity-flow" aria-label="workflow">
|
||||
<div class="identity-flow__rail" />
|
||||
<div class="identity-flow__step identity-flow__step--active"><span>01</span><div><strong>{{ t('admin.shippingIdentityRules.definitions') }}</strong><small>{{ t('admin.shippingIdentityRules.definitionHint') }}</small></div></div>
|
||||
<div class="identity-flow__step"><span>02</span><div><strong>{{ t('admin.shippingIdentityRules.ruleSets') }}</strong><small>{{ t('admin.shippingIdentityRules.saveDraft') }}</small></div></div>
|
||||
<div class="identity-flow__step"><span>03</span><div><strong>{{ t('admin.shippingIdentityRules.openCustomerMaster') }}</strong><small>{{ t('admin.shippingIdentityRules.workflowHint') }}</small></div></div>
|
||||
</section>
|
||||
|
||||
<p v-if="loading" class="identity-loading"><CircleDotDashed class="h-4 w-4 animate-spin" />{{ t('admin.shippingIdentityRules.loading') }}</p>
|
||||
|
||||
<div v-else class="identity-workbench">
|
||||
<section class="identity-panel identity-panel--definitions">
|
||||
<div class="identity-panel__heading">
|
||||
<div><p class="identity-panel__eyebrow"><Tags class="h-4 w-4" />{{ t('admin.shippingIdentityRules.definitions') }}</p><h3>{{ activeDefinitions.length }}</h3></div>
|
||||
<p>{{ t('admin.shippingIdentityRules.definitionHint') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="catalog?.definitions.length" class="identity-definition-list">
|
||||
<article v-for="definition in catalog.definitions" :key="definition.id" class="identity-definition-row">
|
||||
<div class="identity-definition-row__icon"><Tags class="h-4 w-4" /></div>
|
||||
<div class="min-w-0"><strong>{{ definition.display_name }}</strong><p>{{ definition.description || sourceDisplay(definition) }}</p></div>
|
||||
<span class="identity-target">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</span>
|
||||
<span class="identity-automation" :class="{ 'identity-automation--enabled': definition.max_automation === 'conditional' }">{{ t(`admin.shippingIdentityRules.automations.${definition.max_automation}`) }}</span>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else class="identity-empty"><Tags class="h-5 w-5" /><span>{{ t('admin.shippingIdentityRules.definitionHint') }}</span></div>
|
||||
|
||||
<form class="identity-definition-form" @submit.prevent="saveDefinition">
|
||||
<div class="identity-form-title"><Plus class="h-4 w-4" /><strong>{{ t('admin.shippingIdentityRules.addDefinition') }}</strong></div>
|
||||
<p class="identity-form-guide">{{ t('admin.shippingIdentityRules.formGuide') }}</p>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.displayName') }}</span><input v-model="form.display_name" required class="input-field" :placeholder="t('admin.shippingIdentityRules.displayNamePlaceholder')"></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.source') }}</span><select v-model="form.source_adapter_key" class="input-field"><option v-for="adapter in catalog?.catalog.source_adapters" :key="adapter.key" :value="adapter.key">{{ adapter.display_name }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.target') }}</span><select v-model="form.target_type" class="input-field" :disabled="!isOrderFieldSource"><option value="customer">{{ t('admin.shippingIdentityRules.targets.customer') }}</option><option value="site">{{ t('admin.shippingIdentityRules.targets.site') }}</option></select></label>
|
||||
<label v-if="isEmailSource"><span>{{ t('admin.shippingIdentityRules.emailType') }}</span><select v-model="form.source_projection" class="input-field"><option value="email">{{ catalog?.catalog.source_adapters.find((item) => item.key === 'email_metadata')?.options.email?.display_name }}</option><option value="domain">{{ catalog?.catalog.source_adapters.find((item) => item.key === 'email_metadata')?.options.domain?.display_name }}</option></select></label>
|
||||
<label v-if="isOrderFieldSource"><span>{{ t('admin.shippingIdentityRules.selectField') }}</span><select v-model="form.order_field_id" required class="input-field"><option value="">{{ t('admin.shippingIdentityRules.selectField') }}</option><option v-for="field in catalog?.order_fields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select></label>
|
||||
<label v-if="isTemplateSource"><span>{{ t('admin.shippingIdentityRules.source') }}</span><div class="identity-static-field">{{ t('admin.shippingIdentityRules.templateValue') }}</div></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.evidenceLabel') }}</span><input v-model="form.evidence_label" required class="input-field" :placeholder="t('admin.shippingIdentityRules.evidenceLabelPlaceholder')"></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.description') }}</span><input v-model="form.description" class="input-field" :placeholder="t('admin.shippingIdentityRules.descriptionPlaceholder')"></label>
|
||||
<div class="identity-source-help"><strong>{{ t('admin.shippingIdentityRules.selectionResult') }}</strong><span>{{ selectedSourceHint }}</span><small>{{ t(`admin.shippingIdentityRules.automations.${selectedAutomation}`) }}</small></div>
|
||||
<button type="submit" class="btn-primary identity-definition-form__submit" :disabled="saving || (isOrderFieldSource && !form.order_field_id)"><Plus class="h-4 w-4" />{{ t('admin.shippingIdentityRules.addDefinition') }}</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<aside class="identity-panel identity-panel--publication">
|
||||
<div class="identity-publication__header">
|
||||
<div class="identity-panel__eyebrow"><Layers3 class="h-4 w-4" />{{ t('admin.shippingIdentityRules.ruleSets') }}</div>
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="saving" @click="createDraft"><Plus class="h-4 w-4" />{{ t('admin.shippingIdentityRules.createDraft') }}</button>
|
||||
</div>
|
||||
<p class="identity-publication__hint">{{ t('admin.shippingIdentityRules.ruleSetHint') }}</p>
|
||||
|
||||
<div class="identity-version-list">
|
||||
<button v-for="item in ruleSets" :key="item.id" type="button" class="identity-version" :class="{ 'identity-version--selected': selectedRuleSet?.id === item.id }" @click="selectedRuleSet = item">
|
||||
<span>V{{ item.version }}</span><small>{{ t(`admin.shippingIdentityRules.status.${item.status}`) }}</small>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedRuleSet?.status === 'draft'" class="identity-selection">
|
||||
<div class="identity-selection__heading"><span>{{ t('admin.shippingIdentityRules.definitions') }}</span><strong>{{ selectedDefinitionCount }}/{{ activeDefinitions.length }}</strong></div>
|
||||
<label v-for="definition in activeDefinitions" :key="definition.id" class="identity-check-row">
|
||||
<input v-model="selectedDefinitionIds" type="checkbox" :value="definition.id"><span>{{ definition.display_name }}</span><small>{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedRuleSet" class="identity-publication__actions">
|
||||
<template v-if="selectedRuleSet.status === 'draft'">
|
||||
<button type="button" class="btn-ghost" :disabled="saving || !selectedDefinitionCount" @click="saveDraft"><FileCheck2 class="h-4 w-4" />{{ t('admin.shippingIdentityRules.saveDraft') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving || !selectedDefinitionCount" @click="publishDraft"><Send class="h-4 w-4" />{{ t('admin.shippingIdentityRules.publish') }}</button>
|
||||
</template>
|
||||
<div v-else class="identity-published"><Check class="h-4 w-4" /><span>{{ t('admin.shippingIdentityRules.status.published') }}</span><code>{{ selectedRuleSet.checksum || '-' }}</code></div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-rules-page { max-width: 1380px; margin: 0 auto; display: grid; gap: 1.25rem; color: #183253; }
|
||||
.identity-hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: .5rem .25rem .75rem; }
|
||||
.identity-kicker, .identity-panel__eyebrow { display: flex; align-items: center; gap: .45rem; color: #0d8ac6; font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
|
||||
.identity-hero h2 { margin: .35rem 0; color: #102a43; font-size: clamp(1.65rem, 2.5vw, 2.2rem); font-weight: 800; letter-spacing: -.045em; }
|
||||
.identity-hero p:not(.identity-kicker) { max-width: 760px; color: #6d829c; font-size: .93rem; line-height: 1.65; }
|
||||
.identity-hero__meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
|
||||
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid #bfe7f8; border-radius: 999px; background: #effaff; color: #087aaa; font-size: .78rem; font-weight: 700; white-space: nowrap; }
|
||||
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: #18b17c; box-shadow: 0 0 0 4px #dff8ed; }.identity-pulse--draft { background: #e09b22; box-shadow: 0 0 0 4px #fff2d5; }
|
||||
.identity-hero__link { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
|
||||
.identity-flow { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 1rem; overflow: hidden; border: 1px solid #dce9f2; border-radius: 1rem; background: linear-gradient(105deg, #f4fbff, #fff); }
|
||||
.identity-flow__rail { position: absolute; top: 1.84rem; left: 12%; right: 12%; height: 1px; background: #cce5f2; }
|
||||
.identity-flow__step { position: relative; z-index: 1; display: flex; gap: .75rem; align-items: flex-start; min-width: 0; }
|
||||
.identity-flow__step > span { display: grid; place-items: center; flex: 0 0 1.65rem; height: 1.65rem; border: 1px solid #b9d8e8; border-radius: 50%; background: #fff; color: #6b8298; font-size: .66rem; font-weight: 800; }
|
||||
.identity-flow__step--active > span { border-color: #0d93cf; background: #0d93cf; color: #fff; box-shadow: 0 0 0 4px #dff4fc; }
|
||||
.identity-flow strong { display: block; color: #193652; font-size: .82rem; font-weight: 800; }
|
||||
.identity-flow small { display: -webkit-box; overflow: hidden; margin-top: .15rem; color: #7a8fa6; font-size: .72rem; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
||||
.identity-loading { display: flex; align-items: center; gap: .5rem; padding: 2rem; color: #6f839b; font-size: .9rem; }
|
||||
.identity-workbench { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); gap: 1.25rem; align-items: start; }
|
||||
.identity-panel { border: 1px solid #dce8f0; border-radius: 1rem; background: #fff; box-shadow: 0 10px 28px rgba(32, 78, 114, .055); }
|
||||
.identity-panel--definitions { overflow: hidden; }
|
||||
.identity-panel__heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.35rem 1rem; border-bottom: 1px solid #edf3f7; }
|
||||
.identity-panel__heading h3 { margin: .2rem 0 0; color: #12395a; font-size: 2rem; font-weight: 800; line-height: 1; }
|
||||
.identity-panel__heading > p { max-width: 28rem; color: #71879e; font-size: .78rem; line-height: 1.55; text-align: right; }
|
||||
.identity-definition-list { display: grid; }
|
||||
.identity-definition-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .78rem 1.35rem; border-bottom: 1px solid #edf3f7; transition: background .18s ease; }
|
||||
.identity-definition-row:hover { background: #f7fbfd; }
|
||||
.identity-definition-row__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #e9f7fd; color: #0b90cc; }
|
||||
.identity-definition-row strong { color: #1a3856; font-size: .86rem; font-weight: 750; }
|
||||
.identity-definition-row p { overflow: hidden; margin-top: .18rem; color: #8194a8; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.identity-target, .identity-automation { padding: .32rem .52rem; border-radius: 999px; background: #f1f5f8; color: #677f98; font-size: .7rem; white-space: nowrap; }
|
||||
.identity-automation--enabled { background: #e4f8ef; color: #12865c; }
|
||||
.identity-empty { display: flex; align-items: center; gap: .55rem; min-height: 5.5rem; padding: 1.2rem 1.35rem; color: #7c91a7; font-size: .82rem; }
|
||||
.identity-definition-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; padding: 1.1rem 1.35rem 1.35rem; background: linear-gradient(135deg, #f7fbfd 0%, #f3f9fc 100%); }
|
||||
.identity-form-title { grid-column: 1 / -1; display: flex; align-items: center; gap: .42rem; color: #173857; font-size: .85rem; }
|
||||
.identity-form-guide { grid-column: 1 / -1; margin: -.45rem 0 .1rem; color: #73889e; font-size: .75rem; line-height: 1.55; }
|
||||
.identity-definition-form label { display: grid; gap: .35rem; color: #667f99; font-size: .72rem; font-weight: 700; }
|
||||
.identity-definition-form label small { color: #8295a8; font-size: .67rem; font-weight: 500; line-height: 1.35; }
|
||||
.identity-definition-form .input-field, .identity-static-field { box-sizing: border-box; min-width: 0; height: 2.75rem; padding: 0 .8rem; border-color: #d9e7ef; background: #fff; font-size: .83rem; line-height: 1.25; }
|
||||
.identity-definition-form select.input-field { padding-top: 0; padding-bottom: 0; line-height: 2.75rem; }
|
||||
.identity-static-field { display: flex; align-items: center; padding: 0 .8rem; border: 1px solid #d9e7ef; border-radius: .65rem; color: #5f7893; }
|
||||
.identity-source-help { display: grid; align-content: center; gap: .12rem; min-height: 2.75rem; padding: .48rem .7rem; border: 1px solid #d6eaf5; border-radius: .65rem; background: #edf8fe; color: #537189; font-size: .69rem; line-height: 1.35; }
|
||||
.identity-source-help strong { color: #187eae; font-size: .72rem; }.identity-source-help small { color: #2e9068; font-size: .68rem; }
|
||||
.identity-definition-form__submit { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; align-self: end; min-height: 2.5rem; }
|
||||
.identity-panel--publication { position: sticky; top: 1rem; padding: 1.25rem; }
|
||||
.identity-publication__header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
|
||||
.identity-publication__header .btn-ghost, .identity-publication__actions button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
|
||||
.identity-publication__hint { margin: .75rem 0 1rem; color: #75899f; font-size: .78rem; line-height: 1.6; }
|
||||
.identity-version-list { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid #e9f0f4; }
|
||||
.identity-version { display: inline-flex; align-items: center; gap: .35rem; padding: .46rem .6rem; border: 1px solid #dbe7ee; border-radius: .6rem; background: #fff; color: #668099; font-size: .73rem; transition: all .18s ease; }
|
||||
.identity-version:hover, .identity-version--selected { border-color: #0b91cd; background: #eefaff; color: #087cae; }
|
||||
.identity-version span { font-weight: 800; }.identity-version small { font-size: .68rem; }
|
||||
.identity-selection { margin: 1rem 0; }
|
||||
.identity-selection__heading { display: flex; justify-content: space-between; margin-bottom: .6rem; color: #274563; font-size: .78rem; font-weight: 750; }
|
||||
.identity-selection__heading strong { color: #0a8bc4; }
|
||||
.identity-check-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .54rem 0; border-bottom: 1px dashed #e2ebf1; color: #37516c; font-size: .78rem; }
|
||||
.identity-check-row input { accent-color: #0c94ce; }.identity-check-row small { color: #8496a8; font-size: .68rem; }
|
||||
.identity-publication__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; padding-top: 1rem; }
|
||||
.identity-publication__actions .btn-primary, .identity-publication__actions .btn-ghost { min-width: 0; font-size: .79rem; }
|
||||
.identity-published { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: .45rem; padding: .7rem; border-radius: .65rem; background: #eaf9f0; color: #16895e; font-size: .78rem; font-weight: 700; }.identity-published code { overflow: hidden; color: #56826f; font-size: .67rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@media (max-width: 980px) { .identity-workbench { grid-template-columns: 1fr; }.identity-panel--publication { position: static; }.identity-hero { align-items: flex-start; flex-direction: column; gap: .85rem; }.identity-hero__meta { justify-content: flex-start; }.identity-flow__rail { display: none; } }
|
||||
@media (max-width: 700px) { .identity-rules-page { gap: 1rem; }.identity-flow { grid-template-columns: 1fr; }.identity-definition-form { grid-template-columns: 1fr; }.identity-definition-row { grid-template-columns: auto minmax(0, 1fr); }.identity-target, .identity-automation { justify-self: start; }.identity-panel__heading { align-items: flex-start; flex-direction: column; }.identity-panel__heading > p { text-align: left; }.identity-definition-row__icon { grid-row: span 2; }.identity-publication__actions { grid-template-columns: 1fr; } }
|
||||
@media (prefers-reduced-motion: reduce) { .identity-definition-row, .identity-version { transition: none; } }
|
||||
</style>
|
||||
@@ -43,9 +43,13 @@
|
||||
<h2>{{ t(currentSection.labelKey) }}</h2>
|
||||
<p>{{ t(currentSection.helpKey) }}</p>
|
||||
</div>
|
||||
<div class="workbench-actions">
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBulkParsingBinding">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</button>
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBatchValidation">{{ t('admin.shippingInventory.batchValidation') }}</button>
|
||||
<button v-if="isEditableTab" type="button" class="primary-action" @click="createNew">
|
||||
{{ t('admin.shippingInventory.createNew') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
@@ -110,7 +114,7 @@
|
||||
<aside class="editor-drawer" role="dialog" aria-modal="true" :aria-label="t(currentEditorSection.labelKey)">
|
||||
<header class="drawer-header">
|
||||
<div>
|
||||
<h3>{{ selectedId ? rowTitle(currentItems.find((item) => Number(item.id) === selectedId) || {}) : t('admin.shippingInventory.createNew') }}</h3>
|
||||
<div class="drawer-title-row"><h3>{{ selectedId ? rowTitle(currentItems.find((item) => Number(item.id) === selectedId) || {}) : t('admin.shippingInventory.createNew') }}</h3><span v-if="activeTab === 'sources' && selectedId" class="source-run-status" :class="{ enabled: source.enabled }">{{ source.enabled ? t('admin.shippingInventory.siteEnabled') : t('admin.shippingInventory.siteNotEnabled') }}</span></div>
|
||||
<p>{{ t(currentEditorSection.helpKey) }}</p>
|
||||
</div>
|
||||
<button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeDrawer">×</button>
|
||||
@@ -133,7 +137,7 @@
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySiteName') }}</span><input v-model="source.display_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="source.connector_type"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connection') }}</span><select v-model.number="source.rpa_profile_id" required><option :value="0">{{ t('admin.shippingInventory.chooseConnection') }}</option><option v-for="item in compatibleProfiles" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><output class="setup-status">{{ source.parsing_profile_id ? parsingProfileName(source.parsing_profile_id) : t('admin.shippingInventory.notGenerated') }}</output><small>{{ t('admin.shippingInventory.parsingProfileGeneratedByTest') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" :disabled="source.enabled"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplates') }}</span><select v-model.number="source.excel_template_id"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in excelTemplates.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.template_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" required></label>
|
||||
@@ -142,45 +146,46 @@
|
||||
<header class="readiness-heading">
|
||||
<div>
|
||||
<span class="readiness-kicker">{{ t('admin.shippingInventory.activationStatus') }}</span>
|
||||
<strong>{{ source.enabled ? t('admin.shippingInventory.activationReady') : t('admin.shippingInventory.activationDraft') }}</strong>
|
||||
<strong>{{ readinessHeadline }}</strong>
|
||||
<p>{{ readinessGuidance }}</p>
|
||||
</div>
|
||||
<span class="readiness-count">{{ readinessSummary }}</span>
|
||||
</header>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in readinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy">
|
||||
<b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b>
|
||||
<small>{{ readinessDetail(check) }}</small>
|
||||
</div>
|
||||
<button
|
||||
v-if="readinessActionLabel(check) && !source.enabled"
|
||||
type="button"
|
||||
class="readiness-action"
|
||||
:disabled="isReadinessActionBlocked(check)"
|
||||
:title="isReadinessActionBlocked(check) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined"
|
||||
@click="runReadinessAction(check)"
|
||||
>{{ readinessActionLabel(check) }}</button>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-if="!source.enabled" class="readiness-note">{{ t('admin.shippingInventory.configurationTestHint') }}</p>
|
||||
<section class="readiness-section">
|
||||
<div class="readiness-section-heading">
|
||||
<b>{{ t('admin.shippingInventory.activationRequiredTitle') }}</b>
|
||||
<small>{{ t('admin.shippingInventory.activationRequiredHint') }}</small>
|
||||
</div>
|
||||
<ol v-if="firstBlockingCheck && !source.enabled" class="readiness-steps">
|
||||
<li :class="`is-${firstBlockingCheck.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }}</b><small>{{ readinessDetail(firstBlockingCheck) }}</small></div>
|
||||
<button v-if="readinessActionLabel(firstBlockingCheck)" type="button" class="readiness-action" :disabled="isReadinessActionBlocked(firstBlockingCheck)" :title="isReadinessActionBlocked(firstBlockingCheck) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="runReadinessAction(firstBlockingCheck)">{{ readinessActionLabel(firstBlockingCheck) }}</button>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
|
||||
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.activationOptionalHint') }}</small></summary>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in optionalReadinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b><small>{{ readinessDetail(check) }}</small></div>
|
||||
</li>
|
||||
</ol>
|
||||
</details>
|
||||
<template v-if="configurationTest">
|
||||
<p class="readiness-run" :class="{ failed: configurationTest.status === 'failed' }">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
|
||||
<dl class="readiness-audit">
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestRunNo') }}</dt><dd>{{ configurationTest.run_no }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div>
|
||||
</dl>
|
||||
<details class="readiness-audit"><summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }}</summary><dl><div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div></dl></details>
|
||||
<p v-if="configurationTest.error_message" class="form-tip">{{ configurationTest.error_message }}</p>
|
||||
<p v-if="configurationTest.status === 'completed_empty'" class="form-tip">{{ t('admin.shippingInventory.configurationTestEmptyResult') }}</p>
|
||||
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }}</small><button type="button" class="secondary-action" @click="confirmTestProfile(candidate.profile_id)">{{ t('admin.shippingInventory.confirmTestProfile') }}</button></article>
|
||||
<p v-if="!(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
<p v-if="configurationTest.result?.current_profile_verified" class="configuration-test-verified">{{ t(`admin.shippingInventory.currentProfileVerified.${configurationTest.result.profile_match_level || 'compatible'}`) }}</p>
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.configurationTestCandidateHint') }}</small></article>
|
||||
<p v-if="!configurationTest.result?.current_profile_verified && !(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
</section>
|
||||
</template>
|
||||
<footer class="readiness-footer">
|
||||
<button v-if="!source.enabled" type="button" class="primary-action" :disabled="!source.activation?.ready || sourceDirty" :title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="requestSourceActivation">{{ t('admin.shippingInventory.activateSource') }}</button>
|
||||
<button v-else type="button" class="text-action danger" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
<footer v-if="source.enabled" class="readiness-footer">
|
||||
<button type="button" class="text-action danger" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
</footer>
|
||||
</section>
|
||||
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
|
||||
@@ -201,7 +206,6 @@
|
||||
</div>
|
||||
<button type="button" class="secondary-action full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</template>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.matchAliases') }}</span><input :value="source.match_aliases_json.join(', ')" :placeholder="t('admin.shippingInventory.aliasHint')" @input="source.match_aliases_json = splitValues(($event.target as HTMLInputElement).value)"></label>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'parsing'">
|
||||
@@ -333,9 +337,7 @@
|
||||
<label><span>{{ t('admin.shippingInventory.priority') }}</span><input v-model.number="rule.priority" :disabled="ruleReadOnly" type="number"></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.ruleConditions') }}</div>
|
||||
<div v-for="(condition, index) in rule.conditions" :key="index" class="condition-row full">
|
||||
<select v-model="condition.source_kind" :disabled="ruleReadOnly"><option value="order_field">{{ t('admin.shippingInventory.routeConditionSource.order_field') }}</option><option value="system_fact">{{ t('admin.shippingInventory.routeConditionSource.system_fact') }}</option></select>
|
||||
<select v-if="condition.source_kind === 'order_field'" v-model="condition.order_field_id" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-else v-model="condition.system_fact_key" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="key in systemFacts" :key="key" :value="key">{{ t(`admin.shippingInventory.systemFact.${key}`) }}</option></select>
|
||||
<select v-model="condition.order_field_id" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-model="condition.operator" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.operator')"><option v-for="item in operators" :key="item.value" :value="item.value">{{ item.label }}</option></select>
|
||||
<input v-if="conditionNeedsExpected(condition)" v-model="condition.expected" :disabled="ruleReadOnly" :placeholder="t('admin.shippingInventory.expectedValue')">
|
||||
<span v-else class="condition-empty">{{ t('admin.shippingInventory.noExpectedValue') }}</span>
|
||||
@@ -363,6 +365,7 @@
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="secondary-action" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentTemplate">{{ t('admin.shippingInventory.publishTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus !== 'draft'" type="button" class="secondary-action" @click="createTemplateVersion">{{ t('admin.shippingInventory.createTemplateVersion') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId" type="button" class="secondary-action" @click="openTemplateCloneDialog">{{ t('admin.shippingInventory.cloneTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentTemplate">{{ t('admin.shippingInventory.retireTemplate') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentParsingProfile">{{ t('admin.shippingInventory.publishProfile') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentParsingProfile">{{ t('admin.shippingInventory.retireProfile') }}</button>
|
||||
@@ -386,6 +389,46 @@
|
||||
@cancel="clearConfirmation"
|
||||
@confirm="confirmPendingAction"
|
||||
/>
|
||||
<div v-if="templateClone.visible" class="drawer-mask clone-template-mask" @click.self="closeTemplateCloneDialog">
|
||||
<section class="clone-template-dialog" role="dialog" aria-modal="true" :aria-labelledby="'clone-template-title'">
|
||||
<header class="clone-template-header">
|
||||
<div><h3 id="clone-template-title">{{ t('admin.shippingInventory.cloneTemplate') }}</h3><p>{{ t('admin.shippingInventory.cloneTemplateHint') }}</p></div>
|
||||
<button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeTemplateCloneDialog">×</button>
|
||||
</header>
|
||||
<form class="clone-template-form" @submit.prevent="cloneCurrentTemplate">
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="templateClone.template_code" required pattern="[A-Za-z0-9_-]{2,64}" autocomplete="off"><small>{{ t('admin.shippingInventory.cloneTemplateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="templateClone.display_name" required autocomplete="off"></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="templateClone.saving" @click="closeTemplateCloneDialog">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="templateClone.saving">{{ templateClone.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.cloneTemplateConfirm') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="bulkBinding.visible" class="drawer-mask clone-template-mask" @click.self="closeBulkParsingBinding">
|
||||
<section class="clone-template-dialog" role="dialog" aria-modal="true" aria-labelledby="bulk-parsing-binding-title">
|
||||
<header class="clone-template-header"><div><h3 id="bulk-parsing-binding-title">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</h3><p>{{ t('admin.shippingInventory.bulkBindParsingProfileHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBulkParsingBinding">×</button></header>
|
||||
<form class="clone-template-form" @submit.prevent="submitBulkParsingBinding">
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" multiple required><option v-for="item in sources.filter((row) => !row.enabled)" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="bulkBinding.profileId" required><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.bulkBindParsingProfile') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="batchValidation.visible" class="drawer-mask clone-template-mask" @click.self="closeBatchValidation">
|
||||
<section class="batch-validation-dialog" role="dialog" aria-modal="true" aria-labelledby="batch-validation-title">
|
||||
<header class="clone-template-header"><div><h3 id="batch-validation-title">{{ t('admin.shippingInventory.batchValidation') }}</h3><p>{{ t('admin.shippingInventory.batchValidationHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBatchValidation">×</button></header>
|
||||
<form v-if="!batchValidation.result" class="batch-selection" @submit.prevent="submitBatchValidation">
|
||||
<div class="batch-selection-toolbar"><label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><input v-model="batchValidation.query" :placeholder="t('admin.shippingInventory.batchValidationSearch')"></label><div class="batch-selection-actions"><button type="button" class="text-action" :disabled="!filteredBatchValidationSources.length" @click="toggleFilteredBatchValidationSources">{{ allFilteredBatchValidationSourcesSelected ? t('admin.shippingInventory.batchValidationClearFiltered') : t('admin.shippingInventory.batchValidationSelectFiltered') }}</button><b>{{ t('admin.shippingInventory.batchValidationSelected', { count: batchValidation.sourceIds.length }) }}</b></div></div>
|
||||
<div class="batch-source-list"><label v-for="item in filteredBatchValidationSources" :key="String(item.id)" class="batch-source-option"><input v-model="batchValidation.sourceIds" type="checkbox" :value="Number(item.id)"><span><b>{{ item.display_name || item.source_code }}</b><small>{{ item.source_code }} · {{ connectionName(item.source_code) }}</small></span></label><p v-if="!filteredBatchValidationSources.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoSites') }}</p></div>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="batchValidation.saving" @click="closeBatchValidation">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="batchValidation.saving || !batchValidation.sourceIds.length">{{ batchValidation.saving ? t('admin.shippingInventory.configurationTestRunning') : t('admin.shippingInventory.batchValidation') }}</button></div>
|
||||
</form>
|
||||
<div v-else class="batch-progress">
|
||||
<div class="batch-progress-heading"><div><span>{{ t(`admin.shippingInventory.batchValidationStatus.${batchValidation.result.status}`) }}</span><strong>{{ t('admin.shippingInventory.batchValidationProgress', batchValidation.result) }}</strong></div><b>{{ batchCompletedCount }} / {{ batchValidation.result.total_count }}</b></div>
|
||||
<div class="batch-progress-bar" role="progressbar" :aria-valuenow="batchCompletedCount" :aria-valuemax="batchValidation.result.total_count"><i :style="{ width: `${batchProgressPercent}%` }"></i></div>
|
||||
<div class="batch-stat-grid"><button type="button" :class="{ active: batchValidation.statusFilter === 'all' }" @click="batchValidation.statusFilter = 'all'"><b>{{ batchValidation.result.total_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.total') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'processing' }" @click="batchValidation.statusFilter = 'processing'"><b>{{ batchProcessingCount }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.processing') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed' }" @click="batchValidation.statusFilter = 'completed'"><b>{{ batchValidation.result.success_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.success') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed_empty' }" @click="batchValidation.statusFilter = 'completed_empty'"><b>{{ batchValidation.result.empty_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.empty') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'failed' }" @click="batchValidation.statusFilter = 'failed'"><b>{{ batchValidation.result.failed_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.failed') }}</span></button></div>
|
||||
<div class="batch-run-list"><article v-for="run in filteredBatchValidationRuns" :key="run.run_no" class="batch-run" :class="`is-${run.status}`"><span class="batch-run-marker"></span><div><b>{{ sourceTitleById(run.inventory_source_id) }}</b><small>{{ t(`admin.shippingInventory.configurationTestStage.${run.stage}`) }}</small></div><small v-if="run.error_message" class="batch-run-error">{{ run.error_message }}</small></article><p v-if="!filteredBatchValidationRuns.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoRuns') }}</p></div>
|
||||
<div class="clone-template-actions"><button v-if="batchValidation.result.failed_count" type="button" class="secondary-action" @click="retryBatchValidation">{{ t('admin.shippingInventory.retryFailedValidation') }}</button><button type="button" class="primary-action" @click="closeBatchValidation">{{ t('admin.close') }}</button></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="auditDetail" class="drawer-mask" @click.self="auditDetail = null"><aside class="editor-drawer audit-detail" role="dialog" aria-modal="true"><header class="drawer-header"><div><h3>{{ auditDetail.kind === 'snapshot' ? t('admin.shippingInventory.snapshotDetail') : t('admin.shippingInventory.exportDetail') }}</h3><p>{{ auditDetail.item.inventory_file_no || auditDetail.item.rpa_run_no || '-' }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="auditDetail = null">×</button></header><dl><template v-for="entry in auditDetailEntries" :key="entry.label"><dt>{{ entry.label }}</dt><dd>{{ entry.value }}</dd></template></dl></aside></div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -407,7 +450,6 @@ import {
|
||||
deleteShippingInventoryParsingProfile,
|
||||
deleteShippingInventoryRule,
|
||||
deleteShippingInventorySource,
|
||||
activateShippingInventorySource,
|
||||
deactivateShippingInventorySource,
|
||||
deleteShippingRpaProfile,
|
||||
getShippingInventoryConfig,
|
||||
@@ -416,6 +458,7 @@ import {
|
||||
getShippingInventoryRoutingFields,
|
||||
createShippingExcelTemplate,
|
||||
createShippingExcelTemplateVersion,
|
||||
cloneShippingExcelTemplate,
|
||||
getShippingExcelTemplateLayout,
|
||||
createShippingInventoryStructureAnalysis,
|
||||
createShippingInventoryParsingDraftFromAnalysis,
|
||||
@@ -426,7 +469,10 @@ import {
|
||||
startShippingInventoryConfigurationTest,
|
||||
getShippingInventoryConfigurationTest,
|
||||
getLatestShippingInventoryConfigurationTest,
|
||||
confirmShippingInventoryConfigurationTestProfile,
|
||||
startShippingInventoryValidationBatch,
|
||||
getShippingInventoryValidationBatch,
|
||||
getLatestActiveShippingInventoryValidationBatch,
|
||||
retryFailedShippingInventoryValidationBatch,
|
||||
downloadShippingInventorySnapshot,
|
||||
updateShippingExcelTemplate,
|
||||
publishShippingExcelTemplate,
|
||||
@@ -441,14 +487,16 @@ import {
|
||||
saveShippingInventoryRule,
|
||||
saveShippingInventorySource,
|
||||
saveShippingRpaProfile,
|
||||
bulkBindShippingInventorySourceParsingProfile,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck, ShippingInventoryValidationBatch } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
|
||||
|
||||
type TabKey = 'orderSchema' | 'profiles' | 'parsing' | 'inventoryFields' | 'templates' | 'sources' | 'rules' | 'snapshots' | 'exports' | 'mappings';
|
||||
type Item = Record<string, any>;
|
||||
type Parameter = { name: string; mode: 'single' | 'multi_text' | 'multi_select'; values: string[]; required: boolean; select_all: boolean; joiner?: string };
|
||||
type RuleCondition = { source_kind: 'order_field' | 'system_fact'; order_field_id: string; system_fact_key: string; operator: string; expected: string };
|
||||
type RuleCondition = { source_kind: 'order_field'; order_field_id: string; operator: string; expected: string };
|
||||
type ParsingFieldMapping = { inventory_field: string; source_header: string };
|
||||
type ParsingMatchKey = { order_field_id: string; inventory_field: string };
|
||||
type TemplateMapping = { sheet: string; row_mode: 'header' | 'line'; start_row: number; target_column: number; source_kind: 'order_field' | 'inventory_field' | 'system_fact' | 'constant'; source_key: string; formatter: string };
|
||||
@@ -464,7 +512,7 @@ const orderSchemaPublished = ref(false);
|
||||
const saving = ref(false);
|
||||
const confirmation = reactive({
|
||||
visible: false,
|
||||
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'activateSource' | 'deactivateSource' | 'replaceInventorySample' | '',
|
||||
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'deactivateSource' | 'replaceInventorySample' | '',
|
||||
title: '',
|
||||
message: '',
|
||||
confirmText: '',
|
||||
@@ -495,7 +543,6 @@ const configurationTest = ref<ShippingInventoryConfigurationTest | null>(null);
|
||||
const configurationTestLoading = ref(false);
|
||||
let configurationTestTimer: number | null = null;
|
||||
const routingFields = ref<Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>>([]);
|
||||
const systemFacts = ref<string[]>([]);
|
||||
const templateSystemFacts = ref<string[]>([]);
|
||||
const templateSourceKinds = ref<Array<TemplateMapping['source_kind']>>([]);
|
||||
const templateRowModes = ref<Array<TemplateMapping['row_mode']>>([]);
|
||||
@@ -525,9 +572,13 @@ const profile = reactive({ profile_code: '', display_name: '', connector_type: '
|
||||
const parsing = reactive({ profile_code: '', display_name: '', file_format: 'xlsx', sheet_name: '', header_row_index: 1, field_mappings: [] as ParsingFieldMapping[], match_keys: [] as ParsingMatchKey[] });
|
||||
const inventoryField = reactive<InventoryFieldForm>({ display_name: '', description: '', value_type: 'text', usage_type: 'general', sort_order: 100, status: 'active' });
|
||||
const excelTemplate = reactive({ template_code: '', display_name: '', filename_pattern: '{business_no}.xlsx', mappings: [] as TemplateMapping[], file: null as File | null });
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], match_aliases_json: [] as string[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const templateClone = reactive({ visible: false, template_code: '', display_name: '', saving: false });
|
||||
const bulkBinding = reactive({ visible: false, sourceIds: [] as number[], profileId: 0, saving: false });
|
||||
const batchValidation = reactive({ visible: false, sourceIds: [] as number[], query: '', statusFilter: 'all' as 'all' | 'processing' | 'completed' | 'completed_empty' | 'failed', saving: false, result: null as ShippingInventoryValidationBatch | null });
|
||||
let batchValidationTimer: number | null = null;
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const sourceBaseline = ref('');
|
||||
const rule = reactive({ rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }] as RuleCondition[], source_codes: [] as string[] });
|
||||
const rule = reactive({ rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }] as RuleCondition[], source_codes: [] as string[] });
|
||||
const mapping = reactive({ inventory_source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
const compatibleRoutingFields = computed(() => routingFields.value.filter((item) => item.scope === (rule.scope === 'task' ? 'header' : 'line')));
|
||||
const activeInventoryFields = computed(() => inventoryFields.value.filter((item) => item.status === 'active'));
|
||||
@@ -544,11 +595,24 @@ const canAddParsingMatchKey = computed(() => Boolean(
|
||||
));
|
||||
const sourceDirty = computed(() => Boolean(selectedId.value && sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput()));
|
||||
const readinessChecks = computed<ShippingInventoryReadinessCheck[]>(() => source.activation?.checks || []);
|
||||
const requiredReadinessChecks = computed(() => readinessChecks.value.filter((item) => item.blocking));
|
||||
const firstBlockingCheck = computed(() => requiredReadinessChecks.value.find((item) => item.status !== 'passed'));
|
||||
const optionalReadinessChecks = computed(() => readinessChecks.value.filter((item) => !item.blocking));
|
||||
const readinessSummary = computed(() => {
|
||||
const total = readinessChecks.value.length;
|
||||
const passed = readinessChecks.value.filter((item) => item.status === 'passed').length;
|
||||
const required = requiredReadinessChecks.value;
|
||||
const total = required.length;
|
||||
const passed = required.filter((item) => item.status === 'passed').length;
|
||||
return t('admin.shippingInventory.readinessProgress', { passed, total });
|
||||
});
|
||||
const readinessHeadline = computed(() => {
|
||||
if (source.enabled) return t('admin.shippingInventory.activationReady');
|
||||
return source.activation?.ready ? t('admin.shippingInventory.activationCanEnable') : t('admin.shippingInventory.activationDraft');
|
||||
});
|
||||
const readinessGuidance = computed(() => source.enabled
|
||||
? t('admin.shippingInventory.activationEnabledHint')
|
||||
: source.activation?.ready
|
||||
? t('admin.shippingInventory.activationCanEnableHint')
|
||||
: t('admin.shippingInventory.activationMissingHint'));
|
||||
const sampleReplacementNotice = computed(() => {
|
||||
const difference = pendingSampleReplacement.value?.difference || {};
|
||||
const missing = Array.isArray(difference.missing_mapped_headers) ? difference.missing_mapped_headers : [];
|
||||
@@ -687,6 +751,31 @@ const auditDetailEntries = computed(() => {
|
||||
['库存源', sourceName(item.source_code)], ['货代仓库', warehouseName(item)], ['运行号', item.rpa_run_no || t('admin.shippingInventory.historyNotCaptured')], ['状态', auditStatus(item.export_status || item.snapshot_status)], ['导出时间', auditDate(item.exported_at)], ['有效至', auditDate(item.expires_at)], ['库存行数', item.line_count ? t('admin.shippingInventory.lineCountValue', { count: item.line_count }) : t('admin.shippingInventory.historyNotCaptured')], ['结果说明', item.error_message || auditResult(item)],
|
||||
].map(([label, value]) => ({ label, value }));
|
||||
});
|
||||
const filteredBatchValidationSources = computed(() => {
|
||||
const query = batchValidation.query.trim().toLowerCase();
|
||||
return sources.value.filter((item) => !item.enabled && item.parsing_profile_id && (
|
||||
!query || [item.display_name, item.source_code, connectionName(item.source_code)].some((value) => String(value || '').toLowerCase().includes(query))
|
||||
));
|
||||
});
|
||||
const allFilteredBatchValidationSourcesSelected = computed(() => filteredBatchValidationSources.value.length > 0 && filteredBatchValidationSources.value.every(
|
||||
(item) => batchValidation.sourceIds.includes(Number(item.id)),
|
||||
));
|
||||
const batchCompletedCount = computed(() => {
|
||||
const result = batchValidation.result;
|
||||
return result ? result.success_count + result.empty_count + result.failed_count : 0;
|
||||
});
|
||||
const batchProcessingCount = computed(() => Math.max(0, Number(batchValidation.result?.total_count || 0) - batchCompletedCount.value));
|
||||
const batchProgressPercent = computed(() => {
|
||||
const total = Number(batchValidation.result?.total_count || 0);
|
||||
return total ? Math.round(batchCompletedCount.value / total * 100) : 0;
|
||||
});
|
||||
const filteredBatchValidationRuns = computed(() => {
|
||||
const result = batchValidation.result;
|
||||
if (!result) return [];
|
||||
if (batchValidation.statusFilter === 'all') return result.runs;
|
||||
if (batchValidation.statusFilter === 'processing') return result.runs.filter((run) => ['awaiting_rpa', 'processing'].includes(run.status));
|
||||
return result.runs.filter((run) => run.status === batchValidation.statusFilter);
|
||||
});
|
||||
|
||||
/** 加载服务端配置与运行审计投影,页面不保留第二份真相。 */
|
||||
async function load(): Promise<void> {
|
||||
@@ -700,12 +789,13 @@ async function load(): Promise<void> {
|
||||
inventoryFields.value = inventoryFieldRows as Item[];
|
||||
excelTemplates.value = templateRows as Item[];
|
||||
temporaryInventorySessions.value = temporarySessions as Item[];
|
||||
routingFields.value = fieldCatalog.order_fields; systemFacts.value = fieldCatalog.system_facts;
|
||||
routingFields.value = fieldCatalog.order_fields;
|
||||
orderSchemaPublished.value = fieldCatalog.order_schema_published && configurationCatalog.order_schema_published;
|
||||
templateSystemFacts.value = configurationCatalog.template_system_facts;
|
||||
templateSourceKinds.value = configurationCatalog.template_source_kinds;
|
||||
templateRowModes.value = configurationCatalog.template_row_modes;
|
||||
templateFormatters.value = configurationCatalog.template_formatters;
|
||||
await restoreActiveBatchValidation();
|
||||
} catch (cause) {
|
||||
showError(cause, 'loadFailed');
|
||||
}
|
||||
@@ -737,10 +827,10 @@ function createNew(): void {
|
||||
templateSheetColumns.value = {};
|
||||
}
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], match_aliases_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
|
||||
sourceBaseline.value = '';
|
||||
}
|
||||
if (activeTab.value === 'rules') Object.assign(rule, { rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
if (activeTab.value === 'rules') Object.assign(rule, { rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
if (activeTab.value === 'mappings') Object.assign(mapping, { inventory_source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
drawerOpen.value = true;
|
||||
}
|
||||
@@ -783,15 +873,17 @@ function selectItem(item: Item): void {
|
||||
void loadTemplateLayout(selectedId.value);
|
||||
}
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { ...item, fixed_warehouse_id: item.fixed_warehouse_id || '', report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '', ...(item.report_path_json || {}) }, query_parameters_json: (item.query_parameters_json || []).map((parameter: Parameter) => ({ ...parameter })), match_aliases_json: [...(item.match_aliases_json || [])] });
|
||||
const reportPath = item.connector_type === 'dbs'
|
||||
? { program_group: '', program_label: '', report_group: 'Inventory', report_name: '', ...(item.report_path_json || {}) }
|
||||
: item.report_path_json;
|
||||
Object.assign(source, { ...item, fixed_warehouse_id: item.fixed_warehouse_id || '', report_path_json: normaliseInventoryReportPath(item.connector_type, reportPath), query_parameters_json: (item.query_parameters_json || []).map((parameter: Parameter) => ({ ...parameter })) });
|
||||
sourceBaseline.value = serialiseSourceInput();
|
||||
void restoreConfigurationTest(Number(item.id));
|
||||
}
|
||||
if (activeTab.value === 'rules') Object.assign(rule, {
|
||||
rule_code: item.rule_code || '', rule_name: item.rule_name || '', scope: item.scope || 'line', priority: item.priority || 0,
|
||||
conditions: (item.conditions?.length ? item.conditions : [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected_value_json: '' }]).map((condition: Record<string, unknown>) => ({
|
||||
source_kind: String(condition.source_kind || 'order_field') as 'order_field' | 'system_fact',
|
||||
order_field_id: String(condition.order_field_id || ''), system_fact_key: String(condition.system_fact_key || ''), operator: String(condition.operator || ''),
|
||||
source_kind: 'order_field', order_field_id: String(condition.order_field_id || ''), operator: String(condition.operator || ''),
|
||||
expected: Array.isArray(condition.expected_value_json) ? condition.expected_value_json.join(', ') : String(condition.expected_value_json || ''),
|
||||
})),
|
||||
source_codes: item.action_payload_json?.source_codes || [],
|
||||
@@ -800,6 +892,95 @@ function selectItem(item: Item): void {
|
||||
drawerOpen.value = true;
|
||||
}
|
||||
|
||||
/** 打开批量绑定对话框;服务端将在提交前全量预检,禁止部分站点成功。 */
|
||||
function openBulkParsingBinding(): void {
|
||||
bulkBinding.sourceIds = [];
|
||||
bulkBinding.profileId = 0;
|
||||
bulkBinding.visible = true;
|
||||
}
|
||||
|
||||
function closeBulkParsingBinding(): void {
|
||||
if (!bulkBinding.saving) bulkBinding.visible = false;
|
||||
}
|
||||
|
||||
function openBatchValidation(): void {
|
||||
batchValidation.sourceIds = [];
|
||||
batchValidation.query = '';
|
||||
batchValidation.statusFilter = 'all';
|
||||
if (!batchValidation.result || !['queued', 'running'].includes(batchValidation.result.status)) batchValidation.result = null;
|
||||
batchValidation.visible = true;
|
||||
if (batchValidation.result && ['queued', 'running'].includes(batchValidation.result.status)) void pollBatchValidation();
|
||||
}
|
||||
|
||||
/** 搜索后的全选只作用于当前可见站点,避免误把不在筛选范围内的站点加入测试。 */
|
||||
function toggleFilteredBatchValidationSources(): void {
|
||||
const ids = filteredBatchValidationSources.value.map((item) => Number(item.id));
|
||||
if (allFilteredBatchValidationSourcesSelected.value) {
|
||||
batchValidation.sourceIds = batchValidation.sourceIds.filter((id) => !ids.includes(id));
|
||||
return;
|
||||
}
|
||||
batchValidation.sourceIds = [...new Set([...batchValidation.sourceIds, ...ids])];
|
||||
}
|
||||
|
||||
function closeBatchValidation(): void {
|
||||
if (batchValidationTimer !== null) window.clearTimeout(batchValidationTimer);
|
||||
batchValidationTimer = null;
|
||||
if (!batchValidation.saving) batchValidation.visible = false;
|
||||
}
|
||||
|
||||
async function submitBatchValidation(): Promise<void> {
|
||||
batchValidation.saving = true;
|
||||
try {
|
||||
batchValidation.result = await startShippingInventoryValidationBatch(batchValidation.sourceIds);
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
finally { batchValidation.saving = false; }
|
||||
}
|
||||
|
||||
async function pollBatchValidation(): Promise<void> {
|
||||
const result = batchValidation.result;
|
||||
if (!result) return;
|
||||
try {
|
||||
batchValidation.result = await getShippingInventoryValidationBatch(result.id);
|
||||
if (batchValidation.result.status === 'queued' || batchValidation.result.status === 'running') {
|
||||
batchValidationTimer = window.setTimeout(() => { void pollBatchValidation(); }, 2000);
|
||||
}
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 页面刷新后从服务端恢复仍在运行的批量验证,并继续轮询真实状态。 */
|
||||
async function restoreActiveBatchValidation(): Promise<void> {
|
||||
try {
|
||||
const active = await getLatestActiveShippingInventoryValidationBatch();
|
||||
if (!active) return;
|
||||
batchValidation.result = active;
|
||||
batchValidation.visible = true;
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
async function retryBatchValidation(): Promise<void> {
|
||||
if (!batchValidation.result) return;
|
||||
try {
|
||||
batchValidation.result = await retryFailedShippingInventoryValidationBatch(batchValidation.result.id);
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 原子绑定所选停用站点;任一站点不兼容时由服务端整体拒绝。 */
|
||||
async function submitBulkParsingBinding(): Promise<void> {
|
||||
bulkBinding.saving = true;
|
||||
try {
|
||||
await bulkBindShippingInventorySourceParsingProfile({
|
||||
source_ids: bulkBinding.sourceIds, parsing_profile_id: bulkBinding.profileId,
|
||||
});
|
||||
bulkBinding.visible = false;
|
||||
await load();
|
||||
message.success(t('admin.shippingInventory.bulkParsingProfileBound'));
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
finally { bulkBinding.saving = false; }
|
||||
}
|
||||
|
||||
/** 从对象存储读取已保存模板的工作表与栏位,避免编辑旧模板时要求重新上传。 */
|
||||
async function loadTemplateLayout(templateId: number | null): Promise<void> {
|
||||
if (!templateId || activeTab.value !== 'templates') return;
|
||||
@@ -870,8 +1051,8 @@ async function saveCurrent(): Promise<void> {
|
||||
await createShippingExcelTemplate(form);
|
||||
}
|
||||
}
|
||||
if (activeTab.value === 'sources') await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'rules') await saveShippingInventoryRule({ rule_code: rule.rule_code, rule_name: rule.rule_name || rule.rule_code, scope: rule.scope, priority: rule.priority, match_mode: 'all', action_type: 'add_source_candidates', action_payload_json: { source_codes: splitValues(rule.source_codes) }, conditions: rule.conditions.map((condition) => ({ source_kind: condition.source_kind, order_field_id: condition.source_kind === 'order_field' ? condition.order_field_id : null, system_fact_key: condition.source_kind === 'system_fact' ? condition.system_fact_key : null, operator: condition.operator, expected_value_json: normalizeExpectedValue(condition) })) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'sources') await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null, report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'rules') await saveShippingInventoryRule({ rule_code: rule.rule_code, rule_name: rule.rule_name || rule.rule_code, scope: rule.scope, priority: rule.priority, match_mode: 'all', action_type: 'add_source_candidates', action_payload_json: { source_codes: splitValues(rule.source_codes) }, conditions: rule.conditions.map((condition) => ({ source_kind: 'order_field', order_field_id: condition.order_field_id, operator: condition.operator, expected_value_json: normalizeExpectedValue(condition) })) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'mappings') await saveShippingInventoryExternalMapping({ ...mapping, freight_warehouse_id: mapping.freight_warehouse_id || null, external_organization_code: mapping.external_organization_code || null, external_site_code: mapping.external_site_code || null }, selectedId.value || undefined);
|
||||
await load();
|
||||
closeDrawer();
|
||||
@@ -907,6 +1088,29 @@ async function createTemplateVersion(): Promise<void> {
|
||||
selectItem(created);
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
}
|
||||
/** 从当前模板版本复制受管文件和配置,作为新编码下独立的 v1 草稿。 */
|
||||
function openTemplateCloneDialog(): void {
|
||||
templateClone.template_code = '';
|
||||
templateClone.display_name = `${excelTemplate.display_name || excelTemplate.template_code} ${t('admin.shippingInventory.copySuffix')}`;
|
||||
templateClone.visible = true;
|
||||
}
|
||||
function closeTemplateCloneDialog(): void {
|
||||
if (!templateClone.saving) templateClone.visible = false;
|
||||
}
|
||||
async function cloneCurrentTemplate(): Promise<void> {
|
||||
if (!selectedId.value) return;
|
||||
templateClone.saving = true;
|
||||
try {
|
||||
const created = await cloneShippingExcelTemplate(selectedId.value, {
|
||||
template_code: templateClone.template_code,
|
||||
display_name: templateClone.display_name,
|
||||
}) as Item;
|
||||
templateClone.visible = false;
|
||||
await load();
|
||||
selectItem(created);
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
finally { templateClone.saving = false; }
|
||||
}
|
||||
/** 退役模板前由后端确认没有启用库存源仍在引用。 */
|
||||
async function retireCurrentTemplate(): Promise<void> { openConfirmation('retireTemplate', t('admin.shippingInventory.confirmRetireTemplate')); }
|
||||
/** 解析 Profile 仅在没有库存源引用时允许退役。 */
|
||||
@@ -940,7 +1144,6 @@ async function confirmPendingAction(): Promise<void> {
|
||||
if (action === 'retireTemplate') await retireShippingExcelTemplate(selectedId.value);
|
||||
if (action === 'retireParsing') await retireShippingInventoryParsingProfile(selectedId.value);
|
||||
if (action === 'retireInventoryField') await retireShippingInventoryField(selectedId.value);
|
||||
if (action === 'activateSource') await activateShippingInventorySource(selectedId.value);
|
||||
if (action === 'deactivateSource') await deactivateShippingInventorySource(selectedId.value);
|
||||
if (action === 'replaceInventorySample') { sampleReplacementConfirmed.value = true; await saveCurrent(); return; }
|
||||
if (action === 'delete' && activeTab.value === 'profiles') await deleteShippingRpaProfile(selectedId.value);
|
||||
@@ -957,16 +1160,6 @@ async function confirmPendingAction(): Promise<void> {
|
||||
|
||||
function clearConfirmation(): void { confirmation.visible = false; confirmation.action = ''; }
|
||||
|
||||
/** 展示启用前置条件,避免管理员在普通保存时误以为站点已经进入正式运行。 */
|
||||
function requestSourceActivation(): void {
|
||||
confirmation.visible = true;
|
||||
confirmation.action = 'activateSource';
|
||||
confirmation.title = t('admin.shippingInventory.activateSource');
|
||||
confirmation.message = t('admin.shippingInventory.activateSourceConfirm');
|
||||
confirmation.confirmText = t('admin.shippingInventory.activateSource');
|
||||
confirmation.tone = 'primary';
|
||||
}
|
||||
|
||||
/** 停用动作使用平台确认弹窗,防止误将正在运行的库存站点下线。 */
|
||||
function requestSourceDeactivation(): void {
|
||||
confirmation.visible = true;
|
||||
@@ -1008,20 +1201,19 @@ async function pollConfigurationTest(): Promise<void> {
|
||||
configurationTest.value = updated;
|
||||
if (isConfigurationTestRunning(updated)) {
|
||||
configurationTestTimer = window.setTimeout(() => { void pollConfigurationTest(); }, 2000);
|
||||
} else {
|
||||
await refreshSelectedSource();
|
||||
}
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 仅在测试完成后确认候选方案,成功后刷新库存站点以显示新的解析方案绑定。 */
|
||||
async function confirmTestProfile(profileId: number): Promise<void> {
|
||||
if (!selectedId.value || !configurationTest.value?.run_no) return;
|
||||
try {
|
||||
await confirmShippingInventoryConfigurationTestProfile(selectedId.value, String(configurationTest.value.run_no), profileId);
|
||||
message.success(t('admin.shippingInventory.configurationTestProfileConfirmed'));
|
||||
await load();
|
||||
const item = sources.value.find((row) => Number(row.id) === selectedId.value);
|
||||
if (item) selectItem(item);
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
/** 测试结束后回读服务端的启用投影,避免抽屉继续展示测试前的过期门禁。 */
|
||||
async function refreshSelectedSource(): Promise<void> {
|
||||
const sourceId = selectedId.value;
|
||||
if (!sourceId) return;
|
||||
await load();
|
||||
const refreshed = sources.value.find((item) => Number(item.id) === sourceId);
|
||||
if (refreshed) selectItem(refreshed);
|
||||
}
|
||||
|
||||
/** 新增一行结构化 DBS 查询参数,避免要求管理员编辑 JSON。 */
|
||||
@@ -1097,7 +1289,7 @@ function applyAnalysisCandidate(): void {
|
||||
parsing.field_mappings = parsing.field_mappings.filter((item) => headers.has(item.source_header));
|
||||
}
|
||||
function candidateKey(candidate: Item): string { return `${candidate.sheet_name || 'csv'}-${candidate.header_row_index}`; }
|
||||
function addRuleCondition(): void { rule.conditions.push({ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }); }
|
||||
function addRuleCondition(): void { rule.conditions.push({ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }); }
|
||||
function removeRuleCondition(index: number): void { if (rule.conditions.length > 1) rule.conditions.splice(index, 1); }
|
||||
function splitValues(value: string | string[]): string[] { return (Array.isArray(value) ? value : value.split(',')).map((item) => item.trim()).filter(Boolean); }
|
||||
function conditionNeedsExpected(condition: RuleCondition): boolean { return !['is_empty', 'is_not_empty'].includes(condition.operator); }
|
||||
@@ -1204,7 +1396,10 @@ function inventoryFieldOptionLabel(field: Item): string {
|
||||
function formatDate(value: unknown): string { return value ? new Date(String(value)).toLocaleString() : '-'; }
|
||||
function auditDate(value: unknown): string { return value ? formatDate(value) : t('admin.shippingInventory.historyNotCaptured'); }
|
||||
function sourceName(sourceCode: unknown): string { return String(sourceCode || t('admin.shippingInventory.historyNotCaptured')); }
|
||||
function parsingProfileName(profileId: unknown): string { const item = parsingProfiles.value.find((row) => Number(row.id) === Number(profileId)); return String(item?.display_name || item?.profile_code || t('admin.shippingInventory.notGenerated')); }
|
||||
function sourceTitleById(sourceId: number): string {
|
||||
const item = sources.value.find((source) => Number(source.id) === Number(sourceId));
|
||||
return String(item?.display_name || item?.source_code || sourceId);
|
||||
}
|
||||
/** 将会影响测试输入的站点字段稳定序列化,用于阻止管理员针对未保存配置运行测试或启用。 */
|
||||
function serialiseSourceInput(): string {
|
||||
return JSON.stringify({
|
||||
@@ -1212,8 +1407,7 @@ function serialiseSourceInput(): string {
|
||||
rpa_profile_id: source.rpa_profile_id, parsing_profile_id: source.parsing_profile_id,
|
||||
excel_template_id: source.excel_template_id, warehouse_resolution_mode: source.warehouse_resolution_mode,
|
||||
fixed_warehouse_id: source.fixed_warehouse_id, snapshot_ttl_seconds: source.snapshot_ttl_seconds,
|
||||
report_path_json: source.report_path_json, query_parameters_json: source.query_parameters_json,
|
||||
match_aliases_json: source.match_aliases_json,
|
||||
report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json), query_parameters_json: source.query_parameters_json,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1230,11 +1424,13 @@ function readinessDetail(check: ShippingInventoryReadinessCheck): string {
|
||||
if (check.status === 'passed') return t('admin.shippingInventory.readinessState.passed');
|
||||
if (check.status === 'stale') return t('admin.shippingInventory.readinessState.stale');
|
||||
if (check.status === 'failed') return t('admin.shippingInventory.readinessState.failed');
|
||||
return check.blocking ? t('admin.shippingInventory.readinessState.required') : t('admin.shippingInventory.readinessState.waiting');
|
||||
if (check.status === 'empty') return t('admin.shippingInventory.readinessState.empty');
|
||||
return check.blocking ? t('admin.shippingInventory.readinessState.required') : t('admin.shippingInventory.readinessState.optional');
|
||||
}
|
||||
|
||||
/** 每项门禁只映射一个推荐动作;已经通过和依赖测试的辅助检查不额外制造操作入口。 */
|
||||
function readinessActionLabel(check: ShippingInventoryReadinessCheck): string {
|
||||
if (!check.blocking) return '';
|
||||
if (!needsReadinessAction(check)) return '';
|
||||
if (check.action === 'run_configuration_test') return configurationTestLoading.value
|
||||
? t('admin.shippingInventory.configurationTestRunning')
|
||||
@@ -1328,9 +1524,15 @@ onMounted(load);
|
||||
.status-dot.on { background: #22c55e; }
|
||||
.status-dot.off { background: #b2bdc9; }
|
||||
.drawer-mask { position: fixed; z-index: 40; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 28%); }
|
||||
.workbench-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.clone-template-mask { z-index: 80; align-items: center; justify-content: center; padding: 20px; }
|
||||
.clone-template-dialog { width: min(480px, 100%); border-radius: 10px; background: #fff; box-shadow: 0 18px 48px rgb(15 23 42 / 25%); }
|
||||
.clone-template-header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; padding: 18px 20px; }.clone-template-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.clone-template-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.clone-template-form { display: grid; gap: 14px; padding: 20px; }.clone-template-form label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.clone-template-form input { min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.clone-template-form small { color: #94a3b8; font-size: 11px; line-height: 1.45; }.clone-template-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf2f7; padding-top: 14px; }
|
||||
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar input { min-width: 0; border: 1px solid #d8e5ed; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .text-action { padding: 6px 8px; background: #f1f7fa; color: #17769d; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }.batch-source-option input { margin: 3px 0 0; accent-color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
|
||||
.editor-drawer { width: min(760px, 100vw); height: 100%; overflow-y: auto; border-left: 1px solid #dbe5ed; background: #fff; box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
|
||||
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 18px 20px; }
|
||||
.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }
|
||||
.drawer-title-row { display: flex; align-items: center; gap: 9px; }.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.source-run-status { flex: 0 0 auto; border: 1px solid #f2d3cd; border-radius: 999px; background: #fff4f1; padding: 3px 7px; color: #a53f30; font-size: 11px; font-weight: 700; }.source-run-status.enabled { border-color: #c7e7d0; background: #eefaf1; color: #247442; }
|
||||
.drawer-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.drawer-close { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #64748b; font-size: 24px; line-height: 1; cursor: pointer; }
|
||||
.drawer-close:hover { background: #f1f5f9; color: #334155; }
|
||||
@@ -1349,11 +1551,13 @@ onMounted(load);
|
||||
.filename-variable-menu { position: absolute; z-index: 3; top: calc(100% + 5px); left: 0; width: min(440px, 100%); overflow: hidden; border: 1px solid #cfdde7; border-radius: 7px; background: #fff; box-shadow: 0 10px 24px rgb(15 23 42 / 14%); padding: 4px; }
|
||||
.filename-variable-menu button { display: grid; width: 100%; grid-template-columns: 154px minmax(0, 1fr); gap: 8px; border: 0; border-radius: 4px; background: transparent; padding: 7px 8px; color: #64748b; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
||||
.filename-variable-menu button:hover, .filename-variable-menu button.active { background: #eef8f7; color: #145f5a; }.filename-variable-menu code { color: #047f76; font-size: 12px; }.filename-variable-menu p { margin: 0; padding: 8px; color: #94a3b8; font-size: 12px; }
|
||||
.readiness-card { display: grid; gap: 13px; border: 1px solid #d9e6ef; border-radius: 10px; background: linear-gradient(135deg, #fbfdff, #f4f9fc); padding: 15px; }.readiness-card.ready { border-color: #b7e4c7; background: linear-gradient(135deg, #fbfffc, #f2fbf5); }
|
||||
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }.readiness-heading > div { display: grid; gap: 4px; }.readiness-kicker { color: #64748b; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }.readiness-heading strong { color: #263b4e; font-size: 13px; line-height: 1.45; }.readiness-count { flex: 0 0 auto; border-radius: 999px; background: #eaf4fa; padding: 4px 8px; color: #176f9f; font-size: 11px; font-weight: 700; }.readiness-card.ready .readiness-count { background: #e8f7ed; color: #19703a; }
|
||||
.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 48px; border-top: 1px solid #e6eef4; padding: 8px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-note, .readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 10px; font-weight: 700; letter-spacing: .03em; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }.readiness-footer { display: flex; justify-content: flex-end; border-top: 1px solid #e6eef4; padding-top: 11px; }
|
||||
.readiness-card { display: grid; gap: 12px; border: 1px solid #cfe2ea; border-radius: 12px; background: #fbfdfe; padding: 16px; }.readiness-card.ready { border-color: #b9dfc4; background: #fcfffd; }
|
||||
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }.readiness-heading > div { display: grid; gap: 5px; }.readiness-kicker { color: #5f798c; font-size: 11px; font-weight: 700; letter-spacing: .04em; }.readiness-heading strong { color: #263b4e; font-size: 14px; line-height: 1.4; }.readiness-heading p { margin: 0; color: #6d8292; font-size: 12px; line-height: 1.45; }.readiness-count { flex: 0 0 auto; border: 1px solid #cce7f1; border-radius: 999px; background: #edf8fc; padding: 5px 9px; color: #176f9f; font-size: 12px; font-weight: 700; white-space: nowrap; }.readiness-card.ready .readiness-count { border-color: #cce8d4; background: #eef9f1; color: #19703a; }
|
||||
.readiness-section { border: 1px solid #e1edf2; border-radius: 9px; background: #fff; padding: 0 12px; }.readiness-section-heading { display: grid; gap: 2px; padding: 11px 0 8px; }.readiness-section-heading b { color: #385166; font-size: 12px; }.readiness-section-heading small { color: #8192a0; font-size: 11px; }.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 46px; border-top: 1px solid #edf2f5; padding: 7px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }
|
||||
.readiness-optional { border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-optional summary, .readiness-audit summary { display: flex; align-items: baseline; gap: 8px; color: #61798a; cursor: pointer; list-style: none; }.readiness-optional summary::-webkit-details-marker, .readiness-audit summary::-webkit-details-marker { display: none; }.readiness-optional summary::before, .readiness-audit summary::before { color: #4d849f; content: '›'; font-size: 16px; line-height: .8; transition: transform .15s; }.readiness-optional[open] summary::before, .readiness-audit[open] summary::before { transform: rotate(90deg); }.readiness-optional summary span { color: #516b7d; font-size: 12px; font-weight: 700; }.readiness-optional summary small { color: #8797a5; font-size: 11px; }.readiness-optional .readiness-steps { margin-top: 8px; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { margin: 0; border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-audit summary { color: #61798a; font-size: 11px; font-weight: 700; }.readiness-audit dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 9px 0 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit dl > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 11px; font-weight: 700; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }.readiness-footer { display: flex; justify-content: flex-end; border-top: 1px solid #e6eef4; padding-top: 11px; }
|
||||
.form-tip { border-radius: 8px; background: #f1f6fa; padding: 11px; color: #5d7084; font-size: 12px; line-height: 1.55; }
|
||||
.configuration-test-verified { margin: 0; border-left: 3px solid #34a56b; background: #effaf3; padding: 9px 10px; color: #256b43; font-size: 12px; font-weight: 600; line-height: 1.45; }
|
||||
.sample-evidence-card { display: grid; gap: 12px; border: 1px solid #d7e3ed; border-radius: 8px; background: #f8fbfd; padding: 14px; }
|
||||
.sample-evidence-card > div { display: grid; gap: 3px; }.sample-evidence-card strong { color: #334155; font-size: 13px; }.sample-evidence-card p, .sample-evidence-card > small { margin: 0; color: #6b7f91; font-size: 12px; line-height: 1.55; }
|
||||
.sample-evidence-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }.sample-evidence-card dl div { min-width: 0; }.sample-evidence-card dt { color: #8190a0; font-size: 11px; }.sample-evidence-card dd { margin: 3px 0 0; overflow-wrap: anywhere; color: #475569; font-size: 12px; font-weight: 600; }
|
||||
@@ -1385,7 +1589,7 @@ onMounted(load);
|
||||
.condition-empty { color: #8190a0; font-size: 12px; }
|
||||
.inline-check { flex-direction: row !important; align-items: center; gap: 4px !important; white-space: nowrap; font-size: 11px !important; }
|
||||
.switch-field { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.status-switch { display: inline-flex; width: fit-content; align-items: center; gap: 7px; border: 0; background: transparent; padding: 2px 0; color: #94a3b8; font: inherit; font-size: 12px; cursor: pointer; }.status-switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background .18s; }.status-switch i::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 25%); content: ''; transition: transform .18s; }.status-switch.on { color: #15803d; }.status-switch.on i { background: #22c55e; }.status-switch.on i::after { transform: translateX(14px); }.status-switch b { font-weight: 500; }
|
||||
.form-actions { display: flex; gap: 10px; padding-top: 8px; }
|
||||
.form-actions { position: sticky; z-index: 2; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; grid-column: 1 / -1; margin: 6px -20px -20px; border-top: 1px solid #dce6ef; background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
|
||||
.audit-table-wrap { overflow-x: auto; border: 1px solid #dce6ef; border-radius: 10px; background: #fff; }
|
||||
.audit-table { table-layout: fixed; border-collapse: collapse; font-size: 12px; }
|
||||
.audit-table th { position: relative; overflow: hidden; padding: 11px 12px; background: #f8fafc; color: #64748b; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@@ -1399,5 +1603,5 @@ onMounted(load);
|
||||
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
|
||||
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
|
||||
@media (max-width: 980px) { .console-header { display: block; } .flow-strip { display: inline-flex; margin-top: 18px; } .console-layout { grid-template-columns: 1fr; } .section-nav { flex-direction: row; gap: 12px; overflow-x: auto; } .nav-group { display: flex; align-items: center; gap: 4px; } .nav-group > p { display: none; } .section-nav button { min-width: max-content; border-bottom: 3px solid transparent; border-left: 0; } .section-nav button.active { border-bottom-color: #16877f; border-left: 0; } .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; } .readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
|
||||
</style>
|
||||
+8
@@ -8,6 +8,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
|
||||
|
||||
const check = (status: ShippingInventoryReadinessCheck['status'], blocking: boolean): ShippingInventoryReadinessCheck => ({
|
||||
code: 'configuration_test', status, blocking, action: 'run_configuration_test', evidence: {},
|
||||
@@ -33,4 +34,11 @@ describe('shippingInventoryReadiness', () => {
|
||||
expect(isConfigurationTestRunning({ run_no: 'RUN-3', status: 'completed', stage: 'ready_for_confirmation' })).toBe(false);
|
||||
expect(isConfigurationTestRunning({ run_no: 'RUN-4', status: 'failed', stage: 'failed' })).toBe(false);
|
||||
});
|
||||
|
||||
it('removes DBS report paths before saving a Crane inventory source', () => {
|
||||
// 关键断言:Crane 不支持 DBS 四级路径,编辑回填的默认值不得再次提交给后端。
|
||||
const dbsPath = { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inventory', report_name: 'On Hand' };
|
||||
expect(normaliseInventoryReportPath('crane', dbsPath)).toEqual({});
|
||||
expect(normaliseInventoryReportPath('dbs', dbsPath)).toEqual(dbsPath);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/shippingInventorySourceForm.ts
|
||||
* 用途:规范化库存站点表单中仅适用于 DBS 的报表路径字段。
|
||||
* 依赖:无外部依赖,仅处理库存站点表单的连接器类型和 JSON 路径。
|
||||
* 逻辑:ShippingInventoryPage 在回填、保存和脏状态比较时调用,避免非 DBS 站点携带 DBS 默认路径。
|
||||
*/
|
||||
|
||||
export type InventoryReportPath = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* 返回可发送给库存站点接口的报表路径。
|
||||
* 核心逻辑:DBS 必须保留其四级报表路径;Crane 等非 DBS Driver 不支持该字段,统一发送空对象。
|
||||
* @param connectorType - 当前库存站点的 Driver 类型。
|
||||
* @param reportPath - 表单当前保存或回填的路径对象。
|
||||
* @returns DBS 的路径副本,或非 DBS 的空对象;不会修改原始表单数据。
|
||||
*/
|
||||
export function normaliseInventoryReportPath(connectorType: unknown, reportPath: InventoryReportPath | null | undefined): InventoryReportPath {
|
||||
return String(connectorType || '').trim().toLowerCase() === 'dbs' ? { ...(reportPath || {}) } : {};
|
||||
}
|
||||
@@ -306,6 +306,7 @@ const syncDraftFields = (): void => {
|
||||
...(byId.get(field.id) || {
|
||||
field_id: field.id,
|
||||
display_name: published.value?.definition?.fields.find((item) => item.field_id === field.id)?.display_name || field.field_code,
|
||||
business_purpose: 'general',
|
||||
required: false,
|
||||
aliases: [],
|
||||
...defaultRule(field),
|
||||
@@ -666,6 +667,7 @@ onMounted(async () => {
|
||||
<div class="rule-basics">
|
||||
<label><span>{{ t('admin.shippingOrderSchema.displayName') }}</span><input v-model="selectedRuleConfig.display_name" :disabled="isReadOnly"></label>
|
||||
<label><span>{{ t('admin.shippingOrderSchema.fieldName') }}</span><input v-model="editingFieldCode" :disabled="isReadOnly" @change="saveFieldCode"></label>
|
||||
<label><span>{{ t('admin.shippingOrderSchema.businessPurpose') }}</span><select v-model="selectedRuleConfig.business_purpose" :disabled="isReadOnly || !selectedDraftField?.enabled || fieldFor(selectedRuleConfig)?.scope !== 'line'"><option v-for="item in ['general', 'part_number', 'quantity', 'reservation_id', 'inventory_source_hint']" :key="item" :value="item">{{ t(`admin.shippingOrderSchema.businessPurposeOption.${item}`) }}</option></select></label>
|
||||
<label class="span-two"><span>{{ t('admin.shippingOrderSchema.aliases') }}</span><input :value="selectedRuleConfig.aliases.join(', ')" :disabled="isReadOnly || !selectedDraftField?.enabled" @input="!isReadOnly && (selectedRuleConfig.aliases = splitValues(($event.target as HTMLInputElement).value))"></label>
|
||||
<label class="span-two"><span>{{ t('admin.shippingOrderSchema.extractionInstruction') }}</span><textarea v-model="selectedRuleConfig.extraction_instruction" :disabled="isReadOnly || !selectedDraftField?.enabled" :placeholder="t('admin.shippingOrderSchema.extractionInstructionPlaceholder')"></textarea></label>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* features/admin/shippingConfigNavigation.spec.ts
|
||||
* 用途:锁定货代配置二级导航与后台路由的注册契约。
|
||||
* 依赖:货代配置子模块注册表、后台路由、Vitest。
|
||||
* 逻辑:防止新增或调整子页面时丢失深链、权限复用或当前子项高亮标识。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { adminRoutes } from '@/app/router/routes/admin.routes';
|
||||
import { SHIPPING_CONFIG_SUB_MODULE_METAS } from './constants/modules';
|
||||
|
||||
const shippingRoutes = adminRoutes[0].children?.filter((route) =>
|
||||
route.name === 'AdminShippingInventory' || route.name === 'AdminShippingIdentityRules',
|
||||
) ?? [];
|
||||
|
||||
describe('shipping configuration navigation contract', () => {
|
||||
it('registers inventory and identity rules as the only shipping configuration subpages', () => {
|
||||
// 关键断言:导航注册表与深链路由必须一一对应,避免后台入口不可发现。
|
||||
expect(SHIPPING_CONFIG_SUB_MODULE_METAS).toEqual([
|
||||
{ id: 'inventory', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.nav.shippingInventory' },
|
||||
{ id: 'identity_rules', routeName: 'AdminShippingIdentityRules', path: 'shipping-identity-rules', labelKey: 'admin.nav.shippingIdentityRules' },
|
||||
]);
|
||||
expect(shippingRoutes).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('keeps both deep links behind the shared shipping inventory admin boundary', () => {
|
||||
// 关键断言:菜单可见性不是授权;两个页面均须保留 requiresAdmin 和共享模块权限标识。
|
||||
expect(shippingRoutes.map((route) => route.meta)).toEqual([
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'inventory' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'identity_rules' }),
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/stores/admin-nav.store.ts
|
||||
* 管理后台导航 UI 状态(侧栏折叠、报表/企微子菜单展开、角标)。
|
||||
* 管理后台导航 UI 状态(侧栏折叠、货代/报表/企微子菜单展开、角标)。
|
||||
*
|
||||
* 角标数据来自 GET /api/admin/dashboard/badges,在 store 内做 TTL 缓存与 in-flight 去重,
|
||||
* 避免切换 admin 子路由时重复请求(AdminLayout 挂载一次即可)。
|
||||
@@ -20,6 +20,8 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
const reportsExpanded = ref(false);
|
||||
/** 企业微信子菜单:默认折叠 */
|
||||
const wecomExpanded = ref(false);
|
||||
/** 货代配置子菜单:默认折叠,进入库存或识别规则页时由导航自动展开。 */
|
||||
const shippingConfigExpanded = ref(false);
|
||||
/** 「用户审批」导航角标:pending 注册用户数 */
|
||||
const pendingApprovalsCount = ref(0);
|
||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||
@@ -88,6 +90,7 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
sidebarCollapsed,
|
||||
reportsExpanded,
|
||||
wecomExpanded,
|
||||
shippingConfigExpanded,
|
||||
pendingApprovalsCount,
|
||||
pendingRequestsCount,
|
||||
toggleSidebar,
|
||||
|
||||
@@ -20,6 +20,9 @@ export type AdminModuleId =
|
||||
| 'shipping_inventory'
|
||||
| 'reports';
|
||||
|
||||
/** 货代配置领域下可由侧栏展示和高亮的稳定子页面。 */
|
||||
export type ShippingConfigSubModuleId = 'inventory' | 'identity_rules';
|
||||
|
||||
export type AdminReportTableId =
|
||||
| 'usage_analysis'
|
||||
| 'users'
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* features/admin/types/shipping-identity-rules.types.ts
|
||||
* 用途:货代客户可配置识别规则管理 API 的前端 DTO。
|
||||
* 依赖:无。
|
||||
* 逻辑:规则管理页和客户证据值入口依此展示稳定字段引用与不可变版本。
|
||||
*/
|
||||
|
||||
export type ShippingIdentityTargetType = 'customer' | 'site';
|
||||
export type ShippingIdentitySourceAdapterKey = 'email_metadata' | 'document_template' | 'order_field';
|
||||
export type ShippingIdentityAutomation = 'none' | 'conditional';
|
||||
|
||||
export interface ShippingIdentityDefinition {
|
||||
id: string;
|
||||
definition_code: string;
|
||||
display_name: string;
|
||||
description?: string | null;
|
||||
evidence_label: string;
|
||||
target_type: ShippingIdentityTargetType;
|
||||
source_adapter_key: ShippingIdentitySourceAdapterKey;
|
||||
source_selector: Record<string, unknown>;
|
||||
attribute_key: string;
|
||||
order_field_id?: string | null;
|
||||
order_field?: { field_id: string; field_code: string; scope: 'header' | 'line'; value_type: string; status: string; display_name?: string } | null;
|
||||
normalizer_key: string;
|
||||
comparator_key: string;
|
||||
default_weight: number;
|
||||
max_automation: ShippingIdentityAutomation;
|
||||
status: 'active' | 'retired';
|
||||
}
|
||||
|
||||
export interface ShippingIdentitySourceAdapter {
|
||||
key: ShippingIdentitySourceAdapterKey;
|
||||
display_name: string;
|
||||
description: string;
|
||||
selectors: Record<string, unknown>;
|
||||
options: Record<string, { display_name: string; normalizer_key: string; max_automation: ShippingIdentityAutomation }>;
|
||||
}
|
||||
|
||||
export interface ShippingIdentityRuleSet {
|
||||
id: number;
|
||||
version: number;
|
||||
status: 'draft' | 'published' | 'retired';
|
||||
lock_version: number;
|
||||
checksum?: string | null;
|
||||
change_note?: string | null;
|
||||
source_rule_set_id?: number | null;
|
||||
definition?: { definitions: ShippingIdentityDefinition[] };
|
||||
}
|
||||
|
||||
export interface ShippingIdentityRuleCatalog {
|
||||
definitions: ShippingIdentityDefinition[];
|
||||
order_fields: Array<{ field_id: string; field_code: string; display_name: string; scope: 'header' | 'line'; value_type: string }>;
|
||||
catalog: {
|
||||
target_types: ShippingIdentityTargetType[];
|
||||
source_adapters: ShippingIdentitySourceAdapter[];
|
||||
};
|
||||
}
|
||||
@@ -21,6 +21,7 @@ export interface ShippingOrderFieldConfig {
|
||||
value_type?: ShippingOrderField['value_type'];
|
||||
display_name: string;
|
||||
description?: string | null;
|
||||
business_purpose?: 'general' | 'part_number' | 'quantity' | 'reservation_id' | 'inventory_source_hint';
|
||||
required: boolean;
|
||||
aliases: string[];
|
||||
normalizer_key: string;
|
||||
|
||||
@@ -19,6 +19,8 @@ import type {
|
||||
ShippingCreateBatchFromIntakesResponse,
|
||||
ShippingTaskCreateResponse,
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskBatchDispositionResponse,
|
||||
ShippingTaskPage,
|
||||
ShippingTaskSummary,
|
||||
ShippingCustomerOption,
|
||||
ShippingTaskUiState,
|
||||
@@ -69,13 +71,20 @@ const reportRetryRpaDebug = (hypothesisId: string, msg: string, data: Record<str
|
||||
reportShippingDebugEvent('shipping.api.ts', hypothesisId, msg, data);
|
||||
// #endregion
|
||||
|
||||
export const listWorkspaceShippingTasks = (params?: { process_status?: string; limit?: number }) => {
|
||||
export const listWorkspaceShippingTasks = (params?: {
|
||||
process_status?: string;
|
||||
lifecycle_status?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}) => {
|
||||
/** 拉取当前用户可见的发货任务列表。 */
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.process_status) sp.set('process_status', params.process_status);
|
||||
if (params?.limit) sp.set('limit', String(params.limit));
|
||||
if (params?.lifecycle_status) sp.set('lifecycle_status', params.lifecycle_status);
|
||||
if (params?.page) sp.set('page', String(params.page));
|
||||
if (params?.page_size) sp.set('page_size', String(params.page_size));
|
||||
const qs = sp.toString();
|
||||
return requestJson<ShippingTaskSummary[]>(`/api/workspace/shipping-tasks${qs ? '?' + qs : ''}`);
|
||||
return requestJson<ShippingTaskPage>(`/api/workspace/shipping-tasks${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
export const listWorkspaceShippingBatches = (params?: { limit?: number }) => {
|
||||
@@ -137,6 +146,30 @@ export async function downloadWorkspaceShippingExportArchive(payload: { batch_no
|
||||
return { blob: await response.blob(), filename: encoded ? decodeURIComponent(encoded) : (plain || 'shipping_exports.zip') };
|
||||
}
|
||||
|
||||
/** 批量移动任务到回收站;服务端按每条任务当前事实决定仅删除或作废后删除。 */
|
||||
export const deleteWorkspaceShippingTasks = (taskNos: string[], reason: string) =>
|
||||
requestJson<ShippingTaskBatchDispositionResponse>(
|
||||
'/api/workspace/shipping-tasks/batch-delete', jsonPost({ task_nos: taskNos, reason }),
|
||||
);
|
||||
|
||||
/** 批量归档任务,适用于外部上传中或已上传而禁止平台单方作废的任务。 */
|
||||
export const archiveWorkspaceShippingTasks = (taskNos: string[]) =>
|
||||
requestJson<ShippingTaskBatchDispositionResponse>(
|
||||
'/api/workspace/shipping-tasks/batch-archive', jsonPost({ task_nos: taskNos }),
|
||||
);
|
||||
|
||||
/** 批量恢复回收站中的纯误建任务。 */
|
||||
export const restoreWorkspaceShippingTasks = (taskNos: string[]) =>
|
||||
requestJson<ShippingTaskBatchDispositionResponse>(
|
||||
'/api/workspace/shipping-tasks/batch-restore', jsonPost({ task_nos: taskNos }),
|
||||
);
|
||||
|
||||
/** 仅管理员可永久清除回收站中的纯误建任务;服务端会重新统计所有阻断引用。 */
|
||||
export const purgeWorkspaceShippingTasks = (taskNos: string[], reason: string) =>
|
||||
requestJson<ShippingTaskBatchDispositionResponse>(
|
||||
'/api/workspace/shipping-tasks/batch-purge', jsonPost({ task_nos: taskNos, reason }),
|
||||
);
|
||||
|
||||
/**
|
||||
* 确认当前任务的库存 RPA 来源。
|
||||
* @param taskNo - 发货任务编号
|
||||
@@ -671,6 +704,9 @@ export type {
|
||||
ShippingCreateBatchFromIntakesResponse,
|
||||
ShippingTaskCreateResponse,
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskBatchDispositionResponse,
|
||||
ShippingTaskDispositionResult,
|
||||
ShippingTaskPage,
|
||||
ShippingTaskSummary,
|
||||
ShippingTaskUiState,
|
||||
ShippingWorkflowStep,
|
||||
|
||||
@@ -190,6 +190,27 @@ describe('useChat shipping_order_extraction_state SSE', () => {
|
||||
expect(isAllowedAfterStreamTerminal('agent_message')).toBe(false);
|
||||
});
|
||||
|
||||
it('clears a generic stream failure after persisted partial completion', () => {
|
||||
const message: ChatMessage = {
|
||||
role: 'assistant',
|
||||
content: '请求失败,请稍后重试。',
|
||||
stream_error: true,
|
||||
};
|
||||
|
||||
applyShippingOrderExtractionStateToMessage(message, {
|
||||
status: 'partially_completed',
|
||||
phase: 'result_persisted',
|
||||
message: '仍有 1 个订单需要补充信息',
|
||||
pending_count: 1,
|
||||
terminal: true,
|
||||
});
|
||||
|
||||
// 关键断言:已保存的订单部分完成结果不得被通用 SSE 断流提示覆盖。
|
||||
expect(message.content).toBe('');
|
||||
expect(message.stream_error).toBe(false);
|
||||
expect(message.shipping_order_extraction_state?.status).toBe('partially_completed');
|
||||
});
|
||||
|
||||
it('hydrates persisted terminal state from ChatLog payload', () => {
|
||||
const message: ChatMessage = {
|
||||
role: 'assistant',
|
||||
|
||||
@@ -174,6 +174,13 @@ const SHIPPING_ORDER_EXTRACTION_STATUSES = new Set<ShippingOrderExtractionStatus
|
||||
'failed',
|
||||
]);
|
||||
|
||||
const STREAM_ERROR_FALLBACK_SUFFIXES = [
|
||||
'请求失败,请稍后重试。',
|
||||
'請求失敗,請稍後重試。',
|
||||
'The request failed. Please try again.',
|
||||
'คำขอล้มเหลว โปรดลองใหม่อีกครั้ง',
|
||||
];
|
||||
|
||||
/**
|
||||
* 将未知 SSE payload 规范为订单识别状态。
|
||||
* 核心逻辑:只接受固定状态枚举;计数字段统一约束为非负整数,避免异常上游值破坏卡片布局。
|
||||
@@ -219,6 +226,12 @@ export const applyShippingOrderExtractionStateToMessage = (
|
||||
if (!state) return;
|
||||
if (msg.shipping_order_extraction_state?.terminal && !state.terminal) return;
|
||||
msg.shipping_order_extraction_state = state;
|
||||
if (msg.stream_error && (state.status === 'completed' || state.status === 'partially_completed')) {
|
||||
// 已持久化的订单事实优先于连接层通用断流提示,避免业务成功仍向用户误报失败。
|
||||
const fallbackSuffix = STREAM_ERROR_FALLBACK_SUFFIXES.find((suffix) => msg.content.endsWith(suffix));
|
||||
if (fallbackSuffix) msg.content = msg.content.slice(0, -fallbackSuffix.length).trimEnd();
|
||||
msg.stream_error = false;
|
||||
}
|
||||
msg.payload = {
|
||||
...(msg.payload && typeof msg.payload === 'object' ? msg.payload as Record<string, unknown> : {}),
|
||||
shipping_order_extraction_state: state,
|
||||
|
||||
@@ -260,7 +260,7 @@ export function sanitizeShippingConversationText(text: string, enabled: boolean)
|
||||
result = result
|
||||
.replace(/\bcreate_task\b/gi, '新建任务')
|
||||
.replace(/\bget_task_status\b/gi, '查询任务状态')
|
||||
.replace(/\bparse_notice\b/gi, '解析发货通知')
|
||||
.replace(/\bsubmit_order_extraction\b/gi, '提交订单抽取')
|
||||
.replace(/\bsubmit_decision\b/gi, '提交处理结果')
|
||||
.replace(/\bmatch_inventory\b/gi, '匹配库存')
|
||||
.replace(/\bgenerate_excel\b/gi, '生成发货 Excel')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/chat/shipping/shippingUploadPrompt.ts
|
||||
* 用途:通知上传后提示语构建、文件格式识别与临时库存声明判断。
|
||||
* 依赖:无;useChatShippingUploadHandler 在上传成功后调用。
|
||||
* 逻辑:按 checkpoint 生成不同 follow-up 提示;通知建批后触发 Dify LLM 解析续办。
|
||||
* 逻辑:按 checkpoint 生成不同 follow-up 提示;通知建批后触发 Dify 完整动态订单抽取。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
|
||||
@@ -10,7 +10,7 @@ import i18n from '@/i18n';
|
||||
* 根据上传 API 响应 checkpoint 生成发给 Agent 的 follow-up 提示语。
|
||||
*/
|
||||
/**
|
||||
* 根据通知建批 API 响应生成发给 Dify 的 follow-up 提示语(触发画布 LLM 抽取 + parse_notice)。
|
||||
* 根据通知建批 API 响应生成发给 Dify 的 follow-up 提示语(触发完整订单抽取链)。
|
||||
*/
|
||||
export function buildShippingNoticeUploadPrompt(
|
||||
result: Record<string, unknown> | null | undefined,
|
||||
|
||||
@@ -43,13 +43,16 @@ describe('shipping notice order extraction state', () => {
|
||||
expect(resolveShippingOrderExtractionStatus(undefined, 'not_started')).toBe('not_started');
|
||||
});
|
||||
|
||||
it('restores only in-progress and retryable parsing attachments into the input area', () => {
|
||||
it('restores in-progress, retryable, and pending-candidate attachments into the input area', () => {
|
||||
expect(shouldRestoreShippingNoticeIntake('queued')).toBe(true);
|
||||
expect(shouldRestoreShippingNoticeIntake('parsing')).toBe(true);
|
||||
expect(shouldRestoreShippingNoticeIntake('parse_failed')).toBe(true);
|
||||
expect(shouldRestoreShippingNoticeIntake('parsed', 'partially_completed', 2)).toBe(true);
|
||||
|
||||
// Parsed files are already persisted in the user message bubble.
|
||||
// 已完成且没有待审核 Candidate 的文件仅保留在用户消息气泡中。
|
||||
expect(shouldRestoreShippingNoticeIntake('parsed')).toBe(false);
|
||||
expect(shouldRestoreShippingNoticeIntake('parsed', 'partially_completed', 0)).toBe(false);
|
||||
expect(shouldRestoreShippingNoticeIntake('parsed', 'completed', 2)).toBe(false);
|
||||
expect(shouldRestoreShippingNoticeIntake('consumed')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -37,13 +37,23 @@ const ACTIVE_ORDER_EXTRACTION = new Set(['extracting']);
|
||||
/**
|
||||
* 判断服务端 Intake 是否应恢复到输入栏。
|
||||
* AI 触发时机:无;页面刷新或重新打开会话时调用。
|
||||
* 已解析文件已作为用户消息附件固化在对话气泡中,不能再次显示在输入栏;仅恢复仍在处理中的文件和可手动重试的解析失败文件。
|
||||
* @param parseStatus - 服务端返回的预解析状态
|
||||
* 已解析文件已作为用户消息附件固化在对话气泡中,不能再次显示在输入栏;但存在待审核
|
||||
* Candidate 的部分完成 Intake 必须恢复,否则用户无法补充字段并继续建单。
|
||||
* @param parseStatus - 服务端返回的预解析状态。
|
||||
* @param orderExtractionStatus - 服务端返回的订单抽取状态。
|
||||
* @param candidateCount - 当前仍可审核的订单 Candidate 数量。
|
||||
* @returns 是否恢复为待发送附件卡片
|
||||
*/
|
||||
export function shouldRestoreShippingNoticeIntake(parseStatus: string | null | undefined): boolean {
|
||||
export function shouldRestoreShippingNoticeIntake(
|
||||
parseStatus: string | null | undefined,
|
||||
orderExtractionStatus?: string | null,
|
||||
candidateCount = 0,
|
||||
): boolean {
|
||||
const status = String(parseStatus || '').trim().toLowerCase();
|
||||
return ACTIVE_PARSE.has(status) || status === 'parse_failed';
|
||||
const extractionStatus = String(orderExtractionStatus || '').trim().toLowerCase();
|
||||
return ACTIVE_PARSE.has(status)
|
||||
|| status === 'parse_failed'
|
||||
|| (extractionStatus === 'partially_completed' && candidateCount > 0);
|
||||
}
|
||||
|
||||
/** 判断 Intake 是否仍需轮询上传预处理或订单抽取状态。 */
|
||||
@@ -437,7 +447,11 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
const restoreForConversation = async (conversationId?: string | null) => {
|
||||
const { items } = await listActiveShippingNoticeIntakes(conversationId);
|
||||
const restored: ShippingNoticePendingAttachment[] = items
|
||||
.filter((item) => shouldRestoreShippingNoticeIntake(item.parse_status))
|
||||
.filter((item) => shouldRestoreShippingNoticeIntake(
|
||||
item.parse_status,
|
||||
item.order_extraction_status,
|
||||
item.candidates?.length || 0,
|
||||
))
|
||||
.map((item) => ({
|
||||
id: `restored_${item.intake_no}`,
|
||||
kind: 'shipping_notice' as const,
|
||||
|
||||
@@ -81,6 +81,16 @@ export interface ShippingTaskSummary {
|
||||
upload_attempt?: number | null;
|
||||
pending_human_reason?: string | null;
|
||||
error_message?: string | null;
|
||||
lifecycle_status?: 'active' | 'voided' | 'archived' | string;
|
||||
deleted_at?: string | null;
|
||||
voided_at?: string | null;
|
||||
void_reason?: string | null;
|
||||
archived_at?: string | null;
|
||||
disposition_capabilities?: Partial<Record<'delete' | 'void' | 'archive' | 'restore', {
|
||||
allowed: boolean;
|
||||
code?: string | null;
|
||||
reason?: string | null;
|
||||
}>>;
|
||||
conversation_id?: string | null;
|
||||
export_file_name?: string | null;
|
||||
freight_ref_no?: string | null;
|
||||
@@ -239,6 +249,26 @@ export interface ShippingFieldAdjudication {
|
||||
conflicts?: Array<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
/** 工作台任务列表的数据库分页响应;items 仅包含当前页。 */
|
||||
export interface ShippingTaskPage {
|
||||
items: ShippingTaskSummary[];
|
||||
page: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ShippingTaskDispositionResult {
|
||||
task_no: string;
|
||||
status: 'deleted' | 'voided_and_deleted' | 'archived' | 'restored' | 'blocked' | string;
|
||||
code?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface ShippingTaskBatchDispositionResponse {
|
||||
results: ShippingTaskDispositionResult[];
|
||||
requested_count: number;
|
||||
}
|
||||
|
||||
export interface ShippingOrderCustomerMatchCandidate {
|
||||
customer_id: number;
|
||||
standard_name: string;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { BusinessError, requestJson, resolveLocalizedErrorMessage } from '@/shared/api/client';
|
||||
import type {
|
||||
ShippingCustomerIdentifier,
|
||||
ShippingCustomerImportBatch,
|
||||
ShippingCustomerLifecycleImpact,
|
||||
ShippingCustomerLifecycleTimeline,
|
||||
@@ -21,7 +20,9 @@ import type {
|
||||
ShippingCustomerRow,
|
||||
ShippingCustomerShadowItem,
|
||||
ShippingCustomerShadowReport,
|
||||
ShippingIdentifierFormState,
|
||||
ShippingIdentityEvidence,
|
||||
ShippingIdentityEvidenceFormState,
|
||||
ShippingPublishedEvidenceDefinitions,
|
||||
} from '../types/customer-master.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
@@ -89,13 +90,33 @@ export const deactivateShippingCustomer = (id: number, reason: string) =>
|
||||
method: 'POST', ...jsonAuth(), body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
export const createShippingCustomerIdentifier = (customerId: number, payload: ShippingIdentifierFormState) =>
|
||||
requestJson<ShippingCustomerIdentifier>(`/api/admin/shipping-customers/${customerId}/identifiers`, {
|
||||
method: 'POST', ...jsonAuth(), body: JSON.stringify(payload),
|
||||
});
|
||||
/** 读取当前已发布规则集中可由客户主数据维护的兼容证据定义。 */
|
||||
export const getShippingPublishedEvidenceDefinitions = (targetType: 'customer' | 'site') =>
|
||||
requestJson<ShippingPublishedEvidenceDefinitions>(
|
||||
`/api/admin/shipping-identity-rules/published-evidence-definitions?target_type=${targetType}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
export const updateShippingCustomerIdentifier = (identifierId: number, payload: Record<string, unknown>) =>
|
||||
requestJson<ShippingCustomerIdentifier>(`/api/admin/shipping-customer-identifiers/${identifierId}`, {
|
||||
/** 为客户主体或送货站点新建配置化识别证据。 */
|
||||
export const createShippingIdentityEvidence = (form: ShippingIdentityEvidenceFormState) => {
|
||||
const targetId = form.target_id;
|
||||
const path = form.target_type === 'customer'
|
||||
? `/api/admin/shipping-customers/${targetId}/identity-evidences`
|
||||
: `/api/admin/shipping-customer-sites/${targetId}/identity-evidences`;
|
||||
return requestJson<ShippingIdentityEvidence>(path, {
|
||||
method: 'POST', ...jsonAuth(), body: JSON.stringify({
|
||||
definition_id: form.definition_id,
|
||||
raw_value: form.raw_value,
|
||||
status: form.status,
|
||||
auto_match_allowed: form.auto_match_allowed,
|
||||
remark: form.remark,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
/** 审核、停用或调整配置化证据授权;服务端要求高风险变更理由。 */
|
||||
export const updateShippingIdentityEvidence = (evidenceId: number, payload: Record<string, unknown>) =>
|
||||
requestJson<ShippingIdentityEvidence>(`/api/admin/shipping-identity-evidences/${evidenceId}`, {
|
||||
method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ onMounted(() => { void Promise.all([admin.loadCustomers(), admin.loadShadowRepor
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.name') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.shortCode') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.status') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.identifiers') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.identityEvidences') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.cases') }}</th>
|
||||
<th class="px-5 py-4 text-right">{{ t('admin.shippingCustomers.headers.actions') }}</th>
|
||||
</tr></thead>
|
||||
@@ -67,7 +67,7 @@ onMounted(() => { void Promise.all([admin.loadCustomers(), admin.loadShadowRepor
|
||||
<td class="px-5 py-4"><div class="font-medium text-primary">{{ customer.standard_name }}</div><div v-if="customer.remark" class="text-xs text-muted truncate max-w-sm">{{ customer.remark }}</div></td>
|
||||
<td class="px-5 py-4 font-mono text-sm">{{ customer.short_code }}</td>
|
||||
<td class="px-5 py-4"><span class="text-sm" :class="customer.status === 'active' ? 'text-emerald-600' : 'text-muted'">{{ t(`admin.shippingCustomers.status.${customer.status}`) }}</span></td>
|
||||
<td class="px-5 py-4 text-sm">{{ customer.identifier_count }}</td>
|
||||
<td class="px-5 py-4 text-sm">{{ customer.identity_evidence_count || 0 }}</td>
|
||||
<td class="px-5 py-4 text-sm">{{ customer.case_count }}</td>
|
||||
<td class="px-5 py-4"><div class="flex justify-end gap-1">
|
||||
<button type="button" class="p-2 text-indigo-600 hover:bg-indigo-50 rounded-lg" :title="t('admin.shippingCustomers.identifiers.title')" @click="admin.openIdentifiers(customer)"><Fingerprint class="w-4 h-4" /></button>
|
||||
@@ -87,7 +87,7 @@ onMounted(() => { void Promise.all([admin.loadCustomers(), admin.loadShadowRepor
|
||||
<CustomerShadowQualityPanel :report="admin.shadowReport.value" :customers="admin.importTargetCustomers.value.length ? admin.importTargetCustomers.value : admin.customers.value" :loading="admin.isShadowLoading.value" @refresh="admin.loadShadowReport" @label="admin.labelShadowResolution" />
|
||||
|
||||
<CustomerFormModal :visible="admin.showCustomerModal.value" :form="admin.customerForm.value" :is-saving="admin.isSaving.value" @close="admin.closeCustomerModal" @save="admin.saveCustomer" />
|
||||
<CustomerIdentifiersPanel :visible="admin.showIdentifiersPanel.value" :customer="admin.selectedCustomer.value" :is-saving="admin.isSaving.value" @close="admin.showIdentifiersPanel.value = false" @add="admin.addIdentifier" @update="admin.updateIdentifier" @add-external-ref="admin.addExternalRef" @add-site="admin.addSite" />
|
||||
<CustomerIdentifiersPanel :visible="admin.showIdentifiersPanel.value" :customer="admin.selectedCustomer.value" :published-definitions="admin.publishedEvidenceDefinitions.value" :is-saving="admin.isSaving.value" @close="admin.showIdentifiersPanel.value = false" @add-evidence="admin.addIdentityEvidence" @update-evidence="admin.updateIdentityEvidence" @add-external-ref="admin.addExternalRef" @add-site="admin.addSite" />
|
||||
<CustomerImportDialog :visible="admin.showImportDialog.value" :batch="admin.importBatch.value" :customers="admin.importTargetCustomers.value" :is-importing="admin.isImporting.value" @close="admin.showImportDialog.value = false" @upload="admin.uploadImport" @decide="admin.decideImportRow" @publish="admin.publishImport" @template="admin.downloadTemplate" @reconciliation="admin.downloadReconciliation" />
|
||||
<CustomerDeleteDialog :visible="admin.showDeleteDialog.value" :customer="admin.deleteCustomer.value" :impact="admin.deleteImpact.value" :is-saving="admin.isSaving.value" @close="admin.closeDeleteCustomer" @confirm="admin.confirmDeleteCustomer" />
|
||||
<CustomerLifecyclePanel :visible="admin.showLifecyclePanel.value" :customer="admin.lifecycleCustomer.value" :timeline="admin.lifecycleTimeline.value" @close="admin.closeLifecycleTimeline" />
|
||||
|
||||
+69
-77
@@ -1,51 +1,82 @@
|
||||
<!--
|
||||
features/shipping-notice/customers/components/CustomerIdentifiersPanel.vue
|
||||
用途:展示、新增、审核和停用客户识别证据。
|
||||
用途:维护客户主体和送货站点的全配置识别证据。
|
||||
依赖:customer-master.types、vue-i18n。
|
||||
逻辑:所有修改通过事件上送 composable;本组件不直接访问 API。
|
||||
逻辑:定义目录由服务端按已发布规则集提供;组件不维护类型枚举,也不直接调用 API。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingCustomerRow,
|
||||
ShippingIdentifierFormState,
|
||||
ShippingIdentityEvidenceFormState,
|
||||
ShippingPublishedEvidenceDefinitions,
|
||||
} from '@/features/shipping-notice/types/customer-master.types';
|
||||
import { createEmptyShippingIdentifierForm } from '@/features/shipping-notice/types/customer-master.types';
|
||||
import { createEmptyShippingIdentityEvidenceForm } from '@/features/shipping-notice/types/customer-master.types';
|
||||
|
||||
const props = defineProps<{ visible: boolean; customer: ShippingCustomerRow | null; isSaving: boolean }>();
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
customer: ShippingCustomerRow | null;
|
||||
publishedDefinitions: ShippingPublishedEvidenceDefinitions | null;
|
||||
isSaving: boolean;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
add: [form: ShippingIdentifierFormState];
|
||||
update: [id: number, payload: Record<string, unknown>];
|
||||
addEvidence: [form: ShippingIdentityEvidenceFormState];
|
||||
updateEvidence: [id: number, payload: Record<string, unknown>];
|
||||
addExternalRef: [payload: { source_system: string; customer_code: string }];
|
||||
addSite: [payload: { site_name: string; site_code: string; address?: string; city?: string; country?: string; remark?: string }];
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
const form = ref(createEmptyShippingIdentifierForm());
|
||||
const form = ref(createEmptyShippingIdentityEvidenceForm());
|
||||
const externalRefForm = ref({ source_system: '', customer_code: '' });
|
||||
const siteForm = ref({ site_name: '', site_code: '', address: '', city: '', country: '', remark: '' });
|
||||
|
||||
/** 切换客户或关闭面板时清空未提交证据。 */
|
||||
const currentDefinitions = computed(() => (props.publishedDefinitions?.definitions || []).filter(
|
||||
(item) => item.target_type === form.value.target_type,
|
||||
));
|
||||
const selectedDefinition = computed(() => currentDefinitions.value.find(
|
||||
(item) => item.id === form.value.definition_id,
|
||||
));
|
||||
const selectedSite = computed(() => (props.customer?.sites || []).find((item) => item.id === form.value.target_id));
|
||||
const targetReady = computed(() => form.value.target_type === 'customer'
|
||||
? Boolean(props.customer?.id)
|
||||
: Boolean(selectedSite.value));
|
||||
|
||||
/** 切换客户、可见性或目标对象时清空未提交的证据草稿。 */
|
||||
watch(() => [props.visible, props.customer?.id], () => {
|
||||
form.value = createEmptyShippingIdentifierForm();
|
||||
form.value = { ...createEmptyShippingIdentityEvidenceForm(), target_id: props.customer?.id };
|
||||
externalRefForm.value = { source_system: '', customer_code: '' };
|
||||
siteForm.value = { site_name: '', site_code: '', address: '', city: '', country: '', remark: '' };
|
||||
});
|
||||
|
||||
/** 提交证据后重置表单,实际保存由父级处理。 */
|
||||
const submit = (): void => {
|
||||
emit('add', { ...form.value });
|
||||
form.value = createEmptyShippingIdentifierForm();
|
||||
/** 目标切换时限定定义目录,避免将客户定义提交给站点或反向提交。 */
|
||||
watch(() => form.value.target_type, (targetType) => {
|
||||
form.value.definition_id = '';
|
||||
form.value.target_id = targetType === 'customer' ? props.customer?.id : undefined;
|
||||
form.value.auto_match_allowed = false;
|
||||
});
|
||||
|
||||
/** 所选定义不允许自动化时立即清除授权,后端仍会二次校验。 */
|
||||
watch(selectedDefinition, (definition) => {
|
||||
if (definition?.max_automation !== 'conditional') form.value.auto_match_allowed = false;
|
||||
});
|
||||
|
||||
/** 提交配置化证据;目标 ID 与定义均由当前表单明确携带。 */
|
||||
const submitEvidence = (): void => {
|
||||
emit('addEvidence', { ...form.value, raw_value: form.value.raw_value.trim(), remark: form.value.remark.trim() });
|
||||
form.value.raw_value = '';
|
||||
form.value.remark = '';
|
||||
form.value.auto_match_allowed = false;
|
||||
};
|
||||
|
||||
/** 提交来源系统客户编码;客户简称仍由客户基本信息统一维护。 */
|
||||
/** 提交来源系统客户编码;该语义有独立主数据模型,不能伪装成普通证据值。 */
|
||||
const submitExternalRef = (): void => {
|
||||
emit('addExternalRef', { ...externalRefForm.value });
|
||||
externalRefForm.value = { source_system: '', customer_code: '' };
|
||||
};
|
||||
|
||||
/** 提交送货站点;站点用于 Ship-to 匹配,不创建新的账款客户。 */
|
||||
/** 提交送货站点;站点证据需在站点创建完成后选择对应站点维护。 */
|
||||
const submitSite = (): void => {
|
||||
emit('addSite', { ...siteForm.value });
|
||||
siteForm.value = { site_name: '', site_code: '', address: '', city: '', country: '', remark: '' };
|
||||
@@ -56,10 +87,7 @@ const submitSite = (): void => {
|
||||
<div v-if="visible && customer" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-5xl max-h-[92vh] scale-100">
|
||||
<div class="px-6 py-5 border-b border-subtle flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="section-title">{{ t('admin.shippingCustomers.identifiers.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ customer.standard_name }} · {{ customer.short_code }}</p>
|
||||
</div>
|
||||
<div><h3 class="section-title">{{ t('admin.shippingCustomers.identifiers.title') }}</h3><p class="section-desc mt-1">{{ customer.standard_name }} · {{ customer.short_code }}</p></div>
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.close') }}</button>
|
||||
</div>
|
||||
<div class="px-6 py-5 overflow-y-auto space-y-6">
|
||||
@@ -67,71 +95,35 @@ const submitSite = (): void => {
|
||||
<div><h4 class="font-semibold text-primary">{{ t('admin.shippingCustomers.externalRefs.title') }}</h4><p class="text-xs text-muted mt-1">{{ t('admin.shippingCustomers.externalRefs.hint') }}</p></div>
|
||||
<div v-if="customer.external_refs?.length" class="flex flex-wrap gap-2"><span v-for="item in customer.external_refs" :key="item.id" class="badge">{{ item.source_system }} · {{ item.customer_code }}</span></div>
|
||||
<p v-else class="text-sm text-muted">{{ t('admin.shippingCustomers.externalRefs.empty') }}</p>
|
||||
<div class="grid grid-cols-1 md:grid-cols-[1fr_1fr_auto] gap-3">
|
||||
<input v-model="externalRefForm.source_system" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.externalRefs.sourceSystem')" />
|
||||
<input v-model="externalRefForm.customer_code" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.externalRefs.customerCode')" />
|
||||
<button type="button" class="btn-primary" :disabled="isSaving || !externalRefForm.source_system.trim() || !externalRefForm.customer_code.trim()" @click="submitExternalRef">{{ t('admin.add') }}</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-[1fr_1fr_auto] gap-3"><input v-model="externalRefForm.source_system" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.externalRefs.sourceSystem')"><input v-model="externalRefForm.customer_code" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.externalRefs.customerCode')"><button type="button" class="btn-primary" :disabled="isSaving || !externalRefForm.source_system.trim() || !externalRefForm.customer_code.trim()" @click="submitExternalRef">{{ t('admin.add') }}</button></div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-xl border border-default p-4 space-y-4">
|
||||
<div><h4 class="font-semibold text-primary">{{ t('admin.shippingCustomers.sites.title') }}</h4><p class="text-xs text-muted mt-1">{{ t('admin.shippingCustomers.sites.hint') }}</p></div>
|
||||
<div v-if="customer.sites?.length" class="grid gap-2"><div v-for="site in customer.sites" :key="site.id" class="rounded-lg bg-surface-soft p-3"><div class="font-medium text-primary">{{ site.site_name }} · {{ site.site_code }}</div><div class="text-xs text-muted mt-1">{{ [site.address, site.city, site.country].filter(Boolean).join(' · ') || '-' }}</div></div></div>
|
||||
<div v-if="customer.sites?.length" class="grid gap-2"><div v-for="site in customer.sites" :key="site.id" class="rounded-lg bg-surface-soft p-3"><div class="font-medium text-primary">{{ site.site_name }} · {{ site.site_code }}</div><div class="text-xs text-muted mt-1">{{ [site.address, site.city, site.country].filter(Boolean).join(' · ') || '-' }}</div><div v-if="site.identity_evidences?.length" class="mt-2 space-y-1 text-xs text-muted"><div>{{ t('admin.shippingCustomers.identifiers.siteEvidenceCount', { count: site.identity_evidences.length }) }}</div><div v-for="evidence in site.identity_evidences" :key="evidence.id" class="flex items-center justify-between gap-2"><span>{{ evidence.definition?.display_name || evidence.definition?.definition_code || evidence.definition_id }} · {{ evidence.raw_value }}</span><span class="flex gap-2"><button v-if="evidence.status !== 'approved'" type="button" class="btn-ghost text-xs" @click="emit('updateEvidence', evidence.id, { status: 'approved' })">{{ t('admin.shippingCustomers.identifiers.approve') }}</button><button v-if="evidence.status === 'approved' && !evidence.auto_match_allowed && evidence.definition?.max_automation === 'conditional'" type="button" class="btn-ghost text-xs" @click="emit('updateEvidence', evidence.id, { auto_match_allowed: true })">{{ t('admin.shippingCustomers.identifiers.enableAuto') }}</button><button v-if="evidence.status !== 'disabled'" type="button" class="btn-ghost text-xs text-red-600" @click="emit('updateEvidence', evidence.id, { status: 'disabled' })">{{ t('admin.shippingCustomers.identifiers.disable') }}</button></span></div></div></div></div>
|
||||
<p v-else class="text-sm text-muted">{{ t('admin.shippingCustomers.sites.empty') }}</p>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<input v-model="siteForm.site_name" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.siteName')" />
|
||||
<input v-model="siteForm.site_code" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.siteCode')" />
|
||||
<input v-model="siteForm.address" class="input-field text-sm md:col-span-2" :placeholder="t('admin.shippingCustomers.sites.address')" />
|
||||
<input v-model="siteForm.city" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.city')" />
|
||||
<input v-model="siteForm.country" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.country')" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3"><input v-model="siteForm.site_name" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.siteName')"><input v-model="siteForm.site_code" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.siteCode')"><input v-model="siteForm.address" class="input-field text-sm md:col-span-2" :placeholder="t('admin.shippingCustomers.sites.address')"><input v-model="siteForm.city" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.city')"><input v-model="siteForm.country" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.sites.country')"></div>
|
||||
<div class="flex justify-end"><button type="button" class="btn-primary" :disabled="isSaving || !siteForm.site_name.trim() || !siteForm.site_code.trim()" @click="submitSite">{{ t('admin.add') }}</button></div>
|
||||
</section>
|
||||
|
||||
<div class="rounded-xl border border-default overflow-x-auto">
|
||||
<table class="admin-table min-w-[780px]">
|
||||
<thead><tr>
|
||||
<th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.type') }}</th>
|
||||
<th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.value') }}</th>
|
||||
<th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.status') }}</th>
|
||||
<th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.autoMatch') }}</th>
|
||||
<th class="px-4 py-3 text-right">{{ t('admin.shippingCustomers.headers.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-if="!customer.identifiers?.length">
|
||||
<td colspan="5" class="admin-table-empty px-4">{{ t('admin.shippingCustomers.identifiers.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="item in customer.identifiers" :key="item.id">
|
||||
<td class="px-4 py-3 text-sm">{{ t(`admin.shippingCustomers.identifierTypes.${item.identifier_type}`) }}</td>
|
||||
<td class="px-4 py-3 text-sm"><div>{{ item.raw_value }}</div><div class="text-xs text-muted">{{ item.normalized_value }}</div></td>
|
||||
<td class="px-4 py-3 text-sm">{{ t(`admin.shippingCustomers.identifierStatus.${item.status}`) }}</td>
|
||||
<td class="px-4 py-3 text-sm">{{ item.auto_match_allowed ? t('admin.shippingCustomers.yes') : t('admin.shippingCustomers.no') }}</td>
|
||||
<td class="px-4 py-3"><div class="flex justify-end gap-2">
|
||||
<button v-if="item.status !== 'approved'" type="button" class="btn-ghost text-xs" @click="emit('update', item.id, { status: 'approved' })">{{ t('admin.shippingCustomers.identifiers.approve') }}</button>
|
||||
<button v-if="item.status === 'approved' && !item.auto_match_allowed" type="button" class="btn-ghost text-xs" @click="emit('update', item.id, { auto_match_allowed: true })">{{ t('admin.shippingCustomers.identifiers.enableAuto') }}</button>
|
||||
<button v-if="item.status !== 'disabled'" type="button" class="btn-ghost text-xs text-red-600" @click="emit('update', item.id, { status: 'disabled' })">{{ t('admin.shippingCustomers.identifiers.disable') }}</button>
|
||||
</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="rounded-xl border border-default p-4 space-y-4">
|
||||
<h4 class="font-semibold text-primary">{{ t('admin.shippingCustomers.identifiers.add') }}</h4>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<select v-model="form.identifier_type" class="input-field text-sm">
|
||||
<option v-for="kind in ['name_alias','email','domain','template_fingerprint','address','contact']" :key="kind" :value="kind">{{ t(`admin.shippingCustomers.identifierTypes.${kind}`) }}</option>
|
||||
</select>
|
||||
<input v-model="form.identifier_value" class="input-field text-sm md:col-span-2" :placeholder="t('admin.shippingCustomers.identifiers.valuePlaceholder')" />
|
||||
<select v-model="form.status" class="input-field text-sm">
|
||||
<option value="pending">{{ t('admin.shippingCustomers.identifierStatus.pending') }}</option>
|
||||
<option value="approved">{{ t('admin.shippingCustomers.identifierStatus.approved') }}</option>
|
||||
</select>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary"><input v-model="form.auto_match_allowed" type="checkbox" :disabled="form.status !== 'approved'" />{{ t('admin.shippingCustomers.identifiers.allowAuto') }}</label>
|
||||
<input v-model="form.remark" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.fields.remark')" />
|
||||
<section class="rounded-xl border border-default p-4 space-y-4">
|
||||
<div><h4 class="font-semibold text-primary">{{ t('admin.shippingCustomers.identifiers.add') }}</h4><p class="text-xs text-muted mt-1">{{ t('admin.shippingCustomers.identifiers.definitionHint') }}</p></div>
|
||||
<p v-if="publishedDefinitions?.disabled_reason" class="text-sm text-amber-700">{{ t('admin.shippingCustomers.identifiers.publishedRuleRequired') }}</p>
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<select v-model="form.target_type" class="input-field text-sm"><option value="customer">{{ t('admin.shippingCustomers.identifiers.targets.customer') }}</option><option value="site">{{ t('admin.shippingCustomers.identifiers.targets.site') }}</option></select>
|
||||
<select v-if="form.target_type === 'site'" v-model.number="form.target_id" class="input-field text-sm"><option :value="undefined">{{ t('admin.shippingCustomers.identifiers.selectSite') }}</option><option v-for="site in customer.sites || []" :key="site.id" :value="site.id">{{ site.site_name }} · {{ site.site_code }}</option></select><div v-else class="input-field text-sm bg-surface-soft">{{ customer.standard_name }}</div>
|
||||
<select v-model="form.definition_id" class="input-field text-sm"><option value="">{{ t('admin.shippingCustomers.identifiers.selectDefinition') }}</option><option v-for="definition in currentDefinitions" :key="definition.id" :value="definition.id">{{ definition.display_name }}</option></select>
|
||||
<input v-model="form.raw_value" class="input-field text-sm md:col-span-2" :placeholder="t('admin.shippingCustomers.identifiers.valuePlaceholder')">
|
||||
<select v-model="form.status" class="input-field text-sm"><option value="pending">{{ t('admin.shippingCustomers.identifierStatus.pending') }}</option><option value="approved">{{ t('admin.shippingCustomers.identifierStatus.approved') }}</option></select>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary"><input v-model="form.auto_match_allowed" type="checkbox" :disabled="form.status !== 'approved' || selectedDefinition?.max_automation !== 'conditional'">{{ t('admin.shippingCustomers.identifiers.allowAuto') }}</label>
|
||||
<input v-model="form.remark" class="input-field text-sm" :placeholder="t('admin.shippingCustomers.fields.remark')">
|
||||
</div>
|
||||
<div class="flex justify-end"><button type="button" class="btn-primary" :disabled="isSaving" @click="submit">{{ t('admin.add') }}</button></div>
|
||||
</div>
|
||||
<p v-if="selectedDefinition && selectedDefinition.max_automation === 'none'" class="text-xs text-muted">{{ t('admin.shippingCustomers.identifiers.manualOnly') }}</p>
|
||||
<div class="flex justify-end"><button type="button" class="btn-primary" :disabled="isSaving || Boolean(publishedDefinitions?.disabled_reason) || !targetReady || !form.definition_id || !form.raw_value.trim()" @click="submitEvidence">{{ t('admin.add') }}</button></div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-xl border border-default overflow-x-auto"><table class="admin-table min-w-[780px]"><thead><tr><th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.definition') }}</th><th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.value') }}</th><th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.status') }}</th><th class="px-4 py-3 text-left">{{ t('admin.shippingCustomers.identifiers.autoMatch') }}</th><th class="px-4 py-3 text-right">{{ t('admin.shippingCustomers.headers.actions') }}</th></tr></thead><tbody><tr v-if="!customer.identity_evidences?.length"><td colspan="5" class="admin-table-empty px-4">{{ t('admin.shippingCustomers.identifiers.empty') }}</td></tr><tr v-for="item in customer.identity_evidences" :key="item.id"><td class="px-4 py-3 text-sm"><div>{{ item.definition?.display_name || item.definition?.definition_code || item.definition_id }}</div><div class="text-xs text-muted">{{ item.definition?.evidence_label }}</div></td><td class="px-4 py-3 text-sm"><div>{{ item.raw_value }}</div><div class="text-xs text-muted">{{ item.normalized_value }}</div></td><td class="px-4 py-3 text-sm">{{ t(`admin.shippingCustomers.identifierStatus.${item.status}`) }}</td><td class="px-4 py-3 text-sm">{{ item.auto_match_allowed ? t('admin.shippingCustomers.yes') : t('admin.shippingCustomers.no') }}</td><td class="px-4 py-3"><div class="flex justify-end gap-2"><button v-if="item.status !== 'approved'" type="button" class="btn-ghost text-xs" @click="emit('updateEvidence', item.id, { status: 'approved' })">{{ t('admin.shippingCustomers.identifiers.approve') }}</button><button v-if="item.status === 'approved' && !item.auto_match_allowed && item.definition?.max_automation === 'conditional'" type="button" class="btn-ghost text-xs" @click="emit('updateEvidence', item.id, { auto_match_allowed: true })">{{ t('admin.shippingCustomers.identifiers.enableAuto') }}</button><button v-if="item.status !== 'disabled'" type="button" class="btn-ghost text-xs text-red-600" @click="emit('updateEvidence', item.id, { status: 'disabled' })">{{ t('admin.shippingCustomers.identifiers.disable') }}</button></div></td></tr></tbody></table></section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+19
-12
@@ -10,7 +10,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
createShippingCustomer,
|
||||
createShippingCustomerExternalRef,
|
||||
createShippingCustomerIdentifier,
|
||||
createShippingIdentityEvidence,
|
||||
createShippingCustomerSite,
|
||||
deleteShippingCustomer,
|
||||
deactivateShippingCustomer,
|
||||
@@ -27,7 +27,8 @@ import {
|
||||
mergeShippingCustomer,
|
||||
publishShippingCustomerImport,
|
||||
updateShippingCustomer,
|
||||
updateShippingCustomerIdentifier,
|
||||
getShippingPublishedEvidenceDefinitions,
|
||||
updateShippingIdentityEvidence,
|
||||
uploadShippingCustomerImport,
|
||||
} from '@/features/shipping-notice/api/customer-master.api';
|
||||
import type {
|
||||
@@ -39,7 +40,8 @@ import type {
|
||||
ShippingCustomerImportRow,
|
||||
ShippingCustomerRow,
|
||||
ShippingCustomerShadowReport,
|
||||
ShippingIdentifierFormState,
|
||||
ShippingIdentityEvidenceFormState,
|
||||
ShippingPublishedEvidenceDefinitions,
|
||||
} from '@/features/shipping-notice/types/customer-master.types';
|
||||
import {
|
||||
createEmptyShippingCustomerForm,
|
||||
@@ -54,6 +56,7 @@ export function useShippingCustomersAdmin() {
|
||||
const customers = ref<ShippingCustomerRow[]>([]);
|
||||
const importTargetCustomers = ref<ShippingCustomerRow[]>([]);
|
||||
const selectedCustomer = ref<ShippingCustomerRow | null>(null);
|
||||
const publishedEvidenceDefinitions = ref<ShippingPublishedEvidenceDefinitions | null>(null);
|
||||
const customerForm = ref<ShippingCustomerFormState>(createEmptyShippingCustomerForm());
|
||||
const importBatch = ref<ShippingCustomerImportBatch | null>(null);
|
||||
const shadowReport = ref<ShippingCustomerShadowReport | null>(null);
|
||||
@@ -311,7 +314,11 @@ export function useShippingCustomersAdmin() {
|
||||
/** 拉取客户详情并打开识别证据面板。 */
|
||||
const openIdentifiers = async (customer: ShippingCustomerRow): Promise<void> => {
|
||||
try {
|
||||
selectedCustomer.value = await getShippingCustomer(customer.id);
|
||||
const [detail, definitions] = await Promise.all([
|
||||
getShippingCustomer(customer.id), getShippingPublishedEvidenceDefinitions('customer'),
|
||||
]);
|
||||
selectedCustomer.value = detail;
|
||||
publishedEvidenceDefinitions.value = definitions;
|
||||
showIdentifiersPanel.value = true;
|
||||
} catch (error) {
|
||||
showError(error, 'admin.shippingCustomers.msg.loadFailed');
|
||||
@@ -319,17 +326,17 @@ export function useShippingCustomersAdmin() {
|
||||
};
|
||||
|
||||
/** 新增识别证据后刷新当前客户详情和列表计数。 */
|
||||
const addIdentifier = async (form: ShippingIdentifierFormState): Promise<void> => {
|
||||
const addIdentityEvidence = async (form: ShippingIdentityEvidenceFormState): Promise<void> => {
|
||||
if (!selectedCustomer.value) return;
|
||||
if (!form.identifier_value.trim()) {
|
||||
if (!form.definition_id || !form.raw_value.trim() || !form.target_id) {
|
||||
msg.warning(t('admin.shippingCustomers.msg.identifierRequired'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await createShippingCustomerIdentifier(selectedCustomer.value.id, {
|
||||
await createShippingIdentityEvidence({
|
||||
...form,
|
||||
identifier_value: form.identifier_value.trim(),
|
||||
raw_value: form.raw_value.trim(),
|
||||
remark: form.remark.trim(),
|
||||
});
|
||||
selectedCustomer.value = await getShippingCustomer(selectedCustomer.value.id);
|
||||
@@ -343,12 +350,12 @@ export function useShippingCustomersAdmin() {
|
||||
};
|
||||
|
||||
/** 更新证据审核状态或自动匹配授权,并刷新详情。 */
|
||||
const updateIdentifier = async (identifierId: number, payload: Record<string, unknown>): Promise<void> => {
|
||||
const updateIdentityEvidence = async (evidenceId: number, payload: Record<string, unknown>): Promise<void> => {
|
||||
if (!selectedCustomer.value) return;
|
||||
try {
|
||||
const reason = window.prompt(t('admin.shippingCustomers.prompts.identifierChangeReason'))?.trim();
|
||||
if (!reason) return;
|
||||
await updateShippingCustomerIdentifier(identifierId, { ...payload, reason });
|
||||
await updateShippingIdentityEvidence(evidenceId, { ...payload, reason });
|
||||
selectedCustomer.value = await getShippingCustomer(selectedCustomer.value.id);
|
||||
} catch (error) {
|
||||
showError(error, 'admin.shippingCustomers.msg.saveFailed');
|
||||
@@ -491,12 +498,12 @@ export function useShippingCustomersAdmin() {
|
||||
};
|
||||
|
||||
return {
|
||||
customers, importTargetCustomers, selectedCustomer, customerForm, importBatch, shadowReport, deleteCustomer, deleteImpact, lifecycleCustomer, lifecycleTimeline, mergeCustomer, mergeImpact,
|
||||
customers, importTargetCustomers, selectedCustomer, publishedEvidenceDefinitions, customerForm, importBatch, shadowReport, deleteCustomer, deleteImpact, lifecycleCustomer, lifecycleTimeline, mergeCustomer, mergeImpact,
|
||||
searchQuery, statusFilter, page, pageSize, total, pages,
|
||||
isLoading, isSaving, isImporting, isShadowLoading,
|
||||
showCustomerModal, showIdentifiersPanel, showImportDialog, showDeleteDialog, showLifecyclePanel, showMergeDialog,
|
||||
loadCustomers, searchCustomers, openCreateCustomer, openEditCustomer, closeCustomerModal,
|
||||
saveCustomer, deactivateCustomer, openLifecycleTimeline, closeLifecycleTimeline, openDeleteCustomer, closeDeleteCustomer, confirmDeleteCustomer, openMergeCustomer, previewMergeCustomer, closeMergeCustomer, confirmMergeCustomer, openIdentifiers, addIdentifier, updateIdentifier, addExternalRef, addSite,
|
||||
saveCustomer, deactivateCustomer, openLifecycleTimeline, closeLifecycleTimeline, openDeleteCustomer, closeDeleteCustomer, confirmDeleteCustomer, openMergeCustomer, previewMergeCustomer, closeMergeCustomer, confirmMergeCustomer, openIdentifiers, addIdentityEvidence, updateIdentityEvidence, addExternalRef, addSite,
|
||||
openImport, uploadImport, decideImportRow, publishImport, downloadTemplate, downloadReconciliation,
|
||||
loadShadowReport, labelShadowResolution,
|
||||
};
|
||||
|
||||
@@ -31,7 +31,9 @@ export interface ShippingCustomerRow {
|
||||
remark?: string | null;
|
||||
case_count: number;
|
||||
identifier_count: number;
|
||||
identity_evidence_count?: number;
|
||||
identifiers?: ShippingCustomerIdentifier[];
|
||||
identity_evidences?: ShippingIdentityEvidence[];
|
||||
external_refs?: ShippingCustomerExternalRef[];
|
||||
sites?: ShippingCustomerSite[];
|
||||
created_at?: string | null;
|
||||
@@ -64,6 +66,42 @@ export interface ShippingCustomerSite {
|
||||
status: string;
|
||||
remark?: string | null;
|
||||
identifiers: Array<Record<string, unknown>>;
|
||||
identity_evidences?: ShippingIdentityEvidence[];
|
||||
}
|
||||
|
||||
export interface ShippingIdentityDefinitionOption {
|
||||
id: string;
|
||||
definition_code: string;
|
||||
display_name: string;
|
||||
description?: string | null;
|
||||
evidence_label: string;
|
||||
target_type: 'customer' | 'site';
|
||||
source_adapter_key: 'email_metadata' | 'document_template' | 'order_field';
|
||||
source_selector: Record<string, unknown>;
|
||||
attribute_key: string;
|
||||
normalizer_key: string;
|
||||
max_automation: 'none' | 'conditional';
|
||||
order_field?: { field_id: string; field_code: string; display_name?: string } | null;
|
||||
}
|
||||
|
||||
export interface ShippingIdentityEvidence {
|
||||
id: number;
|
||||
definition_id: string;
|
||||
definition?: ShippingIdentityDefinitionOption | null;
|
||||
customer_id?: number | null;
|
||||
site_id?: number | null;
|
||||
raw_value: string;
|
||||
normalized_value: string;
|
||||
status: ShippingIdentifierStatus;
|
||||
auto_match_allowed: boolean;
|
||||
remark?: string | null;
|
||||
confirmed_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingPublishedEvidenceDefinitions {
|
||||
rule_set: { id: number; version: number; checksum?: string | null } | null;
|
||||
definitions: ShippingIdentityDefinitionOption[];
|
||||
disabled_reason?: 'published_rule_set_required' | null;
|
||||
}
|
||||
|
||||
export interface ShippingCustomerLifecycleImpact {
|
||||
@@ -84,6 +122,7 @@ export interface ShippingCustomerLifecycleImpact {
|
||||
};
|
||||
cascade: {
|
||||
identifiers: number;
|
||||
identity_evidences: number;
|
||||
sites: number;
|
||||
};
|
||||
}
|
||||
@@ -106,6 +145,8 @@ export interface ShippingCustomerMergeImpact {
|
||||
migrate: {
|
||||
identifiers: number;
|
||||
duplicate_identifiers: number;
|
||||
identity_evidences: number;
|
||||
duplicate_identity_evidences: number;
|
||||
external_references: number;
|
||||
sites: number;
|
||||
};
|
||||
@@ -256,6 +297,16 @@ export interface ShippingIdentifierFormState {
|
||||
remark: string;
|
||||
}
|
||||
|
||||
export interface ShippingIdentityEvidenceFormState {
|
||||
target_type: 'customer' | 'site';
|
||||
target_id?: number;
|
||||
definition_id: string;
|
||||
raw_value: string;
|
||||
status: ShippingIdentifierStatus;
|
||||
auto_match_allowed: boolean;
|
||||
remark: string;
|
||||
}
|
||||
|
||||
/** 创建空客户表单,避免页面和弹窗各自维护默认值。 */
|
||||
export const createEmptyShippingCustomerForm = (): ShippingCustomerFormState => ({
|
||||
standard_name: '',
|
||||
@@ -283,3 +334,13 @@ export const createEmptyShippingIdentifierForm = (): ShippingIdentifierFormState
|
||||
auto_match_allowed: false,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
/** 创建空配置化证据表单;定义下拉必须由当前已发布规则集提供。 */
|
||||
export const createEmptyShippingIdentityEvidenceForm = (): ShippingIdentityEvidenceFormState => ({
|
||||
target_type: 'customer',
|
||||
definition_id: '',
|
||||
raw_value: '',
|
||||
status: 'pending',
|
||||
auto_match_allowed: false,
|
||||
remark: '',
|
||||
});
|
||||
@@ -8,7 +8,8 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, Download, ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { Archive, ArrowLeft, Download, ExternalLink, RefreshCw, RotateCcw, Trash2 } from 'lucide-vue-next';
|
||||
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
|
||||
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
|
||||
import ShippingTaskParsedResultCard from '@/features/chat/components/ShippingTaskParsedResultCard.vue';
|
||||
@@ -16,9 +17,13 @@ import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
getWorkspaceShippingTask,
|
||||
archiveWorkspaceShippingTasks,
|
||||
deleteWorkspaceShippingTasks,
|
||||
downloadWorkspaceShippingExportArchive,
|
||||
listShippingChatAgents,
|
||||
listWorkspaceShippingTasks,
|
||||
purgeWorkspaceShippingTasks,
|
||||
restoreWorkspaceShippingTasks,
|
||||
SHIPPING_NOTICE_AGENT_CODE,
|
||||
workspaceShippingExportUrl,
|
||||
type ShippingCurrentStepProgress,
|
||||
@@ -29,7 +34,6 @@ import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import { sanitizeShippingRuntimeStatusText } from '@/features/chat/shipping/shippingText';
|
||||
import {
|
||||
retainVisibleShippingExportSelection,
|
||||
selectVisibleShippingExports,
|
||||
updateShippingExportSelection,
|
||||
} from '@/features/shipping-notice/utils/exportSelection';
|
||||
@@ -42,16 +46,26 @@ const props = defineProps<{
|
||||
const router = useRouter();
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const authStore = useAuthStore();
|
||||
const isAdmin = computed(() => authStore.isAdmin);
|
||||
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
const selectedTaskNo = ref<string | null>(null);
|
||||
const selectedExportTaskNos = ref<string[]>([]);
|
||||
const selectedTaskNos = ref<string[]>([]);
|
||||
const archiveDownloading = ref(false);
|
||||
const dispositionSubmitting = ref(false);
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
const statusFilter = ref('all');
|
||||
const lifecycleFilter = ref('active');
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
const currentPage = ref(1);
|
||||
const pageSize = 10;
|
||||
const totalTasks = ref(0);
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
|
||||
const pageStart = computed(() => (totalTasks.value === 0 ? 0 : (currentPage.value - 1) * pageSize + 1));
|
||||
const pageEnd = computed(() => Math.min(currentPage.value * pageSize, totalTasks.value));
|
||||
const batchProgressLabel = computed(() => {
|
||||
if (!detail.value?.batch_index || !detail.value?.batch_total) return '';
|
||||
return t('chat.shippingNoticeUi.batchProgress', {
|
||||
@@ -67,6 +81,12 @@ const statusOptions = computed(() => [
|
||||
label: t(`workspace.shippingNotice.status.${labelKey}`),
|
||||
})),
|
||||
]);
|
||||
const lifecycleOptions = computed(() => [
|
||||
{ value: 'active', label: t('workspace.shippingNotice.lifecycle.active') },
|
||||
{ value: 'deleted', label: t('workspace.shippingNotice.lifecycle.deleted') },
|
||||
{ value: 'voided', label: t('workspace.shippingNotice.lifecycle.voided') },
|
||||
{ value: 'archived', label: t('workspace.shippingNotice.lifecycle.archived') },
|
||||
]);
|
||||
|
||||
type ShippingStatusSource = Pick<
|
||||
ShippingTaskSummary,
|
||||
@@ -179,24 +199,47 @@ const hasInventorySourceFields = computed(() => {
|
||||
);
|
||||
});
|
||||
|
||||
const loadCases = async () => {
|
||||
/** 拉取当前筛选条件的一页任务;筛选/刷新时重置页码以避免落入空页。 */
|
||||
const loadCases = async (resetPage = false) => {
|
||||
if (resetPage) currentPage.value = 1;
|
||||
loading.value = true;
|
||||
try {
|
||||
tasks.value = await listWorkspaceShippingTasks({
|
||||
let result = await listWorkspaceShippingTasks({
|
||||
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||
limit: 100,
|
||||
lifecycle_status: lifecycleFilter.value,
|
||||
page: currentPage.value,
|
||||
page_size: pageSize,
|
||||
});
|
||||
selectedExportTaskNos.value = retainVisibleShippingExportSelection(
|
||||
selectedExportTaskNos.value,
|
||||
tasks.value.map((item) => item.task_no),
|
||||
);
|
||||
// 删除当前页最后一条后可能出现空页;回退一页重新查询,避免显示误导性的空结果。
|
||||
if (result.items.length === 0 && result.total > 0 && currentPage.value > 1) {
|
||||
currentPage.value = Math.ceil(result.total / pageSize);
|
||||
result = await listWorkspaceShippingTasks({
|
||||
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||
lifecycle_status: lifecycleFilter.value,
|
||||
page: currentPage.value,
|
||||
page_size: pageSize,
|
||||
});
|
||||
}
|
||||
tasks.value = result.items;
|
||||
totalTasks.value = result.total;
|
||||
selectedTaskNos.value = [];
|
||||
selectedTaskNo.value = null;
|
||||
} catch {
|
||||
tasks.value = [];
|
||||
totalTasks.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 切换分页时清空仅当前页有效的下载选择,防止跨页误下载。 */
|
||||
const changePage = async (page: number) => {
|
||||
const normalized = Math.max(1, Math.min(page, totalPages.value));
|
||||
if (normalized === currentPage.value || loading.value) return;
|
||||
currentPage.value = normalized;
|
||||
await loadCases();
|
||||
};
|
||||
|
||||
const loadDetail = async (taskNo: string) => {
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
@@ -260,25 +303,59 @@ const downloadExportArchive = async (payload: { batch_no?: string; task_nos?: st
|
||||
};
|
||||
|
||||
/** 更新单票勾选;数量门禁与后端 100 票限制一致。 */
|
||||
const toggleExportTask = (taskNo: string, checked: boolean) => {
|
||||
selectedExportTaskNos.value = updateShippingExportSelection(selectedExportTaskNos.value, taskNo, checked);
|
||||
const toggleTask = (taskNo: string, checked: boolean) => {
|
||||
selectedTaskNos.value = updateShippingExportSelection(selectedTaskNos.value, taskNo, checked);
|
||||
};
|
||||
|
||||
/** 全选或清空当前查询结果,不跨筛选条件保留不可见任务。 */
|
||||
const toggleAllVisibleExports = (checked: boolean) => {
|
||||
selectedExportTaskNos.value = checked
|
||||
/** 全选或清空当前页结果,切页后不保留选择。 */
|
||||
const toggleAllVisibleTasks = (checked: boolean) => {
|
||||
selectedTaskNos.value = checked
|
||||
? selectVisibleShippingExports(tasks.value.map((item) => item.task_no))
|
||||
: [];
|
||||
};
|
||||
|
||||
const allVisibleExportsSelected = computed(() => (
|
||||
tasks.value.length > 0 && tasks.value.every((item) => selectedExportTaskNos.value.includes(item.task_no))
|
||||
const allVisibleTasksSelected = computed(() => (
|
||||
tasks.value.length > 0 && tasks.value.every((item) => selectedTaskNos.value.includes(item.task_no))
|
||||
));
|
||||
|
||||
/** 按用户显式选择下载,后端仍逐票执行权限与 Artifact 当前性校验。 */
|
||||
const downloadSelectedExports = async () => {
|
||||
if (!selectedExportTaskNos.value.length) return;
|
||||
await downloadExportArchive({ task_nos: selectedExportTaskNos.value });
|
||||
if (!selectedTaskNos.value.length) return;
|
||||
await downloadExportArchive({ task_nos: selectedTaskNos.value });
|
||||
};
|
||||
|
||||
/** 批量执行回收站、归档或恢复;删除必须显式录入原因,服务端仍逐票重算资格。 */
|
||||
const applyTaskDisposition = async (action: 'delete' | 'archive' | 'restore' | 'purge') => {
|
||||
if (!selectedTaskNos.value.length || dispositionSubmitting.value) return;
|
||||
let reason = '';
|
||||
if (action === 'delete' || action === 'purge') {
|
||||
const promptKey = action === 'purge'
|
||||
? 'workspace.shippingNotice.disposition.purgeReasonPrompt'
|
||||
: 'workspace.shippingNotice.disposition.reasonPrompt';
|
||||
reason = window.prompt(t(promptKey))?.trim() || '';
|
||||
if (!reason) return;
|
||||
}
|
||||
if (!window.confirm(t('workspace.shippingNotice.disposition.confirm', {
|
||||
action: t(`workspace.shippingNotice.disposition.actions.${action}`), count: selectedTaskNos.value.length,
|
||||
}))) return;
|
||||
dispositionSubmitting.value = true;
|
||||
try {
|
||||
const result = action === 'delete'
|
||||
? await deleteWorkspaceShippingTasks(selectedTaskNos.value, reason)
|
||||
: action === 'archive'
|
||||
? await archiveWorkspaceShippingTasks(selectedTaskNos.value)
|
||||
: action === 'restore'
|
||||
? await restoreWorkspaceShippingTasks(selectedTaskNos.value)
|
||||
: await purgeWorkspaceShippingTasks(selectedTaskNos.value, reason);
|
||||
const blocked = result.results.filter((item) => item.status === 'blocked').length;
|
||||
if (blocked) msg.error(t('workspace.shippingNotice.disposition.partial', { success: result.results.length - blocked, blocked }));
|
||||
else msg.success(t('workspace.shippingNotice.disposition.success', { count: result.results.length }));
|
||||
await loadCases();
|
||||
} catch {
|
||||
msg.error(t('workspace.shippingNotice.disposition.failed'));
|
||||
} finally {
|
||||
dispositionSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const shortageLines = computed(() => detail.value?.shortage?.lines || []);
|
||||
@@ -319,7 +396,7 @@ onMounted(async () => {
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="loadCases"
|
||||
@click="loadCases(true)"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.refresh') }}
|
||||
@@ -333,34 +410,80 @@ onMounted(async () => {
|
||||
<option v-for="opt in statusOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.filters.lifecycle') }}</label>
|
||||
<select v-model="lifecycleFilter" class="rounded-xl border border-default bg-surface px-3 py-2 text-sm">
|
||||
<option v-for="opt in lifecycleOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700"
|
||||
@click="loadCases"
|
||||
@click="loadCases(true)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.search') }}
|
||||
</button>
|
||||
<label class="ml-auto inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allVisibleExportsSelected"
|
||||
:checked="allVisibleTasksSelected"
|
||||
:disabled="tasks.length === 0"
|
||||
@change="toggleAllVisibleExports(($event.target as HTMLInputElement).checked)"
|
||||
@change="toggleAllVisibleTasks(($event.target as HTMLInputElement).checked)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.selectAllVisible') }}
|
||||
</label>
|
||||
<span class="text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.selectedCount', { count: selectedExportTaskNos.length }) }}
|
||||
{{ $t('workspace.shippingNotice.selectedCount', { count: selectedTaskNos.length }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="selectedExportTaskNos.length === 0 || archiveDownloading"
|
||||
:disabled="selectedTaskNos.length === 0 || archiveDownloading"
|
||||
@click="downloadSelectedExports"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.downloadSelected') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="lifecycleFilter === 'active'"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="selectedTaskNos.length === 0 || dispositionSubmitting"
|
||||
@click="applyTaskDisposition('archive')"
|
||||
>
|
||||
<Archive class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.disposition.actions.archive') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="lifecycleFilter === 'active'"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-rose-300 px-3 py-2 text-sm font-medium text-rose-700 hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="selectedTaskNos.length === 0 || dispositionSubmitting"
|
||||
@click="applyTaskDisposition('delete')"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.disposition.actions.delete') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="lifecycleFilter === 'deleted'"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="selectedTaskNos.length === 0 || dispositionSubmitting"
|
||||
@click="applyTaskDisposition('restore')"
|
||||
>
|
||||
<RotateCcw class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.disposition.actions.restore') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="lifecycleFilter === 'deleted' && isAdmin"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-rose-300 px-3 py-2 text-sm font-medium text-rose-700 hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="selectedTaskNos.length === 0 || dispositionSubmitting"
|
||||
@click="applyTaskDisposition('purge')"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.disposition.actions.purge') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-5">
|
||||
@@ -381,8 +504,8 @@ onMounted(async () => {
|
||||
type="checkbox"
|
||||
class="mt-1"
|
||||
:aria-label="$t('workspace.shippingNotice.selectForDownload', { taskNo: item.task_no })"
|
||||
:checked="selectedExportTaskNos.includes(item.task_no)"
|
||||
@change="toggleExportTask(item.task_no, ($event.target as HTMLInputElement).checked)"
|
||||
:checked="selectedTaskNos.includes(item.task_no)"
|
||||
@change="toggleTask(item.task_no, ($event.target as HTMLInputElement).checked)"
|
||||
>
|
||||
<button type="button" class="min-w-0 flex-1 text-left" @click="selectedTaskNo = item.task_no">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
@@ -404,6 +527,31 @@ onMounted(async () => {
|
||||
</div>
|
||||
</button>
|
||||
</article>
|
||||
<div
|
||||
v-if="totalTasks > 0"
|
||||
class="flex items-center justify-between gap-2 pt-2 text-sm text-muted"
|
||||
>
|
||||
<span>{{ $t('workspace.shippingNotice.pagination.summary', { start: pageStart, end: pageEnd, total: totalTasks }) }}</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="currentPage <= 1 || loading"
|
||||
@click="changePage(currentPage - 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.previous') }}
|
||||
</button>
|
||||
<span class="whitespace-nowrap">{{ $t('workspace.shippingNotice.pagination.page', { page: currentPage, total: totalPages }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="currentPage >= totalPages || loading"
|
||||
@click="changePage(currentPage + 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-3 rounded-2xl border border-default bg-surface/50 p-5">
|
||||
|
||||
Reference in new issue
Block a user