提交
This commit is contained in:
1 parent
b9ff9c9d67
commit
44749ae716
87 files changed
+35089
-21918
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
|
||||
export type PlanContractDisplayLine = {
|
||||
side: string
|
||||
no: string
|
||||
pending?: boolean
|
||||
}
|
||||
|
||||
type PlanContractLike = {
|
||||
contractId?: string
|
||||
contractNo?: string
|
||||
}
|
||||
|
||||
type PlanContractParties = {
|
||||
supplierName?: string | null
|
||||
customerName?: string | null
|
||||
supplierContracts?: PlanContractLike[]
|
||||
demanderContracts?: PlanContractLike[]
|
||||
}
|
||||
|
||||
/** 单侧:有编号显示编号;非内置缺合同「待补充」;内置缺合同「—」 */
|
||||
export function planContractSideLines(
|
||||
side: '供' | '需',
|
||||
contracts: PlanContractLike[] | undefined,
|
||||
customerName?: string | null
|
||||
): PlanContractDisplayLine[] {
|
||||
const lines: PlanContractDisplayLine[] = []
|
||||
for (const item of contracts || []) {
|
||||
const no = item.contractNo || item.contractId
|
||||
if (no) lines.push({ side, no: String(no) })
|
||||
}
|
||||
if (lines.length) return lines
|
||||
if (isPlInternalCustomerName(customerName)) {
|
||||
return [{ side, no: '—' }]
|
||||
}
|
||||
return [{ side, no: '待补充', pending: true }]
|
||||
}
|
||||
|
||||
/** 合同列:供/需各至少一行 */
|
||||
export function planContractLines(plan: PlanContractParties): PlanContractDisplayLine[] {
|
||||
return [
|
||||
...planContractSideLines('供', plan.supplierContracts, plan.supplierName),
|
||||
...planContractSideLines('需', plan.demanderContracts, plan.customerName)
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user