@@ -124,7 +124,7 @@
< label > < span > { { t ( 'admin.shippingInventory.inventorySiteName' ) } } < / span > < input v-model = "source.display_name" class="input-field" required > < / label >
< label > < span > { { t ( 'admin.shippingInventory.connectorType' ) } } < / span > < select v-model = "source.connector_type" class="select-field"><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 " class = "select-field" 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 > < select v -model .number = " source.parsing_profile_id " class = "select-field" :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.parsingProfiles' ) } } < / span > < select v -model .number = " source.parsing_profile_id " class = "select-field" :disabled = "source.enabled" > < option :value = "0" > { { t ( 'admin.shippingInventory.notConfigured' ) } } < / option > < option v-for = "item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'movement' )" :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 " class = "select-field" > < 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" 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 >
@@ -178,6 +178,7 @@
< 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 >
< label class = "full" > < span > { { t ( 'admin.shippingInventory.movementBindingLabel' ) } } < / span > < select v -model .number = " receiptConfig.parsing_profile_id " class = "select-field" > < option :value = "null" > { { t ( 'admin.shippingInventory.movementBindingNone' ) } } < / option > < option v-for = "item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'movement')" :key="`movement-bind-${item.id}`" :value="Number(item.id)" > {{ item.display_name | | item.profile_code }} V {{ item.version }} < / option > < / select > < small > { { t ( 'admin.shippingInventory.movementBindingHint' ) } } < / small > < / label >
< / div >
< / section >
< / template >
@@ -185,21 +186,32 @@
< template v-else-if = "activeTab === 'parsing'" >
< template v-if = "parsingReadOnly" >
< section class = "parsing-summary full" >
< div > < span > { { t ( 'admin.shippingInventory.parsingPurposeLabel' ) } } < / span > < strong > { { t ( ` admin.shippingInventory.parsingPurpose. ${ parsing . purpose === 'movement' ? 'movement' : 'inventory' } ` ) } } < / strong > < / div >
< div > < span > { { t ( 'admin.shippingInventory.fileFormat' ) } } < / span > < strong > { { parsing . file _format . toUpperCase ( ) } } < / strong > < / div >
< div > < span > { { t ( 'admin.shippingInventory.sheetName' ) } } < / span > < strong > { { parsing . sheet _name || t ( 'admin.shippingInventory.csvFile' ) } } < / strong > < / div >
< div > < span > { { t ( 'admin.shippingInventory.headerRowIndex' ) } } < / span > < strong > { { t ( 'admin.shippingInventory.headerRowOption' , { row : parsing . header _row _index } ) } } < / strong > < / div >
< / section >
< section class = "readonly-mapping-section full" >
< div class = "subsection" > { { t ( 'admin.shippingInventory.fieldMappings' ) } } < / div >
< p class = "section-hint" > { { t ( 'admin.shippingInventory.readonlyFieldMappingsHint' ) } } < / p >
< div v-for = "(item, index) in parsing.field_mappings" :key="`readonly-field-${index}`" class="parsing-mapping-card " >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < / div >
< div class = "mapping-display " > < span > { { t ( 'admin.shippingInventory.inventoryField ' ) } } < / span > < b > { { inventoryFieldName ( item . inventory _field ) } } < / b > < small > { { inventoryFieldDescription ( item . inventory _field ) } } < / small > < / div >
< div class = "mapping-arrow" aria -hidden = " true " > → < / div >
< div class = "mapping-display" > < span > { { t ( 'admin.shippingInventory.sourceHeader' ) } } < / span > < b > { { item . source _header } } < / b > < / div >
< / div >
< div class = "subsection" > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .fieldMappings ` ) } } < / div >
< p class = "section-hint" > { { t ( parsing . purpose === 'movement' ? 'admin.shippingInventory.movementMappingHint' : 'admin.shippingInventory.readonlyFieldMappingsHint' ) } } < / p >
< template v-if = "parsing.purpose === 'movement' " >
< div v-for = "(item, index) in parsing.movement_mappings" :key="`readonly-movement-${item.code}`" class="parsing-mapping-card" >
< div class = "mapping-title " > < strong > { { t ( 'admin.shippingInventory.mappingItem ' , { number : index + 1 } ) } } < / strong > < / div >
< div class = "mapping-display" > < span > { { t ( 'admin.shippingInventory.movementStandardField' ) } } < / span > < b > { { t ( ` admin.shippingInventory.movementFields. ${ item . code } ` ) } } < / b > < small > < b v-if = "item.required">{{ t('admin.shippingInventory.movementRequiredMark') }}</b><template v-if="item.required && item.is_identity"> · </template><b v-if="item.is_identity" > {{ t ( ' admin.shippingInventory.movementIdentityMark ' ) }} < / b > < / small > < / div >
< div class = "mapping-arrow" aria -hidden = " true " > → < / div >
< div class = "mapping-display" > < span > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .sourceHeader ` ) } } < / span > < b > { { item . alias || '-' } } < / b > < / div >
< / div >
< / template >
< template v-else >
< div v-for = "(item, index) in parsing.field_mappings" :key="`readonly-field-${index}`" class="parsing-mapping-card" >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < / div >
< div class = "mapping-display" > < span > { { t ( 'admin.shippingInventory.inventoryField' ) } } < / span > < b > { { inventoryFieldName ( item . inventory _field ) } } < / b > < small > { { inventoryFieldDescription ( item . inventory _field ) } } < / small > < / div >
< div class = "mapping-arrow" aria -hidden = " true " > → < / div >
< div class = "mapping-display" > < span > { { t ( 'admin.shippingInventory.sourceHeader' ) } } < / span > < b > { { item . source _header } } < / b > < / div >
< / div >
< / template >
< / section >
< section class = "readonly-mapping-section full" >
< section v-if = "parsing.purpose !== 'movement'" class=" readonly-mapping-section full" >
< div class = "subsection" > { { t ( 'admin.shippingInventory.matchKeys' ) } } < / div >
< p class = "section-hint" > { { t ( 'admin.shippingInventory.readonlyMatchKeysHint' ) } } < / p >
< div v-for = "(item, index) in parsing.match_keys" :key="`readonly-match-${index}`" class="parsing-mapping-card match-key-card" >
@@ -213,12 +225,13 @@
< / template >
< template v-else >
< label > < span > { { t ( 'admin.shippingInventory.parsingProfileCode' ) } } < / span > < input v-model = "parsing.profile_code" class="input-field" :disabled="Boolean(selectedId)" required > < / label >
< label > < span > { { t ( 'admin.shippingInventory.parsingProfileName' ) } } < / span > < input v-model = "parsing.display_name" class="input-field" required > < / label >
< label > < span > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .code ` ) } } < / span > < input v-model = "parsing.profile_code" class="input-field" :disabled="Boolean(selectedId)" required > < / label >
< label > < span > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .name ` ) } } < / span > < input v-model = "parsing.display_name" class="input-field" required > < / label >
< label > < span > { { t ( 'admin.shippingInventory.parsingPurposeLabel' ) } } < / span > < select v-model = "parsing.purpose" class="select-field" :disabled="Boolean(selectedId)" @change="resetMappingRowsForPurpose"><option value="inventory">{{ t('admin.shippingInventory.parsingPurpose.inventory') }}</option><option value="movement" > {{ t ( ' admin.shippingInventory.parsingPurpose.movement ' ) }} < / option > < / select > < small > { { t ( 'admin.shippingInventory.parsingPurposeHint' ) } } < / small > < / label >
< label > < span > { { t ( 'admin.shippingInventory.fileFormat' ) } } < / span > < select v-model = "parsing.file_format" class="select-field"><option value="xls">xls</option><option value="xlsx">xlsx</option><option value="csv" > csv < / option > < / select > < / label >
< label v-if = "!selectedId" class="full"><span>{{ t('admin.shippingInventory.temporaryInventorySession') }}</span><select v-model="selectedTemporaryInventorySession" class="select-field" @change="loadTemporaryInventorySession"><option value="">{{ t('admin.shippingInventory.temporaryInventorySessionNone') }}</option><option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no" > {{ item.source_file_name }} · {{ item.session_no }} < / option > < / select > < small > { { t ( 'admin.shippingInventory.temporaryInventorySessionHint' ) } } < / small > < / label >
< label v-if = "!selectedId && parsing.purpose !== 'movement' " class="full"><span>{{ t('admin.shippingInventory.temporaryInventorySession') }}</span><select v-model="selectedTemporaryInventorySession" class="select-field" @change="loadTemporaryInventorySession"><option value="">{{ t('admin.shippingInventory.temporaryInventorySessionNone') }}</option><option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no" > {{ item.source_file_name }} · {{ item.session_no }} < / option > < / select > < small > { { t ( 'admin.shippingInventory.temporaryInventorySessionHint' ) } } < / small > < / label >
< div v-if = "temporaryInventorySessionSelected" class="form-tip full" > {{ t ( ' admin.shippingInventory.temporaryInventorySessionSelected ' , { mapping : temporaryInventorySessionSelected.confirmed_usage ? .mapping_origin | | ' - ' } ) }} < / div >
< label v-if = "!selectedId" class="full"><span>{{ t(' admin.shippingInventory.inventoryS ampleFile' ) }}</span><input type="file" accept=".xls,.xlsx,.csv" :disabled="analysisLoading || Boolean(temporaryInventorySessionSelected)" @change="analyseInventorySample" > < small > { { t ( 'admin.shippingInventory.inventorySampleFileHint' ) } } < / small > < / label >
< label v-if = "!selectedId" class="full"><span>{{ t(` admin.shippingInventory.${parsingLabelNs}.s ampleFile` ) }}</span><input type="file" accept=".xls,.xlsx,.csv" :disabled="analysisLoading || Boolean(temporaryInventorySessionSelected)" @change="analyseInventorySample" > < small > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .sampleFileHint ` ) } } < / small > < / label >
< section v-else-if = "structureAnalysis" class="sample-evidence-card full" >
< div >
< strong > { { pendingSampleReplacement ? t ( 'admin.shippingInventory.pendingInventorySampleReplacement' ) : t ( 'admin.shippingInventory.savedInventorySample' ) } } < / strong >
@@ -236,28 +249,37 @@
< template v-if = "structureAnalysis" >
< label > < span > { { t ( 'admin.shippingInventory.sheetName' ) } } < / span > < select v-model = "parsing.sheet_name" class="select-field" @change="applyAnalysisCandidate"><option v-for="candidate in analysisCandidates" :key="candidateKey(candidate)" :value="candidate.sheet_name || ''" > {{ candidate.sheet_name | | t ( ' admin.shippingInventory.csvFile ' ) }} < / option > < / select > < / label >
< label > < span > { { t ( 'admin.shippingInventory.headerRowIndex' ) } } < / span > < select v -model .number = " parsing.header_row_index " class = "select-field" @change ="applyAnalysisCandidate" > < option v-for = "candidate in analysisCandidatesForSheet" :key="candidateKey(candidate)" :value="candidate.header_row_index" > {{ t ( ' admin.shippingInventory.headerRowOption ' , { row : candidate.header_row_index } ) }} < / option > < / select > < / label >
< section class = "analysis-preview full" > < strong > { { t ( 'admin.shippingInventory.inventoryAnalysisPreview' ) } } < / strong > < p > { { t ( 'admin.shippingInventory.inventoryAnalysisSummary' , structureAnalysis . validation _summary ) } } < / p > < div class = "analysis-columns" > < span v-for = "column in selectedAnalysisColumns" :key="`${column.index}-${column.header}`" > < b > { { column . header || t ( 'admin.shippingInventory.emptyHeader' ) } } < / b > < small > { { column . inferred _type } } · { { column . sample _values ? . join ( ' / ' ) || '-' } } < / small > < / span > < / div > < / section >
< section v-if = "structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.shippingInventory.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.shippingInventory.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.shippingInventory.columnOrderChanged') }}</p><button type="button" class="btn-secondary btn-sm" @click="adoptRecommendedProfile(candidate.profile_id)" > {{ t ( ' admin.shippingInventory.adoptParsingPlan ' ) }} < / button > < / article > < / div > < / section >
< section class = "analysis-preview full" > < strong > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .analysisPreview ` ) } } < / strong > < p > { { t ( 'admin.shippingInventory.inventoryAnalysisSummary' , structureAnalysis . validation _summary ) } } < / p > < div class = "analysis-columns" > < span v-for = "column in selectedAnalysisColumns" :key="`${column.index}-${column.header}`" > < b > { { column . header || t ( 'admin.shippingInventory.emptyHeader' ) } } < / b > < small > { { column . inferred _type } } · { { column . sample _values ? . join ( ' / ' ) || '-' } } < / small > < / span > < / div > < / section >
< section v-if = "parsing.purpose !== 'movement' && structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.shippingInventory.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.shippingInventory.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.shippingInventory.columnOrderChanged') }}</p><button type="button" class="btn-secondary btn-sm" @click="adoptRecommendedProfile(candidate.profile_id)" > {{ t ( ' admin.shippingInventory.adoptParsingPlan ' ) }} < / button > < / article > < / div > < / section >
< / template >
< div v-else class = "form-tip full" > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .sampleRequired ` ) } } < / div >
< template v-if = "parsing.purpose === 'movement'" >
< div class = "subsection full" > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .fieldMappings ` ) } } < small > { { t ( 'admin.shippingInventory.movementMappingHint' ) } } < / small > < / div >
< div v-for = "item in parsing.movement_mappings" :key="`movement-${item.code}`" class="parsing-mapping-card full" >
< div class = "mapping-title" > < strong > { { t ( ` admin.shippingInventory.movementFields. ${ item . code } ` ) } } < / strong > < small > < b v-if = "item.required">{{ t('admin.shippingInventory.movementRequiredMark') }}</b><template v-if="item.required && item.is_identity"> · </template><b v-if="item.is_identity" > {{ t ( ' admin.shippingInventory.movementIdentityMark ' ) }} < / b > < / small > < / div >
< label class = "full" > < span > { { t ( ` admin.shippingInventory. ${ parsingLabelNs } .sourceHeader ` ) } } < / span > < select v-model = "item.alias" class="select-field" :disabled="!structureAnalysis" :required="item.required"><option value="">{{ t('admin.shippingInventory.chooseSourceHeader') }}</option><option v-for="header in selectedAnalysisHeaders" :key="header" :value="header" > {{ header }} < / option > < / select > < / label >
< / div >
< / template >
< template v-else >
< div class = "subsection full" > { { t ( 'admin.shippingInventory.fieldMappings' ) } } < / div >
< div v-for = "(item, index) in parsing.field_mappings" :key="`field-${index}`" class="parsing-mapping-card full" >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < button type = "button" class = "btn-danger btn-sm" @click ="parsing.field_mappings.splice(index, 1)" > {{ t ( ' admin.delete ' ) }} < / button > < / div >
< label > < span > { { t ( 'admin.shippingInventory.inventoryField' ) } } < / span > < select v-model = "item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in activeInventoryFields" :key="field.id" :value="String(field.id)" > {{ inventoryFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< label > < span > { { t ( 'admin.shippingInventory.sourceHeader' ) } } < / span > < select v-model = "item.source_header" class="select-field" :disabled="!structureAnalysis" required><option value="">{{ t('admin.shippingInventory.chooseSourceHeader') }}</option><option v-for="header in selectedAnalysisHeaders" :key="header" :value="header" > {{ header }} < / option > < / select > < / label >
< small v-if = "item.inventory_field" class="mapping-help" > {{ inventoryFieldDescription ( item.inventory_field ) }} < / small >
< / div >
< button type = "button" class = "btn-secondary btn-sm full" :disabled = "!structureAnalysis" @click ="addParsingFieldMapping" > {{ t ( ' admin.shippingInventory.addFieldMapping ' ) }} < / button >
< div class = "subsection full" > { { t ( 'admin.shippingInventory.matchKeys' ) } } < small > { { t ( 'admin.shippingInventory.matchKeysHint' ) } } < / small > < / div >
< div v-for = "(item, index) in parsing.match_keys" :key="`match-${index}`" class="parsing-mapping-card match-key-card full" >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < button type = "button" class = "btn-danger btn-sm" @click ="parsing.match_keys.splice(index, 1)" > {{ t ( ' admin.delete ' ) }} < / button > < / div >
< label > < span > { { t ( 'admin.shippingInventory.orderField' ) } } < / span > < select v-model = "item.order_field_id" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseOrderField') }}</option><option v-for="field in matchingOrderFields" :key="field.field_id" :value="field.field_id" > {{ orderFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< label > < span > { { t ( 'admin.shippingInventory.inventoryField' ) } } < / span > < select v-model = "item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in mappedMatchingInventoryFields" :key="field.id" :value="String(field.id)" > {{ inventoryFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< small v-if = "item.inventory_field" class="mapping-help" > {{ inventoryFieldDescription ( item.inventory_field ) }} < / small >
< / div >
< button type = "button" class = "btn-secondary btn-sm full" :disabled = "!canAddParsingMatchKey" @click ="addParsingMatchKey" > {{ t ( ' admin.shippingInventory.addMatchKey ' ) }} < / button >
< p v-if = "!unusedMatchingInventoryFields.length || !unusedOrderMatchFields.length" class="match-key-tip full" > {{ t ( ' admin.shippingInventory.matchKeysComplete ' ) }} < / p >
< p v-else-if = "!structureAnalysis" class="match-key-tip full" > {{ t ( ' admin.shippingInventory.matchKeysAnalysisRequired ' ) }} < / p >
< / template >
< div v-else class = "form-tip full" > { { t ( 'admin.shippingInventory.inventorySampleRequired' ) } } < / div >
< div class = "subsection full" > { { t ( 'admin.shippingInventory.fieldMappings' ) } } < / div >
< div v-for = "(item, index) in parsing.field_mappings" :key="`field-${index}`" class="parsing-mapping-card full" >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < button type = "button" class = "btn-danger btn-sm" @click ="parsing.field_mappings.splice(index, 1)" > {{ t ( ' admin.delete ' ) }} < / button > < / div >
< label > < span > { { t ( 'admin.shippingInventory.inventoryField' ) } } < / span > < select v-model = "item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in activeInventoryFields" :key="field.id" :value="String(field.id)" > {{ inventoryFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< label > < span > { { t ( 'admin.shippingInventory.sourceHeader' ) } } < / span > < select v-model = "item.source_header" class="select-field" :disabled="!structureAnalysis" required><option value="">{{ t('admin.shippingInventory.chooseSourceHeader') }}</option><option v-for="header in selectedAnalysisHeaders" :key="header" :value="header" > {{ header }} < / option > < / select > < / label >
< small v-if = "item.inventory_field" class="mapping-help" > {{ inventoryFieldDescription ( item.inventory_field ) }} < / small >
< / div >
< button type = "button" class = "btn-secondary btn-sm full" :disabled = "!structureAnalysis" @click ="addParsingFieldMapping" > {{ t ( ' admin.shippingInventory.addFieldMapping ' ) }} < / button >
< div class = "subsection full" > { { t ( 'admin.shippingInventory.matchKeys' ) } } < small > { { t ( 'admin.shippingInventory.matchKeysHint' ) } } < / small > < / div >
< div v-for = "(item, index) in parsing.match_keys" :key="`match-${index}`" class="parsing-mapping-card match-key-card full" >
< div class = "mapping-title" > < strong > { { t ( 'admin.shippingInventory.mappingItem' , { number : index + 1 } ) } } < / strong > < button type = "button" class = "btn-danger btn-sm" @click ="parsing.match_keys.splice(index, 1)" > {{ t ( ' admin.delete ' ) }} < / button > < / div >
< label > < span > { { t ( 'admin.shippingInventory.orderField' ) } } < / span > < select v-model = "item.order_field_id" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseOrderField') }}</option><option v-for="field in matchingOrderFields" :key="field.field_id" :value="field.field_id" > {{ orderFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< label > < span > { { t ( 'admin.shippingInventory.inventoryField' ) } } < / span > < select v-model = "item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in mappedMatchingInventoryFields" :key="field.id" :value="String(field.id)" > {{ inventoryFieldOptionLabel ( field ) }} < / option > < / select > < / label >
< small v-if = "item.inventory_field" class="mapping-help" > {{ inventoryFieldDescription ( item.inventory_field ) }} < / small >
< / div >
< button type = "button" class = "btn-secondary btn-sm full" :disabled = "!canAddParsingMatchKey" @click ="addParsingMatchKey" > {{ t ( ' admin.shippingInventory.addMatchKey ' ) }} < / button >
< p v-if = "!unusedMatchingInventoryFields.length || !unusedOrderMatchFields.length" class="match-key-tip full" > {{ t ( ' admin.shippingInventory.matchKeysComplete ' ) }} < / p >
< p v-else-if = "!structureAnalysis" class="match-key-tip full" > {{ t ( ' admin.shippingInventory.matchKeysAnalysisRequired ' ) }} < / p >
< / template >
< / template >
@@ -333,7 +355,7 @@
< 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 }" >
< section v-if = "activeTab === 'sources' && 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 >
@@ -423,7 +445,7 @@
< 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" class="select-field" 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 " class = "select-field" 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 >
< label > < span > { { t ( 'admin.shippingInventory.parsingProfiles' ) } } < / span > < select v -model .number = " bulkBinding.profileId " class = "select-field" required > < option :value = "0" > { { t ( 'admin.shippingInventory.notConfigured' ) } } < / option > < option v-for = "item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'movement' )" :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 = "btn-ghost btn-sm" :disabled = "bulkBinding.saving" @click ="closeBulkParsingBinding" > {{ t ( ' admin.cancel ' ) }} < / button > < button type = "submit" class = "btn-primary" :disabled = "bulkBinding.saving" > { { bulkBinding . saving ? t ( 'admin.shippingInventory.saving' ) : t ( 'admin.shippingInventory.bulkBindParsingProfile' ) } } < / button > < / div >
< / form >
< / section >
@@ -479,6 +501,7 @@ import {
getShippingExcelTemplateLayout ,
createShippingInventoryStructureAnalysis ,
createShippingInventoryParsingDraftFromAnalysis ,
fetchMovementFields ,
previewShippingInventorySampleReplacement ,
createShippingParsingDraftFromTemporarySession ,
adoptShippingInventoryParsingProfile ,
@@ -512,6 +535,7 @@ import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessChec
import { isConfigurationTestRunning , needsReadinessAction , readinessMarkerKind } from './shippingInventoryReadiness' ;
import { normaliseInventoryReportPath } from './shippingInventorySourceForm' ;
import { buildReceiptReportConfigPayload } from './receiptReportConfigForm' ;
import { buildMovementFieldMapping } from './movementParsingProfileForm' ;
type TabKey = 'profiles' | 'parsing' | 'inventoryFields' | 'templates' | 'sources' | 'rules' | 'snapshots' | 'exports' | 'mappings' ;
type Item = Record < string , any > ;
@@ -617,7 +641,13 @@ const successTextsInput = computed<string>({
get : ( ) => ( profile . upload _config _json . success _texts || [ ] ) . join ( '\n' ) ,
set : ( value ) => { profile . upload _config _json . success _texts = String ( value || '' ) . split ( /\r?\n/ ) . map ( ( item ) => item . trim ( ) ) . filter ( Boolean ) ; } ,
} ) ;
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 parsing = reactive ( {
profile _code : '' , display _name : '' , file _format : 'xlsx' , sheet _name : '' , header _row _index : 1 ,
purpose : 'inventory' as 'inventory' | 'movement' ,
field _mappings : [ ] as ParsingFieldMapping [ ] , match _keys : [ ] as ParsingMatchKey [ ] ,
movement _mappings : [ ] as Array < { code : string ; alias : string ; required : boolean ; is _identity : boolean } > ,
} ) ;
const movementFields = ref < Array < { code : string ; value_type : string ; required : boolean ; is_identity : boolean } > > ( [ ] ) ;
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 templateClone = reactive ( { visible : false , template _code : '' , display _name : '' , saving : false } ) ;
@@ -625,7 +655,7 @@ 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 ( { report _path _json : { program _group : '' , program _label : '' , report _group : 'Inbound' , report _name : '' } as Record < string , string > , query _parameters _json : [ ] as Parameter [ ] } ) ;
const receiptConfig = reactive ( { report _path _json : { program _group : '' , program _label : '' , report _group : 'Inbound' , report _name : '' } as Record < string , string > , query _parameters _json : [ ] as Parameter [ ] , parsing _profile _id : null as number | null } ) ;
const receiptConfigExists = ref ( false ) ;
const receiptSectionTouched = ref ( false ) ;
const receiptSectionOpen = ref ( false ) ;
@@ -720,6 +750,8 @@ const ruleReadOnly = computed(() => ['published', 'retired'].includes(selectedRu
const selectedTemplateStatus = computed ( ( ) => excelTemplates . value . find ( ( item ) => Number ( item . id ) === selectedId . value ) ? . status || 'draft' ) ;
const selectedParsingStatus = computed ( ( ) => parsingProfiles . value . find ( ( item ) => Number ( item . id ) === selectedId . value ) ? . status || 'draft' ) ;
const parsingReadOnly = computed ( ( ) => activeTab . value === 'parsing' && [ 'published' , 'retired' ] . includes ( selectedParsingStatus . value ) ) ;
/** 按规则用途切换弹窗标签命名空间:收料异动模式下不再出现"库存"措辞。 */
const parsingLabelNs = computed ( ( ) => parsing . purpose === 'movement' ? 'movementParsing' : 'inventoryParsing' ) ;
const inventoryFieldReadOnly = computed ( ( ) => activeTab . value === 'inventoryFields' && inventoryField . status !== 'active' ) ;
const analysisCandidates = computed < Item [ ] > ( ( ) => structureAnalysis . value ? . structure ? . candidates || [ ] ) ;
const analysisCandidatesForSheet = computed < Item [ ] > ( ( ) => analysisCandidates . value . filter ( ( item ) => String ( item . sheet _name || '' ) === parsing . sheet _name ) ) ;
@@ -817,12 +849,13 @@ const filteredBatchValidationRuns = computed(() => {
/** 加载服务端配置与运行审计投影,页面不保留第二份真相。 */
async function load ( ) : Promise < void > {
try {
const [ [ profileRows , sourceRows , ruleRows , mappingRows , snapshotRows , exportRows , parsingRows , templateRows ] , inventoryFieldRows , fieldCatalog , configurationCatalog , temporarySessions ] = await Promise . all ( [
getShippingInventoryConfig ( ) , getShippingInventoryFields ( ) , getShippingInventoryRoutingFields ( ) , getShippingInventoryConfigurationCatalog ( ) , listShippingTemporaryInventorySessions ( ) ,
const [ [ profileRows , sourceRows , ruleRows , mappingRows , snapshotRows , exportRows , parsingRows , templateRows ] , inventoryFieldRows , fieldCatalog , configurationCatalog , temporarySessions , movementFieldRows ] = await Promise . all ( [
getShippingInventoryConfig ( ) , getShippingInventoryFields ( ) , getShippingInventoryRoutingFields ( ) , getShippingInventoryConfigurationCatalog ( ) , listShippingTemporaryInventorySessions ( ) , fetchMovementFields ( ) ,
] ) ;
profiles . value = profileRows as Item [ ] ; sources . value = sourceRows as Item [ ] ; rules . value = ruleRows as Item [ ] ;
mappings . value = mappingRows as Item [ ] ; snapshots . value = snapshotRows as Item [ ] ; exports . value = exportRows as Item [ ] ;
parsingProfiles . value = parsingRows as Item [ ] ;
movementFields . value = movementFieldRows ;
inventoryFields . value = inventoryFieldRows as Item [ ] ;
excelTemplates . value = templateRows as Item [ ] ;
temporaryInventorySessions . value = temporarySessions as Item [ ] ;
@@ -845,6 +878,7 @@ function resetReceiptConfig(connectorType: unknown): void {
? { report _name : 'Inbound Details' }
: { program _group : '' , program _label : '' , report _group : 'Inbound' , report _name : '' } ,
query _parameters _json : [ ] ,
parsing _profile _id : null ,
} ) ;
}
@@ -864,6 +898,7 @@ async function loadReceiptConfig(sourceId: number, connectorType: unknown): Prom
? { report _name : 'Inbound Details' }
: { program _group : '' , program _label : '' , report _group : 'Inbound' , report _name : '' , ... ( ( config . report _path _json || { } ) as Record < string , string > ) } ,
query _parameters _json : Array . isArray ( config . query _parameters _json ) ? config . query _parameters _json . map ( ( parameter ) => ( { ... parameter } ) ) : [ ] ,
parsing _profile _id : config . parsing _profile _id ? Number ( config . parsing _profile _id ) : null ,
} ) ;
receiptConfigExists . value = true ;
receiptSectionOpen . value = true ;
@@ -924,7 +959,7 @@ function selectInventoryMappingTab(tab: 'parsing' | 'inventoryFields'): void {
function createNew ( ) : void {
selectedId . value = null ;
if ( activeTab . value === 'profiles' ) Object . assign ( profile , { profile _code : '' , display _name : '' , connector _type : 'dbs' , login _url : '' , username : '' , password : '' , login _config _json : { auth _mode : 'password' } , enabled : true , upload _config _json : defaultUploadConfig ( 'dbs' ) } ) ;
if ( activeTab . value === 'parsing' ) { Object . assign ( parsing , { profile _code : '' , display _name : '' , file _format : 'xlsx' , sheet _name : '' , header _row _index : 1 , field _mappings : [ ] , match _keys : [ ] } ) ; structureAnalysis . value = null ; pendingSampleReplacement . value = null ; sampleReplacementConfirmed . value = false ; selectedTemporaryInventorySession . value = '' ; }
if ( activeTab . value === 'parsing' ) { Object . assign ( parsing , { profile _code : '' , display _name : '' , file _format : 'xlsx' , sheet _name : '' , header _row _index : 1 , purpose : 'inventory' , field _mappings : [ ] , match _keys : [ ] , movement _mappings : [ ] } ) ; structureAnalysis . value = null ; pendingSampleReplacement . value = null ; sampleReplacementConfirmed . value = false ; selectedTemporaryInventorySession . value = '' ; }
if ( activeTab . value === 'inventoryFields' ) Object . assign ( inventoryField , { display _name : '' , description : '' , value _type : 'text' , usage _type : 'general' , sort _order : 100 , status : 'active' } ) ;
if ( activeTab . value === 'templates' ) {
Object . assign ( excelTemplate , { template _code : '' , display _name : '' , filename _pattern : '{business_no}.xlsx' , mappings : [ ] , file : null } ) ;
@@ -953,8 +988,10 @@ function selectItem(item: Item): void {
if ( activeTab . value === 'parsing' ) Object . assign ( parsing , {
profile _code : item . profile _code , display _name : item . display _name , file _format : item . file _format ,
sheet _name : item . definition ? . sheet _name || '' , header _row _index : item . definition ? . header _row _index ? ? 0 ,
purpose : item . purpose === 'movement' ? 'movement' : 'inventory' ,
field _mappings : Object . entries ( item . definition ? . field _mapping || { } ) . map ( ( [ inventory _field , source _header ] ) => ( { inventory _field , source _header : String ( source _header ) } ) ) ,
match _keys : ( item . definition ? . match _keys || [ ] ) . map ( ( entry : Record < string , unknown > ) => ( { order _field _id : String ( entry . order _field _id || '' ) , inventory _field : String ( entry . inventory _field _id || entry . inventory _field || '' ) } ) ) ,
movement _mappings : buildMovementMappings ( item ) ,
} ) ;
if ( activeTab . value === 'parsing' ) {
// 草稿恢复保存的最小化样本证据,而不是要求管理员再次上传原始库存文件。
@@ -1120,7 +1157,13 @@ async function saveCurrent(): Promise<void> {
try {
if ( activeTab . value === 'profiles' ) await saveShippingRpaProfile ( { ... profile , display _name : profile . display _name || profile . profile _code , upload _config _json : profile . upload _config _json } , selectedId . value || undefined ) ;
if ( activeTab . value === 'parsing' ) {
const payload = {
const payload = parsing . purpose === 'movement' ? {
profile _code : parsing . profile _code , display _name : parsing . display _name || parsing . profile _code , file _format : parsing . file _format ,
purpose : 'movement' , sheet _name : parsing . sheet _name || null , header _row _index : parsing . header _row _index ,
// 标准异动字段契约:code 由只读目录下发,这里只裁剪/校验别名映射。
field _mapping : buildMovementFieldMapping ( parsing . movement _mappings ) ,
match _keys : [ ] as string [ ] ,
} : {
profile _code : parsing . profile _code , display _name : parsing . display _name || parsing . profile _code , file _format : parsing . file _format ,
sheet _name : parsing . sheet _name || null , header _row _index : parsing . header _row _index ,
field _mapping : Object . fromEntries ( parsing . field _mappings . map ( ( item ) => [ item . inventory _field , item . source _header ] ) ) ,
@@ -1364,6 +1407,31 @@ async function refreshSelectedSource(): Promise<void> {
/** 新增一行结构化 DBS 查询参数,避免要求管理员编辑 JSON。 */
function addParameter ( ) : void { source . query _parameters _json . push ( { name : '' , mode : 'single' , values : [ ] , required : false , select _all : false } ) ; }
/** 把已保存 movement 规则的定义与只读字段目录合并为可编辑映射行;目录缺失时退化为纯 code 行。 */
function buildMovementMappings ( item : Item ) {
const saved = ( item . definition ? . field _mapping || { } ) as Record < string , unknown > ;
const catalog = movementFields . value . length
? movementFields . value
: Object . keys ( saved ) . map ( ( code ) => ( { code , required : false , is _identity : false } ) ) ;
return catalog . map ( ( field ) => ( {
code : field . code , alias : String ( saved [ field . code ] || '' ) ,
required : Boolean ( field . required ) , is _identity : Boolean ( field . is _identity ) ,
} ) ) ;
}
/** 切换用途时初始化对应映射行:movement 预填标准字段目录,inventory 清空自由映射。 */
function resetMappingRowsForPurpose ( ) : void {
if ( parsing . purpose === 'movement' ) {
parsing . movement _mappings = movementFields . value . map ( ( field ) => ( {
code : field . code , alias : '' , required : Boolean ( field . required ) , is _identity : Boolean ( field . is _identity ) ,
} ) ) ;
parsing . field _mappings = [ ] ;
parsing . match _keys = [ ] ;
} else {
parsing . movement _mappings = [ ] ;
}
}
function addParsingFieldMapping ( ) : void {
if ( ! structureAnalysis . value ) {
message . warning ( t ( 'admin.shippingInventory.inventorySampleRequired' ) ) ;
@@ -1531,6 +1599,8 @@ function rowTitle(item: Item): string { return String(item.display_name || item.
function rowMeta ( item : Item ) : string {
if ( activeTab . value === 'inventoryFields' ) return ` ${ t ( ` admin.shippingInventory.inventoryFieldType. ${ item . value _type || 'text' } ` ) } · ${ t ( ` admin.shippingInventory.inventoryFieldPurposeOption. ${ item . usage _type || 'general' } ` ) } ` ;
if ( item . connector _type ) return String ( item . display _name ? t ( ` admin.shippingInventory.platform. ${ item . connector _type } ` ) : item . connector _type ) ;
// 解析规则列表带出用途徽标文案,库存/异动两种规则在列表一眼可分。
if ( activeTab . value === 'parsing' ) return ` ${ t ( ` admin.shippingInventory.parsingPurpose. ${ item . purpose === 'movement' ? 'movement' : 'inventory' } ` ) } · V ${ item . version ? ? '-' } ` ;
return String ( item . source _code || item . profile _code || item . rule _code || item . external _warehouse _code || '-' ) ;
}