优化
This commit is contained in:
@@ -5,7 +5,6 @@ import { Plus, RefreshCw, Save, Sparkles, Trash2, Upload } from '@lucide/vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam'
|
||||
import { batchQueryPlatformCoLoadGroups, type CoLoadGroup } from '@/modules/unified-orders'
|
||||
import AdminPage from '@/shared/components/AdminPage.vue'
|
||||
import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue'
|
||||
import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
@@ -32,6 +31,7 @@ import type {
|
||||
SmartLoadingPlan,
|
||||
} from '../types'
|
||||
import { groupSmartLoadingItems, type SmartLoadingInboundItem } from '../smartLoadingItems'
|
||||
import { loadSmartLoadingPlanCoLoadGroups, type SmartLoadingPlanCoLoadGroup } from '../smartLoadingPlanGroups'
|
||||
|
||||
const props = withDefaults(defineProps<{ embedded?: boolean }>(), { embedded: false })
|
||||
|
||||
@@ -55,7 +55,7 @@ const assignOpen = ref(false)
|
||||
const selectedCandidate = ref<SmartLoadingCandidateRow | null>(null)
|
||||
const assignForm = reactive({ packageCount: 1 })
|
||||
const quantityDrafts = reactive<Record<string, number>>({})
|
||||
const planGroupsByInboundId = ref(new Map<string, CoLoadGroup>())
|
||||
const planGroupsByInboundId = ref(new Map<string, SmartLoadingPlanCoLoadGroup>())
|
||||
const query = ref<QueryModel>({ customerId: '', inboundCode: '' })
|
||||
const appliedQuery = ref<QueryModel>({ ...query.value })
|
||||
let selectionRequest = 0
|
||||
@@ -95,10 +95,10 @@ function memberOrderSummaries<T extends { orderId: string; orderNo?: string | nu
|
||||
}
|
||||
return [...orders.values()].map((order) => `${order.label}:${order.inboundCodes.join('、')}`)
|
||||
}
|
||||
function groupOrderCount(group: CoLoadGroup) { return new Set(group.members.map((member) => member.orderId)).size }
|
||||
function groupMemberLabel(group: CoLoadGroup) {
|
||||
const orderCount = groupOrderCount(group)
|
||||
return group.members.length === orderCount ? `${orderCount} 票` : `${orderCount} 票 · ${group.members.length} 个入仓片段`
|
||||
function groupMemberLabel(group: SmartLoadingPlanCoLoadGroup) {
|
||||
return group.inboundFragmentCount === group.memberOrderCount
|
||||
? `${group.memberOrderCount} 票`
|
||||
: `${group.memberOrderCount} 票 · ${group.inboundFragmentCount} 个入仓片段`
|
||||
}
|
||||
const displayedCandidates = computed<SmartLoadingCandidateRow[]>(() => {
|
||||
const rows: SmartLoadingCandidateRow[] = []
|
||||
@@ -128,7 +128,7 @@ const displayedCandidates = computed<SmartLoadingCandidateRow[]>(() => {
|
||||
}
|
||||
return rows
|
||||
})
|
||||
type SmartLoadingPlanRow = SmartLoadingInboundItem & { coLoadGroup: CoLoadGroup | null; memberInboundCodes: string[]; memberOrderSummaries: string[] }
|
||||
type SmartLoadingPlanRow = SmartLoadingInboundItem & { coLoadGroup: SmartLoadingPlanCoLoadGroup | null; memberInboundCodes: string[]; memberOrderSummaries: string[] }
|
||||
const displayedPlanItems = computed<SmartLoadingPlanRow[]>(() => {
|
||||
const inboundRows = groupSmartLoadingItems(plan.value?.items || [])
|
||||
const result: SmartLoadingPlanRow[] = []
|
||||
@@ -261,18 +261,6 @@ function acceptPlan(next: SmartLoadingPlan, preserved: Record<string, number> =
|
||||
if (syncContainerStatus) container.planStatus = next.status
|
||||
}
|
||||
}
|
||||
async function loadPlanGroups(request = selectionRequest) {
|
||||
planGroupsByInboundId.value = new Map()
|
||||
const currentPlan = plan.value
|
||||
const orderIds = [...new Set((currentPlan?.items || []).map((item) => item.orderId))]
|
||||
if (!currentPlan || !orderIds.length || !canAssign.value) return
|
||||
const groups = await batchQueryPlatformCoLoadGroups(orderIds)
|
||||
if (request !== selectionRequest || plan.value?.id !== currentPlan.id) return
|
||||
const byInbound = new Map<string, CoLoadGroup>()
|
||||
for (const info of groups) for (const member of info.group.members) byInbound.set(member.inboundId, info.group)
|
||||
planGroupsByInboundId.value = byInbound
|
||||
syncDrafts(currentPlan)
|
||||
}
|
||||
function clearSelectionData() {
|
||||
plan.value = null
|
||||
candidates.value = []
|
||||
@@ -303,7 +291,8 @@ async function loadSelectedData(preserved: Record<string, number> = {}) {
|
||||
candidates.value = candidateResult
|
||||
if (planResult.value) {
|
||||
acceptPlan(planResult.value, preserved, false)
|
||||
await loadPlanGroups(request)
|
||||
planGroupsByInboundId.value = await loadSmartLoadingPlanCoLoadGroups(planResult.value)
|
||||
syncDrafts(planResult.value, preserved)
|
||||
}
|
||||
else noDraft.value = planResult.missing
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user