diff --git a/src/pages_function/pages/materialInbound/materialConfirm.vue b/src/pages_function/pages/materialInbound/materialConfirm.vue index f799e39..2a310d0 100644 --- a/src/pages_function/pages/materialInbound/materialConfirm.vue +++ b/src/pages_function/pages/materialInbound/materialConfirm.vue @@ -71,27 +71,21 @@ 库区 - - - - {{ selectedArea ? selectedArea.label : (loadingAreas ? '加载中...' : '请选择') }} - - - - - - - {{ item.label }} - + + + + + + 选择 - 暂无数据 - + @@ -161,11 +155,11 @@ const inboundQty = ref(null) const warehouseOptions = ref([]) const selectedWarehouse = ref(null) -// 库区下拉 +// 库区 const areaOptions = ref([]) const selectedArea = ref(null) -const showAreaDropdown = ref(false) const loadingAreas = ref(false) +const areaScanInput = ref('') const materialImage = computed(() => { const images = material.value.images @@ -295,17 +289,41 @@ async function loadWarehouses() { } // 库区 -function toggleAreaDropdown() { - if (!selectedWarehouse.value) { - uni.showToast({ title: '请先选择仓库', icon: 'none' }) - return +function getAreaIndex(selected, options) { + if (!selected) return -1 + const index = options.findIndex((item) => String(item.value) === String(selected.value)) + return index >= 0 ? index : -1 +} + +function onAreaChange(event) { + const index = Number(event.detail.value) + if (index >= 0 && index < areaOptions.value.length) { + selectedArea.value = areaOptions.value[index] + areaScanInput.value = selectedArea.value.label } - showAreaDropdown.value = !showAreaDropdown.value } -function handleSelectArea(item) { - selectedArea.value = item - showAreaDropdown.value = false + +function getAreaScanId(value) { + const text = String(value || '').trim() + if (!text) return '' + const match = text.match(/WAREHOUSE_AREA[-_:](\d+)/i) + if (match) return match[1] + const tail = text.match(/(\d+)$/) + return tail ? tail[1] : text } + +async function onAreaScanConfirm() { + const areaId = getAreaScanId(areaScanInput.value) + if (!areaId) return + const area = areaOptions.value.find((item) => String(item.value) === String(areaId)) + if (!area) { + uni.showToast({ title: '未找到该库区', icon: 'none' }) + return + } + selectedArea.value = area + areaScanInput.value = area.label +} + async function loadAreas(warehouseId) { if (!warehouseId) return loadingAreas.value = true @@ -363,9 +381,7 @@ async function loadStockCount() { } } -onHide(() => { - showAreaDropdown.value = false -}) +onHide(() => {})