feat(shipping-notice): 添加识别定义和规则集管理功能,支持客户和站点的可配置识别规则
This commit is contained in:
1 parent
88408490d7
commit
34d489a2d1
167 files changed
+10365
-7978
No files matched your search
@@ -43,9 +43,13 @@
|
||||
<h2>{{ t(currentSection.labelKey) }}</h2>
|
||||
<p>{{ t(currentSection.helpKey) }}</p>
|
||||
</div>
|
||||
<div class="workbench-actions">
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBulkParsingBinding">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</button>
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBatchValidation">{{ t('admin.shippingInventory.batchValidation') }}</button>
|
||||
<button v-if="isEditableTab" type="button" class="primary-action" @click="createNew">
|
||||
{{ t('admin.shippingInventory.createNew') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
@@ -110,7 +114,7 @@
|
||||
<aside class="editor-drawer" role="dialog" aria-modal="true" :aria-label="t(currentEditorSection.labelKey)">
|
||||
<header class="drawer-header">
|
||||
<div>
|
||||
<h3>{{ selectedId ? rowTitle(currentItems.find((item) => Number(item.id) === selectedId) || {}) : t('admin.shippingInventory.createNew') }}</h3>
|
||||
<div class="drawer-title-row"><h3>{{ selectedId ? rowTitle(currentItems.find((item) => Number(item.id) === selectedId) || {}) : t('admin.shippingInventory.createNew') }}</h3><span v-if="activeTab === 'sources' && selectedId" class="source-run-status" :class="{ enabled: source.enabled }">{{ source.enabled ? t('admin.shippingInventory.siteEnabled') : t('admin.shippingInventory.siteNotEnabled') }}</span></div>
|
||||
<p>{{ t(currentEditorSection.helpKey) }}</p>
|
||||
</div>
|
||||
<button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeDrawer">×</button>
|
||||
@@ -133,7 +137,7 @@
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySiteName') }}</span><input v-model="source.display_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="source.connector_type"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connection') }}</span><select v-model.number="source.rpa_profile_id" required><option :value="0">{{ t('admin.shippingInventory.chooseConnection') }}</option><option v-for="item in compatibleProfiles" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><output class="setup-status">{{ source.parsing_profile_id ? parsingProfileName(source.parsing_profile_id) : t('admin.shippingInventory.notGenerated') }}</output><small>{{ t('admin.shippingInventory.parsingProfileGeneratedByTest') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" :disabled="source.enabled"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplates') }}</span><select v-model.number="source.excel_template_id"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in excelTemplates.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.template_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" required></label>
|
||||
@@ -142,45 +146,46 @@
|
||||
<header class="readiness-heading">
|
||||
<div>
|
||||
<span class="readiness-kicker">{{ t('admin.shippingInventory.activationStatus') }}</span>
|
||||
<strong>{{ source.enabled ? t('admin.shippingInventory.activationReady') : t('admin.shippingInventory.activationDraft') }}</strong>
|
||||
<strong>{{ readinessHeadline }}</strong>
|
||||
<p>{{ readinessGuidance }}</p>
|
||||
</div>
|
||||
<span class="readiness-count">{{ readinessSummary }}</span>
|
||||
</header>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in readinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy">
|
||||
<b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b>
|
||||
<small>{{ readinessDetail(check) }}</small>
|
||||
</div>
|
||||
<button
|
||||
v-if="readinessActionLabel(check) && !source.enabled"
|
||||
type="button"
|
||||
class="readiness-action"
|
||||
:disabled="isReadinessActionBlocked(check)"
|
||||
:title="isReadinessActionBlocked(check) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined"
|
||||
@click="runReadinessAction(check)"
|
||||
>{{ readinessActionLabel(check) }}</button>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-if="!source.enabled" class="readiness-note">{{ t('admin.shippingInventory.configurationTestHint') }}</p>
|
||||
<section class="readiness-section">
|
||||
<div class="readiness-section-heading">
|
||||
<b>{{ t('admin.shippingInventory.activationRequiredTitle') }}</b>
|
||||
<small>{{ t('admin.shippingInventory.activationRequiredHint') }}</small>
|
||||
</div>
|
||||
<ol v-if="firstBlockingCheck && !source.enabled" class="readiness-steps">
|
||||
<li :class="`is-${firstBlockingCheck.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }}</b><small>{{ readinessDetail(firstBlockingCheck) }}</small></div>
|
||||
<button v-if="readinessActionLabel(firstBlockingCheck)" type="button" class="readiness-action" :disabled="isReadinessActionBlocked(firstBlockingCheck)" :title="isReadinessActionBlocked(firstBlockingCheck) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="runReadinessAction(firstBlockingCheck)">{{ readinessActionLabel(firstBlockingCheck) }}</button>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
|
||||
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.activationOptionalHint') }}</small></summary>
|
||||
<ol class="readiness-steps">
|
||||
<li v-for="check in optionalReadinessChecks" :key="check.code" :class="`is-${check.status}`">
|
||||
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
|
||||
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b><small>{{ readinessDetail(check) }}</small></div>
|
||||
</li>
|
||||
</ol>
|
||||
</details>
|
||||
<template v-if="configurationTest">
|
||||
<p class="readiness-run" :class="{ failed: configurationTest.status === 'failed' }">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
|
||||
<dl class="readiness-audit">
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestRunNo') }}</dt><dd>{{ configurationTest.run_no }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div>
|
||||
</dl>
|
||||
<details class="readiness-audit"><summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }}</summary><dl><div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div></dl></details>
|
||||
<p v-if="configurationTest.error_message" class="form-tip">{{ configurationTest.error_message }}</p>
|
||||
<p v-if="configurationTest.status === 'completed_empty'" class="form-tip">{{ t('admin.shippingInventory.configurationTestEmptyResult') }}</p>
|
||||
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }}</small><button type="button" class="secondary-action" @click="confirmTestProfile(candidate.profile_id)">{{ t('admin.shippingInventory.confirmTestProfile') }}</button></article>
|
||||
<p v-if="!(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
<p v-if="configurationTest.result?.current_profile_verified" class="configuration-test-verified">{{ t(`admin.shippingInventory.currentProfileVerified.${configurationTest.result.profile_match_level || 'compatible'}`) }}</p>
|
||||
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.configurationTestCandidateHint') }}</small></article>
|
||||
<p v-if="!configurationTest.result?.current_profile_verified && !(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
|
||||
</section>
|
||||
</template>
|
||||
<footer class="readiness-footer">
|
||||
<button v-if="!source.enabled" type="button" class="primary-action" :disabled="!source.activation?.ready || sourceDirty" :title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="requestSourceActivation">{{ t('admin.shippingInventory.activateSource') }}</button>
|
||||
<button v-else type="button" class="text-action danger" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
<footer v-if="source.enabled" class="readiness-footer">
|
||||
<button type="button" class="text-action danger" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
</footer>
|
||||
</section>
|
||||
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
|
||||
@@ -201,7 +206,6 @@
|
||||
</div>
|
||||
<button type="button" class="secondary-action full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</template>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.matchAliases') }}</span><input :value="source.match_aliases_json.join(', ')" :placeholder="t('admin.shippingInventory.aliasHint')" @input="source.match_aliases_json = splitValues(($event.target as HTMLInputElement).value)"></label>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'parsing'">
|
||||
@@ -333,9 +337,7 @@
|
||||
<label><span>{{ t('admin.shippingInventory.priority') }}</span><input v-model.number="rule.priority" :disabled="ruleReadOnly" type="number"></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.ruleConditions') }}</div>
|
||||
<div v-for="(condition, index) in rule.conditions" :key="index" class="condition-row full">
|
||||
<select v-model="condition.source_kind" :disabled="ruleReadOnly"><option value="order_field">{{ t('admin.shippingInventory.routeConditionSource.order_field') }}</option><option value="system_fact">{{ t('admin.shippingInventory.routeConditionSource.system_fact') }}</option></select>
|
||||
<select v-if="condition.source_kind === 'order_field'" v-model="condition.order_field_id" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-else v-model="condition.system_fact_key" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="key in systemFacts" :key="key" :value="key">{{ t(`admin.shippingInventory.systemFact.${key}`) }}</option></select>
|
||||
<select v-model="condition.order_field_id" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-model="condition.operator" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.operator')"><option v-for="item in operators" :key="item.value" :value="item.value">{{ item.label }}</option></select>
|
||||
<input v-if="conditionNeedsExpected(condition)" v-model="condition.expected" :disabled="ruleReadOnly" :placeholder="t('admin.shippingInventory.expectedValue')">
|
||||
<span v-else class="condition-empty">{{ t('admin.shippingInventory.noExpectedValue') }}</span>
|
||||
@@ -363,6 +365,7 @@
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="secondary-action" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentTemplate">{{ t('admin.shippingInventory.publishTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus !== 'draft'" type="button" class="secondary-action" @click="createTemplateVersion">{{ t('admin.shippingInventory.createTemplateVersion') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId" type="button" class="secondary-action" @click="openTemplateCloneDialog">{{ t('admin.shippingInventory.cloneTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentTemplate">{{ t('admin.shippingInventory.retireTemplate') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentParsingProfile">{{ t('admin.shippingInventory.publishProfile') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentParsingProfile">{{ t('admin.shippingInventory.retireProfile') }}</button>
|
||||
@@ -386,6 +389,46 @@
|
||||
@cancel="clearConfirmation"
|
||||
@confirm="confirmPendingAction"
|
||||
/>
|
||||
<div v-if="templateClone.visible" class="drawer-mask clone-template-mask" @click.self="closeTemplateCloneDialog">
|
||||
<section class="clone-template-dialog" role="dialog" aria-modal="true" :aria-labelledby="'clone-template-title'">
|
||||
<header class="clone-template-header">
|
||||
<div><h3 id="clone-template-title">{{ t('admin.shippingInventory.cloneTemplate') }}</h3><p>{{ t('admin.shippingInventory.cloneTemplateHint') }}</p></div>
|
||||
<button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeTemplateCloneDialog">×</button>
|
||||
</header>
|
||||
<form class="clone-template-form" @submit.prevent="cloneCurrentTemplate">
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="templateClone.template_code" required pattern="[A-Za-z0-9_-]{2,64}" autocomplete="off"><small>{{ t('admin.shippingInventory.cloneTemplateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="templateClone.display_name" required autocomplete="off"></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="templateClone.saving" @click="closeTemplateCloneDialog">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="templateClone.saving">{{ templateClone.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.cloneTemplateConfirm') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="bulkBinding.visible" class="drawer-mask clone-template-mask" @click.self="closeBulkParsingBinding">
|
||||
<section class="clone-template-dialog" role="dialog" aria-modal="true" aria-labelledby="bulk-parsing-binding-title">
|
||||
<header class="clone-template-header"><div><h3 id="bulk-parsing-binding-title">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</h3><p>{{ t('admin.shippingInventory.bulkBindParsingProfileHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBulkParsingBinding">×</button></header>
|
||||
<form class="clone-template-form" @submit.prevent="submitBulkParsingBinding">
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" multiple required><option v-for="item in sources.filter((row) => !row.enabled)" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="bulkBinding.profileId" required><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.bulkBindParsingProfile') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="batchValidation.visible" class="drawer-mask clone-template-mask" @click.self="closeBatchValidation">
|
||||
<section class="batch-validation-dialog" role="dialog" aria-modal="true" aria-labelledby="batch-validation-title">
|
||||
<header class="clone-template-header"><div><h3 id="batch-validation-title">{{ t('admin.shippingInventory.batchValidation') }}</h3><p>{{ t('admin.shippingInventory.batchValidationHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBatchValidation">×</button></header>
|
||||
<form v-if="!batchValidation.result" class="batch-selection" @submit.prevent="submitBatchValidation">
|
||||
<div class="batch-selection-toolbar"><label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><input v-model="batchValidation.query" :placeholder="t('admin.shippingInventory.batchValidationSearch')"></label><div class="batch-selection-actions"><button type="button" class="text-action" :disabled="!filteredBatchValidationSources.length" @click="toggleFilteredBatchValidationSources">{{ allFilteredBatchValidationSourcesSelected ? t('admin.shippingInventory.batchValidationClearFiltered') : t('admin.shippingInventory.batchValidationSelectFiltered') }}</button><b>{{ t('admin.shippingInventory.batchValidationSelected', { count: batchValidation.sourceIds.length }) }}</b></div></div>
|
||||
<div class="batch-source-list"><label v-for="item in filteredBatchValidationSources" :key="String(item.id)" class="batch-source-option"><input v-model="batchValidation.sourceIds" type="checkbox" :value="Number(item.id)"><span><b>{{ item.display_name || item.source_code }}</b><small>{{ item.source_code }} · {{ connectionName(item.source_code) }}</small></span></label><p v-if="!filteredBatchValidationSources.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoSites') }}</p></div>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="batchValidation.saving" @click="closeBatchValidation">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="batchValidation.saving || !batchValidation.sourceIds.length">{{ batchValidation.saving ? t('admin.shippingInventory.configurationTestRunning') : t('admin.shippingInventory.batchValidation') }}</button></div>
|
||||
</form>
|
||||
<div v-else class="batch-progress">
|
||||
<div class="batch-progress-heading"><div><span>{{ t(`admin.shippingInventory.batchValidationStatus.${batchValidation.result.status}`) }}</span><strong>{{ t('admin.shippingInventory.batchValidationProgress', batchValidation.result) }}</strong></div><b>{{ batchCompletedCount }} / {{ batchValidation.result.total_count }}</b></div>
|
||||
<div class="batch-progress-bar" role="progressbar" :aria-valuenow="batchCompletedCount" :aria-valuemax="batchValidation.result.total_count"><i :style="{ width: `${batchProgressPercent}%` }"></i></div>
|
||||
<div class="batch-stat-grid"><button type="button" :class="{ active: batchValidation.statusFilter === 'all' }" @click="batchValidation.statusFilter = 'all'"><b>{{ batchValidation.result.total_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.total') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'processing' }" @click="batchValidation.statusFilter = 'processing'"><b>{{ batchProcessingCount }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.processing') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed' }" @click="batchValidation.statusFilter = 'completed'"><b>{{ batchValidation.result.success_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.success') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed_empty' }" @click="batchValidation.statusFilter = 'completed_empty'"><b>{{ batchValidation.result.empty_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.empty') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'failed' }" @click="batchValidation.statusFilter = 'failed'"><b>{{ batchValidation.result.failed_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.failed') }}</span></button></div>
|
||||
<div class="batch-run-list"><article v-for="run in filteredBatchValidationRuns" :key="run.run_no" class="batch-run" :class="`is-${run.status}`"><span class="batch-run-marker"></span><div><b>{{ sourceTitleById(run.inventory_source_id) }}</b><small>{{ t(`admin.shippingInventory.configurationTestStage.${run.stage}`) }}</small></div><small v-if="run.error_message" class="batch-run-error">{{ run.error_message }}</small></article><p v-if="!filteredBatchValidationRuns.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoRuns') }}</p></div>
|
||||
<div class="clone-template-actions"><button v-if="batchValidation.result.failed_count" type="button" class="secondary-action" @click="retryBatchValidation">{{ t('admin.shippingInventory.retryFailedValidation') }}</button><button type="button" class="primary-action" @click="closeBatchValidation">{{ t('admin.close') }}</button></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div v-if="auditDetail" class="drawer-mask" @click.self="auditDetail = null"><aside class="editor-drawer audit-detail" role="dialog" aria-modal="true"><header class="drawer-header"><div><h3>{{ auditDetail.kind === 'snapshot' ? t('admin.shippingInventory.snapshotDetail') : t('admin.shippingInventory.exportDetail') }}</h3><p>{{ auditDetail.item.inventory_file_no || auditDetail.item.rpa_run_no || '-' }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="auditDetail = null">×</button></header><dl><template v-for="entry in auditDetailEntries" :key="entry.label"><dt>{{ entry.label }}</dt><dd>{{ entry.value }}</dd></template></dl></aside></div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -407,7 +450,6 @@ import {
|
||||
deleteShippingInventoryParsingProfile,
|
||||
deleteShippingInventoryRule,
|
||||
deleteShippingInventorySource,
|
||||
activateShippingInventorySource,
|
||||
deactivateShippingInventorySource,
|
||||
deleteShippingRpaProfile,
|
||||
getShippingInventoryConfig,
|
||||
@@ -416,6 +458,7 @@ import {
|
||||
getShippingInventoryRoutingFields,
|
||||
createShippingExcelTemplate,
|
||||
createShippingExcelTemplateVersion,
|
||||
cloneShippingExcelTemplate,
|
||||
getShippingExcelTemplateLayout,
|
||||
createShippingInventoryStructureAnalysis,
|
||||
createShippingInventoryParsingDraftFromAnalysis,
|
||||
@@ -426,7 +469,10 @@ import {
|
||||
startShippingInventoryConfigurationTest,
|
||||
getShippingInventoryConfigurationTest,
|
||||
getLatestShippingInventoryConfigurationTest,
|
||||
confirmShippingInventoryConfigurationTestProfile,
|
||||
startShippingInventoryValidationBatch,
|
||||
getShippingInventoryValidationBatch,
|
||||
getLatestActiveShippingInventoryValidationBatch,
|
||||
retryFailedShippingInventoryValidationBatch,
|
||||
downloadShippingInventorySnapshot,
|
||||
updateShippingExcelTemplate,
|
||||
publishShippingExcelTemplate,
|
||||
@@ -441,14 +487,16 @@ import {
|
||||
saveShippingInventoryRule,
|
||||
saveShippingInventorySource,
|
||||
saveShippingRpaProfile,
|
||||
bulkBindShippingInventorySourceParsingProfile,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck, ShippingInventoryValidationBatch } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
|
||||
|
||||
type TabKey = 'orderSchema' | 'profiles' | 'parsing' | 'inventoryFields' | 'templates' | 'sources' | 'rules' | 'snapshots' | 'exports' | 'mappings';
|
||||
type Item = Record<string, any>;
|
||||
type Parameter = { name: string; mode: 'single' | 'multi_text' | 'multi_select'; values: string[]; required: boolean; select_all: boolean; joiner?: string };
|
||||
type RuleCondition = { source_kind: 'order_field' | 'system_fact'; order_field_id: string; system_fact_key: string; operator: string; expected: string };
|
||||
type RuleCondition = { source_kind: 'order_field'; order_field_id: string; operator: string; expected: string };
|
||||
type ParsingFieldMapping = { inventory_field: string; source_header: string };
|
||||
type ParsingMatchKey = { order_field_id: string; inventory_field: string };
|
||||
type TemplateMapping = { sheet: string; row_mode: 'header' | 'line'; start_row: number; target_column: number; source_kind: 'order_field' | 'inventory_field' | 'system_fact' | 'constant'; source_key: string; formatter: string };
|
||||
@@ -464,7 +512,7 @@ const orderSchemaPublished = ref(false);
|
||||
const saving = ref(false);
|
||||
const confirmation = reactive({
|
||||
visible: false,
|
||||
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'activateSource' | 'deactivateSource' | 'replaceInventorySample' | '',
|
||||
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'deactivateSource' | 'replaceInventorySample' | '',
|
||||
title: '',
|
||||
message: '',
|
||||
confirmText: '',
|
||||
@@ -495,7 +543,6 @@ const configurationTest = ref<ShippingInventoryConfigurationTest | null>(null);
|
||||
const configurationTestLoading = ref(false);
|
||||
let configurationTestTimer: number | null = null;
|
||||
const routingFields = ref<Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>>([]);
|
||||
const systemFacts = ref<string[]>([]);
|
||||
const templateSystemFacts = ref<string[]>([]);
|
||||
const templateSourceKinds = ref<Array<TemplateMapping['source_kind']>>([]);
|
||||
const templateRowModes = ref<Array<TemplateMapping['row_mode']>>([]);
|
||||
@@ -525,9 +572,13 @@ const profile = reactive({ profile_code: '', display_name: '', connector_type: '
|
||||
const parsing = reactive({ profile_code: '', display_name: '', file_format: 'xlsx', sheet_name: '', header_row_index: 1, field_mappings: [] as ParsingFieldMapping[], match_keys: [] as ParsingMatchKey[] });
|
||||
const inventoryField = reactive<InventoryFieldForm>({ display_name: '', description: '', value_type: 'text', usage_type: 'general', sort_order: 100, status: 'active' });
|
||||
const excelTemplate = reactive({ template_code: '', display_name: '', filename_pattern: '{business_no}.xlsx', mappings: [] as TemplateMapping[], file: null as File | null });
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], match_aliases_json: [] as string[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const templateClone = reactive({ visible: false, template_code: '', display_name: '', saving: false });
|
||||
const bulkBinding = reactive({ visible: false, sourceIds: [] as number[], profileId: 0, saving: false });
|
||||
const batchValidation = reactive({ visible: false, sourceIds: [] as number[], query: '', statusFilter: 'all' as 'all' | 'processing' | 'completed' | 'completed_empty' | 'failed', saving: false, result: null as ShippingInventoryValidationBatch | null });
|
||||
let batchValidationTimer: number | null = null;
|
||||
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
|
||||
const sourceBaseline = ref('');
|
||||
const rule = reactive({ rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }] as RuleCondition[], source_codes: [] as string[] });
|
||||
const rule = reactive({ rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }] as RuleCondition[], source_codes: [] as string[] });
|
||||
const mapping = reactive({ inventory_source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
const compatibleRoutingFields = computed(() => routingFields.value.filter((item) => item.scope === (rule.scope === 'task' ? 'header' : 'line')));
|
||||
const activeInventoryFields = computed(() => inventoryFields.value.filter((item) => item.status === 'active'));
|
||||
@@ -544,11 +595,24 @@ const canAddParsingMatchKey = computed(() => Boolean(
|
||||
));
|
||||
const sourceDirty = computed(() => Boolean(selectedId.value && sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput()));
|
||||
const readinessChecks = computed<ShippingInventoryReadinessCheck[]>(() => source.activation?.checks || []);
|
||||
const requiredReadinessChecks = computed(() => readinessChecks.value.filter((item) => item.blocking));
|
||||
const firstBlockingCheck = computed(() => requiredReadinessChecks.value.find((item) => item.status !== 'passed'));
|
||||
const optionalReadinessChecks = computed(() => readinessChecks.value.filter((item) => !item.blocking));
|
||||
const readinessSummary = computed(() => {
|
||||
const total = readinessChecks.value.length;
|
||||
const passed = readinessChecks.value.filter((item) => item.status === 'passed').length;
|
||||
const required = requiredReadinessChecks.value;
|
||||
const total = required.length;
|
||||
const passed = required.filter((item) => item.status === 'passed').length;
|
||||
return t('admin.shippingInventory.readinessProgress', { passed, total });
|
||||
});
|
||||
const readinessHeadline = computed(() => {
|
||||
if (source.enabled) return t('admin.shippingInventory.activationReady');
|
||||
return source.activation?.ready ? t('admin.shippingInventory.activationCanEnable') : t('admin.shippingInventory.activationDraft');
|
||||
});
|
||||
const readinessGuidance = computed(() => source.enabled
|
||||
? t('admin.shippingInventory.activationEnabledHint')
|
||||
: source.activation?.ready
|
||||
? t('admin.shippingInventory.activationCanEnableHint')
|
||||
: t('admin.shippingInventory.activationMissingHint'));
|
||||
const sampleReplacementNotice = computed(() => {
|
||||
const difference = pendingSampleReplacement.value?.difference || {};
|
||||
const missing = Array.isArray(difference.missing_mapped_headers) ? difference.missing_mapped_headers : [];
|
||||
@@ -687,6 +751,31 @@ const auditDetailEntries = computed(() => {
|
||||
['库存源', sourceName(item.source_code)], ['货代仓库', warehouseName(item)], ['运行号', item.rpa_run_no || t('admin.shippingInventory.historyNotCaptured')], ['状态', auditStatus(item.export_status || item.snapshot_status)], ['导出时间', auditDate(item.exported_at)], ['有效至', auditDate(item.expires_at)], ['库存行数', item.line_count ? t('admin.shippingInventory.lineCountValue', { count: item.line_count }) : t('admin.shippingInventory.historyNotCaptured')], ['结果说明', item.error_message || auditResult(item)],
|
||||
].map(([label, value]) => ({ label, value }));
|
||||
});
|
||||
const filteredBatchValidationSources = computed(() => {
|
||||
const query = batchValidation.query.trim().toLowerCase();
|
||||
return sources.value.filter((item) => !item.enabled && item.parsing_profile_id && (
|
||||
!query || [item.display_name, item.source_code, connectionName(item.source_code)].some((value) => String(value || '').toLowerCase().includes(query))
|
||||
));
|
||||
});
|
||||
const allFilteredBatchValidationSourcesSelected = computed(() => filteredBatchValidationSources.value.length > 0 && filteredBatchValidationSources.value.every(
|
||||
(item) => batchValidation.sourceIds.includes(Number(item.id)),
|
||||
));
|
||||
const batchCompletedCount = computed(() => {
|
||||
const result = batchValidation.result;
|
||||
return result ? result.success_count + result.empty_count + result.failed_count : 0;
|
||||
});
|
||||
const batchProcessingCount = computed(() => Math.max(0, Number(batchValidation.result?.total_count || 0) - batchCompletedCount.value));
|
||||
const batchProgressPercent = computed(() => {
|
||||
const total = Number(batchValidation.result?.total_count || 0);
|
||||
return total ? Math.round(batchCompletedCount.value / total * 100) : 0;
|
||||
});
|
||||
const filteredBatchValidationRuns = computed(() => {
|
||||
const result = batchValidation.result;
|
||||
if (!result) return [];
|
||||
if (batchValidation.statusFilter === 'all') return result.runs;
|
||||
if (batchValidation.statusFilter === 'processing') return result.runs.filter((run) => ['awaiting_rpa', 'processing'].includes(run.status));
|
||||
return result.runs.filter((run) => run.status === batchValidation.statusFilter);
|
||||
});
|
||||
|
||||
/** 加载服务端配置与运行审计投影,页面不保留第二份真相。 */
|
||||
async function load(): Promise<void> {
|
||||
@@ -700,12 +789,13 @@ async function load(): Promise<void> {
|
||||
inventoryFields.value = inventoryFieldRows as Item[];
|
||||
excelTemplates.value = templateRows as Item[];
|
||||
temporaryInventorySessions.value = temporarySessions as Item[];
|
||||
routingFields.value = fieldCatalog.order_fields; systemFacts.value = fieldCatalog.system_facts;
|
||||
routingFields.value = fieldCatalog.order_fields;
|
||||
orderSchemaPublished.value = fieldCatalog.order_schema_published && configurationCatalog.order_schema_published;
|
||||
templateSystemFacts.value = configurationCatalog.template_system_facts;
|
||||
templateSourceKinds.value = configurationCatalog.template_source_kinds;
|
||||
templateRowModes.value = configurationCatalog.template_row_modes;
|
||||
templateFormatters.value = configurationCatalog.template_formatters;
|
||||
await restoreActiveBatchValidation();
|
||||
} catch (cause) {
|
||||
showError(cause, 'loadFailed');
|
||||
}
|
||||
@@ -737,10 +827,10 @@ function createNew(): void {
|
||||
templateSheetColumns.value = {};
|
||||
}
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], match_aliases_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
|
||||
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
|
||||
sourceBaseline.value = '';
|
||||
}
|
||||
if (activeTab.value === 'rules') Object.assign(rule, { rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
if (activeTab.value === 'rules') Object.assign(rule, { rule_code: '', rule_name: '', scope: 'line', priority: 100, conditions: [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }], source_codes: [] });
|
||||
if (activeTab.value === 'mappings') Object.assign(mapping, { inventory_source_id: 0, freight_warehouse_id: '', external_system_code: 'TOPGP', external_organization_code: '', external_site_code: '', external_warehouse_code: '', external_warehouse_name: '', enabled: true });
|
||||
drawerOpen.value = true;
|
||||
}
|
||||
@@ -783,15 +873,17 @@ function selectItem(item: Item): void {
|
||||
void loadTemplateLayout(selectedId.value);
|
||||
}
|
||||
if (activeTab.value === 'sources') {
|
||||
Object.assign(source, { ...item, fixed_warehouse_id: item.fixed_warehouse_id || '', report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '', ...(item.report_path_json || {}) }, query_parameters_json: (item.query_parameters_json || []).map((parameter: Parameter) => ({ ...parameter })), match_aliases_json: [...(item.match_aliases_json || [])] });
|
||||
const reportPath = item.connector_type === 'dbs'
|
||||
? { program_group: '', program_label: '', report_group: 'Inventory', report_name: '', ...(item.report_path_json || {}) }
|
||||
: item.report_path_json;
|
||||
Object.assign(source, { ...item, fixed_warehouse_id: item.fixed_warehouse_id || '', report_path_json: normaliseInventoryReportPath(item.connector_type, reportPath), query_parameters_json: (item.query_parameters_json || []).map((parameter: Parameter) => ({ ...parameter })) });
|
||||
sourceBaseline.value = serialiseSourceInput();
|
||||
void restoreConfigurationTest(Number(item.id));
|
||||
}
|
||||
if (activeTab.value === 'rules') Object.assign(rule, {
|
||||
rule_code: item.rule_code || '', rule_name: item.rule_name || '', scope: item.scope || 'line', priority: item.priority || 0,
|
||||
conditions: (item.conditions?.length ? item.conditions : [{ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected_value_json: '' }]).map((condition: Record<string, unknown>) => ({
|
||||
source_kind: String(condition.source_kind || 'order_field') as 'order_field' | 'system_fact',
|
||||
order_field_id: String(condition.order_field_id || ''), system_fact_key: String(condition.system_fact_key || ''), operator: String(condition.operator || ''),
|
||||
source_kind: 'order_field', order_field_id: String(condition.order_field_id || ''), operator: String(condition.operator || ''),
|
||||
expected: Array.isArray(condition.expected_value_json) ? condition.expected_value_json.join(', ') : String(condition.expected_value_json || ''),
|
||||
})),
|
||||
source_codes: item.action_payload_json?.source_codes || [],
|
||||
@@ -800,6 +892,95 @@ function selectItem(item: Item): void {
|
||||
drawerOpen.value = true;
|
||||
}
|
||||
|
||||
/** 打开批量绑定对话框;服务端将在提交前全量预检,禁止部分站点成功。 */
|
||||
function openBulkParsingBinding(): void {
|
||||
bulkBinding.sourceIds = [];
|
||||
bulkBinding.profileId = 0;
|
||||
bulkBinding.visible = true;
|
||||
}
|
||||
|
||||
function closeBulkParsingBinding(): void {
|
||||
if (!bulkBinding.saving) bulkBinding.visible = false;
|
||||
}
|
||||
|
||||
function openBatchValidation(): void {
|
||||
batchValidation.sourceIds = [];
|
||||
batchValidation.query = '';
|
||||
batchValidation.statusFilter = 'all';
|
||||
if (!batchValidation.result || !['queued', 'running'].includes(batchValidation.result.status)) batchValidation.result = null;
|
||||
batchValidation.visible = true;
|
||||
if (batchValidation.result && ['queued', 'running'].includes(batchValidation.result.status)) void pollBatchValidation();
|
||||
}
|
||||
|
||||
/** 搜索后的全选只作用于当前可见站点,避免误把不在筛选范围内的站点加入测试。 */
|
||||
function toggleFilteredBatchValidationSources(): void {
|
||||
const ids = filteredBatchValidationSources.value.map((item) => Number(item.id));
|
||||
if (allFilteredBatchValidationSourcesSelected.value) {
|
||||
batchValidation.sourceIds = batchValidation.sourceIds.filter((id) => !ids.includes(id));
|
||||
return;
|
||||
}
|
||||
batchValidation.sourceIds = [...new Set([...batchValidation.sourceIds, ...ids])];
|
||||
}
|
||||
|
||||
function closeBatchValidation(): void {
|
||||
if (batchValidationTimer !== null) window.clearTimeout(batchValidationTimer);
|
||||
batchValidationTimer = null;
|
||||
if (!batchValidation.saving) batchValidation.visible = false;
|
||||
}
|
||||
|
||||
async function submitBatchValidation(): Promise<void> {
|
||||
batchValidation.saving = true;
|
||||
try {
|
||||
batchValidation.result = await startShippingInventoryValidationBatch(batchValidation.sourceIds);
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
finally { batchValidation.saving = false; }
|
||||
}
|
||||
|
||||
async function pollBatchValidation(): Promise<void> {
|
||||
const result = batchValidation.result;
|
||||
if (!result) return;
|
||||
try {
|
||||
batchValidation.result = await getShippingInventoryValidationBatch(result.id);
|
||||
if (batchValidation.result.status === 'queued' || batchValidation.result.status === 'running') {
|
||||
batchValidationTimer = window.setTimeout(() => { void pollBatchValidation(); }, 2000);
|
||||
}
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 页面刷新后从服务端恢复仍在运行的批量验证,并继续轮询真实状态。 */
|
||||
async function restoreActiveBatchValidation(): Promise<void> {
|
||||
try {
|
||||
const active = await getLatestActiveShippingInventoryValidationBatch();
|
||||
if (!active) return;
|
||||
batchValidation.result = active;
|
||||
batchValidation.visible = true;
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
async function retryBatchValidation(): Promise<void> {
|
||||
if (!batchValidation.result) return;
|
||||
try {
|
||||
batchValidation.result = await retryFailedShippingInventoryValidationBatch(batchValidation.result.id);
|
||||
await pollBatchValidation();
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 原子绑定所选停用站点;任一站点不兼容时由服务端整体拒绝。 */
|
||||
async function submitBulkParsingBinding(): Promise<void> {
|
||||
bulkBinding.saving = true;
|
||||
try {
|
||||
await bulkBindShippingInventorySourceParsingProfile({
|
||||
source_ids: bulkBinding.sourceIds, parsing_profile_id: bulkBinding.profileId,
|
||||
});
|
||||
bulkBinding.visible = false;
|
||||
await load();
|
||||
message.success(t('admin.shippingInventory.bulkParsingProfileBound'));
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
finally { bulkBinding.saving = false; }
|
||||
}
|
||||
|
||||
/** 从对象存储读取已保存模板的工作表与栏位,避免编辑旧模板时要求重新上传。 */
|
||||
async function loadTemplateLayout(templateId: number | null): Promise<void> {
|
||||
if (!templateId || activeTab.value !== 'templates') return;
|
||||
@@ -870,8 +1051,8 @@ async function saveCurrent(): Promise<void> {
|
||||
await createShippingExcelTemplate(form);
|
||||
}
|
||||
}
|
||||
if (activeTab.value === 'sources') await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'rules') await saveShippingInventoryRule({ rule_code: rule.rule_code, rule_name: rule.rule_name || rule.rule_code, scope: rule.scope, priority: rule.priority, match_mode: 'all', action_type: 'add_source_candidates', action_payload_json: { source_codes: splitValues(rule.source_codes) }, conditions: rule.conditions.map((condition) => ({ source_kind: condition.source_kind, order_field_id: condition.source_kind === 'order_field' ? condition.order_field_id : null, system_fact_key: condition.source_kind === 'system_fact' ? condition.system_fact_key : null, operator: condition.operator, expected_value_json: normalizeExpectedValue(condition) })) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'sources') await saveShippingInventorySource({ ...source, enabled: false, fixed_warehouse_id: source.warehouse_resolution_mode === 'fixed' ? source.fixed_warehouse_id : null, report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'rules') await saveShippingInventoryRule({ rule_code: rule.rule_code, rule_name: rule.rule_name || rule.rule_code, scope: rule.scope, priority: rule.priority, match_mode: 'all', action_type: 'add_source_candidates', action_payload_json: { source_codes: splitValues(rule.source_codes) }, conditions: rule.conditions.map((condition) => ({ source_kind: 'order_field', order_field_id: condition.order_field_id, operator: condition.operator, expected_value_json: normalizeExpectedValue(condition) })) }, selectedId.value || undefined);
|
||||
if (activeTab.value === 'mappings') await saveShippingInventoryExternalMapping({ ...mapping, freight_warehouse_id: mapping.freight_warehouse_id || null, external_organization_code: mapping.external_organization_code || null, external_site_code: mapping.external_site_code || null }, selectedId.value || undefined);
|
||||
await load();
|
||||
closeDrawer();
|
||||
@@ -907,6 +1088,29 @@ async function createTemplateVersion(): Promise<void> {
|
||||
selectItem(created);
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
}
|
||||
/** 从当前模板版本复制受管文件和配置,作为新编码下独立的 v1 草稿。 */
|
||||
function openTemplateCloneDialog(): void {
|
||||
templateClone.template_code = '';
|
||||
templateClone.display_name = `${excelTemplate.display_name || excelTemplate.template_code} ${t('admin.shippingInventory.copySuffix')}`;
|
||||
templateClone.visible = true;
|
||||
}
|
||||
function closeTemplateCloneDialog(): void {
|
||||
if (!templateClone.saving) templateClone.visible = false;
|
||||
}
|
||||
async function cloneCurrentTemplate(): Promise<void> {
|
||||
if (!selectedId.value) return;
|
||||
templateClone.saving = true;
|
||||
try {
|
||||
const created = await cloneShippingExcelTemplate(selectedId.value, {
|
||||
template_code: templateClone.template_code,
|
||||
display_name: templateClone.display_name,
|
||||
}) as Item;
|
||||
templateClone.visible = false;
|
||||
await load();
|
||||
selectItem(created);
|
||||
} catch (cause) { showError(cause, 'saveFailed'); }
|
||||
finally { templateClone.saving = false; }
|
||||
}
|
||||
/** 退役模板前由后端确认没有启用库存源仍在引用。 */
|
||||
async function retireCurrentTemplate(): Promise<void> { openConfirmation('retireTemplate', t('admin.shippingInventory.confirmRetireTemplate')); }
|
||||
/** 解析 Profile 仅在没有库存源引用时允许退役。 */
|
||||
@@ -940,7 +1144,6 @@ async function confirmPendingAction(): Promise<void> {
|
||||
if (action === 'retireTemplate') await retireShippingExcelTemplate(selectedId.value);
|
||||
if (action === 'retireParsing') await retireShippingInventoryParsingProfile(selectedId.value);
|
||||
if (action === 'retireInventoryField') await retireShippingInventoryField(selectedId.value);
|
||||
if (action === 'activateSource') await activateShippingInventorySource(selectedId.value);
|
||||
if (action === 'deactivateSource') await deactivateShippingInventorySource(selectedId.value);
|
||||
if (action === 'replaceInventorySample') { sampleReplacementConfirmed.value = true; await saveCurrent(); return; }
|
||||
if (action === 'delete' && activeTab.value === 'profiles') await deleteShippingRpaProfile(selectedId.value);
|
||||
@@ -957,16 +1160,6 @@ async function confirmPendingAction(): Promise<void> {
|
||||
|
||||
function clearConfirmation(): void { confirmation.visible = false; confirmation.action = ''; }
|
||||
|
||||
/** 展示启用前置条件,避免管理员在普通保存时误以为站点已经进入正式运行。 */
|
||||
function requestSourceActivation(): void {
|
||||
confirmation.visible = true;
|
||||
confirmation.action = 'activateSource';
|
||||
confirmation.title = t('admin.shippingInventory.activateSource');
|
||||
confirmation.message = t('admin.shippingInventory.activateSourceConfirm');
|
||||
confirmation.confirmText = t('admin.shippingInventory.activateSource');
|
||||
confirmation.tone = 'primary';
|
||||
}
|
||||
|
||||
/** 停用动作使用平台确认弹窗,防止误将正在运行的库存站点下线。 */
|
||||
function requestSourceDeactivation(): void {
|
||||
confirmation.visible = true;
|
||||
@@ -1008,20 +1201,19 @@ async function pollConfigurationTest(): Promise<void> {
|
||||
configurationTest.value = updated;
|
||||
if (isConfigurationTestRunning(updated)) {
|
||||
configurationTestTimer = window.setTimeout(() => { void pollConfigurationTest(); }, 2000);
|
||||
} else {
|
||||
await refreshSelectedSource();
|
||||
}
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
}
|
||||
|
||||
/** 仅在测试完成后确认候选方案,成功后刷新库存站点以显示新的解析方案绑定。 */
|
||||
async function confirmTestProfile(profileId: number): Promise<void> {
|
||||
if (!selectedId.value || !configurationTest.value?.run_no) return;
|
||||
try {
|
||||
await confirmShippingInventoryConfigurationTestProfile(selectedId.value, String(configurationTest.value.run_no), profileId);
|
||||
message.success(t('admin.shippingInventory.configurationTestProfileConfirmed'));
|
||||
await load();
|
||||
const item = sources.value.find((row) => Number(row.id) === selectedId.value);
|
||||
if (item) selectItem(item);
|
||||
} catch (cause) { showError(cause, 'configurationTestFailed'); }
|
||||
/** 测试结束后回读服务端的启用投影,避免抽屉继续展示测试前的过期门禁。 */
|
||||
async function refreshSelectedSource(): Promise<void> {
|
||||
const sourceId = selectedId.value;
|
||||
if (!sourceId) return;
|
||||
await load();
|
||||
const refreshed = sources.value.find((item) => Number(item.id) === sourceId);
|
||||
if (refreshed) selectItem(refreshed);
|
||||
}
|
||||
|
||||
/** 新增一行结构化 DBS 查询参数,避免要求管理员编辑 JSON。 */
|
||||
@@ -1097,7 +1289,7 @@ function applyAnalysisCandidate(): void {
|
||||
parsing.field_mappings = parsing.field_mappings.filter((item) => headers.has(item.source_header));
|
||||
}
|
||||
function candidateKey(candidate: Item): string { return `${candidate.sheet_name || 'csv'}-${candidate.header_row_index}`; }
|
||||
function addRuleCondition(): void { rule.conditions.push({ source_kind: 'order_field', order_field_id: '', system_fact_key: '', operator: 'prefix', expected: '' }); }
|
||||
function addRuleCondition(): void { rule.conditions.push({ source_kind: 'order_field', order_field_id: '', operator: 'prefix', expected: '' }); }
|
||||
function removeRuleCondition(index: number): void { if (rule.conditions.length > 1) rule.conditions.splice(index, 1); }
|
||||
function splitValues(value: string | string[]): string[] { return (Array.isArray(value) ? value : value.split(',')).map((item) => item.trim()).filter(Boolean); }
|
||||
function conditionNeedsExpected(condition: RuleCondition): boolean { return !['is_empty', 'is_not_empty'].includes(condition.operator); }
|
||||
@@ -1204,7 +1396,10 @@ function inventoryFieldOptionLabel(field: Item): string {
|
||||
function formatDate(value: unknown): string { return value ? new Date(String(value)).toLocaleString() : '-'; }
|
||||
function auditDate(value: unknown): string { return value ? formatDate(value) : t('admin.shippingInventory.historyNotCaptured'); }
|
||||
function sourceName(sourceCode: unknown): string { return String(sourceCode || t('admin.shippingInventory.historyNotCaptured')); }
|
||||
function parsingProfileName(profileId: unknown): string { const item = parsingProfiles.value.find((row) => Number(row.id) === Number(profileId)); return String(item?.display_name || item?.profile_code || t('admin.shippingInventory.notGenerated')); }
|
||||
function sourceTitleById(sourceId: number): string {
|
||||
const item = sources.value.find((source) => Number(source.id) === Number(sourceId));
|
||||
return String(item?.display_name || item?.source_code || sourceId);
|
||||
}
|
||||
/** 将会影响测试输入的站点字段稳定序列化,用于阻止管理员针对未保存配置运行测试或启用。 */
|
||||
function serialiseSourceInput(): string {
|
||||
return JSON.stringify({
|
||||
@@ -1212,8 +1407,7 @@ function serialiseSourceInput(): string {
|
||||
rpa_profile_id: source.rpa_profile_id, parsing_profile_id: source.parsing_profile_id,
|
||||
excel_template_id: source.excel_template_id, warehouse_resolution_mode: source.warehouse_resolution_mode,
|
||||
fixed_warehouse_id: source.fixed_warehouse_id, snapshot_ttl_seconds: source.snapshot_ttl_seconds,
|
||||
report_path_json: source.report_path_json, query_parameters_json: source.query_parameters_json,
|
||||
match_aliases_json: source.match_aliases_json,
|
||||
report_path_json: normaliseInventoryReportPath(source.connector_type, source.report_path_json), query_parameters_json: source.query_parameters_json,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1230,11 +1424,13 @@ function readinessDetail(check: ShippingInventoryReadinessCheck): string {
|
||||
if (check.status === 'passed') return t('admin.shippingInventory.readinessState.passed');
|
||||
if (check.status === 'stale') return t('admin.shippingInventory.readinessState.stale');
|
||||
if (check.status === 'failed') return t('admin.shippingInventory.readinessState.failed');
|
||||
return check.blocking ? t('admin.shippingInventory.readinessState.required') : t('admin.shippingInventory.readinessState.waiting');
|
||||
if (check.status === 'empty') return t('admin.shippingInventory.readinessState.empty');
|
||||
return check.blocking ? t('admin.shippingInventory.readinessState.required') : t('admin.shippingInventory.readinessState.optional');
|
||||
}
|
||||
|
||||
/** 每项门禁只映射一个推荐动作;已经通过和依赖测试的辅助检查不额外制造操作入口。 */
|
||||
function readinessActionLabel(check: ShippingInventoryReadinessCheck): string {
|
||||
if (!check.blocking) return '';
|
||||
if (!needsReadinessAction(check)) return '';
|
||||
if (check.action === 'run_configuration_test') return configurationTestLoading.value
|
||||
? t('admin.shippingInventory.configurationTestRunning')
|
||||
@@ -1328,9 +1524,15 @@ onMounted(load);
|
||||
.status-dot.on { background: #22c55e; }
|
||||
.status-dot.off { background: #b2bdc9; }
|
||||
.drawer-mask { position: fixed; z-index: 40; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 28%); }
|
||||
.workbench-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.clone-template-mask { z-index: 80; align-items: center; justify-content: center; padding: 20px; }
|
||||
.clone-template-dialog { width: min(480px, 100%); border-radius: 10px; background: #fff; box-shadow: 0 18px 48px rgb(15 23 42 / 25%); }
|
||||
.clone-template-header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; padding: 18px 20px; }.clone-template-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.clone-template-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.clone-template-form { display: grid; gap: 14px; padding: 20px; }.clone-template-form label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.clone-template-form input { min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.clone-template-form small { color: #94a3b8; font-size: 11px; line-height: 1.45; }.clone-template-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf2f7; padding-top: 14px; }
|
||||
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar input { min-width: 0; border: 1px solid #d8e5ed; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .text-action { padding: 6px 8px; background: #f1f7fa; color: #17769d; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }.batch-source-option input { margin: 3px 0 0; accent-color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
|
||||
.editor-drawer { width: min(760px, 100vw); height: 100%; overflow-y: auto; border-left: 1px solid #dbe5ed; background: #fff; box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
|
||||
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 18px 20px; }
|
||||
.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }
|
||||
.drawer-title-row { display: flex; align-items: center; gap: 9px; }.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.source-run-status { flex: 0 0 auto; border: 1px solid #f2d3cd; border-radius: 999px; background: #fff4f1; padding: 3px 7px; color: #a53f30; font-size: 11px; font-weight: 700; }.source-run-status.enabled { border-color: #c7e7d0; background: #eefaf1; color: #247442; }
|
||||
.drawer-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.drawer-close { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #64748b; font-size: 24px; line-height: 1; cursor: pointer; }
|
||||
.drawer-close:hover { background: #f1f5f9; color: #334155; }
|
||||
@@ -1349,11 +1551,13 @@ onMounted(load);
|
||||
.filename-variable-menu { position: absolute; z-index: 3; top: calc(100% + 5px); left: 0; width: min(440px, 100%); overflow: hidden; border: 1px solid #cfdde7; border-radius: 7px; background: #fff; box-shadow: 0 10px 24px rgb(15 23 42 / 14%); padding: 4px; }
|
||||
.filename-variable-menu button { display: grid; width: 100%; grid-template-columns: 154px minmax(0, 1fr); gap: 8px; border: 0; border-radius: 4px; background: transparent; padding: 7px 8px; color: #64748b; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
||||
.filename-variable-menu button:hover, .filename-variable-menu button.active { background: #eef8f7; color: #145f5a; }.filename-variable-menu code { color: #047f76; font-size: 12px; }.filename-variable-menu p { margin: 0; padding: 8px; color: #94a3b8; font-size: 12px; }
|
||||
.readiness-card { display: grid; gap: 13px; border: 1px solid #d9e6ef; border-radius: 10px; background: linear-gradient(135deg, #fbfdff, #f4f9fc); padding: 15px; }.readiness-card.ready { border-color: #b7e4c7; background: linear-gradient(135deg, #fbfffc, #f2fbf5); }
|
||||
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }.readiness-heading > div { display: grid; gap: 4px; }.readiness-kicker { color: #64748b; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }.readiness-heading strong { color: #263b4e; font-size: 13px; line-height: 1.45; }.readiness-count { flex: 0 0 auto; border-radius: 999px; background: #eaf4fa; padding: 4px 8px; color: #176f9f; font-size: 11px; font-weight: 700; }.readiness-card.ready .readiness-count { background: #e8f7ed; color: #19703a; }
|
||||
.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 48px; border-top: 1px solid #e6eef4; padding: 8px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-note, .readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 10px; font-weight: 700; letter-spacing: .03em; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }.readiness-footer { display: flex; justify-content: flex-end; border-top: 1px solid #e6eef4; padding-top: 11px; }
|
||||
.readiness-card { display: grid; gap: 12px; border: 1px solid #cfe2ea; border-radius: 12px; background: #fbfdfe; padding: 16px; }.readiness-card.ready { border-color: #b9dfc4; background: #fcfffd; }
|
||||
.readiness-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }.readiness-heading > div { display: grid; gap: 5px; }.readiness-kicker { color: #5f798c; font-size: 11px; font-weight: 700; letter-spacing: .04em; }.readiness-heading strong { color: #263b4e; font-size: 14px; line-height: 1.4; }.readiness-heading p { margin: 0; color: #6d8292; font-size: 12px; line-height: 1.45; }.readiness-count { flex: 0 0 auto; border: 1px solid #cce7f1; border-radius: 999px; background: #edf8fc; padding: 5px 9px; color: #176f9f; font-size: 12px; font-weight: 700; white-space: nowrap; }.readiness-card.ready .readiness-count { border-color: #cce8d4; background: #eef9f1; color: #19703a; }
|
||||
.readiness-section { border: 1px solid #e1edf2; border-radius: 9px; background: #fff; padding: 0 12px; }.readiness-section-heading { display: grid; gap: 2px; padding: 11px 0 8px; }.readiness-section-heading b { color: #385166; font-size: 12px; }.readiness-section-heading small { color: #8192a0; font-size: 11px; }.readiness-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }.readiness-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 46px; border-top: 1px solid #edf2f5; padding: 7px 0; }.readiness-marker { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #e9eef3; color: #6c7d8d; font-size: 12px; font-weight: 800; }.readiness-copy { display: grid; min-width: 0; gap: 2px; }.readiness-copy b { overflow: hidden; color: #425466; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.readiness-copy small { color: #8190a0; font-size: 11px; line-height: 1.35; }.readiness-steps .is-passed .readiness-marker { background: #dff6e6; color: #16803a; }.readiness-steps .is-passed .readiness-copy b { color: #2d6b40; }.readiness-steps .is-failed .readiness-marker, .readiness-steps .is-stale .readiness-marker { background: #fff0ed; color: #bf4a38; }.readiness-steps .is-failed .readiness-copy b, .readiness-steps .is-stale .readiness-copy b { color: #9d382b; }
|
||||
.readiness-optional { border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-optional summary, .readiness-audit summary { display: flex; align-items: baseline; gap: 8px; color: #61798a; cursor: pointer; list-style: none; }.readiness-optional summary::-webkit-details-marker, .readiness-audit summary::-webkit-details-marker { display: none; }.readiness-optional summary::before, .readiness-audit summary::before { color: #4d849f; content: '›'; font-size: 16px; line-height: .8; transition: transform .15s; }.readiness-optional[open] summary::before, .readiness-audit[open] summary::before { transform: rotate(90deg); }.readiness-optional summary span { color: #516b7d; font-size: 12px; font-weight: 700; }.readiness-optional summary small { color: #8797a5; font-size: 11px; }.readiness-optional .readiness-steps { margin-top: 8px; }
|
||||
.readiness-action { border: 0; border-radius: 5px; background: #e8f3f9; padding: 6px 8px; color: #16759f; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }.readiness-action:hover { background: #d8edf7; }.readiness-run { margin: 0; border-left: 3px solid #74b8d8; background: #f0f8fc; padding: 8px 10px; color: #547185; font-size: 11px; line-height: 1.5; }.readiness-run.failed { border-left-color: #e06a58; background: #fff5f3; color: #9d382b; }.readiness-audit { margin: 0; border-top: 1px solid #e4edf2; padding-top: 10px; }.readiness-audit summary { color: #61798a; font-size: 11px; font-weight: 700; }.readiness-audit dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 9px 0 0; overflow: hidden; border: 1px solid #dce8ef; border-radius: 7px; background: #dce8ef; }.readiness-audit dl > div { min-width: 0; background: #fff; padding: 8px 9px; }.readiness-audit dt { color: #7b8998; font-size: 11px; font-weight: 700; }.readiness-audit dd { overflow: hidden; margin: 4px 0 0; color: #3d5366; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }.readiness-footer { display: flex; justify-content: flex-end; border-top: 1px solid #e6eef4; padding-top: 11px; }
|
||||
.form-tip { border-radius: 8px; background: #f1f6fa; padding: 11px; color: #5d7084; font-size: 12px; line-height: 1.55; }
|
||||
.configuration-test-verified { margin: 0; border-left: 3px solid #34a56b; background: #effaf3; padding: 9px 10px; color: #256b43; font-size: 12px; font-weight: 600; line-height: 1.45; }
|
||||
.sample-evidence-card { display: grid; gap: 12px; border: 1px solid #d7e3ed; border-radius: 8px; background: #f8fbfd; padding: 14px; }
|
||||
.sample-evidence-card > div { display: grid; gap: 3px; }.sample-evidence-card strong { color: #334155; font-size: 13px; }.sample-evidence-card p, .sample-evidence-card > small { margin: 0; color: #6b7f91; font-size: 12px; line-height: 1.55; }
|
||||
.sample-evidence-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }.sample-evidence-card dl div { min-width: 0; }.sample-evidence-card dt { color: #8190a0; font-size: 11px; }.sample-evidence-card dd { margin: 3px 0 0; overflow-wrap: anywhere; color: #475569; font-size: 12px; font-weight: 600; }
|
||||
@@ -1385,7 +1589,7 @@ onMounted(load);
|
||||
.condition-empty { color: #8190a0; font-size: 12px; }
|
||||
.inline-check { flex-direction: row !important; align-items: center; gap: 4px !important; white-space: nowrap; font-size: 11px !important; }
|
||||
.switch-field { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.status-switch { display: inline-flex; width: fit-content; align-items: center; gap: 7px; border: 0; background: transparent; padding: 2px 0; color: #94a3b8; font: inherit; font-size: 12px; cursor: pointer; }.status-switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background .18s; }.status-switch i::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 25%); content: ''; transition: transform .18s; }.status-switch.on { color: #15803d; }.status-switch.on i { background: #22c55e; }.status-switch.on i::after { transform: translateX(14px); }.status-switch b { font-weight: 500; }
|
||||
.form-actions { display: flex; gap: 10px; padding-top: 8px; }
|
||||
.form-actions { position: sticky; z-index: 2; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; grid-column: 1 / -1; margin: 6px -20px -20px; border-top: 1px solid #dce6ef; background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
|
||||
.audit-table-wrap { overflow-x: auto; border: 1px solid #dce6ef; border-radius: 10px; background: #fff; }
|
||||
.audit-table { table-layout: fixed; border-collapse: collapse; font-size: 12px; }
|
||||
.audit-table th { position: relative; overflow: hidden; padding: 11px 12px; background: #f8fafc; color: #64748b; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@@ -1399,5 +1603,5 @@ onMounted(load);
|
||||
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
|
||||
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
|
||||
@media (max-width: 980px) { .console-header { display: block; } .flow-strip { display: inline-flex; margin-top: 18px; } .console-layout { grid-template-columns: 1fr; } .section-nav { flex-direction: row; gap: 12px; overflow-x: auto; } .nav-group { display: flex; align-items: center; gap: 4px; } .nav-group > p { display: none; } .section-nav button { min-width: max-content; border-bottom: 3px solid transparent; border-left: 0; } .section-nav button.active { border-bottom-color: #16877f; border-left: 0; } .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; } .readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
|
||||
</style>
|
||||
+8
@@ -8,6 +8,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
|
||||
|
||||
const check = (status: ShippingInventoryReadinessCheck['status'], blocking: boolean): ShippingInventoryReadinessCheck => ({
|
||||
code: 'configuration_test', status, blocking, action: 'run_configuration_test', evidence: {},
|
||||
@@ -33,4 +34,11 @@ describe('shippingInventoryReadiness', () => {
|
||||
expect(isConfigurationTestRunning({ run_no: 'RUN-3', status: 'completed', stage: 'ready_for_confirmation' })).toBe(false);
|
||||
expect(isConfigurationTestRunning({ run_no: 'RUN-4', status: 'failed', stage: 'failed' })).toBe(false);
|
||||
});
|
||||
|
||||
it('removes DBS report paths before saving a Crane inventory source', () => {
|
||||
// 关键断言:Crane 不支持 DBS 四级路径,编辑回填的默认值不得再次提交给后端。
|
||||
const dbsPath = { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inventory', report_name: 'On Hand' };
|
||||
expect(normaliseInventoryReportPath('crane', dbsPath)).toEqual({});
|
||||
expect(normaliseInventoryReportPath('dbs', dbsPath)).toEqual(dbsPath);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/shippingInventorySourceForm.ts
|
||||
* 用途:规范化库存站点表单中仅适用于 DBS 的报表路径字段。
|
||||
* 依赖:无外部依赖,仅处理库存站点表单的连接器类型和 JSON 路径。
|
||||
* 逻辑:ShippingInventoryPage 在回填、保存和脏状态比较时调用,避免非 DBS 站点携带 DBS 默认路径。
|
||||
*/
|
||||
|
||||
export type InventoryReportPath = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* 返回可发送给库存站点接口的报表路径。
|
||||
* 核心逻辑:DBS 必须保留其四级报表路径;Crane 等非 DBS Driver 不支持该字段,统一发送空对象。
|
||||
* @param connectorType - 当前库存站点的 Driver 类型。
|
||||
* @param reportPath - 表单当前保存或回填的路径对象。
|
||||
* @returns DBS 的路径副本,或非 DBS 的空对象;不会修改原始表单数据。
|
||||
*/
|
||||
export function normaliseInventoryReportPath(connectorType: unknown, reportPath: InventoryReportPath | null | undefined): InventoryReportPath {
|
||||
return String(connectorType || '').trim().toLowerCase() === 'dbs' ? { ...(reportPath || {}) } : {};
|
||||
}
|
||||
Reference in new issue
Block a user