| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 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)
- }
- })
- })
- }
|