import type { CertType, QuotaCert } from '@/api/pl/quota-cert' import { certFormGroups } from '@/views/pl/quota-cert/model' export const certStatusLabels: Record = { draft: '待核对', active: '已启用', suspended: '已停用', closed: '已核销', void: '已作废' } export const refLabels: Record = { purchase_permit: '购买许可证', purchase_filing: '购买备案证明', export_permit: '出口许可证', unknown: '待确认' } const longFaceKeys = new Set([ 'buyerAddress', 'sellerAddress', 'shipperAddress', 'carrierAddressPhone', 'routeText', 'purchasePurpose', 'packagingText', 'remark' ]) export type FaceField = { label: string; value: string; wide?: boolean } export type FaceGroup = { title: string; fields: FaceField[] } export function certCategoryLabel( cert: Pick & { certType?: CertType | null }, kind?: CertType ) { const certKind = kind || cert.certType if (certKind === 'transport') { const names = (cert.derivedCategoryNames || []) .map((item) => String(item || '').trim()) .filter(Boolean) return names.join('、') || '—' } return String(cert.categoryName || '').trim() || '—' } export function certFaceGroups( cert: QuotaCert, kind: CertType, display: (cert: QuotaCert, key: string) => string ): FaceGroup[] { const groups = certFormGroups(kind).map((group, index) => { const fields = group.fields.map((field) => ({ label: field[1], value: field[0] === 'vehicleNumbersJson' ? cert.vehicleNumbersJson?.filter(Boolean).join('、') || '—' : display(cert, field[0]), wide: longFaceKeys.has(field[0]) || field[0] === 'vehicleNumbersJson' })) if (index === 0) { fields.unshift( { label: '状态', value: display(cert, 'status') }, { label: '系统客户', value: String(cert.customerName || '').trim() || '—', wide: true }, { label: '证用品类', value: certCategoryLabel(cert, kind), wide: true } ) } return { title: group.title, fields } }) groups[groups.length - 1].fields.push({ label: '系统备注', value: display(cert, 'remark'), wide: true }) return groups }