提交
This commit is contained in:
1 parent
4611dbc2b2
commit
ebf006eeff
46 files changed
+36802
-20974
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { Plan, PlanDelivery, PlanLoad, PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import {
|
||||
planContractSideLines,
|
||||
type PlanContractDisplayLine
|
||||
@@ -29,7 +30,9 @@ export function resolvePlanStopsForList(plan: Plan): {
|
||||
load: PlanLoad
|
||||
deliveries: PlanDelivery[]
|
||||
} {
|
||||
if (plan.load && (plan.deliveries?.length ?? 0) > 0) {
|
||||
// 有段次结构时优先用 load/deliveries(含段上 contracts);勿因 deliveries 为空回退 legacy,
|
||||
// 否则会丢掉 stop.contracts,误用空的 supplierContracts/demanderContracts。
|
||||
if (plan.load) {
|
||||
return {
|
||||
load: plan.load,
|
||||
deliveries: plan.deliveries || []
|
||||
@@ -163,6 +166,85 @@ export function getStopCustomerName(row: PlPlanListDisplayRow): string {
|
||||
return (row.stop.customerName || '').trim() || '—'
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档列表:入库/出库列展示方向(按本段客户)。
|
||||
* - 装货:山峡/云栋 → 出库;其他 → 入库
|
||||
* - 送货:山峡/云栋 → 入库;其他 → 出库
|
||||
*/
|
||||
export function resolveArchiveListIoColumn(
|
||||
kind: PlPlanListDisplayRowKind,
|
||||
customerName?: string | null
|
||||
): 'inbound' | 'outbound' {
|
||||
const internal = isPlInternalCustomerName(customerName)
|
||||
if (kind === 'load') return internal ? 'outbound' : 'inbound'
|
||||
return internal ? 'inbound' : 'outbound'
|
||||
}
|
||||
|
||||
/** 段次归档实际数量(装货读 inboundQty,送货读 outboundQty) */
|
||||
export function getStopArchiveActualQty(product: PlanStopProduct, kind: PlPlanListDisplayRowKind): number | null {
|
||||
const raw = kind === 'load' ? product.inboundQty : product.outboundQty
|
||||
if (raw == null || raw === '') return null
|
||||
const num = Number(raw)
|
||||
return Number.isFinite(num) ? num : null
|
||||
}
|
||||
|
||||
export function getStopArchiveUnitPrice(
|
||||
product: PlanStopProduct,
|
||||
kind: PlPlanListDisplayRowKind
|
||||
): number | null {
|
||||
const raw = kind === 'load' ? product.inboundPrice : product.outboundPrice
|
||||
if (raw == null || raw === '') return null
|
||||
const num = Number(raw)
|
||||
return Number.isFinite(num) ? num : null
|
||||
}
|
||||
|
||||
export function getStopArchiveAmount(
|
||||
product: PlanStopProduct,
|
||||
kind: PlPlanListDisplayRowKind
|
||||
): number | null {
|
||||
const stored = kind === 'load' ? product.inboundAmount : product.outboundAmount
|
||||
if (stored != null && stored !== '') {
|
||||
const num = Number(stored)
|
||||
if (Number.isFinite(num)) return num
|
||||
}
|
||||
const qty = getStopArchiveActualQty(product, kind)
|
||||
const price = getStopArchiveUnitPrice(product, kind)
|
||||
if (qty == null || price == null) return null
|
||||
const amount = qty * price
|
||||
return Number.isFinite(amount) ? amount : null
|
||||
}
|
||||
|
||||
export function sumStopArchiveActualQty(
|
||||
stopProducts: PlanStopProduct[],
|
||||
kind: PlPlanListDisplayRowKind
|
||||
): number {
|
||||
return stopProducts.reduce((sum, item) => sum + (getStopArchiveActualQty(item, kind) || 0), 0)
|
||||
}
|
||||
|
||||
export function sumStopArchiveIoQty(
|
||||
stopProducts: PlanStopProduct[],
|
||||
kind: PlPlanListDisplayRowKind,
|
||||
customerName: string | null | undefined,
|
||||
column: 'inbound' | 'outbound'
|
||||
): number {
|
||||
if (resolveArchiveListIoColumn(kind, customerName) !== column) return 0
|
||||
return sumStopArchiveActualQty(stopProducts, kind)
|
||||
}
|
||||
|
||||
export function sumStopArchiveUnitPrice(
|
||||
stopProducts: PlanStopProduct[],
|
||||
kind: PlPlanListDisplayRowKind
|
||||
): number {
|
||||
return stopProducts.reduce((sum, item) => sum + (getStopArchiveUnitPrice(item, kind) || 0), 0)
|
||||
}
|
||||
|
||||
export function sumStopArchiveAmount(
|
||||
stopProducts: PlanStopProduct[],
|
||||
kind: PlPlanListDisplayRowKind
|
||||
): number {
|
||||
return stopProducts.reduce((sum, item) => sum + (getStopArchiveAmount(item, kind) || 0), 0)
|
||||
}
|
||||
|
||||
/** 装货行展示供方;送货行留空 */
|
||||
export function getStopSupplierNameDisplay(row: PlPlanListDisplayRow): string {
|
||||
if (row.kind !== 'load') return '—'
|
||||
|
||||
Reference in new issue
Block a user