fix(outbound): map warehouse location field correctly and implement natural sorting by location path for picking route optimization
This commit is contained in:
@ -34,7 +34,7 @@
|
||||
|
||||
<el-table
|
||||
v-else
|
||||
:data="selectedItems"
|
||||
:data="sortedSelectedItems"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="uniqueKey"
|
||||
@ -340,6 +340,16 @@ const userStore = useUserStore()
|
||||
|
||||
// --- 状态变量 ---
|
||||
const selectedItems = ref<any[]>([])
|
||||
|
||||
// 按库位路径自然升序排序(优化拣货路径)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user