提交
This commit is contained in:
1 parent
c90f72fd34
commit
6b6c80f182
100 files changed
+18631
-6278
No files matched your search
@@ -66,3 +66,13 @@ export function getProductUnitLabel(
|
||||
if (!unit) return '—'
|
||||
return getLabel('crm_product_unit', unit) || unit
|
||||
}
|
||||
|
||||
/** CRM 计量单位「吨」的字典值及历史直存文案 */
|
||||
export const TON_PRODUCT_UNIT_VALUES = new Set(['dun', '吨'])
|
||||
|
||||
/** 地磅过磅单位为吨;空单位按业务默认视为吨 */
|
||||
export function isTonProductUnit(unit: string | null | undefined): boolean {
|
||||
const code = (unit || '').trim()
|
||||
if (!code) return true
|
||||
return TON_PRODUCT_UNIT_VALUES.has(code)
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { InventoryRecord } from '@/api/db/inventory'
|
||||
import type { TransportInventoryLink } from '@/api/pl'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const SITE_INSTRUCTION = '说明:请打开链接上传现场附件并填写备注。'
|
||||
|
||||
type SiteSummaryRecord = {
|
||||
productName?: string
|
||||
batchNo?: string
|
||||
planNo?: string
|
||||
siteUrl?: string
|
||||
}
|
||||
|
||||
export function buildSiteSummaryFromInventoryLinks(options: {
|
||||
planNo?: string
|
||||
licensePlate?: string
|
||||
pickupTime?: string
|
||||
planDate?: string
|
||||
records: SiteSummaryRecord[]
|
||||
}) {
|
||||
const lines = ['【运输现场】']
|
||||
const planNo = options.planNo || options.records[0]?.planNo
|
||||
if (planNo) lines.push(`计划号:${planNo}`)
|
||||
if (options.licensePlate) lines.push(`车牌:${options.licensePlate}`)
|
||||
const time = formatDateTime(options.pickupTime) || options.planDate
|
||||
if (time) lines.push(`时间:${time}`)
|
||||
|
||||
const validRecords = options.records.filter(item => item.siteUrl)
|
||||
if (!validRecords.length) {
|
||||
lines.push('现场链接:—')
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
if (validRecords.length === 1) {
|
||||
const record = validRecords[0]
|
||||
lines.push(`产品:${record.productName || '—'}`)
|
||||
if (record.batchNo) lines.push(`出入库单号:${record.batchNo}`)
|
||||
lines.push(`现场链接:${record.siteUrl}`)
|
||||
} else {
|
||||
lines.push('')
|
||||
validRecords.forEach((record, index) => {
|
||||
lines.push(`【${index + 1}】${record.productName || '产品'}`)
|
||||
if (record.batchNo) lines.push(`出入库单号:${record.batchNo}`)
|
||||
lines.push(`现场链接:${record.siteUrl}`)
|
||||
if (index < validRecords.length - 1) lines.push('')
|
||||
})
|
||||
}
|
||||
|
||||
lines.push('')
|
||||
lines.push(SITE_INSTRUCTION)
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
export function buildSiteSummaryFromInventory(record: InventoryRecord, siteUrl: string) {
|
||||
const spec = record.specification?.trim()
|
||||
const product = spec ? `${record.product}(${spec})` : record.product
|
||||
const lines = [
|
||||
'【出入库现场】',
|
||||
`出入库单号:${record.batchNo || '—'}`,
|
||||
`业务类型:${record.businessType}`,
|
||||
`日期:${record.date || '—'}`,
|
||||
`往来单位:${record.partnerCompany || '—'}`,
|
||||
`产品:${product}`,
|
||||
`数量(吨):${record.quantity ?? '—'}`,
|
||||
`车牌:${record.vehicleNo || '—'}`
|
||||
]
|
||||
if (record.planNo) lines.push(`计划号:${record.planNo}`)
|
||||
lines.push(`现场链接:${siteUrl}`)
|
||||
lines.push('')
|
||||
lines.push(SITE_INSTRUCTION)
|
||||
return lines.join('\n')
|
||||
}
|
||||
Reference in new issue
Block a user