57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/**
|
|
* ETC/油卡充值申请发微信群纯文本(无序号)
|
|
*/
|
|
|
|
import { countPlAttachmentUrls } from '@/utils/plFuelRegisterCopy'
|
|
|
|
const TYPE_LABELS = {
|
|
etc: 'ETC',
|
|
fuel: '油卡'
|
|
}
|
|
|
|
export function getPlRechargeTypeLabel(type) {
|
|
return TYPE_LABELS[type] || type || '—'
|
|
}
|
|
|
|
export function buildVehicleRechargeApplyCopyText(row = {}) {
|
|
const dash = '—'
|
|
const plate = String(row.licensePlate || '').trim() || dash
|
|
const odometer =
|
|
row.odometerKm != null && Number.isFinite(Number(row.odometerKm))
|
|
? `${Number(row.odometerKm).toFixed(1)} KM`
|
|
: dash
|
|
return [
|
|
`【${plate} - ETC/油卡充值申请】`,
|
|
`申请单号:${row.applyNo || dash}`,
|
|
`充值类型:${getPlRechargeTypeLabel(row.rechargeType)}`,
|
|
`申请日期:${row.applyDate || dash}`,
|
|
`申请人:${row.applicantName || dash}`,
|
|
`车牌号:${plate}`,
|
|
`期初公里数:${odometer}`,
|
|
`附件个数:${countPlAttachmentUrls(row.attachmentUrls)}`,
|
|
`备注:${String(row.remark || '').trim() || dash}`
|
|
].join('\n')
|
|
}
|
|
|
|
/** 复制到剪贴板;成功返回 true */
|
|
export function copyVehicleRechargeApplyToClipboard(row) {
|
|
const text = buildVehicleRechargeApplyCopyText(row)
|
|
if (!text) {
|
|
uni.showToast({ title: '暂无可复制内容', icon: 'none' })
|
|
return Promise.resolve(false)
|
|
}
|
|
return new Promise((resolve) => {
|
|
uni.setClipboardData({
|
|
data: text,
|
|
success: () => {
|
|
uni.showToast({ title: '已复制', icon: 'success' })
|
|
resolve(true)
|
|
},
|
|
fail: () => {
|
|
uni.showToast({ title: '复制失败', icon: 'none' })
|
|
resolve(false)
|
|
}
|
|
})
|
|
})
|
|
}
|