diff --git a/inventory-web/src/views/outbound/Selection.vue b/inventory-web/src/views/outbound/Selection.vue index 4428516..bf6f032 100644 --- a/inventory-web/src/views/outbound/Selection.vue +++ b/inventory-web/src/views/outbound/Selection.vue @@ -34,7 +34,7 @@ ([]) + +// 按库位路径自然升序排序(优化拣货路径) +const sortedSelectedItems = computed(() => { + return [...selectedItems.value].sort((a, b) => { + const locA = a.warehouse_location || '' + const locB = b.warehouse_location || '' + return locA.localeCompare(locB, 'zh', { numeric: true }) + }) +}) + const manualDialogVisible = ref(false) const bomSelectVisible = ref(false) const previewVisible = ref(false) @@ -452,10 +462,11 @@ const loadStockList = async () => { pageSize: stockPageSize.value, keyword: searchKeyword.value.trim() }) - // 为每个item添加uniqueKey,确保row-key唯一 + // 为每个item添加uniqueKey和确保warehouse_location字段正确映射 stockList.value = (res.data?.list || []).map((item: any) => ({ ...item, - uniqueKey: `${item.type}_${item.id}` + uniqueKey: `${item.type}_${item.id}`, + warehouse_location: item.warehouse_location || item.warehouse_loc || item.full_path || '' })) stockTotal.value = res.data?.total || 0 } catch (e) { @@ -484,7 +495,7 @@ const openManualSelect = async () => { ...i, name: i.name || i.material_name || i.product_name || '未知名称', standard: i.standard || i.spec_model || '', - warehouse_location: i.warehouse_location || (i.warehouse_loc) || '', + warehouse_location: i.warehouse_location || i.warehouse_loc || i.full_path || '', uniqueKey: `${i.type}_${i.id}`, available_quantity: parseFloat(i.available_quantity) || 0, export_quantity: 1