提交
This commit is contained in:
1 parent
c3be9d1dce
commit
299609706c
328 files changed
+144899
-13873
No files matched your search
@@ -0,0 +1,122 @@
|
||||
import type { ContractProductForm, ContractVO } from '@/api/crm/contract/types'
|
||||
|
||||
export interface PlanFormProductRow {
|
||||
id?: string
|
||||
productId: string
|
||||
productNo: string
|
||||
productName: string
|
||||
model?: string
|
||||
categoryName?: string
|
||||
unit: string
|
||||
quantity: number
|
||||
actualQty?: number
|
||||
packageSpec?: string
|
||||
deliveryMethod?: string
|
||||
taxRate?: number
|
||||
taxPrice?: number
|
||||
taxSubtotal?: number
|
||||
taxAmount?: number
|
||||
remark?: string
|
||||
isExplosive?: number
|
||||
isToxic?: number
|
||||
purchaseCertUrl?: string
|
||||
transportCertUrl?: string
|
||||
}
|
||||
|
||||
export function determinePlPlanType(supplierName?: string, destinationName?: string) {
|
||||
if (destinationName && (destinationName.includes('安庆山峡') || destinationName.includes('安徽云栋'))) {
|
||||
return 'inbound'
|
||||
}
|
||||
if (supplierName && (supplierName.includes('安庆山峡') || supplierName.includes('安徽云栋'))) {
|
||||
return 'outbound'
|
||||
}
|
||||
return 'direct'
|
||||
}
|
||||
|
||||
export function resolveBelongsCompany(supplierName?: string) {
|
||||
if (supplierName?.includes('安徽云栋')) return 'yundong'
|
||||
return 'shanxia'
|
||||
}
|
||||
|
||||
export function mapContractProductToPlanRow(item: ContractProductForm, index: number): PlanFormProductRow {
|
||||
const productId = String(item.productId || item.id || index)
|
||||
return {
|
||||
productId,
|
||||
productNo: productId,
|
||||
productName: item.productName || '',
|
||||
model: item.model || item.productModel,
|
||||
categoryName: item.categoryName,
|
||||
unit: item.unit || '吨',
|
||||
quantity: Number(item.quantity || 0),
|
||||
actualQty: Number(item.quantity || 0),
|
||||
packageSpec: item.packageSpec,
|
||||
deliveryMethod: item.deliveryMethod,
|
||||
taxRate: item.taxRate != null ? Number(item.taxRate) : undefined,
|
||||
taxPrice: item.price != null ? Number(item.price) : undefined,
|
||||
taxSubtotal: item.subtotal != null ? Number(item.subtotal) : undefined,
|
||||
taxAmount: item.taxAmount != null ? Number(item.taxAmount) : undefined,
|
||||
remark: item.remark,
|
||||
isExplosive: Number(item.isExplosive ?? 0),
|
||||
isToxic: Number(item.isToxic ?? 0)
|
||||
}
|
||||
}
|
||||
|
||||
export function mapContractProducts(products?: ContractProductForm[]) {
|
||||
return (products || []).map(mapContractProductToPlanRow)
|
||||
}
|
||||
|
||||
export function applyContractToPlanForm(contract: ContractVO) {
|
||||
const supplierName = contract.supplierName || contract.partyA
|
||||
const destinationName = contract.customerName || contract.partyB
|
||||
const planType = determinePlPlanType(supplierName, destinationName)
|
||||
|
||||
return {
|
||||
contractId: String(contract.id),
|
||||
contractNo: contract.contractNo,
|
||||
belongsCompany: resolveBelongsCompany(supplierName),
|
||||
planType,
|
||||
supplierId: contract.supplierId != null ? String(contract.supplierId) : '',
|
||||
supplierName: supplierName || '',
|
||||
destinationId: contract.customerId != null ? String(contract.customerId) : '',
|
||||
destinationName: destinationName || '',
|
||||
customerId: contract.customerId != null ? String(contract.customerId) : '',
|
||||
customerName: contract.customerName || '',
|
||||
contactName: contract.contactName || contract.partyBContact || '',
|
||||
contactPhone: contract.contactMobile || contract.partyBMobile || '',
|
||||
partyA: contract.partyA || '',
|
||||
partyB: contract.partyB || '',
|
||||
contractStartDate: contract.startDate || '',
|
||||
contractEndDate: contract.endDate || '',
|
||||
settlementMethod: contract.settlementMethod || '',
|
||||
hasFreight: contract.settlementMethod?.includes('含运') ? 1 : 0,
|
||||
products: mapContractProducts(contract.products)
|
||||
}
|
||||
}
|
||||
|
||||
export function getPlanTypeLabel(planType: string) {
|
||||
const map: Record<string, string> = {
|
||||
direct: '直销单',
|
||||
inbound: '入库单',
|
||||
outbound: '出库单'
|
||||
}
|
||||
return map[planType] || planType
|
||||
}
|
||||
|
||||
export function getPlanTypeTagType(planType: string) {
|
||||
const map: Record<string, string> = {
|
||||
direct: 'primary',
|
||||
inbound: 'success',
|
||||
outbound: 'warning'
|
||||
}
|
||||
return map[planType] || 'info'
|
||||
}
|
||||
|
||||
export function getDeliveryMethodLabel(method?: string) {
|
||||
const map: Record<string, string> = {
|
||||
self_pick: '山峡自提',
|
||||
one_ticket: '一票制',
|
||||
customer_pick: '客户自提'
|
||||
}
|
||||
if (!method) return '—'
|
||||
return map[method] || method
|
||||
}
|
||||
Reference in new issue
Block a user