fix: 拆包选择商品后锁定货主不可清空,商品搜索限定当前货主,修复弹窗回传store_id缺失

This commit is contained in:
liufumingren 2026-08-24 22:11:24 +08:00
parent 7803bc2879
commit 6d2df0f0d0
2 changed files with 17 additions and 4 deletions

View File

@ -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 ?? ''),

View File

@ -64,10 +64,12 @@
<el-select
v-model="selectedStoreId"
placeholder="无"
clearable
:clearable="!storeLocked"
filterable
size="small"
class="full-width"
:disabled="storeLocked"
:title="storeLocked ? '货主已锁定(原单退回或已选择商品)' : '选择货主'"
@change="handleStoreChange"
>
<el-option v-for="store in storeOptions" :key="store.value" :label="store.label" :value="store.value" />
@ -495,7 +497,7 @@
<!-- 商品选择弹窗 -->
<StockPickerDialog
v-model="stockPickerVisible"
:store-id="selectedStoreId ?? undefined"
:store-id="currentStoreId()"
:initial-keyword="stockPickerKeyword"
@confirm="handleStockSelected"
/>
@ -503,7 +505,7 @@
<!-- 快速添加:条码多商品选择弹窗 -->
<StockPickerDialog
v-model="quickAddPickerVisible"
:store-id="selectedStoreId ?? undefined"
:store-id="currentStoreId()"
:initial-keyword="quickAddKeyword"
@confirm="handleQuickAddSelected"
/>
@ -599,6 +601,8 @@ const {
// 货主选择(来源:returnUnpack.create 返回 + 条码查询商品返回)
const selectedStoreId = ref<number | null>(null)
const storeOptions = ref<Array<{ label: string; value: number }>>([])
/** 货主是否锁定:原单退回或已选择商品后不可再切换 */
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