feat(freight-rpa): 增加出站报表配置与回调支持,重构相关服务
- 将 RPA 管理 API 扩展至出站报表配置,新增出站相关的回调接口。 - 重构 freight_rpa_report_config_service,支持入站与出站报表配置的管理。 - 更新 ORM 模型,增加出站报表相关的持久化模型。 - 统一命名规范,确保在手、入站与出站的概念一致性。
This commit is contained in:
1 parent
39fe3c05f2
commit
911afa0f73
152 files changed
+9861
-2984
No files matched your search
@@ -295,9 +295,9 @@ export const createShippingOnhandStructureAnalysis = (file: File) => {
|
||||
method: 'POST', body: form, ...auth(),
|
||||
});
|
||||
};
|
||||
/** 读取标准异动字段目录(只读领域契约,供收料异动解析规则映射表单)。 */
|
||||
/** 读取标准异动字段目录(只读领域契约,供入站/出站报表规则映射表单)。 */
|
||||
export const fetchMovementFields = () => requestJson<Array<{ code: string; value_type: string; required: boolean; is_identity: boolean }>>(
|
||||
'/api/admin/shipping-notice/movement-fields', auth(),
|
||||
'/api/admin/freight-rpa/movement-fields', auth(),
|
||||
);
|
||||
/** 用已分析的真实栏位创建库存文件解析方案草稿。 */
|
||||
export const createShippingOnhandParsingDraftFromAnalysis = (id: number, payload: Record<string, unknown>) => requestJson<unknown>(
|
||||
@@ -339,13 +339,21 @@ export const saveShippingOnhandSource = (payload: Record<string, unknown>, id?:
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取/保存站点独立入站报表配置(/freight-rpa/sources/<id>/inbound-report-config);严禁通过库存站点保存接口夹带这些字段。 */
|
||||
export const getShippingReceiptReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
export const getInboundReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/inbound-report-config`, auth(),
|
||||
);
|
||||
export const saveShippingReceiptReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
export const saveInboundReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/inbound-report-config`,
|
||||
{ method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取/保存站点独立出站报表配置;载荷键与入站相同,严禁夹带来源站点字段。 */
|
||||
export const getOutboundReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/outbound-report-config`, auth(),
|
||||
);
|
||||
export const saveOutboundReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/outbound-report-config`,
|
||||
{ method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 直接绑定停用库存站点到已发布解析方案;服务端自动写入操作审计。 */
|
||||
export const bindShippingOnhandSourceParsingProfile = (id: number, payload: { parsing_profile_id: number }) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/sources/${id}/bind-parsing-profile`, { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/api/schedule.api.ts
|
||||
* 管理后台定时任务 HTTP API:任务 CRUD、配置、测试执行、运行记录。
|
||||
* 管理后台定时任务 HTTP API:任务 CRUD、配置、测试执行、运行记录、库存/入站/出站 raw-zip。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
@@ -159,8 +159,11 @@ export const adminRunExcelUrl = (runId: number) => `/api/admin/schedule-runs/${r
|
||||
export const adminRunInventoryRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/inventory-raw-zip`;
|
||||
|
||||
export const adminRunReceiptRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/receipt-raw-zip`;
|
||||
export const adminRunInboundRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/inbound-raw-zip`;
|
||||
|
||||
export const adminRunOutboundRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/outbound-raw-zip`;
|
||||
|
||||
export interface RpaWorkerHeartbeatWorker {
|
||||
worker_id?: string;
|
||||
@@ -181,7 +184,7 @@ export interface RpaWorkerHeartbeatWorker {
|
||||
}
|
||||
|
||||
export interface RpaWorkerHeartbeatSummary {
|
||||
scope?: 'onhand' | 'inbound' | string;
|
||||
scope?: 'onhand' | 'inbound' | 'outbound' | string;
|
||||
ready: boolean;
|
||||
message: string;
|
||||
detail_message?: string;
|
||||
@@ -195,7 +198,7 @@ export interface RpaWorkerHeartbeatSummary {
|
||||
workers: RpaWorkerHeartbeatWorker[];
|
||||
}
|
||||
|
||||
export const getAdminRpaWorkersStatus = (scope: 'onhand' | 'inbound' = 'onhand') =>
|
||||
export const getAdminRpaWorkersStatus = (scope: 'onhand' | 'inbound' | 'outbound' = 'onhand') =>
|
||||
getJson<RpaWorkerHeartbeatSummary>(`/api/admin/rpa-workers/status?scope=${encodeURIComponent(scope)}`);
|
||||
|
||||
export type { DifyExecutionSnapshot, ScheduleRun, ScheduleTask, StepLog, TestScheduleRunResult, TestScheduleSqlResult };
|
||||
@@ -1,11 +1,13 @@
|
||||
<!--
|
||||
features/admin/modules/freight-rpa/FreightRpaPage.vue
|
||||
用途:货代库存管理工作台,维护解析方案、连接、站点、模板与运行审计。
|
||||
用途:货代来源站点管理工作台,维护解析方案、连接、站点、入站/出站报表配置、模板与运行审计。
|
||||
依赖:element-plus(抽屉/弹窗/表单控件/标签/空态,沿用管理端 element-trial 主题)、
|
||||
admin.api、Vue Router、Vue Composition API、Vue I18n。
|
||||
admin.api、inboundReportConfigForm、outboundReportConfigForm、parsingProfileListGroups、
|
||||
Vue Router、Vue Composition API、Vue I18n。
|
||||
逻辑:由 AdminLayout 统一业务目录选择工作区;section 深链与当前工作区双向同步。
|
||||
业务脚本保持原逻辑不变;视觉层已迁移 Element Plus(element-trial 主题),
|
||||
间距由 AdminLayout 壳层持有。
|
||||
来源站点详情三块折叠——库存报表|入站报表|出站报表;入站/出站走独立 get/save API。
|
||||
报表规则列表按用途分段(库存→入站→出站),组内按 profile_code / version 排序。
|
||||
视觉层已迁移 Element Plus(element-trial 主题),间距由 AdminLayout 壳层持有。
|
||||
-->
|
||||
<template>
|
||||
<section class="inventory-console">
|
||||
@@ -67,8 +69,33 @@
|
||||
</div>
|
||||
|
||||
<div v-else class="object-list-panel">
|
||||
<div class="object-list">
|
||||
<el-empty v-if="!currentItems.length" class="object-empty" :description="t('admin.freightRpa.emptyConfig')" :image-size="60" />
|
||||
<el-empty v-if="!currentItems.length" class="object-empty" :description="t('admin.freightRpa.emptyConfig')" :image-size="60" />
|
||||
<!-- 报表规则:按用途分段(库存→入站→出站),组内按编号排序 -->
|
||||
<div v-else-if="activeTab === 'parsing'" class="object-groups">
|
||||
<section
|
||||
v-for="group in parsingProfileGroups"
|
||||
:key="group.purpose"
|
||||
class="object-group"
|
||||
:aria-label="parsingPurposeGroupLabel(group.purpose, group.items.length)"
|
||||
>
|
||||
<h3 class="object-group-title">{{ parsingPurposeGroupLabel(group.purpose, group.items.length) }}</h3>
|
||||
<div class="object-list">
|
||||
<button
|
||||
v-for="item in group.items"
|
||||
:key="String(item.id)"
|
||||
type="button"
|
||||
class="object-row"
|
||||
:class="{ selected: selectedId === Number(item.id) }"
|
||||
@click="selectItem(item)"
|
||||
>
|
||||
<span class="row-primary">{{ rowTitle(item) }}</span>
|
||||
<span class="row-secondary">{{ rowMeta(item) }}</span>
|
||||
<span class="status-dot" :class="item.enabled === false || item.status === 'retired' ? 'off' : 'on'"></span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div v-else class="object-list">
|
||||
<button
|
||||
v-for="item in currentItems"
|
||||
:key="String(item.id)"
|
||||
@@ -138,8 +165,8 @@
|
||||
<label><span>{{ t('admin.freightRpa.warehouseResolution') }}</span><el-select v-model="source.warehouse_resolution_mode"><el-option value="fixed" :label="t('admin.freightRpa.fixedWarehouse')" /><el-option value="inventory_match" :label="t('admin.freightRpa.inventoryMatch')" /></el-select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.freightRpa.warehouse') }}</span><el-input v-model="source.fixed_warehouse_id" required /></label>
|
||||
<div v-if="!selectedId" class="form-tip full">{{ t('admin.freightRpa.sourceSavedDisabledHint') }}</div>
|
||||
<!-- DBS/Crane 共用「库存报表配置」分组:DBS 含路径+条件,Crane 仅解析绑定;徽标与收料卡同构。
|
||||
此卡保留自绘折叠头:收料卡的展开动作绑定 toggleReceiptSection(参与保存守卫),el-collapse 无法复刻。 -->
|
||||
<!-- DBS/Crane 共用「库存报表配置」分组:DBS 含路径+条件,Crane 仅解析绑定;徽标与入站卡同构。
|
||||
此卡保留自绘折叠头:入站卡的展开动作绑定 toggleInboundSection(参与保存守卫),el-collapse 无法复刻。 -->
|
||||
<section class="path-card full" :class="{ configured: inventoryReportConfigExists }">
|
||||
<button type="button" class="path-card-header" :aria-expanded="inventoryPathOpen" @click="inventoryPathOpen = !inventoryPathOpen">
|
||||
<span class="path-card-title"><b>{{ t('admin.freightRpa.inventoryReportConfig') }}</b></span>
|
||||
@@ -163,33 +190,59 @@
|
||||
</div>
|
||||
<el-button class="full" size="small" @click="addParameter">{{ t('admin.freightRpa.addParameter') }}</el-button>
|
||||
</template>
|
||||
<label class="full"><span>{{ t('admin.freightRpa.parsingProfiles') }}</span><el-select v-model="source.onhand_report_config.parsing_profile_id"><el-option :value="0" :label="t('admin.freightRpa.notConfigured')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'inbound')" :key="String(item.id)" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
<label class="full"><span>{{ t('admin.freightRpa.parsingProfiles') }}</span><el-select v-model="source.onhand_report_config.parsing_profile_id"><el-option :value="0" :label="t('admin.freightRpa.notConfigured')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'onhand')" :key="String(item.id)" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="selectedId" class="path-card receipt full" :class="{ configured: receiptConfigExists }">
|
||||
<button type="button" class="path-card-header" :aria-expanded="receiptSectionOpen" @click="toggleReceiptSection">
|
||||
<span class="path-card-title"><b>{{ t('admin.freightRpa.receiptReportConfig') }}</b></span>
|
||||
<el-tag class="path-badge" :type="receiptConfigExists ? 'success' : 'info'" size="small">{{ receiptConfigExists ? t('admin.freightRpa.pathSectionConfigured') : t('admin.freightRpa.pathSectionNotConfigured') }}</el-tag>
|
||||
<span class="path-card-toggle" aria-hidden="true">{{ receiptSectionOpen ? '▾' : '▸' }}</span>
|
||||
<section v-if="selectedId" class="path-card inbound full" :class="{ configured: inboundConfigExists }">
|
||||
<button type="button" class="path-card-header" :aria-expanded="inboundSectionOpen" @click="toggleInboundSection">
|
||||
<span class="path-card-title"><b>{{ t('admin.freightRpa.inboundReportConfig') }}</b></span>
|
||||
<el-tag class="path-badge" :type="inboundConfigExists ? 'success' : 'info'" size="small">{{ inboundConfigExists ? t('admin.freightRpa.pathSectionConfigured') : t('admin.freightRpa.pathSectionNotConfigured') }}</el-tag>
|
||||
<span class="path-card-toggle" aria-hidden="true">{{ inboundSectionOpen ? '▾' : '▸' }}</span>
|
||||
</button>
|
||||
<div v-show="receiptSectionOpen" class="path-card-body">
|
||||
<div v-show="inboundSectionOpen" class="path-card-body">
|
||||
<template v-if="source.connector_type === 'dbs'">
|
||||
<label><span>{{ t('admin.freightRpa.programGroup') }}</span><el-input v-model="receiptConfig.report_path_json.program_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.programLabel') }}</span><el-input v-model="receiptConfig.report_path_json.program_label" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportGroup') }}</span><el-input v-model="receiptConfig.report_path_json.report_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportName') }}</span><el-input v-model="receiptConfig.report_path_json.report_name" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.programGroup') }}</span><el-input v-model="inboundConfig.report_path_json.program_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.programLabel') }}</span><el-input v-model="inboundConfig.report_path_json.program_label" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportGroup') }}</span><el-input v-model="inboundConfig.report_path_json.report_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportName') }}</span><el-input v-model="inboundConfig.report_path_json.report_name" required /></label>
|
||||
<div class="subsection full">{{ t('admin.freightRpa.queryParameters') }}</div>
|
||||
<div v-for="(parameter, index) in receiptConfig.query_parameters_json" :key="`receipt-${index}-${parameter.name}`" class="parameter-row full">
|
||||
<div v-for="(parameter, index) in inboundConfig.query_parameters_json" :key="`inbound-${index}-${parameter.name}`" class="parameter-row full">
|
||||
<el-input v-model="parameter.name" :placeholder="t('admin.freightRpa.parameterName')" />
|
||||
<el-select v-model="parameter.mode"><el-option value="single" :label="t('admin.freightRpa.single')" /><el-option value="multi_text" :label="t('admin.freightRpa.multiText')" /><el-option value="multi_select" :label="t('admin.freightRpa.multiSelect')" /></el-select>
|
||||
<el-input :model-value="parameter.values.join(', ')" :placeholder="t('admin.freightRpa.parameterValues')" @update:model-value="parameter.values = splitValues($event)" />
|
||||
<el-checkbox v-model="parameter.required">{{ t('admin.freightRpa.required') }}</el-checkbox>
|
||||
<el-checkbox v-model="parameter.select_all">{{ t('admin.freightRpa.selectAll') }}</el-checkbox>
|
||||
<el-button type="danger" plain size="small" @click="receiptConfig.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</el-button>
|
||||
<el-button type="danger" plain size="small" @click="inboundConfig.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</el-button>
|
||||
</div>
|
||||
<el-button class="full" size="small" @click="addReceiptParameter">{{ t('admin.freightRpa.addParameter') }}</el-button>
|
||||
</template>
|
||||
<label class="full"><span>{{ t('admin.freightRpa.movementBindingLabel') }}</span><el-select v-model="receiptConfig.parsing_profile_id"><el-option :value="null as unknown as string" :label="t('admin.freightRpa.movementBindingNone')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'inbound')" :key="`movement-bind-${item.id}`" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
<label class="full"><span>{{ t('admin.freightRpa.movementBindingLabel') }}</span><el-select v-model="inboundConfig.parsing_profile_id"><el-option :value="null as unknown as string" :label="t('admin.freightRpa.movementBindingNone')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'inbound')" :key="`movement-bind-${item.id}`" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="selectedId" class="path-card outbound full" :class="{ configured: outboundConfigExists }">
|
||||
<button type="button" class="path-card-header" :aria-expanded="outboundSectionOpen" @click="toggleOutboundSection">
|
||||
<span class="path-card-title"><b>{{ t('admin.freightRpa.outboundReportConfig') }}</b></span>
|
||||
<el-tag class="path-badge" :type="outboundConfigExists ? 'success' : 'info'" size="small">{{ outboundConfigExists ? t('admin.freightRpa.pathSectionConfigured') : t('admin.freightRpa.pathSectionNotConfigured') }}</el-tag>
|
||||
<span class="path-card-toggle" aria-hidden="true">{{ outboundSectionOpen ? '▾' : '▸' }}</span>
|
||||
</button>
|
||||
<div v-show="outboundSectionOpen" class="path-card-body">
|
||||
<template v-if="source.connector_type === 'dbs'">
|
||||
<label><span>{{ t('admin.freightRpa.programGroup') }}</span><el-input v-model="outboundConfig.report_path_json.program_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.programLabel') }}</span><el-input v-model="outboundConfig.report_path_json.program_label" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportGroup') }}</span><el-input v-model="outboundConfig.report_path_json.report_group" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.reportName') }}</span><el-input v-model="outboundConfig.report_path_json.report_name" required /></label>
|
||||
<div class="subsection full">{{ t('admin.freightRpa.queryParameters') }}</div>
|
||||
<div v-for="(parameter, index) in outboundConfig.query_parameters_json" :key="`outbound-${index}-${parameter.name}`" class="parameter-row full">
|
||||
<el-input v-model="parameter.name" :placeholder="t('admin.freightRpa.parameterName')" />
|
||||
<el-select v-model="parameter.mode"><el-option value="single" :label="t('admin.freightRpa.single')" /><el-option value="multi_text" :label="t('admin.freightRpa.multiText')" /><el-option value="multi_select" :label="t('admin.freightRpa.multiSelect')" /></el-select>
|
||||
<el-input :model-value="parameter.values.join(', ')" :placeholder="t('admin.freightRpa.parameterValues')" @update:model-value="parameter.values = splitValues($event)" />
|
||||
<el-checkbox v-model="parameter.required">{{ t('admin.freightRpa.required') }}</el-checkbox>
|
||||
<el-checkbox v-model="parameter.select_all">{{ t('admin.freightRpa.selectAll') }}</el-checkbox>
|
||||
<el-button type="danger" plain size="small" @click="outboundConfig.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</el-button>
|
||||
</div>
|
||||
<el-button class="full" size="small" @click="addOutboundParameter">{{ t('admin.freightRpa.addParameter') }}</el-button>
|
||||
</template>
|
||||
<label class="full"><span>{{ t('admin.freightRpa.outboundMovementBindingLabel') }}</span><el-select v-model="outboundConfig.parsing_profile_id"><el-option :value="null as unknown as string" :label="t('admin.freightRpa.movementBindingNone')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'outbound')" :key="`outbound-bind-${item.id}`" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -204,8 +257,8 @@
|
||||
</section>
|
||||
<section class="readonly-mapping-section full">
|
||||
<div class="subsection">{{ t(`admin.freightRpa.${parsingLabelNs}.fieldMappings`) }}</div>
|
||||
<p class="section-hint">{{ t(parsing.purpose === 'inbound' ? 'admin.freightRpa.movementMappingHint' : 'admin.freightRpa.readonlyFieldMappingsHint') }}</p>
|
||||
<template v-if="parsing.purpose === 'inbound'">
|
||||
<p class="section-hint">{{ t(parsingUsesMovementContract ? 'admin.freightRpa.movementMappingHint' : 'admin.freightRpa.readonlyFieldMappingsHint') }}</p>
|
||||
<template v-if="parsingUsesMovementContract">
|
||||
<div v-for="(item, index) in parsing.movement_mappings" :key="`readonly-movement-${item.code}`" class="parsing-mapping-card">
|
||||
<div class="mapping-title"><strong>{{ t('admin.freightRpa.mappingItem', { number: index + 1 }) }}</strong></div>
|
||||
<div class="mapping-display"><span>{{ t('admin.freightRpa.movementStandardField') }}</span><b>{{ t(`admin.freightRpa.movementFields.${item.code}`) }}</b><small><b v-if="item.required">{{ t('admin.freightRpa.movementRequiredMark') }}</b><template v-if="item.required && item.is_identity"> · </template><b v-if="item.is_identity">{{ t('admin.freightRpa.movementIdentityMark') }}</b></small></div>
|
||||
@@ -222,7 +275,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
<section v-if="parsing.purpose !== 'inbound'" class="readonly-mapping-section full">
|
||||
<section v-if="parsingUsesInventoryCatalog" class="readonly-mapping-section full">
|
||||
<div class="subsection">{{ t('admin.freightRpa.matchKeys') }}</div>
|
||||
<p class="section-hint">{{ t('admin.freightRpa.readonlyMatchKeysHint') }}</p>
|
||||
<div v-for="(item, index) in parsing.match_keys" :key="`readonly-match-${index}`" class="parsing-mapping-card match-key-card">
|
||||
@@ -240,7 +293,7 @@
|
||||
<label><span>{{ t(`admin.freightRpa.${parsingLabelNs}.name`) }}</span><el-input v-model="parsing.display_name" required /></label>
|
||||
<label><span>{{ t('admin.freightRpa.parsingPurposeLabel') }}</span><el-select v-model="parsing.purpose" :disabled="Boolean(selectedId)" @change="resetMappingRowsForPurpose"><el-option value="onhand" :label="t('admin.freightRpa.parsingPurpose.onhand')" /><el-option value="inbound" :label="t('admin.freightRpa.parsingPurpose.inbound')" /><el-option value="outbound" :label="t('admin.freightRpa.parsingPurpose.outbound')" /></el-select><small>{{ t('admin.freightRpa.parsingPurposeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.freightRpa.fileFormat') }}</span><el-select v-model="parsing.file_format"><el-option value="xls" label="xls" /><el-option value="xlsx" label="xlsx" /><el-option value="csv" label="csv" /></el-select></label>
|
||||
<label v-if="!selectedId && parsing.purpose !== 'inbound'" class="full"><span>{{ t('admin.freightRpa.temporaryInventorySession') }}</span><el-select v-model="selectedTemporaryInventorySession" @change="loadTemporaryInventorySession"><el-option value="" :label="t('admin.freightRpa.temporaryInventorySessionNone')" /><el-option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no" :label="`${item.source_file_name} · ${item.session_no}`" /></el-select><small>{{ t('admin.freightRpa.temporaryInventorySessionHint') }}</small></label>
|
||||
<label v-if="!selectedId && parsingUsesInventoryCatalog" class="full"><span>{{ t('admin.freightRpa.temporaryInventorySession') }}</span><el-select v-model="selectedTemporaryInventorySession" @change="loadTemporaryInventorySession"><el-option value="" :label="t('admin.freightRpa.temporaryInventorySessionNone')" /><el-option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no" :label="`${item.source_file_name} · ${item.session_no}`" /></el-select><small>{{ t('admin.freightRpa.temporaryInventorySessionHint') }}</small></label>
|
||||
<div v-if="temporaryInventorySessionSelected" class="form-tip full">{{ t('admin.freightRpa.temporaryInventorySessionSelected', { mapping: temporaryInventorySessionSelected.confirmed_usage?.mapping_origin || '-' }) }}</div>
|
||||
<label v-if="!selectedId" class="full"><span>{{ t(`admin.freightRpa.${parsingLabelNs}.sampleFile`) }}</span><input type="file" accept=".xls,.xlsx,.csv" :disabled="analysisLoading || Boolean(temporaryInventorySessionSelected)" @change="analyseInventorySample"><small>{{ t(`admin.freightRpa.${parsingLabelNs}.sampleFileHint`) }}</small></label>
|
||||
<section v-else-if="structureAnalysis" class="sample-evidence-card full">
|
||||
@@ -264,10 +317,10 @@
|
||||
<label><span>{{ t('admin.freightRpa.sheetName') }}</span><el-select v-model="parsing.sheet_name" @change="applyAnalysisCandidate"><el-option v-for="candidate in analysisCandidates" :key="candidateKey(candidate)" :value="candidate.sheet_name || ''" :label="candidate.sheet_name || t('admin.freightRpa.csvFile')" /></el-select></label>
|
||||
<label><span>{{ t('admin.freightRpa.headerRowIndex') }}</span><el-select v-model="parsing.header_row_index" @change="applyAnalysisCandidate"><el-option v-for="candidate in analysisCandidatesForSheet" :key="candidateKey(candidate)" :value="candidate.header_row_index" :label="t('admin.freightRpa.headerRowOption', { row: candidate.header_row_index })" /></el-select></label>
|
||||
<section class="analysis-preview full"><strong>{{ t(`admin.freightRpa.${parsingLabelNs}.analysisPreview`) }}</strong><p>{{ t('admin.freightRpa.inventoryAnalysisSummary', structureAnalysis.validation_summary) }}</p><div class="analysis-columns"><span v-for="column in selectedAnalysisColumns" :key="`${column.index}-${column.header}`"><b>{{ column.header || t('admin.freightRpa.emptyHeader') }}</b><small>{{ column.inferred_type }} · {{ column.sample_values?.join(' / ') || '-' }}</small></span></div></section>
|
||||
<section v-if="parsing.purpose !== 'inbound' && structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.freightRpa.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.freightRpa.recommendationLevel.${candidate.level}`) }} · {{ t('admin.freightRpa.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.freightRpa.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.freightRpa.columnOrderChanged') }}</p><el-button size="small" @click="adoptRecommendedProfile(candidate.profile_id)">{{ t('admin.freightRpa.adoptParsingPlan') }}</el-button></article></div></section>
|
||||
<section v-if="parsingUsesInventoryCatalog && structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.freightRpa.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.freightRpa.recommendationLevel.${candidate.level}`) }} · {{ t('admin.freightRpa.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.freightRpa.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.freightRpa.columnOrderChanged') }}</p><el-button size="small" @click="adoptRecommendedProfile(candidate.profile_id)">{{ t('admin.freightRpa.adoptParsingPlan') }}</el-button></article></div></section>
|
||||
</template>
|
||||
<div v-else class="form-tip full">{{ t(`admin.freightRpa.${parsingLabelNs}.sampleRequired`) }}</div>
|
||||
<template v-if="parsing.purpose === 'inbound'">
|
||||
<template v-if="parsingUsesMovementContract">
|
||||
<div class="subsection full">{{ t(`admin.freightRpa.${parsingLabelNs}.fieldMappings`) }}<small>{{ t('admin.freightRpa.movementMappingHint') }}</small></div>
|
||||
<div v-for="item in parsing.movement_mappings" :key="`movement-${item.code}`" class="parsing-mapping-card full">
|
||||
<div class="mapping-title"><strong>{{ t(`admin.freightRpa.movementFields.${item.code}`) }}</strong><small><b v-if="item.required">{{ t('admin.freightRpa.movementRequiredMark') }}</b><template v-if="item.required && item.is_identity"> · </template><b v-if="item.is_identity">{{ t('admin.freightRpa.movementIdentityMark') }}</b></small></div>
|
||||
@@ -453,7 +506,7 @@
|
||||
</template>
|
||||
<form class="clone-template-form" @submit.prevent="submitBulkParsingBinding">
|
||||
<label><span>{{ t('admin.freightRpa.inventorySites') }}</span><el-select v-model="bulkBinding.sourceIds" multiple><el-option v-for="item in sources" :key="String(item.id)" :value="Number(item.id)" :label="item.display_name || item.source_code" /></el-select></label>
|
||||
<label><span>{{ t('admin.freightRpa.parsingProfiles') }}</span><el-select v-model="bulkBinding.profileId"><el-option :value="0" :label="t('admin.freightRpa.notConfigured')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'inbound')" :key="String(item.id)" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
<label><span>{{ t('admin.freightRpa.parsingProfiles') }}</span><el-select v-model="bulkBinding.profileId"><el-option :value="0" :label="t('admin.freightRpa.notConfigured')" /><el-option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'onhand')" :key="String(item.id)" :value="Number(item.id)" :label="`${item.display_name || item.profile_code} V${item.version}`" /></el-select></label>
|
||||
<div class="clone-template-actions"><el-button size="small" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</el-button><el-button type="primary" native-type="submit" :loading="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.freightRpa.saving') : t('admin.freightRpa.bulkBindParsingProfile') }}</el-button></div>
|
||||
</form>
|
||||
</el-dialog>
|
||||
@@ -581,13 +634,17 @@ import {
|
||||
saveShippingOnhandSource,
|
||||
saveShippingRpaProfile,
|
||||
bulkBindShippingOnhandSourceParsingProfile,
|
||||
getShippingReceiptReportConfig,
|
||||
saveShippingReceiptReportConfig,
|
||||
getInboundReportConfig,
|
||||
saveInboundReportConfig,
|
||||
getOutboundReportConfig,
|
||||
saveOutboundReportConfig,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import type { ShippingOnhandReadinessCheck, ShippingOnhandValidationBatch } from '@/features/admin/api/admin.api';
|
||||
import { normaliseInventoryReportPath } from './shippingOnhandSourceForm';
|
||||
import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
|
||||
import { buildInboundReportConfigPayload } from './inboundReportConfigForm';
|
||||
import { buildOutboundReportConfigPayload } from './outboundReportConfigForm';
|
||||
import { buildMovementFieldMapping } from './movementParsingProfileForm';
|
||||
import { groupParsingProfilesByPurpose, sortParsingProfiles } from './parsingProfileListGroups';
|
||||
|
||||
type TabKey = 'profiles' | 'parsing' | 'inventoryFields' | 'templates' | 'sources' | 'rules' | 'snapshots' | 'exports' | 'mappings';
|
||||
type Item = Record<string, any>;
|
||||
@@ -707,12 +764,17 @@ let batchValidationTimer: number | null = null;
|
||||
// snapshot_ttl_seconds:管理端不再展示;保存时透传存量值。运行时过期以全局 SHIPPING_NOTICE_INVENTORY_SNAPSHOT_TTL_HOURS 为准。
|
||||
// s18 起报表路径/查询条件/解析方案绑定归 onhand_report_config 配置行(站点 DTO 嵌套对象),站点头部只留连接/模板/仓库模式。
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, onhand_report_config: { report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], parsing_profile_id: 0 }, enabled: false, activation: { ready: false, checks: [] as ShippingOnhandReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const receiptConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], parsing_profile_id: null as number | null });
|
||||
const receiptConfigExists = ref(false);
|
||||
const receiptSectionTouched = ref(false);
|
||||
const receiptSectionOpen = ref(false);
|
||||
const inboundConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], parsing_profile_id: null as number | null });
|
||||
const inboundConfigExists = ref(false);
|
||||
const inboundSectionTouched = ref(false);
|
||||
const inboundSectionOpen = ref(false);
|
||||
const outboundConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Outbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], parsing_profile_id: null as number | null });
|
||||
const outboundConfigExists = ref(false);
|
||||
const outboundSectionTouched = ref(false);
|
||||
const outboundSectionOpen = ref(false);
|
||||
const inventoryPathOpen = ref(true);
|
||||
const receiptBaseline = ref('');
|
||||
const inboundBaseline = ref('');
|
||||
const outboundBaseline = ref('');
|
||||
const sourceBaseline = ref('');
|
||||
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({ source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', in_transit_warehouse_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
@@ -738,7 +800,8 @@ const inventoryReportConfigExists = computed(() => {
|
||||
});
|
||||
const sourceDirty = computed(() => Boolean(selectedId.value && (
|
||||
(sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput())
|
||||
|| (receiptConfigExists.value && receiptBaseline.value && receiptBaseline.value !== serialiseReceiptInput())
|
||||
|| (inboundConfigExists.value && inboundBaseline.value && inboundBaseline.value !== serialiseInboundInput())
|
||||
|| (outboundConfigExists.value && outboundBaseline.value && outboundBaseline.value !== serialiseOutboundInput())
|
||||
)));
|
||||
const firstBlockingCheck = computed(() => (source.activation?.checks || []).find((item) => item.blocking && item.status !== 'passed'));
|
||||
const sampleReplacementNotice = computed(() => {
|
||||
@@ -791,7 +854,8 @@ const isInventoryMappingSection = computed(() => ['parsing', 'inventoryFields'].
|
||||
const isEditableTab = computed(() => ['profiles', 'parsing', 'inventoryFields', 'templates', 'sources', 'rules', 'mappings'].includes(activeTab.value));
|
||||
const currentItems = computed<Item[]>(() => {
|
||||
if (activeTab.value === 'profiles') return profiles.value;
|
||||
if (activeTab.value === 'parsing') return parsingProfiles.value;
|
||||
// 解析规则扁平列表也走同一排序契约,供空态 / 抽屉标题查找复用。
|
||||
if (activeTab.value === 'parsing') return sortParsingProfiles(parsingProfiles.value);
|
||||
if (activeTab.value === 'inventoryFields') return inventoryFields.value;
|
||||
if (activeTab.value === 'templates') return excelTemplates.value;
|
||||
if (activeTab.value === 'sources') return sources.value;
|
||||
@@ -799,6 +863,8 @@ const currentItems = computed<Item[]>(() => {
|
||||
if (activeTab.value === 'mappings') return mappings.value;
|
||||
return [];
|
||||
});
|
||||
/** 报表规则列表:按用途分段,空组省略。 */
|
||||
const parsingProfileGroups = computed(() => groupParsingProfilesByPurpose(parsingProfiles.value));
|
||||
const compatibleProfiles = computed(() => profiles.value.filter((item) => item.connector_type === source.connector_type));
|
||||
const selectedRuleStatus = computed(() => rules.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
// 只读判定必须限定在规则页签:selectedId 是各页签共享的,站点 id 可能与规则 id 相同,
|
||||
@@ -807,8 +873,11 @@ const ruleReadOnly = computed(() => activeTab.value === 'rules' && ['published',
|
||||
const selectedTemplateStatus = computed(() => excelTemplates.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
const selectedParsingStatus = computed(() => parsingProfiles.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
const parsingReadOnly = computed(() => activeTab.value === 'parsing' && ['published', 'retired'].includes(selectedParsingStatus.value));
|
||||
/** 按规则用途切换弹窗标签命名空间:入站模式下不再出现"库存"措辞。 */
|
||||
const parsingLabelNs = computed(() => parsing.purpose === 'inbound' ? 'movementParsing' : 'inventoryParsing');
|
||||
/** 入站/出站走异动契约 UI;在手走库存字段目录 + match_keys。 */
|
||||
const parsingUsesMovementContract = computed(() => parsing.purpose === 'inbound' || parsing.purpose === 'outbound');
|
||||
const parsingUsesInventoryCatalog = computed(() => parsing.purpose === 'onhand');
|
||||
/** 按规则用途切换弹窗标签命名空间:异动用途下不再出现"库存"措辞。 */
|
||||
const parsingLabelNs = computed(() => (parsingUsesMovementContract.value ? 'movementParsing' : 'inventoryParsing'));
|
||||
const inventoryFieldReadOnly = computed(() => activeTab.value === 'inventoryFields' && inventoryField.status !== 'active');
|
||||
const analysisCandidates = computed<Item[]>(() => structureAnalysis.value?.structure?.candidates || []);
|
||||
const analysisCandidatesForSheet = computed<Item[]>(() => analysisCandidates.value.filter((item) => String(item.sheet_name || '') === parsing.sheet_name));
|
||||
@@ -929,9 +998,9 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置当前站点的独立收料表单与卡片状态,与库存同构(路径+查询条件)。 */
|
||||
/** 重置当前站点的独立入站表单与卡片状态,与库存同构(路径+查询条件)。 */
|
||||
function resetReceiptConfig(connectorType: unknown): void {
|
||||
Object.assign(receiptConfig, {
|
||||
Object.assign(inboundConfig, {
|
||||
report_path_json: String(connectorType || '').toLowerCase() === 'crane'
|
||||
? { report_name: 'Inbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' },
|
||||
@@ -940,39 +1009,85 @@ function resetReceiptConfig(connectorType: unknown): void {
|
||||
});
|
||||
}
|
||||
|
||||
/** 读取收料独立配置;读取失败不影响库存站点配置和既有库存运行。 */
|
||||
/** 读取入站独立配置;读取失败不影响来源站点配置和既有库存运行。 */
|
||||
async function loadReceiptConfig(sourceId: number, connectorType: unknown): Promise<void> {
|
||||
resetReceiptConfig(connectorType);
|
||||
receiptConfigExists.value = false;
|
||||
receiptSectionTouched.value = false;
|
||||
receiptSectionOpen.value = false;
|
||||
receiptBaseline.value = '';
|
||||
inboundConfigExists.value = false;
|
||||
inboundSectionTouched.value = false;
|
||||
inboundSectionOpen.value = false;
|
||||
inboundBaseline.value = '';
|
||||
try {
|
||||
const config = await getShippingReceiptReportConfig(sourceId);
|
||||
const config = await getInboundReportConfig(sourceId);
|
||||
if (!config) return;
|
||||
const isCrane = String(connectorType || '').toLowerCase() === 'crane';
|
||||
Object.assign(receiptConfig, {
|
||||
Object.assign(inboundConfig, {
|
||||
report_path_json: isCrane
|
||||
? { report_name: 'Inbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '', ...((config.report_path_json || {}) as Record<string, string>) },
|
||||
query_parameters_json: Array.isArray(config.query_parameters_json) ? config.query_parameters_json.map((parameter) => ({ ...parameter })) : [],
|
||||
parsing_profile_id: config.parsing_profile_id ? Number(config.parsing_profile_id) : null,
|
||||
});
|
||||
receiptConfigExists.value = true;
|
||||
receiptSectionOpen.value = true;
|
||||
inboundConfigExists.value = true;
|
||||
inboundSectionOpen.value = true;
|
||||
} catch (cause) { showError(cause, 'loadFailed'); }
|
||||
finally { receiptBaseline.value = serialiseReceiptInput(); }
|
||||
finally { inboundBaseline.value = serialiseInboundInput(); }
|
||||
}
|
||||
|
||||
/** 新增 DBS 可选收料条件;Crane 固定默认查询,不维护查询条件。 */
|
||||
/** 新增 DBS 可选入站条件;Crane 固定默认查询,不维护查询条件。 */
|
||||
function addReceiptParameter(): void {
|
||||
receiptConfig.query_parameters_json.push({ name: '', mode: 'single', values: [], required: false, select_all: false });
|
||||
inboundConfig.query_parameters_json.push({ name: '', mode: 'single', values: [], required: false, select_all: false });
|
||||
}
|
||||
|
||||
/** 展开收料卡即视为有配置意图:统一保存时会提交收料配置,避免未展开时误建空配置。 */
|
||||
function toggleReceiptSection(): void {
|
||||
receiptSectionOpen.value = !receiptSectionOpen.value;
|
||||
if (receiptSectionOpen.value) receiptSectionTouched.value = true;
|
||||
/** 展开入站卡即视为有配置意图:统一保存时会提交入站配置,避免未展开时误建空配置。 */
|
||||
function toggleInboundSection(): void {
|
||||
inboundSectionOpen.value = !inboundSectionOpen.value;
|
||||
if (inboundSectionOpen.value) inboundSectionTouched.value = true;
|
||||
}
|
||||
|
||||
/** 重置当前站点的独立出站表单与卡片状态,与入站同构(路径+查询条件)。 */
|
||||
function resetOutboundConfig(connectorType: unknown): void {
|
||||
Object.assign(outboundConfig, {
|
||||
report_path_json: String(connectorType || '').toLowerCase() === 'crane'
|
||||
? { report_name: 'Outbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Outbound', report_name: '' },
|
||||
query_parameters_json: [],
|
||||
parsing_profile_id: null,
|
||||
});
|
||||
}
|
||||
|
||||
/** 读取出站独立配置;读取失败不影响来源站点、库存与入站配置。 */
|
||||
async function loadOutboundConfig(sourceId: number, connectorType: unknown): Promise<void> {
|
||||
resetOutboundConfig(connectorType);
|
||||
outboundConfigExists.value = false;
|
||||
outboundSectionTouched.value = false;
|
||||
outboundSectionOpen.value = false;
|
||||
outboundBaseline.value = '';
|
||||
try {
|
||||
const config = await getOutboundReportConfig(sourceId);
|
||||
if (!config) return;
|
||||
const isCrane = String(connectorType || '').toLowerCase() === 'crane';
|
||||
Object.assign(outboundConfig, {
|
||||
report_path_json: isCrane
|
||||
? { report_name: 'Outbound Details' }
|
||||
: { program_group: '', program_label: '', report_group: 'Outbound', report_name: '', ...((config.report_path_json || {}) as Record<string, string>) },
|
||||
query_parameters_json: Array.isArray(config.query_parameters_json) ? config.query_parameters_json.map((parameter) => ({ ...parameter })) : [],
|
||||
parsing_profile_id: config.parsing_profile_id ? Number(config.parsing_profile_id) : null,
|
||||
});
|
||||
outboundConfigExists.value = true;
|
||||
outboundSectionOpen.value = true;
|
||||
} catch (cause) { showError(cause, 'loadFailed'); }
|
||||
finally { outboundBaseline.value = serialiseOutboundInput(); }
|
||||
}
|
||||
|
||||
/** 新增 DBS 可选出站条件;Crane 固定 Outbound Details,不维护查询条件。 */
|
||||
function addOutboundParameter(): void {
|
||||
outboundConfig.query_parameters_json.push({ name: '', mode: 'single', values: [], required: false, select_all: false });
|
||||
}
|
||||
|
||||
/** 展开出站卡即视为有配置意图:统一保存时会提交出站配置,避免未展开时误建空配置。 */
|
||||
function toggleOutboundSection(): void {
|
||||
outboundSectionOpen.value = !outboundSectionOpen.value;
|
||||
if (outboundSectionOpen.value) outboundSectionTouched.value = true;
|
||||
}
|
||||
|
||||
/** 接收侧栏或书签中的 section 深链,仅允许打开工作台已注册区段。 */
|
||||
@@ -1018,11 +1133,16 @@ function createNew(): void {
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, onhand_report_config: { report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], parsing_profile_id: 0 }, enabled: false, activation: { ready: false, checks: [], missing_requirements: ['parsing_profile', 'excel_template'] } });
|
||||
resetReceiptConfig('dbs');
|
||||
receiptConfigExists.value = false;
|
||||
receiptSectionTouched.value = false;
|
||||
receiptSectionOpen.value = false;
|
||||
resetOutboundConfig('dbs');
|
||||
inboundConfigExists.value = false;
|
||||
inboundSectionTouched.value = false;
|
||||
inboundSectionOpen.value = false;
|
||||
outboundConfigExists.value = false;
|
||||
outboundSectionTouched.value = false;
|
||||
outboundSectionOpen.value = false;
|
||||
inventoryPathOpen.value = true;
|
||||
receiptBaseline.value = '';
|
||||
inboundBaseline.value = '';
|
||||
outboundBaseline.value = '';
|
||||
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: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
@@ -1082,6 +1202,7 @@ function selectItem(item: Item): void {
|
||||
} });
|
||||
sourceBaseline.value = serialiseSourceInput();
|
||||
void loadReceiptConfig(Number(item.id), String(item.connector_type || ''));
|
||||
void loadOutboundConfig(Number(item.id), String(item.connector_type || ''));
|
||||
}
|
||||
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,
|
||||
@@ -1197,6 +1318,7 @@ async function loadTemplateLayout(templateId: number | null): Promise<void> {
|
||||
/** 关闭抽屉并清除选择,确保切换配置对象时不会残留未保存数据。 */
|
||||
function closeDrawer(): void {
|
||||
resetReceiptConfig(source.connector_type);
|
||||
resetOutboundConfig(source.connector_type);
|
||||
sourceBaseline.value = '';
|
||||
drawerOpen.value = false;
|
||||
selectedId.value = null;
|
||||
@@ -1208,15 +1330,15 @@ async function saveCurrent(): Promise<void> {
|
||||
try {
|
||||
if (activeTab.value === 'profiles') await saveShippingRpaProfile({ ...profile, display_name: profile.display_name || profile.profile_code, upload_config_json: profile.upload_config_json }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'parsing') {
|
||||
const payload = parsing.purpose === 'inbound' ? {
|
||||
const payload = parsingUsesMovementContract.value ? {
|
||||
profile_code: parsing.profile_code, display_name: parsing.display_name || parsing.profile_code, file_format: parsing.file_format,
|
||||
purpose: 'inbound', sheet_name: parsing.sheet_name || null, header_row_index: parsing.header_row_index,
|
||||
purpose: parsing.purpose, sheet_name: parsing.sheet_name || null, header_row_index: parsing.header_row_index,
|
||||
// 标准异动字段契约:code 由只读目录下发,这里只裁剪/校验别名映射。
|
||||
field_mapping: buildMovementFieldMapping(parsing.movement_mappings),
|
||||
match_keys: [] as string[],
|
||||
} : {
|
||||
profile_code: parsing.profile_code, display_name: parsing.display_name || parsing.profile_code, file_format: parsing.file_format,
|
||||
sheet_name: parsing.sheet_name || null, header_row_index: parsing.header_row_index,
|
||||
purpose: 'onhand', sheet_name: parsing.sheet_name || null, header_row_index: parsing.header_row_index,
|
||||
field_mapping: Object.fromEntries(parsing.field_mappings.map((item) => [item.inventory_field, item.source_header])),
|
||||
match_keys: parsing.match_keys.map((item) => ({ order_field_id: item.order_field_id, inventory_field_id: item.inventory_field })),
|
||||
};
|
||||
@@ -1265,16 +1387,28 @@ async function saveCurrent(): Promise<void> {
|
||||
query_parameters_json: source.onhand_report_config.query_parameters_json,
|
||||
parsing_profile_id: source.onhand_report_config.parsing_profile_id,
|
||||
} }, selectedId.value || undefined);
|
||||
// 收料与站点同批保存:仅当已有配置或管理员展开过收料卡时才提交,避免未配置站点被误建空收料配置。
|
||||
if (selectedId.value && (receiptSectionTouched.value || (receiptConfigExists.value && receiptBaseline.value !== serialiseReceiptInput()))) {
|
||||
// 入站与站点同批保存:仅当已有配置或管理员展开过入站卡时才提交,避免未配置站点被误建空入站配置。
|
||||
if (selectedId.value && (inboundSectionTouched.value || (inboundConfigExists.value && inboundBaseline.value !== serialiseInboundInput()))) {
|
||||
try {
|
||||
await saveShippingReceiptReportConfig(selectedId.value, buildReceiptReportConfigPayload(receiptConfig));
|
||||
receiptConfigExists.value = true;
|
||||
receiptBaseline.value = serialiseReceiptInput();
|
||||
await saveInboundReportConfig(selectedId.value, buildInboundReportConfigPayload(inboundConfig));
|
||||
inboundConfigExists.value = true;
|
||||
inboundBaseline.value = serialiseInboundInput();
|
||||
} catch (cause) {
|
||||
showError(cause, 'saveFailed');
|
||||
await load();
|
||||
return; // 站点已保存但收料保存失败:保持抽屉打开,修正后可直接重试统一保存。
|
||||
return; // 站点已保存但入站保存失败:保持抽屉打开,修正后可直接重试统一保存。
|
||||
}
|
||||
}
|
||||
// 出站与站点同批保存:仅当已有配置或管理员展开过出站卡时才提交,避免未配置站点被误建空出站配置。
|
||||
if (selectedId.value && (outboundSectionTouched.value || (outboundConfigExists.value && outboundBaseline.value !== serialiseOutboundInput()))) {
|
||||
try {
|
||||
await saveOutboundReportConfig(selectedId.value, buildOutboundReportConfigPayload(outboundConfig));
|
||||
outboundConfigExists.value = true;
|
||||
outboundBaseline.value = serialiseOutboundInput();
|
||||
} catch (cause) {
|
||||
showError(cause, 'saveFailed');
|
||||
await load();
|
||||
return; // 站点已保存但出站保存失败:保持抽屉打开,修正后可直接重试统一保存。
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1444,9 +1578,9 @@ function buildMovementMappings(item: Item) {
|
||||
}));
|
||||
}
|
||||
|
||||
/** 切换用途时初始化对应映射行:入站(inbound)预填标准异动字段目录,onhand/outbound 清空自由映射。 */
|
||||
/** 切换用途时初始化对应映射行:入站/出站预填标准异动字段目录,在手清空并走库存目录映射。 */
|
||||
function resetMappingRowsForPurpose(): void {
|
||||
if (parsing.purpose === 'inbound') {
|
||||
if (parsingUsesMovementContract.value) {
|
||||
parsing.movement_mappings = movementFields.value.map((field) => ({
|
||||
code: field.code, alias: '', required: Boolean(field.required), is_identity: Boolean(field.is_identity),
|
||||
}));
|
||||
@@ -1651,11 +1785,39 @@ function rowMeta(item: Item): string {
|
||||
}
|
||||
if (activeTab.value === 'inventoryFields') return `${t(`admin.freightRpa.inventoryFieldType.${item.value_type || 'text'}`)} · ${t(`admin.freightRpa.inventoryFieldPurposeOption.${item.usage_type || 'general'}`)}`;
|
||||
if (item.connector_type) return String(item.display_name ? t(`admin.freightRpa.platform.${item.connector_type}`) : item.connector_type);
|
||||
// 解析规则列表带出用途徽标文案,库存/入站/出站三种规则在列表一眼可分。
|
||||
if (activeTab.value === 'parsing') return `${t(`admin.freightRpa.parsingPurpose.${item.purpose}`)} · V${item.version ?? '-'}`;
|
||||
// 解析规则副行:编号 · 用途 · 版本,与「组内按编号排」的可见锚点一致。
|
||||
if (activeTab.value === 'parsing') {
|
||||
const code = String(item.profile_code || '-');
|
||||
const purpose = parsingPurposeLabel(String(item.purpose || ''));
|
||||
return `${code} · ${purpose} · V${item.version ?? '-'}`;
|
||||
}
|
||||
return String(item.source_code || item.profile_code || item.rule_code || item.external_warehouse_code || '-');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析规则用途文案;未知用途回退为原始值,避免 i18n 缺键刷屏。
|
||||
* @param purpose - onhand / inbound / outbound 或其它
|
||||
*/
|
||||
function parsingPurposeLabel(purpose: string): string {
|
||||
const normalised = purpose.trim().toLowerCase();
|
||||
if (normalised === 'onhand' || normalised === 'inbound' || normalised === 'outbound') {
|
||||
return t(`admin.freightRpa.parsingPurpose.${normalised}`);
|
||||
}
|
||||
return purpose || '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组标题:「库存 (3)」;数量用 tabular 语境下的纯文案,供 aria-label 复用。
|
||||
* @param purpose - 用途
|
||||
* @param count - 组内条数
|
||||
*/
|
||||
function parsingPurposeGroupLabel(purpose: string, count: number): string {
|
||||
return t('admin.freightRpa.parsingPurposeGroup', {
|
||||
label: parsingPurposeLabel(purpose),
|
||||
count,
|
||||
});
|
||||
}
|
||||
|
||||
/** 在选择器中同时呈现库存字段名称和维护说明,避免管理员猜测字段用途。 */
|
||||
function inventoryFieldOptionLabel(field: Item): string {
|
||||
const description = String(field.description || '').trim();
|
||||
@@ -1684,13 +1846,22 @@ function serialiseSourceInput(): string {
|
||||
});
|
||||
}
|
||||
|
||||
/** 将收料配置表单稳定序列化(含异动解析规则绑定),作为统一保存与启用守卫的收料脏检查基线。 */
|
||||
function serialiseReceiptInput(): string {
|
||||
/** 将入站配置表单稳定序列化(含异动解析规则绑定),作为统一保存与启用守卫的入站脏检查基线。 */
|
||||
function serialiseInboundInput(): string {
|
||||
return JSON.stringify({
|
||||
report_path_json: receiptConfig.report_path_json,
|
||||
query_parameters_json: receiptConfig.query_parameters_json,
|
||||
// 异动解析绑定必须参与脏检查:否则只改绑定时统一保存会跳过收料配置提交,改动被静默丢弃。
|
||||
parsing_profile_id: receiptConfig.parsing_profile_id ? Number(receiptConfig.parsing_profile_id) : null,
|
||||
report_path_json: inboundConfig.report_path_json,
|
||||
query_parameters_json: inboundConfig.query_parameters_json,
|
||||
// 异动解析绑定必须参与脏检查:否则只改绑定时统一保存会跳过入站配置提交,改动被静默丢弃。
|
||||
parsing_profile_id: inboundConfig.parsing_profile_id ? Number(inboundConfig.parsing_profile_id) : null,
|
||||
});
|
||||
}
|
||||
|
||||
/** 将出站配置表单稳定序列化(含异动解析规则绑定),作为统一保存与启用守卫的出站脏检查基线。 */
|
||||
function serialiseOutboundInput(): string {
|
||||
return JSON.stringify({
|
||||
report_path_json: outboundConfig.report_path_json,
|
||||
query_parameters_json: outboundConfig.query_parameters_json,
|
||||
parsing_profile_id: outboundConfig.parsing_profile_id ? Number(outboundConfig.parsing_profile_id) : null,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1732,6 +1903,15 @@ onMounted(load);
|
||||
.workbench-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 18px; font-weight: 600; letter-spacing: 0; line-height: 28px; }
|
||||
.workbench-heading p { max-width: 660px; margin: 5px 0 0; color: var(--el-text-color-secondary); font-size: 14px; line-height: 20px; }
|
||||
.object-list-panel { min-height: 360px; }
|
||||
.object-groups { display: grid; gap: 18px; }
|
||||
.object-group { display: grid; gap: 8px; }
|
||||
.object-group-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
.object-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
|
||||
.object-empty { grid-column: 1 / -1; }
|
||||
.object-row { position: relative; display: flex; width: 100%; min-height: 72px; flex-direction: column; justify-content: center; gap: 4px; border: 1px solid var(--el-border-color-light); border-radius: 8px; background: var(--el-bg-color); padding: 12px 30px 12px 13px; text-align: left; cursor: pointer; }
|
||||
|
||||
+13
-13
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/receiptReportConfigForm.spec.ts
|
||||
* 用途:覆盖收料报表表单的独立载荷边界。
|
||||
* 依赖:receiptReportConfigForm、vitest。
|
||||
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 收料无独立启停字段,载荷不得包含 enabled。
|
||||
* features/admin/modules/freight-rpa/inboundReportConfigForm.spec.ts
|
||||
* 用途:覆盖入站报表表单的独立载荷边界。
|
||||
* 依赖:inboundReportConfigForm、vitest。
|
||||
* 逻辑:防止入站配置保存时把来源站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 入站无独立启停字段,载荷不得包含 enabled。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
|
||||
import { buildInboundReportConfigPayload } from './inboundReportConfigForm';
|
||||
|
||||
describe('receiptReportConfigForm', () => {
|
||||
it('builds a receipt-only payload without inventory source fields', () => {
|
||||
// 关键断言:收料路径与条件必须走独立 API,不能夹带库存 RPA 配置或启停字段。
|
||||
const payload = buildReceiptReportConfigPayload({
|
||||
describe('inboundReportConfigForm', () => {
|
||||
it('builds an inbound-only payload without inventory source fields', () => {
|
||||
// 关键断言:入站路径与条件必须走独立 API,不能夹带来源站点 RPA 配置或启停字段。
|
||||
const payload = buildInboundReportConfigPayload({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
@@ -23,7 +23,7 @@ describe('receiptReportConfigForm', () => {
|
||||
enabled: true,
|
||||
warehouse_ids_json: ['SHOULD-NOT-LEAK'],
|
||||
inventory_report_path_json: { report_name: 'On Hand' },
|
||||
} as Parameters<typeof buildReceiptReportConfigPayload>[0] & Record<string, unknown>);
|
||||
} as Parameters<typeof buildInboundReportConfigPayload>[0] & Record<string, unknown>);
|
||||
|
||||
expect(payload).toEqual({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
@@ -42,14 +42,14 @@ describe('receiptReportConfigForm', () => {
|
||||
|
||||
it('carries movement profile binding and normalizes absent id to explicit unbind', () => {
|
||||
// 关键断言:异动解析绑定随配置提交;未绑定时必须显式提交 null(解绑),不能省略键。
|
||||
const bound = buildReceiptReportConfigPayload({
|
||||
const bound = buildInboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Inbound Details' },
|
||||
query_parameters_json: [],
|
||||
parsing_profile_id: 7,
|
||||
});
|
||||
expect(bound.parsing_profile_id).toBe(7);
|
||||
|
||||
const unbound = buildReceiptReportConfigPayload({
|
||||
const unbound = buildInboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Inbound Details' },
|
||||
query_parameters_json: [],
|
||||
});
|
||||
+11
-11
@@ -1,26 +1,26 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/receiptReportConfigForm.ts
|
||||
* 用途:构建独立收料报表配置的受限保存载荷。
|
||||
* features/admin/modules/freight-rpa/inboundReportConfigForm.ts
|
||||
* 用途:构建独立入站报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将收料路径与查询条件提交到 /api/admin/freight-rpa/sources/<id>/inbound-report-config,与库存同构(查询条件可选,空=页面默认),
|
||||
* 隔离库存站点字段;收料无独立启停字段,是否运行统一由库存站点 enabled 决定。
|
||||
* 逻辑:页面仅将入站路径与查询条件提交到 /api/admin/freight-rpa/sources/<id>/inbound-report-config,与库存同构(查询条件可选,空=页面默认),
|
||||
* 隔离来源站点字段;入站无独立启停字段,是否运行统一由来源站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type ReceiptReportConfigInput = {
|
||||
export type InboundReportConfigInput = {
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
/** 收料异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
/** 入站异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
parsing_profile_id?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造独立收料配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入收料 API;
|
||||
* 构造独立入站配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入入站 API;
|
||||
* 异动解析绑定随配置一并提交(null=解绑)。
|
||||
* @param input - 抽屉中的收料配置表单状态。
|
||||
* @returns 仅包含收料配置 API 支持字段的深拷贝载荷。
|
||||
* @param input - 抽屉中的入站配置表单状态。
|
||||
* @returns 仅包含入站配置 API 支持字段的深拷贝载荷。
|
||||
*/
|
||||
export function buildReceiptReportConfigPayload(input: ReceiptReportConfigInput): ReceiptReportConfigInput {
|
||||
export function buildInboundReportConfigPayload(input: InboundReportConfigInput): InboundReportConfigInput {
|
||||
return {
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/movementParsingProfileForm.ts
|
||||
* 用途:组装入站解析规则(purpose='inbound')的标准异动字段映射载荷。
|
||||
* 用途:组装入站/出站解析规则(purpose='inbound'|'outbound')的标准异动字段映射载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:标准异动字段目录由后端 /admin/shipping-notice/movement-fields 只读下发,
|
||||
* 逻辑:标准异动字段目录由后端 /admin/freight-rpa/movement-fields 只读下发,
|
||||
* 本模块只做裁剪与校验——映射键是契约 code,必填字段缺失阻断保存;
|
||||
* 不提供任何自定义字段的入口(业务领域字段不允许用户自定义)。
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/outboundReportConfigForm.spec.ts
|
||||
* 用途:覆盖出站报表表单的独立载荷边界。
|
||||
* 依赖:outboundReportConfigForm、vitest。
|
||||
* 逻辑:防止出站配置保存时把来源站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 出站无独立启停字段,载荷不得包含 enabled。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildOutboundReportConfigPayload } from './outboundReportConfigForm';
|
||||
|
||||
describe('outboundReportConfigForm', () => {
|
||||
it('builds an outbound-only payload without inventory source fields', () => {
|
||||
// 关键断言:出站路径与条件必须走独立 API,不能夹带来源站点 RPA 配置或启停字段。
|
||||
const payload = buildOutboundReportConfigPayload({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Outbound', report_name: 'Outbound Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
source_code: 'INVENTORY-SHOULD-NOT-LEAK',
|
||||
snapshot_ttl_seconds: 86400,
|
||||
enabled: true,
|
||||
warehouse_ids_json: ['SHOULD-NOT-LEAK'],
|
||||
inventory_report_path_json: { report_name: 'On Hand' },
|
||||
} as Parameters<typeof buildOutboundReportConfigPayload>[0] & Record<string, unknown>);
|
||||
|
||||
expect(payload).toEqual({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Outbound', report_name: 'Outbound Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
parsing_profile_id: null,
|
||||
});
|
||||
expect(payload).not.toHaveProperty('source_code');
|
||||
expect(payload).not.toHaveProperty('snapshot_ttl_seconds');
|
||||
expect(payload).not.toHaveProperty('enabled');
|
||||
expect(payload).not.toHaveProperty('warehouse_ids_json');
|
||||
});
|
||||
|
||||
it('carries movement profile binding and normalizes absent id to explicit unbind', () => {
|
||||
// 关键断言:异动解析绑定随配置提交;未绑定时必须显式提交 null(解绑),不能省略键。
|
||||
const bound = buildOutboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Outbound Details' },
|
||||
query_parameters_json: [],
|
||||
parsing_profile_id: 9,
|
||||
});
|
||||
expect(bound.parsing_profile_id).toBe(9);
|
||||
|
||||
const unbound = buildOutboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Outbound Details' },
|
||||
query_parameters_json: [],
|
||||
});
|
||||
expect(unbound.parsing_profile_id).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/outboundReportConfigForm.ts
|
||||
* 用途:构建独立出站报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将出站路径与查询条件提交到 /api/admin/freight-rpa/sources/<id>/outbound-report-config,与入站同构(查询条件可选,空=页面默认),
|
||||
* 隔离来源站点字段;出站无独立启停字段,是否运行统一由来源站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type OutboundReportConfigInput = {
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
/** 出站异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
parsing_profile_id?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造独立出站配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入出站 API;
|
||||
* 异动解析绑定随配置一并提交(null=解绑)。
|
||||
* @param input - 抽屉中的出站配置表单状态。
|
||||
* @returns 仅包含出站配置 API 支持字段的深拷贝载荷。
|
||||
*/
|
||||
export function buildOutboundReportConfigPayload(input: OutboundReportConfigInput): OutboundReportConfigInput {
|
||||
return {
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
parsing_profile_id: input.parsing_profile_id ? Number(input.parsing_profile_id) : null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/parsingProfileListGroups.spec.ts
|
||||
* 用途:覆盖报表规则列表「按用途分组 → 组内按编号排序」的纯函数契约。
|
||||
* 依赖:parsingProfileListGroups、vitest。
|
||||
* 逻辑:分组顺序与编号序是列表扫读的稳定契约,变更必须显式同步。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { groupParsingProfilesByPurpose, sortParsingProfiles } from './parsingProfileListGroups';
|
||||
|
||||
describe('parsingProfileListGroups', () => {
|
||||
it('sorts by purpose order then profile_code then version desc', () => {
|
||||
// 关键断言:库存→入站→出站;同组内编号升序;同编号高版本在前。
|
||||
const sorted = sortParsingProfiles([
|
||||
{ id: 1, purpose: 'outbound', profile_code: 'Z_OUT', version: 1 },
|
||||
{ id: 2, purpose: 'onhand', profile_code: 'B_ON', version: 1 },
|
||||
{ id: 3, purpose: 'inbound', profile_code: 'A_IN', version: 1 },
|
||||
{ id: 4, purpose: 'onhand', profile_code: 'A_ON', version: 1 },
|
||||
{ id: 5, purpose: 'onhand', profile_code: 'A_ON', version: 2 },
|
||||
]);
|
||||
expect(sorted.map((row) => `${row.purpose}:${row.profile_code}:V${row.version}`)).toEqual([
|
||||
'onhand:A_ON:V2',
|
||||
'onhand:A_ON:V1',
|
||||
'onhand:B_ON:V1',
|
||||
'inbound:A_IN:V1',
|
||||
'outbound:Z_OUT:V1',
|
||||
]);
|
||||
});
|
||||
|
||||
it('groups by purpose in fixed order and omits empty groups', () => {
|
||||
// 关键断言:空用途不渲染分组壳;组内已按编号排好。
|
||||
const groups = groupParsingProfilesByPurpose([
|
||||
{ id: 1, purpose: 'outbound', profile_code: 'B_OUT', version: 1 },
|
||||
{ id: 2, purpose: 'outbound', profile_code: 'A_OUT', version: 1 },
|
||||
{ id: 3, purpose: 'onhand', profile_code: 'M_ON', version: 1 },
|
||||
]);
|
||||
expect(groups.map((group) => group.purpose)).toEqual(['onhand', 'outbound']);
|
||||
expect(groups[0].items.map((row) => row.profile_code)).toEqual(['M_ON']);
|
||||
expect(groups[1].items.map((row) => row.profile_code)).toEqual(['A_OUT', 'B_OUT']);
|
||||
});
|
||||
|
||||
it('treats unknown purpose as last bucket after outbound', () => {
|
||||
const groups = groupParsingProfilesByPurpose([
|
||||
{ id: 1, purpose: 'legacy', profile_code: 'X', version: 1 },
|
||||
{ id: 2, purpose: 'inbound', profile_code: 'I', version: 1 },
|
||||
]);
|
||||
expect(groups.map((group) => group.purpose)).toEqual(['inbound', 'legacy']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/parsingProfileListGroups.ts
|
||||
* 用途:报表规则列表排序与按用途分组(库存 → 入站 → 出站)。
|
||||
* 依赖:无;纯函数,供 FreightRpaPage 列表渲染使用。
|
||||
* 逻辑:先按固定用途序,再按 profile_code 升序,同编号取 version 降序;空组不产出。
|
||||
*/
|
||||
|
||||
/** 规则用途:与后端 freight_rpa_parsing_profiles.purpose 对齐。 */
|
||||
export type ParsingProfilePurpose = 'onhand' | 'inbound' | 'outbound' | string;
|
||||
|
||||
/** 列表分组最小字段;其它卡片字段原样透传。 */
|
||||
export type ParsingProfileListItem = {
|
||||
purpose?: ParsingProfilePurpose | null;
|
||||
profile_code?: string | null;
|
||||
version?: number | null;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export type ParsingProfileListGroup<T extends ParsingProfileListItem = ParsingProfileListItem> = {
|
||||
purpose: string;
|
||||
items: T[];
|
||||
};
|
||||
|
||||
/** 固定分组顺序:与业务绑定对象(库存站 / 入站配置 / 出站配置)一致。 */
|
||||
export const PARSING_PURPOSE_ORDER = ['onhand', 'inbound', 'outbound'] as const;
|
||||
|
||||
/**
|
||||
* 用途在固定序中的排序权重;未知用途排在已知用途之后。
|
||||
* @param purpose - 规则用途
|
||||
* @returns 越小越靠前
|
||||
*/
|
||||
function purposeRank(purpose: string): number {
|
||||
const index = (PARSING_PURPOSE_ORDER as readonly string[]).indexOf(purpose);
|
||||
return index >= 0 ? index : PARSING_PURPOSE_ORDER.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两条解析规则的列表序。
|
||||
* 核心逻辑:用途序 → 编号升序(忽略大小写)→ 版本降序。
|
||||
* @param left - 左侧规则
|
||||
* @param right - 右侧规则
|
||||
* @returns 负/零/正,供 Array.sort 使用
|
||||
*/
|
||||
export function compareParsingProfiles(
|
||||
left: ParsingProfileListItem,
|
||||
right: ParsingProfileListItem,
|
||||
): number {
|
||||
const leftPurpose = String(left.purpose || '').trim().toLowerCase();
|
||||
const rightPurpose = String(right.purpose || '').trim().toLowerCase();
|
||||
const byPurpose = purposeRank(leftPurpose) - purposeRank(rightPurpose);
|
||||
if (byPurpose !== 0) return byPurpose;
|
||||
|
||||
const leftCode = String(left.profile_code || '').trim();
|
||||
const rightCode = String(right.profile_code || '').trim();
|
||||
const byCode = leftCode.localeCompare(rightCode, undefined, { sensitivity: 'base' });
|
||||
if (byCode !== 0) return byCode;
|
||||
|
||||
return Number(right.version || 0) - Number(left.version || 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按列表契约排序解析规则(扁平结果,供查找 / 空态计数复用)。
|
||||
* @param items - 原始规则列表
|
||||
* @returns 新数组,不修改入参
|
||||
*/
|
||||
export function sortParsingProfiles<T extends ParsingProfileListItem>(items: readonly T[]): T[] {
|
||||
return [...items].sort(compareParsingProfiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用途分组;组顺序固定,空组省略,组内已排序。
|
||||
* @param items - 原始规则列表
|
||||
* @returns 非空分组列表
|
||||
*/
|
||||
export function groupParsingProfilesByPurpose<T extends ParsingProfileListItem>(
|
||||
items: readonly T[],
|
||||
): ParsingProfileListGroup<T>[] {
|
||||
const sorted = sortParsingProfiles(items);
|
||||
const buckets = new Map<string, T[]>();
|
||||
|
||||
for (const item of sorted) {
|
||||
const purpose = String(item.purpose || '').trim().toLowerCase() || 'unknown';
|
||||
const bucket = buckets.get(purpose);
|
||||
if (bucket) bucket.push(item);
|
||||
else buckets.set(purpose, [item]);
|
||||
}
|
||||
|
||||
const orderedPurposes = [
|
||||
...PARSING_PURPOSE_ORDER.filter((purpose) => buckets.has(purpose)),
|
||||
...[...buckets.keys()].filter(
|
||||
(purpose) => !(PARSING_PURPOSE_ORDER as readonly string[]).includes(purpose),
|
||||
),
|
||||
];
|
||||
|
||||
return orderedPurposes.map((purpose) => ({
|
||||
purpose,
|
||||
items: buckets.get(purpose) || [],
|
||||
}));
|
||||
}
|
||||
+7
-4
@@ -11,16 +11,19 @@ describe('ScheduleWorkbenchPanel run table actions', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
expect(content).not.toMatch(/downloadScheduleInventoryRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleReceiptRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleInboundRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleOutboundRawZip\(r\.id\)/);
|
||||
});
|
||||
|
||||
it('only shows raw inventory/receipt download when wecom deep link prompt is active', () => {
|
||||
it('only shows raw inventory/inbound/outbound download when wecom deep link prompt is active', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
expect(content).toMatch(/wecomRawZipPromptRunId/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inventory_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.receipt_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inbound_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.outbound_raw_zip_available"/);
|
||||
expect(content).toMatch(/admin\.wecomRawZipPromptRunId === admin\.expandedScheduleRun\.id/);
|
||||
expect(content).toMatch(/downloadScheduleReceiptRawZip/);
|
||||
expect(content).toMatch(/downloadScheduleInboundRawZip/);
|
||||
expect(content).toMatch(/downloadScheduleOutboundRawZip/);
|
||||
});
|
||||
});
|
||||
+24
-8
@@ -35,11 +35,13 @@ const admin = useSchedulesAdminContext();
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{
|
||||
admin.isReceiptRpaSchedule
|
||||
admin.isInboundRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedReceipt')
|
||||
: admin.isInventoryRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedInventory')
|
||||
: $t('admin.schedule.totalSkipped')
|
||||
: admin.isOutboundRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedOutbound')
|
||||
: admin.isInventoryRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedInventory')
|
||||
: $t('admin.schedule.totalSkipped')
|
||||
}}</div>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
@@ -317,17 +319,31 @@ const admin = useSchedulesAdminContext();
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.receipt_raw_zip_available"
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawReceiptZipWecomHint') }}</p>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawInboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleReceiptRawZip(admin.expandedScheduleRun.id)"
|
||||
@click="admin.downloadScheduleInboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadReceiptRawZipPackage') }}
|
||||
{{ $t('admin.schedule.downloadInboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.outbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawOutboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleOutboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadOutboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
|
||||
+13
-8
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminDeepLink.ts
|
||||
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存/收料包。
|
||||
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存/入站/出站包。
|
||||
* 依赖:vue-router、schedule-admin.state、useScheduleAdminRuns。
|
||||
* 逻辑:SchedulesPage onMounted 在 loadAll 后调用;消费 task_id/run_id/raw_zip/download,自动下载失败时保留手动入口。
|
||||
*/
|
||||
@@ -16,14 +16,14 @@ function parsePositiveInt(raw: unknown): number | null {
|
||||
|
||||
/**
|
||||
* 根据路由 query 打开工作台执行记录;raw_zip=1 时展开 run 并保留手动下载按钮。
|
||||
* 核心逻辑:download=inventory_raw_zip / receipt_raw_zip 时登录后自动下载一次;
|
||||
* 核心逻辑:download=inventory_raw_zip / inbound_raw_zip / outbound_raw_zip 时登录后自动下载一次;
|
||||
* 若企微内置浏览器拦截,用户仍可点醒目按钮重试。
|
||||
*/
|
||||
export function useScheduleAdminDeepLink(
|
||||
state: ScheduleAdminState,
|
||||
runs: Pick<
|
||||
ScheduleAdminRuns,
|
||||
'viewScheduleRuns' | 'downloadScheduleInventoryRawZip' | 'downloadScheduleReceiptRawZip'
|
||||
'viewScheduleRuns' | 'downloadScheduleInventoryRawZip' | 'downloadScheduleInboundRawZip' | 'downloadScheduleOutboundRawZip'
|
||||
>,
|
||||
) {
|
||||
const route = useRoute();
|
||||
@@ -38,8 +38,10 @@ export function useScheduleAdminDeepLink(
|
||||
const downloadKind = String(route.query.download || '');
|
||||
const shouldAutoDownloadInventory =
|
||||
rawZipPrompt && downloadKind === 'inventory_raw_zip';
|
||||
const shouldAutoDownloadReceipt =
|
||||
rawZipPrompt && downloadKind === 'receipt_raw_zip';
|
||||
const shouldAutoDownloadInbound =
|
||||
rawZipPrompt && downloadKind === 'inbound_raw_zip';
|
||||
const shouldAutoDownloadOutbound =
|
||||
rawZipPrompt && downloadKind === 'outbound_raw_zip';
|
||||
|
||||
state.scheduleViewMode.value = 'workbench';
|
||||
state.selectedScheduleId.value = taskId;
|
||||
@@ -53,10 +55,13 @@ export function useScheduleAdminDeepLink(
|
||||
if (target?.inventory_raw_zip_available && shouldAutoDownloadInventory) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleInventoryRawZip(runId);
|
||||
} else if (target?.receipt_raw_zip_available && shouldAutoDownloadReceipt) {
|
||||
} else if (target?.inbound_raw_zip_available && shouldAutoDownloadInbound) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleReceiptRawZip(runId);
|
||||
} else if (target?.inventory_raw_zip_available || target?.receipt_raw_zip_available) {
|
||||
await runs.downloadScheduleInboundRawZip(runId);
|
||||
} else if (target?.outbound_raw_zip_available && shouldAutoDownloadOutbound) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleOutboundRawZip(runId);
|
||||
} else if (target?.inventory_raw_zip_available || target?.inbound_raw_zip_available || target?.outbound_raw_zip_available) {
|
||||
// 深链仅 raw_zip=1 无 download 时仍展示手动入口。
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.spec.ts
|
||||
* 用途:锁定出站排程 job key、Worker scope 与 raw-zip 下载接线,避免回退到仅 inbound。
|
||||
* 依赖:useScheduleAdminRuns 源文件、vitest。
|
||||
* 逻辑:窄测读源码契约,不启动 Vue 运行时。
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('useScheduleAdminRuns outbound schedule wiring', () => {
|
||||
const source = readFileSync(resolve(__dirname, 'useScheduleAdminRuns.ts'), 'utf8');
|
||||
|
||||
it('recognizes freight-rpa-outbound and polls worker scope outbound', () => {
|
||||
// 关键断言:出站排程必须独立于 inbound,徽标 scope 为 outbound。
|
||||
expect(source).toContain("selectedScheduleJobKey.value === 'freight-rpa-outbound'");
|
||||
expect(source).toContain("computed<'onhand' | 'inbound' | 'outbound'>");
|
||||
expect(source).toContain("if (isOutboundRpaSchedule.value) return 'outbound'");
|
||||
expect(source).toContain('isInventoryRpaSchedule.value || isInboundRpaSchedule.value || isOutboundRpaSchedule.value');
|
||||
});
|
||||
|
||||
it('exposes outbound raw-zip download mirroring inbound', () => {
|
||||
expect(source).toContain('downloadScheduleOutboundRawZip');
|
||||
expect(source).toContain('adminRunOutboundRawZipUrl');
|
||||
expect(source).toContain('admin.schedule.msg.downloadOutboundRawZipFailed');
|
||||
});
|
||||
});
|
||||
+56
-25
@@ -2,13 +2,13 @@
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.ts
|
||||
* 执行批次列表:筛选、列宽、展开详情、Excel 下载、指标派生与 RPA Worker 心跳轮询。
|
||||
* 轮询策略(历史查询与监控职责分离):执行记录列表是纯历史查询,仅切任务/查询/重置时按需加载;
|
||||
* RPA Worker 在线状态是监控信号,仅在库存/收料排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
|
||||
* RPA Worker 在线状态是监控信号,仅在库存/入站/出站排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
|
||||
* 后台标签页暂停、请求未返回时跳过(防堆叠),使「在线/离线」徽标及时反映心跳。
|
||||
* 收料/库存排程的跳过列与统计砖分别显示「无收料/跳过」「无库存/跳过」。
|
||||
* 入站/出站/库存排程的跳过列与统计砖分别显示「无入站/跳过」「无出站/跳过」「无库存/跳过」。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, watch, type Ref } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, adminRunReceiptRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
|
||||
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, adminRunInboundRawZipUrl, adminRunOutboundRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { formatDateTime } from '../../utils/schedule-format.utils';
|
||||
@@ -53,19 +53,25 @@ export function useScheduleAdminRuns(
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-onhand',
|
||||
);
|
||||
|
||||
const isReceiptRpaSchedule = computed(
|
||||
const isInboundRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-inbound',
|
||||
);
|
||||
|
||||
const isOutboundRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-outbound',
|
||||
);
|
||||
|
||||
/**
|
||||
* 同步执行记录列表表头文案;收料/库存排程的「跳过」列分别显示无收料/无库存。
|
||||
* 同步执行记录列表表头文案;入站/出站/库存排程的「跳过」列分别显示无入站/无出站/无库存。
|
||||
*/
|
||||
const syncScheduleRunColumnLabels = () => {
|
||||
const skippedKey = isReceiptRpaSchedule.value
|
||||
const skippedKey = isInboundRpaSchedule.value
|
||||
? 'skippedCountReceipt'
|
||||
: isInventoryRpaSchedule.value
|
||||
? 'skippedCountInventory'
|
||||
: 'skippedCount';
|
||||
: isOutboundRpaSchedule.value
|
||||
? 'skippedCountOutbound'
|
||||
: isInventoryRpaSchedule.value
|
||||
? 'skippedCountInventory'
|
||||
: 'skippedCount';
|
||||
const keyToI18n: Record<string, string> = {
|
||||
run_no: 'runNo',
|
||||
started_at: 'startedAt',
|
||||
@@ -85,7 +91,7 @@ export function useScheduleAdminRuns(
|
||||
});
|
||||
};
|
||||
watch(
|
||||
[locale, isReceiptRpaSchedule, isInventoryRpaSchedule],
|
||||
[locale, isInboundRpaSchedule, isOutboundRpaSchedule, isInventoryRpaSchedule],
|
||||
syncScheduleRunColumnLabels,
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -178,15 +184,17 @@ export function useScheduleAdminRuns(
|
||||
return raw ? formatDateTime(raw) : '-';
|
||||
});
|
||||
|
||||
/** 在手(onhand)或入站(inbound)排程工作台均展示 RPA Worker 心跳徽标。 */
|
||||
/** 在手 / 入站 / 出站排程工作台均展示 RPA Worker 心跳徽标。 */
|
||||
const showsRpaWorkerStatus = computed(
|
||||
() => isInventoryRpaSchedule.value || isReceiptRpaSchedule.value,
|
||||
() => isInventoryRpaSchedule.value || isInboundRpaSchedule.value || isOutboundRpaSchedule.value,
|
||||
);
|
||||
|
||||
// scope 取值与后端 /rpa-workers/status 约定一致(Task 11 起 onhand|inbound)。
|
||||
const rpaWorkerStatusScope = computed<'onhand' | 'inbound'>(() =>
|
||||
(isReceiptRpaSchedule.value ? 'inbound' : 'onhand'),
|
||||
);
|
||||
// scope 取值与后端 /rpa-workers/status 约定一致(onhand|inbound|outbound)。
|
||||
const rpaWorkerStatusScope = computed<'onhand' | 'inbound' | 'outbound'>(() => {
|
||||
if (isOutboundRpaSchedule.value) return 'outbound';
|
||||
if (isInboundRpaSchedule.value) return 'inbound';
|
||||
return 'onhand';
|
||||
});
|
||||
|
||||
const rpaWorkerLastHeartbeatAt = computed(() => {
|
||||
const workers = rpaWorkerStatus.value?.workers || [];
|
||||
@@ -217,12 +225,12 @@ export function useScheduleAdminRuns(
|
||||
}
|
||||
};
|
||||
|
||||
// ── RPA Worker 心跳轮询(监控信号,库存/收料排程) ───────────────────────
|
||||
// ── RPA Worker 心跳轮询(监控信号,库存/入站/出站排程) ───────────────────────
|
||||
// 心跳由 Worker 每约 20s 上报一次(服务端 TTL 默认 90s),UI 每 10s 刷新即足够;
|
||||
// 2s 固定轮询只有少量时间点在变化,属于对无变化数据的过度请求。
|
||||
const RPA_WORKER_STATUS_POLL_MS = 10_000;
|
||||
|
||||
/** 是否需要前台轮询心跳:工作台模式且当前排程为库存或收料类 */
|
||||
/** 是否需要前台轮询心跳:工作台模式且当前排程为库存、入站或出站类 */
|
||||
const shouldPollRpaWorkerStatus = computed(
|
||||
() => scheduleViewMode.value === 'workbench' && showsRpaWorkerStatus.value && !!selectedScheduleId.value,
|
||||
);
|
||||
@@ -334,12 +342,12 @@ export function useScheduleAdminRuns(
|
||||
};
|
||||
|
||||
/**
|
||||
* 下载收料原始 ZIP;API 与文件名口径对齐库存 raw zip。
|
||||
* 下载入站原始 ZIP;API 与文件名口径对齐库存 raw zip。
|
||||
*/
|
||||
const downloadScheduleReceiptRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunReceiptRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
const downloadScheduleInboundRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunInboundRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
msg.error(t('admin.schedule.msg.downloadReceiptRawZipFailed'));
|
||||
msg.error(t('admin.schedule.msg.downloadInboundRawZipFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
@@ -347,7 +355,28 @@ export function useScheduleAdminRuns(
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '收料RPA-收料.zip';
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '入站RPA-入站.zip';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
/**
|
||||
* 下载出站原始 ZIP;API 与文件名口径对齐入站 raw zip。
|
||||
*/
|
||||
const downloadScheduleOutboundRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunOutboundRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
msg.error(t('admin.schedule.msg.downloadOutboundRawZipFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '出站RPA-出站.zip';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
@@ -368,7 +397,8 @@ export function useScheduleAdminRuns(
|
||||
selectedScheduleRunMetrics,
|
||||
selectedScheduleLatestRunAt,
|
||||
isInventoryRpaSchedule,
|
||||
isReceiptRpaSchedule,
|
||||
isInboundRpaSchedule,
|
||||
isOutboundRpaSchedule,
|
||||
showsRpaWorkerStatus,
|
||||
rpaWorkerLastHeartbeatAt,
|
||||
refreshRpaWorkerStatus,
|
||||
@@ -376,7 +406,8 @@ export function useScheduleAdminRuns(
|
||||
viewScheduleRuns,
|
||||
downloadScheduleExcel,
|
||||
downloadScheduleInventoryRawZip,
|
||||
downloadScheduleReceiptRawZip,
|
||||
downloadScheduleInboundRawZip,
|
||||
downloadScheduleOutboundRawZip,
|
||||
startScheduleColResize,
|
||||
formatDateTime,
|
||||
isScheduleRunExcelExportFailed,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { adminRoutes } from '@/app/router/routes/admin.routes';
|
||||
import zhCnAdmin from '@/locales/zh-CN/admin.json';
|
||||
import { ADMIN_MODULE_METAS, SHIPPING_CONFIG_SUB_MODULE_METAS } from './constants/modules';
|
||||
import type { ShippingManagementGroupKey } from './stores/admin-nav.store';
|
||||
|
||||
@@ -22,6 +23,14 @@ const shippingRoutes = adminRoutes[0].children?.filter((route) =>
|
||||
) ?? [];
|
||||
|
||||
describe('shipping configuration navigation contract', () => {
|
||||
it('exposes renamed freight RPA entry labels in zh-CN admin locale', () => {
|
||||
// 关键断言:管理端入口文案与规格一致(报表规则 / 来源站点 / 入站报表配置)。
|
||||
expect(zhCnAdmin.freightRpa.parsingProfiles).toBe('报表规则');
|
||||
expect(zhCnAdmin.freightRpa.sources).toBe('来源站点');
|
||||
expect(zhCnAdmin.freightRpa.inboundReportConfig).toBe('入站报表配置');
|
||||
expect(zhCnAdmin.freightRpa.outboundReportConfig).toBe('出站报表配置');
|
||||
});
|
||||
|
||||
it('keeps shipping management between schedules and announcements', () => {
|
||||
// 关键断言:货代管理必须保持在排程管理之后、公告管理之前,匹配后台约定的信息架构。
|
||||
const moduleIds = ADMIN_MODULE_METAS.map((item) => item.id);
|
||||
|
||||
Reference in new issue
Block a user