提交
This commit is contained in:
1 parent
4611dbc2b2
commit
ebf006eeff
46 files changed
+36802
-20974
No files matched your search
@@ -377,14 +377,21 @@ export function plPlanListTabToFilters(tab: PlPlanListTab): {
|
||||
return { planType: plPlanTypeTabToFilter(tab) }
|
||||
}
|
||||
|
||||
/** 危化品证上传页:证书齐备筛选选项 */
|
||||
export const PL_PLAN_HAZARD_CERT_READY_FILTER_OPTIONS = [
|
||||
{ label: '未齐备', value: '0' },
|
||||
{ label: '已齐备', value: '1' }
|
||||
] as const
|
||||
|
||||
export function plPlanCertTabToFilters(tab: PlPlanCertTab): {
|
||||
planType: string
|
||||
certUploadStatus?: string
|
||||
hazardCertReady?: string
|
||||
} {
|
||||
if (tab === 'cert_incomplete') {
|
||||
return { planType: '', certUploadStatus: 'incomplete' }
|
||||
return { planType: '', certUploadStatus: 'incomplete', hazardCertReady: '0' }
|
||||
}
|
||||
return { planType: plPlanTypeTabToFilter(tab) }
|
||||
return { planType: plPlanTypeTabToFilter(tab), hazardCertReady: '' }
|
||||
}
|
||||
|
||||
export function plPlanTypeFilterToTab(planType?: string): PlPlanTypeTab {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
export type PlanContractDisplayLine = {
|
||||
side: string
|
||||
no: string
|
||||
contractId?: string
|
||||
pending?: boolean
|
||||
}
|
||||
|
||||
@@ -26,8 +27,9 @@ export function planContractSideLines(
|
||||
): PlanContractDisplayLine[] {
|
||||
const lines: PlanContractDisplayLine[] = []
|
||||
for (const item of contracts || []) {
|
||||
const no = item.contractNo || item.contractId
|
||||
if (no) lines.push({ side, no: String(no) })
|
||||
const contractId = item.contractId ? String(item.contractId) : undefined
|
||||
const no = item.contractNo || contractId
|
||||
if (no) lines.push({ side, no: String(no), contractId })
|
||||
}
|
||||
if (lines.length) return lines
|
||||
if (isPlInternalCustomerName(customerName)) {
|
||||
|
||||
@@ -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 '—'
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface PlanStopProductFormRow {
|
||||
outboundQty?: number
|
||||
outboundPrice?: number
|
||||
outboundAmount?: number
|
||||
/** 本段归档品牌数量 */
|
||||
brandQtys?: Array<{ brandId: string; brandName?: string; qty: number; unitPrice?: number }>
|
||||
remark?: string
|
||||
isExplosive?: number
|
||||
isToxic?: number
|
||||
@@ -361,6 +363,17 @@ function mapStopProductFromApi(row: PlanStopProduct): PlanStopProductFormRow {
|
||||
outboundQty: row.outboundQty != null ? Number(row.outboundQty) : undefined,
|
||||
outboundPrice: row.outboundPrice != null ? Number(row.outboundPrice) : undefined,
|
||||
outboundAmount: row.outboundAmount != null ? Number(row.outboundAmount) : undefined,
|
||||
brandQtys: (row.brandQtys || [])
|
||||
.filter((item) => Number(item.qty) > 0)
|
||||
.map((item) => ({
|
||||
brandId: String(item.brandId || ''),
|
||||
brandName: item.brandName,
|
||||
qty: Number(item.qty),
|
||||
unitPrice:
|
||||
item.unitPrice != null && Number.isFinite(Number(item.unitPrice))
|
||||
? Number(item.unitPrice)
|
||||
: undefined
|
||||
})),
|
||||
remark: row.remark
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user