This commit is contained in:
zlwu committed 2026-06-21 09:19:07 +08:00
1 parent c3be9d1dce
commit 299609706c
328 files changed
+144899 -13873

No files matched your search

+160
View File
@@ -0,0 +1,160 @@
export function getPlVehicleStatusTagType(status: string) {
const map: Record<string, string> = {
available: 'success',
maintaining: 'warning',
scrapped: 'danger'
}
return map[status] || 'info'
}
export function getPlVehicleStatusLabel(status: string) {
const map: Record<string, string> = {
available: '可用',
maintaining: '维修中',
scrapped: '报废'
}
return map[status] || status
}
export function getPlVehicleTypeLabel(type: string) {
return type === 'self' ? '自有' : type === 'carrier' ? '承运商' : type
}
export function getPlVehicleTypeTagType(type: string) {
return type === 'self' ? 'success' : 'warning'
}
export function getPlCarrierStatusLabel(status: string) {
return status === '1' ? '合作中' : '已终止'
}
export function getPlCarrierStatusTagType(status: string) {
return status === '1' ? 'success' : 'danger'
}
export function getPlanProductSpec(product: { model?: string; packageSpec?: string }) {
return product.model || product.packageSpec || '—'
}
export function getPlanProductQuantity(product: {
quantity?: number | string | null
actualQty?: number | string | null
inboundEstimateQty?: number | string | null
outboundEstimateQty?: number | string | null
}) {
const qty =
product.actualQty ??
product.quantity ??
product.inboundEstimateQty ??
product.outboundEstimateQty
if (qty === undefined || qty === null || qty === '') return '—'
return String(qty)
}
export function formatPlanProductListText(
product: {
productName?: string
model?: string
packageSpec?: string
unit?: string
quantity?: number | string | null
actualQty?: number | string | null
inboundEstimateQty?: number | string | null
outboundEstimateQty?: number | string | null
},
getUnitLabel?: (unit: string) => string
) {
const name = product.productName || '—'
const spec = getPlanProductSpec(product)
const qty = getPlanProductQuantity(product)
const unitRaw = product.unit || ''
const unit = unitRaw ? (getUnitLabel ? getUnitLabel(unitRaw) || unitRaw : unitRaw) : ''
const specPart = spec && spec !== '—' ? `(${spec})` : ''
let qtyUnit = '—'
if (qty !== '—' && unit) {
qtyUnit = `${qty}${unit}`
} else if (qty !== '—') {
qtyUnit = qty
} else if (unit) {
qtyUnit = unit
}
return `${name}${specPart},${qtyUnit}`
}
export function getPlPlanCompanyLabel(company?: string) {
const map: Record<string, string> = { shanxia: '安庆山峡', yundong: '安徽云栋' }
return company ? map[company] || company : '—'
}
export function getPlPlanTypeTagType(type?: string) {
const map: Record<string, string> = { direct: 'primary', inbound: 'success', outbound: 'warning' }
return map[type || ''] || 'info'
}
export function getPlPlanTypeLabel(type?: string) {
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
return type ? map[type] || type : '—'
}
export function getPlPlanFollowStatusTagType(status?: string) {
const map: Record<string, string> = {
draft: 'info',
processing: 'warning',
completed: 'success',
cancelled: 'danger'
}
return map[status || ''] || 'info'
}
export function getPlPlanFollowStatusLabel(status?: string) {
const map: Record<string, string> = {
draft: '草稿',
processing: '进行中',
completed: '已完成',
cancelled: '已取消'
}
return status ? map[status] || status : '—'
}
export function getPlPlanArchiveStatusTagType(status?: string) {
return status === 'archived' ? 'info' : 'success'
}
export function getPlPlanArchiveStatusLabel(status?: string) {
return status === 'archived' ? '已归档' : '未归档'
}
export function getPlPlanCompleteStatusLabel(status?: string) {
return status === 'yes' ? '是' : '否'
}
export function getPlFreightTypeLabel(type?: string) {
const map: Record<string, string> = { by_weight: '按重量', by_trip: '按趟' }
return type ? map[type] || type : '—'
}
export function getPlYesNoLabel(value?: number | boolean | null) {
return value === 1 || value === true ? '是' : '否'
}
/** 解析运输单司机回传附件(JSON 数组或逗号分隔) */
export function parsePlFeedbackImages(raw?: string | string[] | null): string[] {
if (!raw) return []
if (Array.isArray(raw)) return raw.map((item) => String(item).trim()).filter(Boolean)
const text = String(raw).trim()
if (!text) return []
try {
const parsed = JSON.parse(text)
if (Array.isArray(parsed)) {
return parsed.map((item) => String(item).trim()).filter(Boolean)
}
} catch {
// fall through
}
return text
.split(',')
.map((item) => item.trim())
.filter(Boolean)
}