Merge branch 'hugo-shipping-notice' into dev

This commit is contained in:
hugo committed 2026-09-18 15:08:38 +08:00
commit 0e4e581f9a
89 files changed
+7559 -816

No files matched your search

@@ -129,88 +129,44 @@
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode" class="select-field"><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" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.snapshotTtl') }}</span><input v-model.number="source.snapshot_ttl_seconds" class="input-field" min="1" type="number" required></label>
<section v-if="selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
<header class="readiness-heading">
<div>
<span class="readiness-kicker">{{ t('admin.shippingInventory.activationStatus') }}</span>
<strong>{{ readinessHeadline }}</strong>
<p>{{ readinessGuidance }}</p>
</div>
<span class="readiness-count">{{ readinessSummary }}</span>
</header>
<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>
<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">
<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 v-if="source.enabled || source.activation?.ready" class="readiness-footer">
<button v-if="source.enabled" type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
<button
v-else
type="button"
class="btn-primary btn-sm"
:disabled="sourceDirty"
:title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined"
@click="requestSourceActivation"
>{{ t('admin.shippingInventory.activateSource') }}</button>
</footer>
</section>
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
<template v-if="source.connector_type === 'dbs'">
<div class="subsection full">{{ t('admin.shippingInventory.reportPath') }}</div>
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
<section class="path-card full">
<button type="button" class="path-card-header" :aria-expanded="inventoryPathOpen" @click="inventoryPathOpen = !inventoryPathOpen">
<span class="path-card-title"><b>{{ t('admin.shippingInventory.reportPath') }}</b></span>
<span class="path-card-toggle" aria-hidden="true">{{ inventoryPathOpen ? '▾' : '▸' }}</span>
</button>
<div v-show="inventoryPathOpen" class="path-card-body">
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
</template>
<section v-if="selectedId" class="receipt-report-config full">
<div class="subsection">{{ t('admin.shippingInventory.receiptReportConfig') }}<small>{{ t('admin.shippingInventory.receiptReportConfigHint') }}</small></div>
<div class="switch-field"><span>{{ t('admin.shippingInventory.receiptReportEnabled') }}</span><button type="button" class="status-switch" :class="{ on: receiptConfig.enabled }" role="switch" :aria-checked="receiptConfig.enabled" @click="receiptConfig.enabled = !receiptConfig.enabled"><i></i><b>{{ receiptConfig.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
</section>
</template>
<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.shippingInventory.receiptReportConfig') }}</b><small>{{ t('admin.shippingInventory.receiptReportConfigHint') }}</small></span>
<span class="path-badge" :class="receiptConfigExists ? 'on' : 'off'">{{ receiptConfigExists ? t('admin.shippingInventory.pathSectionConfigured') : t('admin.shippingInventory.pathSectionNotConfigured') }}</span>
<span class="path-card-toggle" aria-hidden="true">{{ receiptSectionOpen ? '▾' : '▸' }}</span>
</button>
<div v-show="receiptSectionOpen" class="path-card-body">
<template v-if="source.connector_type === 'dbs'">
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="receiptConfig.report_path_json.program_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="receiptConfig.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="receiptConfig.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="receiptConfig.report_path_json.report_name" class="input-field" required></label>
<label class="full"><span>{{ t('admin.shippingInventory.receiptWarehouses') }}</span><input class="input-field" :value="receiptConfig.warehouse_ids_json.join(', ')" :placeholder="t('admin.shippingInventory.receiptWarehousesHint')" @input="receiptConfig.warehouse_ids_json = splitValues(($event.target as HTMLInputElement).value)"></label>
<div class="subsection full">{{ t('admin.shippingInventory.receiptOptionalParameters') }}</div>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}<small>{{ t('admin.shippingInventory.receiptQueryParametersHint') }}</small></div>
<div v-for="(parameter, index) in receiptConfig.query_parameters_json" :key="`receipt-${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
@@ -222,8 +178,8 @@
<button type="button" class="btn-secondary btn-sm full" @click="addReceiptParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
</template>
<p v-else class="form-tip full">{{ t('admin.shippingInventory.receiptCraneFixedPath') }}</p>
<div class="receipt-config-actions full"><button type="button" class="btn-secondary btn-sm" :disabled="receiptConfigLoading || receiptConfigSaving" @click="saveReceiptConfig">{{ receiptConfigSaving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.saveReceiptReportConfig') }}</button></div>
</section>
</div>
</section>
</template>
<template v-else-if="activeTab === 'parsing'">
@@ -377,6 +333,48 @@
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: mapping.enabled }" role="switch" :aria-checked="mapping.enabled" @click="mapping.enabled = !mapping.enabled"><i></i><b>{{ mapping.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
</template>
<section v-if="selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
<div class="readiness-inline">
<template v-if="source.enabled">
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationReady') }}</b><small v-if="configurationTest?.completed_at">{{ t('admin.shippingInventory.readinessLastVerified', { time: formatDate(configurationTest.completed_at) }) }}</small></div>
<button type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
</template>
<template v-else-if="firstBlockingCheck">
<span class="readiness-marker" :class="`is-${firstBlockingCheck.status}`" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.readinessBlockedBy', { requirement: t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }) }}</b><small>{{ t('admin.shippingInventory.readinessAutoEnableHint') }}</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>
</template>
<template v-else>
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationCanEnable') }}</b></div>
<button type="button" class="btn-primary btn-sm" :disabled="sourceDirty" :title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="requestSourceActivation">{{ t('admin.shippingInventory.activateSource') }}</button>
</template>
</div>
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.readinessOptionalPending', { count: optionalReadinessPending }) }}</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 v-if="configurationTest.status === 'failed'" class="readiness-run failed">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
<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>
<details v-if="configurationTest.status !== 'failed'" class="readiness-audit">
<summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }} · {{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</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>
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
<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>
</details>
</template>
</section>
<div v-if="isEditableTab" class="form-actions full">
<button v-if="!parsingReadOnly" type="submit" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
@@ -627,9 +625,12 @@ const bulkBinding = reactive({ visible: false, sourceIds: [] as number[], profil
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 receiptConfig = reactive({ enabled: false, report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], warehouse_ids_json: [] as string[] });
const receiptConfigLoading = ref(false);
const receiptConfigSaving = ref(false);
const receiptConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[] });
const receiptConfigExists = ref(false);
const receiptSectionTouched = ref(false);
const receiptSectionOpen = ref(false);
const inventoryPathOpen = ref(true);
const receiptBaseline = 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({ 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 });
@@ -646,26 +647,15 @@ const matchingOrderFields = computed(() => routingFields.value.filter((field) =>
const canAddParsingMatchKey = computed(() => Boolean(
structureAnalysis.value && unusedMatchingInventoryFields.value.length && unusedOrderMatchFields.value.length,
));
const sourceDirty = computed(() => Boolean(selectedId.value && sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput()));
const sourceDirty = computed(() => Boolean(selectedId.value && (
(sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput())
|| (receiptConfigExists.value && receiptBaseline.value && receiptBaseline.value !== serialiseReceiptInput())
)));
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 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 optionalReadinessPending = computed(() => optionalReadinessChecks.value.filter((item) => item.status !== 'passed').length);
const sampleReplacementNotice = computed(() => {
const difference = pendingSampleReplacement.value?.difference || {};
const missing = Array.isArray(difference.missing_mapped_headers) ? difference.missing_mapped_headers : [];
@@ -848,36 +838,37 @@ async function load(): Promise<void> {
}
}
/** 重置当前站点的独立收料表单,不借用库存报表路径或查询条件。 */
/** 重置当前站点的独立收料表单与卡片状态,与库存同构(路径+查询条件)。 */
function resetReceiptConfig(connectorType: unknown): void {
Object.assign(receiptConfig, {
enabled: false,
report_path_json: String(connectorType || '').toLowerCase() === 'crane'
? { report_name: 'Inbound Details' }
: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' },
query_parameters_json: [],
warehouse_ids_json: [],
});
}
/** 读取收料独立配置;读取失败不影响库存站点配置和既有库存运行。 */
async function loadReceiptConfig(sourceId: number, connectorType: unknown): Promise<void> {
receiptConfigLoading.value = true;
resetReceiptConfig(connectorType);
receiptConfigExists.value = false;
receiptSectionTouched.value = false;
receiptSectionOpen.value = false;
receiptBaseline.value = '';
try {
const config = await getShippingReceiptReportConfig(sourceId);
if (!config) return;
const isCrane = String(connectorType || '').toLowerCase() === 'crane';
Object.assign(receiptConfig, {
enabled: Boolean(config.enabled),
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 })) : [],
warehouse_ids_json: Array.isArray(config.warehouse_ids_json) ? [...config.warehouse_ids_json].map(String) : [],
});
receiptConfigExists.value = true;
receiptSectionOpen.value = true;
} catch (cause) { showError(cause, 'loadFailed'); }
finally { receiptConfigLoading.value = false; }
finally { receiptBaseline.value = serialiseReceiptInput(); }
}
/** 新增 DBS 可选收料条件;Crane 固定默认查询,不维护查询条件。 */
@@ -885,16 +876,10 @@ function addReceiptParameter(): void {
receiptConfig.query_parameters_json.push({ name: '', mode: 'single', values: [], required: false, select_all: false });
}
/** 仅提交白名单收料字段到独立 API,绝不调用库存 Source 保存接口。 */
async function saveReceiptConfig(): Promise<void> {
if (!selectedId.value) return;
receiptConfigSaving.value = true;
try {
await saveShippingReceiptReportConfig(selectedId.value, buildReceiptReportConfigPayload(receiptConfig));
await loadReceiptConfig(selectedId.value, source.connector_type);
message.success(t('admin.shippingInventory.receiptReportSaved'));
} catch (cause) { showError(cause, 'saveFailed'); }
finally { receiptConfigSaving.value = false; }
/** 展开收料卡即视为有配置意图:统一保存时会提交收料配置,避免未展开时误建空配置。 */
function toggleReceiptSection(): void {
receiptSectionOpen.value = !receiptSectionOpen.value;
if (receiptSectionOpen.value) receiptSectionTouched.value = true;
}
/** 切换管理对象时同步深链并清空选择,避免不同对象的数据残留在编辑器中。 */
@@ -949,6 +934,11 @@ function createNew(): void {
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: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
resetReceiptConfig('dbs');
receiptConfigExists.value = false;
receiptSectionTouched.value = false;
receiptSectionOpen.value = false;
inventoryPathOpen.value = true;
receiptBaseline.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: [] });
@@ -1174,7 +1164,21 @@ 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, report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json) }, 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 (selectedId.value && (receiptSectionTouched.value || (receiptConfigExists.value && receiptBaseline.value !== serialiseReceiptInput()))) {
try {
await saveShippingReceiptReportConfig(selectedId.value, buildReceiptReportConfigPayload(receiptConfig));
receiptConfigExists.value = true;
receiptBaseline.value = serialiseReceiptInput();
} catch (cause) {
showError(cause, 'saveFailed');
await load();
return; // 站点已保存但收料保存失败:保持抽屉打开,修正后可直接重试统一保存。
}
}
}
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();
@@ -1553,6 +1557,14 @@ function serialiseSourceInput(): string {
});
}
/** 将收料配置表单稳定序列化,作为统一保存与启用守卫的收料脏检查基线。 */
function serialiseReceiptInput(): string {
return JSON.stringify({
report_path_json: receiptConfig.report_path_json,
query_parameters_json: receiptConfig.query_parameters_json,
});
}
/** 返回状态轨道的简洁可视标记,文本状态仍由相邻内容提供,避免颜色成为唯一信息来源。 */
function readinessMarker(status: ShippingInventoryReadinessCheck['status']): string {
const marker = readinessMarkerKind(status);
@@ -1673,10 +1685,10 @@ onMounted(load);
.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: 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-inline { display: flex; align-items: center; gap: 10px; }.readiness-inline .readiness-copy { flex: 1 1 auto; }.readiness-inline .readiness-copy b { white-space: normal; }.readiness-inline .readiness-copy small { white-space: normal; }.readiness-inline .btn-sm, .readiness-inline .readiness-action { flex: 0 0 auto; }
.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-inline > .readiness-marker.is-passed { background: #dff6e6; color: #16803a; }.readiness-inline > .readiness-marker.is-failed, .readiness-inline > .readiness-marker.is-stale { background: #fff0ed; color: #bf4a38; }
.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; }
.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; }
.form-tip { border-radius: 8px; background: #f1f6fa; padding: 11px; color: #5d7084; font-size: 12px; line-height: 1.55; }
.upload-config-section { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid #e1edf2; border-radius: 9px; background: #fff; padding: 0 12px 12px; }.upload-config-heading { display: grid; gap: 2px; grid-column: 1 / -1; padding: 11px 0 8px; }.upload-config-heading b { color: #385166; font-size: 12px; }.upload-config-heading small { color: #8192a0; font-size: 11px; }.upload-config-section .full { grid-column: 1 / -1; }.upload-config-section textarea.input-field { resize: vertical; }
.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; }
@@ -1685,9 +1697,12 @@ onMounted(load);
.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; }
.sample-replacement-input { display: grid; gap: 6px; border-top: 1px solid #e5edf3; padding-top: 11px; color: #52677a; font-size: 12px; font-weight: 600; }.sample-replacement-input input { max-width: 100%; }.sample-replacement-warning { border-left: 3px solid #e5a21a; background: #fff9eb; padding: 8px 10px; color: #855e00 !important; }.sample-replacement-warning p { margin: 0; }.sample-replacement-warning ul { display: grid; gap: 3px; margin: 7px 0 0; padding-left: 17px; }
.parameter-row { display: grid; align-items: center; grid-template-columns: 1.1fr .9fr 1.25fr auto auto auto; gap: 8px; border-radius: 8px; background: #f8fafc; padding: 9px; }
.receipt-report-config { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid #dbe8ee; margin-top: 8px; padding-top: 14px; }
.receipt-report-config .subsection, .receipt-report-config .full { grid-column: 1 / -1; }
.receipt-config-actions { display: flex; justify-content: flex-end; }
.path-card { display: grid; grid-column: 1 / -1; border: 1px solid #dbe8ee; border-radius: 10px; background: #fff; overflow: hidden; }
.path-card-header { display: flex; align-items: center; gap: 10px; border: 0; background: #f7fbfd; padding: 10px 12px; cursor: pointer; font: inherit; text-align: left; }.path-card-header:hover { background: #eff7fa; }
.path-card-title { display: grid; flex: 1 1 auto; min-width: 0; gap: 2px; }.path-card-title b { color: #145f5a; font-size: 12px; font-weight: 800; }.path-card-title small { color: #94a3b8; font-size: 11px; font-weight: 400; }
.path-badge { flex: 0 0 auto; border-radius: 999px; background: #eef2f5; padding: 3px 8px; color: #7b8998; font-size: 11px; font-weight: 700; }.path-card.configured .path-badge.on { background: #e6f6ec; color: #19703a; }
.path-card-toggle { flex: 0 0 auto; color: #4d849f; font-size: 14px; line-height: 1; }
.path-card-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid #e6eef4; padding: 14px 12px; }.path-card-body .full { grid-column: 1 / -1; }
.condition-row, .mapping-row, .template-mapping { display: grid; align-items: center; gap: 8px; border-radius: 8px; background: #f8fafc; padding: 9px; }
.condition-row { grid-template-columns: 1.15fr .9fr 1fr auto; }
.mapping-row { grid-template-columns: 1fr 1fr auto; }
@@ -1728,5 +1743,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) { .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, .receipt-report-config { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .btn-primary { 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 .btn-primary { 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, .path-card-body { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .btn-primary { 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-inline { flex-wrap: wrap; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; } }
</style>
@@ -2,7 +2,8 @@
* features/admin/modules/shipping-inventory/receiptReportConfigForm.spec.ts
* 用途:覆盖收料报表表单的独立载荷边界。
* 依赖:receiptReportConfigForm、vitest。
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口。
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口;
* 收料无独立启停字段,载荷不得包含 enabled。
*/
import { describe, expect, it } from 'vitest';
@@ -10,24 +11,30 @@ import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
describe('receiptReportConfigForm', () => {
it('builds a receipt-only payload without inventory source fields', () => {
// 关键断言:收料路径、条件与仓库必须走独立 API,不能夹带库存 RPA 配置。
// 关键断言:收料路径与条件必须走独立 API,不能夹带库存 RPA 配置或启停字段。
const payload = buildReceiptReportConfigPayload({
enabled: true,
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
query_parameters_json: [{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false }],
warehouse_ids_json: ['A', 'B'],
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 buildReceiptReportConfigPayload>[0] & Record<string, unknown>);
expect(payload).toEqual({
enabled: true,
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
query_parameters_json: [{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false }],
warehouse_ids_json: ['A', 'B'],
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 },
],
});
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');
});
});
@@ -2,14 +2,13 @@
* features/admin/modules/shipping-inventory/receiptReportConfigForm.ts
* 用途:构建独立收料报表配置的受限保存载荷。
* 依赖:无外部依赖。
* 逻辑:页面仅将收料路径、可选条件和 Warehouse 列表提交到收料配置 API,隔离库存站点字段。
* 逻辑:页面仅将收料路径与查询条件提交到收料配置 API,与库存同构(Warehouse 为条件之一),
* 隔离库存站点字段;收料无独立启停字段,是否运行统一由库存站点 enabled 决定。
*/
export type ReceiptReportConfigInput = {
enabled: boolean;
report_path_json: Record<string, unknown>;
query_parameters_json: Array<Record<string, unknown>>;
warehouse_ids_json: string[];
};
/**
@@ -20,9 +19,7 @@ export type ReceiptReportConfigInput = {
*/
export function buildReceiptReportConfigPayload(input: ReceiptReportConfigInput): ReceiptReportConfigInput {
return {
enabled: Boolean(input.enabled),
report_path_json: { ...(input.report_path_json || {}) },
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
warehouse_ids_json: [...(input.warehouse_ids_json || [])],
};
}
@@ -1178,7 +1178,7 @@ export async function updateWorkspaceShippingNoticeFields(
taskNo: string,
fields: Partial<ShippingNoticeHeader>,
comment: string | undefined,
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence: ShippingReviewEvidence; reason: string },
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence?: ShippingReviewEvidence; reason?: string },
) {
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-fields`,
@@ -1186,8 +1186,9 @@ export async function updateWorkspaceShippingNoticeFields(
fields,
...(comment ? { comment } : {}),
expected_order_data_version: options.expectedOrderDataVersion,
evidence: options.evidence,
reason: options.reason,
// 证据/理由改为可选:未传时不带字段,与后端免证据编辑通道(Task 2)对齐。
...(options.evidence ? { evidence: options.evidence } : {}),
...(options.reason ? { reason: options.reason } : {}),
...(options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
}),
);
@@ -1207,7 +1208,7 @@ export async function updateWorkspaceShippingNoticeLine(
lineIndex: number,
patch: Partial<ShippingNoticeLine> & { quantity?: number },
comment: string | undefined,
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence: ShippingReviewEvidence; reason: string },
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence?: ShippingReviewEvidence; reason?: string },
) {
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-line`,
@@ -1216,8 +1217,9 @@ export async function updateWorkspaceShippingNoticeLine(
patch,
...(comment ? { comment } : {}),
expected_order_data_version: options.expectedOrderDataVersion,
evidence: options.evidence,
reason: options.reason,
// 证据/理由改为可选:未传时不带字段,与后端免证据编辑通道(Task 2)对齐。
...(options.evidence ? { evidence: options.evidence } : {}),
...(options.reason ? { reason: options.reason } : {}),
...(options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
}),
);
@@ -1186,8 +1186,11 @@ export function useShippingOrderReview(options: {
statusMessage.value = null;
}
} finally {
if (generation !== caseLoadGeneration) return;
// [2026-09-17] initialLoading 仅由 isInitialLoad 的本 load 置位,必须无条件收尾:
// 被 loadReviewCase 等懒加载路径接管代际时,代际守卫之后的清旗会被跳过,
// 首屏永久卡在「正在加载复核结果...」。
if (isInitialLoad) initialLoading.value = false;
if (generation !== caseLoadGeneration) return;
runLoading.value = false;
// 跨 Run 的 beginCrossRunSwitch 会提前打开 caseSwitchLoading;整页 load 收尾必须关掉。
caseSwitchLoading.value = false;
@@ -17,8 +17,9 @@
-->
<script setup lang="ts">
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import type { Component } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Pencil, Plus, RefreshCw, Undo2, Copy, Trash2, X } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
@@ -37,6 +38,7 @@ import {
retryWorkspaceShippingOrderStpAutoCreate,
retryShippingNoticeIntake,
decideWorkspaceShippingOrderReviewLineFulfillment,
updateWorkspaceShippingNoticeLine,
waveWorkspaceShippingOrderReviewLineFulfillment,
setWorkspaceShippingTaskOdmChoice,
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
@@ -1363,6 +1365,9 @@ onMounted(() => {
document.addEventListener('keydown', onExceptionNavKeydown, true);
// [PERF] 深链进入时尽早并行发起任务详情,与 load() 重叠,削减首屏串行加载。
prefetchDeepLinkedTaskDetail();
// OT 直链(无 case_no)下 confirmedNoticeTaskNo 恒空、watch(hasFormalOt) 永不触发;
// 挂载即消费深链预取(复用同一请求,不重复拉取),任务详情才能落地驱动五阶段页签。
if (deepLinkOrderTaskNo.value) void loadFormalTaskDetail();
});
onBeforeUnmount(() => {
@@ -1927,7 +1932,8 @@ async function handleCurrentTaskAction(
break;
case 'open_inventory_match_review':
if (hasFormalOt.value) {
scrollWorkbenchAnchor('review-order-lines-table');
// 正式 OT 后匹配/缺口语境的真实宿主是通知准备工作区;订单明细表不承载库存结果。
scrollWorkbenchAnchor('review-fulfillment-prep-workspace');
} else {
workbenchMode.value = 'inventory';
scrollWorkbenchAnchor('review-inventory-issue-list');
@@ -2430,6 +2436,15 @@ const confirmedNoticeTaskNo = computed(() => String(
|| '',
).trim());
/**
* 深链显式携带的 OT 号(任务中心抽屉等 OT 直链)。
* 仅认 OT- 前缀;Notice 的 SN 号不是 work-item 键,与 externalOrderTaskNo 同一口径。
*/
const deepLinkOrderTaskNo = computed(() => {
const taskNo = String(route.query.task_no || '').trim();
return taskNo.startsWith('OT-') ? taskNo : '';
});
const freightNoticeGroups = ref<ShippingFreightNoticeGroup[]>([]);
const freightNoticeGroupsLoading = ref(false);
const freightNoticeGroupsReason = ref<string | null>(null);
@@ -2591,9 +2606,8 @@ function formalPreparationLineSource(line: {
/** 锁定边界 = Excel 生成(D7):后端 preparation.source_locked 下发,生成后行源只读。 */
const formalPreparationSourceLocked = computed(() => Boolean(formalPreparationContext.value?.source_locked));
/** 多文件冲突行的行内选源暂存(line_no → 选定 source_code),提交后由后端映射快照行并重匹配。 */
const lineSourceSelections = ref<Record<string, string>>({});
const lineSourceBusy = ref(false);
/** 库存源选择不再有独立确认流:行进入就地编辑态后在下拉中改选,随行级「保存」统一提交
* (override_line_inventory_source Gate 动作,见 saveInlineEdit);展示态回退为文本。 */
/** 选源下拉项文案:源编码始终可见(等宽语义由样式层保证)。 */
function lineSourceOptionLabel(code: string): string {
@@ -2601,58 +2615,14 @@ function lineSourceOptionLabel(code: string): string {
return String(code || '').trim().toUpperCase();
}
/**
* 提交歧义行选定源:走正式 Gate 动作 override_line_inventory_source(方案 3·放开,唯一选源入口),
* 后端校验启用/Excel 锁并仅重匹配该行;成功后清空行内暂存并刷新任务详情。
*/
async function submitLineSourceSelection(line: { snapshot_line_id?: number | null; line_no?: string | number | null }) {
const selectionKey = String(line.snapshot_line_id ?? '');
const sourceCode = String(lineSourceSelections.value[selectionKey] || '').trim();
const lineNo = Number(line.line_no);
if (!sourceCode || !Number.isInteger(lineNo) || lineNo < 1 || lineSourceBusy.value) return;
lineSourceBusy.value = true;
try {
await submitFormalGateAction('override_line_inventory_source', {
line_no: lineNo,
source_code: sourceCode,
});
delete lineSourceSelections.value[selectionKey];
} finally {
lineSourceBusy.value = false;
}
}
/** 人工覆写库存源(方案 3·放开):后端下发全部已启用源 source_options,供行级下拉人工指定。 */
const formSourceOptions = computed(() => formalPreparationContext.value?.source_options || []);
const overrideSourceSelections = ref<Record<string, string>>({});
const overrideSourceBusy = ref(false);
function overrideSourceOptionLabel(code: string): string {
// 兜底:下拉只展示源编码(如 DSV360_AWSSG),不展示冗长 display_name,便于快速识别。
return String(code || '').trim().toUpperCase();
}
/**
* 提交人工覆写行库存源:走正式 Gate 动作 override_line_inventory_source(方案 3·放开),
* 后端校验源启用/Excel 锁并仅重匹配该行;成功后清空暂存并刷新任务详情。
*/
async function submitOverrideSource(line: { snapshot_line_id?: number | null; line_no?: string | number | null }) {
const selectionKey = String(line.snapshot_line_id ?? '');
const sourceCode = String(overrideSourceSelections.value[selectionKey] || '').trim();
const lineNo = Number(line.line_no);
if (!sourceCode || !Number.isInteger(lineNo) || lineNo < 1 || overrideSourceBusy.value) return;
overrideSourceBusy.value = true;
try {
await submitFormalGateAction('override_line_inventory_source', {
line_no: lineNo,
source_code: sourceCode,
});
delete overrideSourceSelections.value[selectionKey];
} finally {
overrideSourceBusy.value = false;
}
}
/** 整单 ODM 裁决列可见性:任一行候选多于一个时展示(候选已经客户范围过滤)。 */
const formalPreparationOdmColumnVisible = computed(() =>
(formalPreparationContext.value?.lines || []).some((line) => (line.odm_values?.length || 0) > 1),
@@ -2749,7 +2719,7 @@ async function confirmReleaseInventoryShortage() {
const caseNo = activeCase.value?.case_no;
const reason = releaseInventoryReason.value.trim();
const requiredFields = line?.release_required_fields || [];
if (!line || !caseNo || !reason || requiredFields.some((field) => !releaseInventoryFieldValues.value[field.field_id]?.trim()) || releaseInventoryBusy.value) return;
if (!line || !caseNo || requiredFields.some((field) => !releaseInventoryFieldValues.value[field.field_id]?.trim()) || releaseInventoryBusy.value) return;
releaseInventoryBusy.value = true;
try {
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
@@ -2776,6 +2746,160 @@ function formalPreparationLineInventoryFileNo(line: { snapshot_line_id?: number
return String(line.inventory_file_no || fulfillment?.inventory_file_no || '').trim();
}
/** 行内放行补录条(常显子行):短缺行携带必填放行字段时直接在行下补填,替代弹窗。 */
const releaseBarValues = ref<Record<string, Record<string, string>>>({});
const releaseBarBusy = ref<Record<string, boolean>>({});
function releaseBarKey(line: { snapshot_line_id?: number | null }): string {
return String(line.snapshot_line_id ?? '');
}
/** 放行必填字段:仅短缺行且投影声明了必填补录项(有候选缺失才需要补录)。 */
function releaseBarLineRequiredFields(line: { snapshot_line_id?: number | null }) {
const fulfillment = formalPreparationLineFulfillment(line);
return fulfillment?.release_required_fields || [];
}
/** 缺字段型短缺行:放行走行内补录(而非仅原因的旧弹窗路径)。 */
function releaseBarHasFields(line: {
snapshot_line_id?: number | null;
shortage_qty?: string | number | null;
}): boolean {
return Number(line.shortage_qty || 0) > 0 && releaseBarLineRequiredFields(line).length > 0;
}
/** 补录条展开态:默认收起(表格保持干净),由 ⋯ 菜单「放行缺口」或缺 N 项徽标点击展开。 */
const releaseBarExpandedFor = ref<string | null>(null);
function expandReleaseBar(line: { snapshot_line_id?: number | null }) {
if (inlineEditBusy.value) {
msg.warning(t('chat.shippingOrderReview.inlineEdit.busy'));
return;
}
releaseBarExpandedFor.value = releaseBarKey(line);
}
function releaseBarValue(
line: { snapshot_line_id?: number | null },
field: { field_id?: string | null },
): string {
return releaseBarValues.value[releaseBarKey(line)]?.[String(field.field_id)] ?? '';
}
function updateReleaseBarValue(
line: { snapshot_line_id?: number | null },
field: { field_id?: string | null },
value: string,
) {
const key = releaseBarKey(line);
releaseBarValues.value = {
...releaseBarValues.value,
[key]: { ...(releaseBarValues.value[key] || {}), [String(field.field_id)]: value },
};
}
/** 放行按钮可用性:后端授权 + 必填补录项全部已填 + 非保存中。 */
function releaseBarReadyFor(line: { snapshot_line_id?: number | null }): boolean {
const fulfillment = formalPreparationLineFulfillment(line);
const required = releaseBarLineRequiredFields(line);
return Boolean(
fulfillment?.line_allowed_actions?.includes('release_inventory_shortage')
&& required.every((field) => releaseBarValue(line, field).trim())
&& !releaseBarBusy.value[releaseBarKey(line)],
);
}
/** 行内放行提交:走既有 decide 通道;原因可选(人工放行事实由审计链记录)。 */
async function confirmReleaseBar(line: { snapshot_line_id?: number | null }) {
const caseNo = activeCase.value?.case_no;
const fulfillment = formalPreparationLineFulfillment(line);
const key = releaseBarKey(line);
const required = releaseBarLineRequiredFields(line);
if (
!caseNo || !fulfillment?.draft_line_id
|| !required.every((field) => releaseBarValue(line, field).trim())
|| releaseBarBusy.value[key]
) return;
releaseBarBusy.value = { ...releaseBarBusy.value, [key]: true };
try {
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
draft_line_id: String(fulfillment.draft_line_id || ''),
decision_code: 'release_inventory_shortage',
reason: '',
release_field_values: { ...(releaseBarValues.value[key] || {}) },
expected_draft_version: activeCase.value?.draft?.draft_version,
});
const next = { ...releaseBarValues.value };
delete next[key];
releaseBarValues.value = next;
// 放行写入成功即结束用户交互;Notice/Excel 由后端 Job 异步创建(与原弹窗通道一致)。
handleGateRecoveryAccepted({ releaseAutoAdvance: true });
} catch (error) {
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
} finally {
releaseBarBusy.value = { ...releaseBarBusy.value, [key]: false };
}
}
/** 行结案弹窗状态;与放行缺口弹窗同款交互(原因必填),走 line-fulfillment decide 通道。 */
const closeLineDialogLine = ref<ShippingOrderReviewLineFulfillmentLine | null>(null);
const closeLineReason = ref('');
const closeLineBusy = ref(false);
/**
* 结案按钮可见性:仅「无货可发」的未终态 prep 行开放。
* 核心逻辑:line_allowed_actions 由后端投影下发(终态行返回空数组,天然排除已结案/
* 已放行/已入波次行),前端再叠加短缺信号(is_shortage / 缺量>0 / not_found)过滤;
* 后端 decide API 才是权威闸门,这里只做入口收敛。
*/
function formalPreparationLineCloseVisible(line: { snapshot_line_id?: number | null; shortage_qty?: string | number | null }): boolean {
if (!formalPreparationLineAllows(line, 'close_unfulfillable')) return false;
const fulfillment = formalPreparationLineFulfillment(line);
if (fulfillment?.decision?.decision_code === 'close_unfulfillable') return false;
const notFound = String(fulfillment?.match_result || '').trim().toLowerCase() === 'not_found';
const shortageQty = Number(line.shortage_qty ?? fulfillment?.shortage_qty ?? 0) > 0;
return Boolean(fulfillment?.is_shortage) || shortageQty || notFound;
}
/**
* 打开行结案弹窗:按快照行身份定位履约投影行(携带 draft_line_id)。
* 核心逻辑:与行内编辑互斥——弹窗打开即取消该行编辑态,避免两套写路径叠加。
*/
function openCloseLineDialog(line: { snapshot_line_id?: number | null }) {
const fulfillment = formalPreparationLineFulfillment(line);
if (!fulfillment) return;
cancelInlineEdit();
closeLineDialogLine.value = fulfillment;
closeLineReason.value = '';
}
/**
* 提交行结案决定(decision_code='close_unfulfillable',原因必填)。
* 核心逻辑:复用既有 line-fulfillment decide API;成功后走恢复协调刷新三投影,
* prep 表即时反映已结案状态(后端拒绝无效流转时以 BusinessError 文案提示)。
*/
async function confirmCloseLine() {
const line = closeLineDialogLine.value;
const caseNo = activeCase.value?.case_no;
const reason = closeLineReason.value.trim();
if (!line || !caseNo || !reason || closeLineBusy.value) return;
closeLineBusy.value = true;
try {
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
draft_line_id: String(line.draft_line_id || ''),
decision_code: 'close_unfulfillable',
reason,
expected_draft_version: activeCase.value?.draft?.draft_version,
});
closeLineDialogLine.value = null;
handleGateRecoveryAccepted();
} catch (error) {
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
} finally {
closeLineBusy.value = false;
}
}
/** 下载行级实际匹配快照,禁止退回到任务级 active link。 */
async function downloadFormalPreparationLineInventoryFile(line: {
snapshot_line_id?: number | null;
@@ -2800,6 +2924,257 @@ async function retryFormalPreparationLine(
await submitFormalGateAction(actionCode, { snapshot_line_id: Number(snapshotLineId) });
}
/**
* 库存 RPA 是否运行中(就地编辑的 busy 禁用条件)。
* 核心逻辑:后端 preparation 摘要当前未下发 inventory_rpa_is_running(仅内部计算),
* 故先消费可选下发字段(后端补发即生效),缺失时以 status==='processing'
* (尚无匹配结果且无门禁 → 首轮抓取进行中)兜底;重匹配期间的写冲突由
* 后端 SHIPPING.EDIT_WINDOW_SYSTEM_BUSY 守卫兜底。
*/
const inlineEditBusy = computed(() => {
const preparation = formalTaskDetail.value?.ui_state?.stage_context?.preparation;
if (!preparation) return false;
const running = (preparation as { inventory_rpa_is_running?: unknown }).inventory_rpa_is_running;
if (typeof running === 'boolean') return running;
return preparation.status === 'processing';
});
/** 就地编辑状态:仅一行处于编辑态;保存走既有 update-notice-line 通道(免证据人工修订)。
* 编辑入口 = 行级「编辑」按钮(防单元格误触);编辑态下更多操作列替换为保存/取消。 */
const editingLine = ref<{
snapshot_line_id: number;
line_no: number;
part_number: string;
reservation_id: string;
required_qty: string;
source_code: string;
} | null>(null);
const inlineEditSaving = ref(false);
/**
* 就地编辑草稿种子值:把展示占位「—」还原为空串,避免占位符被当作真实值提交。
* @param value - prep 行展示值(可能为 null / '—' / 数字)
* @returns 可直接进入输入框的字符串
*/
function inlineEditSeedValue(value: unknown): string {
const text = String(value ?? '').trim();
return text === '—' ? '' : text;
}
/**
* 进入单个准备行的就地编辑(料号 / 预约号 / 需求数量三个值列)。
* @param line - prep 展示行;snapshot_line_id 定位编辑行,line_no-1 与后端 line_index 0 基对齐
*/
function startInlineEdit(line: {
snapshot_line_id?: number | null;
line_no?: string | number | null;
part_number?: string | null;
reservation_id?: string | null;
required_qty?: string | number | null;
selected_source_code?: string | null;
source_code?: string | null;
}) {
if (!line.snapshot_line_id || inlineEditSaving.value) return;
// 库存 RPA 运行中禁止改值:匹配进行中修改会与重匹配竞态。
if (inlineEditBusy.value) {
msg.warning(t('chat.shippingOrderReview.inlineEdit.busy'));
return;
}
editingLine.value = {
snapshot_line_id: Number(line.snapshot_line_id),
line_no: Number(line.line_no || 0),
part_number: inlineEditSeedValue(line.part_number),
reservation_id: inlineEditSeedValue(line.reservation_id),
required_qty: inlineEditSeedValue(line.required_qty),
source_code: inlineEditSeedValue(line.selected_source_code || line.source_code),
};
}
/** 行是否处于就地编辑态(统一 Number 收敛,避免模板严格等于的类型漂移)。 */
function isInlineEditing(line: { snapshot_line_id?: number | null }): boolean {
return editingLine.value?.snapshot_line_id === Number(line.snapshot_line_id);
}
/**
* 编辑态库存源下拉选项:多文件冲突行优先取候选源,其余行取全部已启用源;
* 无可用项返回空——此时编辑态库存源保持文本展示(无可选即不可改)。
*/
function inlineSourceOptions(line: {
source_ambiguous?: boolean;
source_candidates?: Array<string>;
}): Array<{ value: string; label: string }> {
if (line.source_ambiguous && (line.source_candidates?.length || 0) > 0) {
return (line.source_candidates || []).map((code) => ({ value: String(code), label: lineSourceOptionLabel(String(code)) }));
}
if (formSourceOptions.value.length) {
return formSourceOptions.value.map((s) => ({ value: String(s.source_code), label: overrideSourceOptionLabel(String(s.source_code)) }));
}
return [];
}
/** 同步编辑态库存源草稿(与三个值列一致:改动仅在保存时提交)。 */
function updateInlineEditSource(value: string) {
if (editingLine.value) editingLine.value.source_code = value;
}
/** 行级动作收纳菜单(⋯)打开状态:键 = snapshot_line_id,单行互斥;坐标视口固定定位,
* Teleport 到 body——表格祖先容器 overflow-auto 会裁剪 absolute 浮层并转为滚动高度。 */
const overflowMenuOpenFor = ref<string | null>(null);
const overflowMenuPos = ref<{ top: number; left: number }>({ top: 0, left: 0 });
function toggleOverflowMenu(key: string, event?: MouseEvent) {
if (overflowMenuOpenFor.value === key) {
overflowMenuOpenFor.value = null;
return;
}
const rect = (event?.currentTarget as HTMLElement | undefined)?.getBoundingClientRect();
const menuWidth = 176;
overflowMenuPos.value = {
top: rect ? Math.min(rect.bottom + 4, window.innerHeight - 8) : 0,
left: rect ? Math.max(8, Math.min(rect.right - menuWidth, window.innerWidth - menuWidth - 8)) : 0,
};
overflowMenuOpenFor.value = key;
}
/**
* 行级收纳菜单项:低频/诊断类动作入口(守卫条件与原常显按钮完全一致),
* 高频的「编辑」保持常显;无可用项时 ⋯ 整体不渲染。
*/
function overflowItems(line: {
snapshot_line_id?: number | null;
shortage_qty?: string | number | null;
}): Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> {
const items: Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> = [];
if (formalPreparationLineAllows(line, 'retry_inventory_matching')) {
items.push({
key: 'retry_inventory_matching',
icon: RefreshCw,
labelKey: inventoryActionLabelKey('retry_inventory_matching')!,
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_matching'),
});
}
// 放行缺口:缺字段型短缺行 → 行内展开补录条(替代弹窗);仅缺原因的行 → 旧弹窗(原因已可选)。
if (formalPreparationLineAllows(line, 'release_inventory_shortage')) {
items.push({
key: 'release_inventory_shortage',
icon: Check,
labelKey: inventoryActionLabelKey('release_inventory_shortage')!,
run: () => {
if (releaseBarHasFields(line)) expandReleaseBar(line);
else openReleaseInventoryShortage(line);
},
});
}
if (formalPreparationLineCloseVisible(line)) {
items.push({
key: 'close_unfulfillable',
icon: X,
labelKey: 'chat.shippingOrderReview.lineActions.closeLine',
run: () => openCloseLineDialog(line),
});
}
if (formalPreparationLineAllows(line, 'retry_inventory_preparation')) {
items.push({
key: 'retry_inventory_preparation',
icon: Bot,
labelKey: inventoryActionLabelKey('retry_inventory_preparation')!,
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_preparation'),
});
}
if (formalPreparationLineInventoryFileNo(line)) {
items.push({
key: 'download_inventory_file',
icon: Download,
labelKey: inventoryActionLabelKey('download_inventory_file') || 'chat.shippingOrderReview.lifecycle.prepare.downloadInventory',
run: () => downloadFormalPreparationLineInventoryFile(line),
});
}
return items;
}
/** 同步需求数量输入:数字输入框经 @input 手动回写,避免 v-model 的隐式 number 转型。 */
function updateInlineEditQty(value: string) {
if (editingLine.value) editingLine.value.required_qty = value;
}
/** 退出就地编辑并丢弃未保存修改。 */
function cancelInlineEdit() {
editingLine.value = null;
}
/**
* 保存就地编辑:仅提交有变化且非空的字段(part_number / reservation_id / qty),
* 成功后提示「请点击重新匹配库存」并刷新任务详情(值列即刻显示新值,重匹配仍需手动触发)。
* @param line - 当前编辑行,用于与编辑起始值比对计算差量补丁
*/
async function saveInlineEdit(line: {
snapshot_line_id?: number | null;
part_number?: string | null;
reservation_id?: string | null;
required_qty?: string | number | null;
selected_source_code?: string | null;
source_code?: string | null;
}) {
const draft = editingLine.value;
if (!draft || !draft.snapshot_line_id || inlineEditSaving.value) return;
// 编辑态行与触发行的快照身份不一致(如刷新后错位)时直接丢弃,禁止错行提交。
if (draft.snapshot_line_id !== Number(line.snapshot_line_id)) {
cancelInlineEdit();
return;
}
const taskNo = String(formalTaskDetail.value?.task_no || '').trim();
const lineIndex = Number(draft.line_no) - 1;
if (!taskNo || !Number.isInteger(lineIndex) || lineIndex < 0) {
cancelInlineEdit();
return;
}
const patch: Record<string, string> = {};
const nextPartNumber = draft.part_number.trim();
if (nextPartNumber !== inlineEditSeedValue(line.part_number)) patch.part_number = nextPartNumber;
const nextReservationId = draft.reservation_id.trim();
if (nextReservationId !== inlineEditSeedValue(line.reservation_id)) patch.reservation_id = nextReservationId;
const nextQty = draft.required_qty.trim();
if (nextQty !== inlineEditSeedValue(line.required_qty) && nextQty) patch.qty = nextQty;
// 库存源草稿与进入编辑时的种子值比对:变化即随保存提交行级源覆写。
const seedSourceCode = inlineEditSeedValue(line.selected_source_code || line.source_code);
const nextSourceCode = draft.source_code.trim();
const sourceChanged = Boolean(nextSourceCode) && nextSourceCode !== seedSourceCode;
if (!Object.keys(patch).length && !sourceChanged) {
cancelInlineEdit();
return;
}
inlineEditSaving.value = true;
try {
// 字段值先落库(update-notice-line);随后的源覆写会触发单行重匹配,读到的是修正后的字段值。
if (Object.keys(patch).length) {
await updateWorkspaceShippingNoticeLine(
taskNo,
lineIndex,
patch,
undefined,
// 免证据人工修订(后端 Task 2 已放宽 evidence/reason);乐观锁版本缺失时
// 退回后端初值 1,冲突由后端 ORDER_DATA_VERSION_MISMATCH 的 409 语义兜底。
{ expectedOrderDataVersion: Number(formalTaskDetail.value?.order_data_version ?? 1) },
);
}
// 库存源覆写沿用既有 Gate 动作(override_line_inventory_source),后端校验后仅重匹配该行。
if (sourceChanged) {
await submitFormalGateAction('override_line_inventory_source', {
line_no: draft.line_no,
source_code: nextSourceCode,
});
}
cancelInlineEdit();
msg.success(t('chat.shippingOrderReview.inlineEdit.saved'));
await loadFormalTaskDetail();
} catch (error) {
// BusinessError.message 即后端业务文案(版本冲突 / 系统处理中),复用既有提示通道。
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
} finally {
inlineEditSaving.value = false;
}
}
/**
* 人工上传登记是后端 Gate 的受控写动作;仅进入「货代上传」工作面不构成授权。
* [§2 单源] 授权从 A(shippingProcessingProjection.ui_state)读 —— §2.5 差异① 已归一,A 的
@@ -2845,7 +3220,12 @@ async function handleManualUploadSuccess() {
* 拉取确认后的 Notice 履约详情,供 Gate Action 与 Artifact 视图使用。
*/
async function loadFormalTaskDetail() {
const taskNo = confirmedNoticeTaskNo.value;
// 深链 OT 兜底:无 case_no 的 OT 直链下选法 2 不拉 Case,activeCase/displayCase
// 均为空、confirmedNoticeTaskNo 恒空;此时必须消费深链 task_no,否则挂载预取的
// 任务详情被丢弃、五阶段页签无身份可裁决(全锁死)。一旦存在任何 Case 上下文
// 则禁止回退,防止深链 OT 串到用户切换后的其他文件。
const taskNo = confirmedNoticeTaskNo.value
|| (displayCase.value ? '' : deepLinkOrderTaskNo.value);
const generation = ++formalTaskDetailGeneration;
if (!taskNo) {
formalTaskDetail.value = null;
@@ -4087,13 +4467,10 @@ const closeAuxiliaryPanelsForCaseSwitch = () => {
llmSuggestionOpen: false,
versionHistoryOpen: false,
};
// [NO-OPTIMISTIC MEMORY] 行级选源/覆写是「点保存才生效」的实提交,未保存的暂存选择
// 不得跨文件/切换残留(否则会把上一文件的未保存意图带进新行)。切换即清空暂存,
// 行回到后端 selected_source_code / source_code,用户须重新选择并点保存。
lineSourceSelections.value = {};
lineSourceBusy.value = false;
overrideSourceSelections.value = {};
overrideSourceBusy.value = false;
// [NO-OPTIMISTIC MEMORY] 行级就地编辑是「点保存才生效」的实提交,未保存的编辑草稿
// 不得跨文件/切换残留(否则会把上一文件的未保存意图带进新行)。切换即丢弃草稿,
// 行回到后端 selected_source_code / source_code,用户须重新进入编辑并保存。
cancelInlineEdit();
};
/**
@@ -4539,8 +4916,13 @@ watch(
// 用户查看面(含回看已完成阶段)驱动 Case 懒加载:选法 2 正式下游切 PDF 后 activeCase
// 为 null,回看接收解析/订单复核/通知准备时必须按需补拉目标 Case,否则这些工作面
// 只能渲染空白或残留上一份 PDF 的数据。
lifecycleActiveStageCode,
(stage) => {
// [2026-09-17] 初次装配(initialLoading/runLoading)未完成前必须让位:loadReviewCase
// 会自增 caseLoadGeneration,令在途 load() 的 finally 跳过 initialLoading 清旗,
// 首屏永久卡在「正在加载复核结果...」且 run/queue 永不装配。装配完成后由旗标
// 翻转重新触发本 watcher,按当前 stage 补拉 Case。
[lifecycleActiveStageCode, initialLoading, runLoading],
([stage]) => {
if (initialLoading.value || runLoading.value) return;
if (!stage || !REVIEW_EDITOR_NEEDED_STAGES.includes(stage)) return;
// 禁止使用 displayCase 兜底:它可能停留在上一份 PDF 的快照上造成串味;
// 目标一律取当前工作面的 activeCase 或切换管线的 requestedCaseNo。
@@ -4927,7 +5309,7 @@ watch(
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalLine truncated
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
</table>
</div>
</div>
@@ -5706,7 +6088,31 @@ watch(
</label>
<div class="mt-4 flex justify-end gap-2">
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" :disabled="releaseInventoryBusy" @click="releaseInventoryLine = null">{{ t('chat.shippingOrderReview.workbench.close') }}</button>
<button type="button" class="rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" :disabled="releaseInventoryBusy || !releaseInventoryReason.trim() || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click="confirmReleaseInventoryShortage">{{ t('chat.shippingOrderReview.lifecycle.prepare.releaseConfirm') }}</button>
<button type="button" class="rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" :disabled="releaseInventoryBusy || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click="confirmReleaseInventoryShortage">{{ t('chat.shippingOrderReview.lifecycle.prepare.releaseConfirm') }}</button>
</div>
</div>
</div>
<div
v-if="closeLineDialogLine"
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
data-testid="review-close-line-dialog"
@click.self="closeLineDialogLine = null"
>
<div class="w-full max-w-md rounded-xl border border-default bg-surface p-4 shadow-xl">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lineActions.closeLine') }}</h2>
<p class="mt-1 text-xs text-muted">{{ t('chat.shippingOrderReview.closeFulfillment.subtitle') }}</p>
<textarea
v-model="closeLineReason"
rows="3"
class="mt-3 w-full rounded-md border border-default bg-surface px-2.5 py-2 text-sm"
data-testid="review-close-line-reason"
:placeholder="t('chat.shippingOrderReview.lineActions.closeLineReason')"
:disabled="closeLineBusy"
/>
<div class="mt-4 flex justify-end gap-2">
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" :disabled="closeLineBusy" @click="closeLineDialogLine = null">{{ t('chat.shippingOrderReview.workbench.close') }}</button>
<button type="button" class="rounded bg-rose-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" data-testid="review-close-line-submit" :disabled="closeLineBusy || !closeLineReason.trim()" @click="confirmCloseLine">{{ t('chat.shippingOrderReview.lineActions.closeLineConfirm') }}</button>
</div>
</div>
</div>
@@ -142,6 +142,16 @@ const lineRows = computed(() => {
return Array.isArray(item?.notice_line_summary) ? item!.notice_line_summary : [];
});
/**
* 数量/缺口展示值:后端 Numeric(24,8) 透出形如 "24.00000000",
* 统一转 number 去尾零(24.00000000→24、2.50000000→2.5),缺失保持 —。
*/
function formatQty(value: unknown): string {
if (value === null || value === undefined || value === '') return '—';
const num = Number(value);
return Number.isFinite(num) ? String(num) : String(value);
}
watch(() => props.item, (item) => {
if (!item) return;
const stage = defaultLifecycleTarget(item);
@@ -173,7 +183,7 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onEsc));
data-testid="my-todos-drawer-scrim"
@click="emit('close')"
/>
<aside class="flex w-[34rem] max-w-[94vw] flex-col bg-surface shadow-2xl">
<aside class="flex w-[52rem] max-w-[94vw] flex-col bg-surface shadow-2xl">
<div class="border-b border-default px-5 py-4">
<div class="flex items-start justify-between gap-3">
<h3 class="break-all font-mono text-base font-bold text-primary" data-testid="my-todos-drawer-title">
@@ -238,14 +248,14 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onEsc));
<table class="w-full border-collapse text-xs" data-testid="my-todos-drawer-lines">
<thead>
<tr class="border-b border-default bg-surface-soft/60 text-left text-muted">
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.lineNo') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.partNumber') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.customerPartNumber') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.reservationId') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shipmentQty') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.availableQty') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shortageQty') }}</th>
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.status') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.lineNo') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.partNumber') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.customerPartNumber') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.reservationId') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shipmentQty') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.availableQty') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shortageQty') }}</th>
<th class="whitespace-nowrap px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.status') }}</th>
</tr>
</thead>
<tbody>
@@ -255,18 +265,18 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onEsc));
class="border-b border-[#f0f3f8]"
>
<td class="px-2.5 py-2 font-mono">{{ line.line_no }}</td>
<td class="px-2.5 py-2 font-mono">{{ line.part_number || '—' }}</td>
<td class="px-2.5 py-2">{{ line.customer_part_number || '—' }}</td>
<td class="px-2.5 py-2 font-mono">{{ line.reservation_id || '—' }}</td>
<td class="px-2.5 py-2 tabular-nums">{{ line.shipment_qty ?? '—' }}</td>
<td class="px-2.5 py-2 tabular-nums">{{ line.available_qty ?? '—' }}</td>
<td class="whitespace-nowrap px-2.5 py-2 font-mono">{{ line.part_number || '—' }}</td>
<td class="whitespace-nowrap px-2.5 py-2">{{ line.customer_part_number || '—' }}</td>
<td class="whitespace-nowrap px-2.5 py-2 font-mono">{{ line.reservation_id || '—' }}</td>
<td class="whitespace-nowrap px-2.5 py-2 tabular-nums">{{ formatQty(line.shipment_qty) }}</td>
<td class="whitespace-nowrap px-2.5 py-2 tabular-nums">{{ formatQty(line.available_qty) }}</td>
<td
class="px-2.5 py-2 tabular-nums"
class="whitespace-nowrap px-2.5 py-2 tabular-nums"
:class="Number(line.shortage_qty || 0) > 0 ? 'font-bold text-red-600' : ''"
>
{{ line.shortage_qty ?? '—' }}
{{ formatQty(line.shortage_qty) }}
</td>
<td class="px-2.5 py-2">{{ line.inventory_status || '—' }}</td>
<td class="whitespace-nowrap px-2.5 py-2">{{ line.inventory_status || '—' }}</td>
</tr>
</tbody>
</table>