diff --git a/src/views/express/returnUnpack/components/StockPickerDialog.vue b/src/views/express/returnUnpack/components/StockPickerDialog.vue index 2051e679..375f5a07 100644 --- a/src/views/express/returnUnpack/components/StockPickerDialog.vue +++ b/src/views/express/returnUnpack/components/StockPickerDialog.vue @@ -76,6 +76,7 @@ import { isStockApiSuccess, parseStockWarehouseSearch, mapStockPickerItem, + getStockStoreId, } from '@/views/order/orderManagement/utils/stock-picker-helpers' import { parseStockWarehouseListResponse } from '@/views/stock/combo_stock/combo-stock-config' @@ -167,7 +168,8 @@ function mapRow(row: any): StockPickerItem | null { const mapped = mapStockPickerItem(row) const id = Number(mapped.item_id) if (!Number.isInteger(id) || id <= 0) return null - const storeId = Number(mapped.store_id ?? row?.store_id) + // 货主ID优先取 store_stock.store_id(stock.warehouse.search 返回结构),其次顶层 store_id + const storeId = Number(getStockStoreId(row) ?? mapped.store_id ?? row?.store_id) return { id, item_code: String(mapped.item_code ?? ''), diff --git a/src/views/express/returnUnpackwork/index.vue b/src/views/express/returnUnpackwork/index.vue index 56a7f5a9..f8444d20 100644 --- a/src/views/express/returnUnpackwork/index.vue +++ b/src/views/express/returnUnpackwork/index.vue @@ -64,10 +64,12 @@ @@ -495,7 +497,7 @@ @@ -503,7 +505,7 @@ @@ -599,6 +601,8 @@ const { // 货主选择(来源:returnUnpack.create 返回 + 条码查询商品返回) const selectedStoreId = ref(null) const storeOptions = ref>([]) +/** 货主是否锁定:原单退回或已选择商品后不可再切换 */ +const storeLocked = ref(false) // 产品状态(快速添加明细时使用) const defaultProductStatus = ref<'normal' | 'damaged'>('normal') @@ -668,6 +672,8 @@ function syncStoreFromStockItem(item: any) { if (selectedStoreId.value == null) { selectedStoreId.value = storeId } + // 选择商品后锁定货主:货主由商品所属仓库决定,不允许再切换 + storeLocked.value = true } // 拆包单列表 + 明细分页 + 操作 @@ -790,6 +796,8 @@ async function handleCreate(barcode?: string) { if (recordStoreId != null) { addStoreCandidate(recordStoreId, data.store_remark || '') } + // 原单退回的拆包单锁定货主,不允许切换 + storeLocked.value = Boolean(data.is_original_return) ElMessage.success(`拆包单创建成功,ID ${data.id}`) // 保留输入的运单号显示在锁定的输入框中(创建后运单号置灰不可改) lastScannedBarcode.value = '' @@ -978,6 +986,8 @@ function handleStockSelected(item: { id: number; item_code: string; item_name: s if (!detailForm.barcode && item.barcode) { detailForm.barcode = item.barcode } + // 手动选择商品后同步并锁定货主 + syncStoreFromStockItem(item) } function openStockPicker() { @@ -1348,6 +1358,7 @@ function resetWorkState() { waybillCode.value = '' detailBarcode.value = '' selectedStoreId.value = null + storeLocked.value = false storeOptions.value = [] defaultProductStatus.value = 'normal' orderDetailData.value = null