| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /** 运输计划 / 运费状态展示 */
- export function dash(val) {
- if (val == null || val === '') return '—'
- return String(val)
- }
- export function formatMoney(val) {
- if (val == null || val === '') return '—'
- const n = Number(val)
- if (Number.isNaN(n)) return String(val)
- return `¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
- }
- export function formatQty(val, unit = '') {
- if (val == null || val === '') return '—'
- const n = Number(val)
- const s = Number.isNaN(n) ? String(val) : String(n)
- return unit ? `${s} ${unit}` : s
- }
- export function planTypeLabel(planType) {
- const map = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
- return map[planType] || planType || '—'
- }
- export function followStatusLabel(status) {
- const map = {
- draft: { text: '草稿', tag: 'muted' },
- processing: { text: '进行中', tag: 'warning' },
- completed: { text: '已完成', tag: 'success' },
- cancelled: { text: '已作废', tag: 'danger' }
- }
- return map[status] || { text: status || '—', tag: 'muted' }
- }
- export function transportStatusLabel(status) {
- const map = {
- pending: { text: '待安排', tag: 'warning' },
- arranged: { text: '已安排', tag: 'info' }
- }
- return map[status] || { text: status || '—', tag: 'muted' }
- }
- export function archiveStatusLabel(status) {
- const map = {
- unarchived: { text: '未归档', tag: 'info' },
- archived: { text: '已归档', tag: 'success' }
- }
- return map[status] || { text: status || '—', tag: 'muted' }
- }
- /**
- * Demo 列表 Tab 语义:待发运 / 在途 / 已完成
- * - 待发运:transportStatus=pending 且未作废
- * - 在途:已安排且跟进未完成
- * - 已完成:followStatus=completed
- */
- export function planListPhase(row) {
- if (!row) return { text: '—', tag: 'muted', key: 'unknown' }
- if (row.followStatus === 'cancelled') return { text: '已作废', tag: 'danger', key: 'cancelled' }
- if (row.followStatus === 'completed') return { text: '已完成', tag: 'success', key: 'done' }
- if (row.transportStatus === 'pending') return { text: '待发运', tag: 'warning', key: 'pending' }
- if (row.transportStatus === 'arranged') return { text: '在途', tag: 'info', key: 'transit' }
- return followStatusLabel(row.followStatus)
- }
- export function settlementStatusLabel(status) {
- const map = {
- pending: { text: '草稿', tag: 'muted' },
- rejected: { text: '已驳回', tag: 'danger' },
- approving: { text: '审批中', tag: 'warning' },
- approved: { text: '待发放', tag: 'info' },
- confirmed: { text: '已发放', tag: 'success' },
- cancelled: { text: '已作废', tag: 'danger' }
- }
- return map[status] || { text: status || '—', tag: 'muted' }
- }
- export function isEditableDraftSettlement(status) {
- return status === 'pending' || status === 'rejected'
- }
- /** 计划卡片副标题:品名 · 数量 · 路线 */
- export function planCardSub(row) {
- if (!row) return '—'
- const products = Array.isArray(row.products) ? row.products : []
- const names = products
- .map((p) => p.productName || p.product_name)
- .filter(Boolean)
- .slice(0, 2)
- const namePart = names.length ? names.join('、') : planTypeLabel(row.planType)
- const qty = products.reduce((sum, p) => sum + (Number(p.quantity) || Number(p.actualQty) || 0), 0)
- const unit = products[0]?.unit || ''
- const qtyPart = qty > 0 ? formatQty(qty, unit) : ''
- const from = row.pickupAddress || row.supplierName || ''
- const to = row.destinationAddress || row.customerName || row.destinationName || ''
- const route = from && to ? `${shortAddr(from)} → ${shortAddr(to)}` : dash(row.customerName || row.destinationName)
- return [namePart, qtyPart, route].filter(Boolean).join(' · ')
- }
- function shortAddr(s) {
- const t = String(s || '')
- return t.length > 10 ? `${t.slice(0, 10)}…` : t
- }
- export function certReadyLabel(ready) {
- return ready ? { text: '证书齐备', tag: 'success' } : { text: '待齐备', tag: 'warning' }
- }
- export function hasPurchaseCert(product) {
- const url = product?.purchaseCertUrl || product?.purchase_cert_url
- return !!(url && String(url).trim())
- }
|