| | |
| | | import { useBoolean, usePermission } from '@/hooks' |
| | | import { copyFence, fetchEnabledOpenCityList, getFenceList } from '@/service/api/operations' |
| | | import { deletePoint, enableDisablePoint, exportPointExcel, fetchFenceAndStationAreaList, fetchPointPageList } from '@/service/api/point' |
| | | import { deleteStation, fetchStationListByElectronicId, fetchStationPageList, updateStationStatus } from '@/service/api/station' |
| | | import { deleteStation, exportStationExcel, fetchStationListByElectronicId, fetchStationPageList, updateStationStatus } from '@/service/api/station' |
| | | import { useWorkbenchStore } from '@/store' |
| | | import { downloadFile } from '@/utils' |
| | | |
| | |
| | | checkedRowKeys.value = rowKeys |
| | | } |
| | | |
| | | function getSelectedStationRows() { |
| | | const selectedKeySet = new Set(checkedRowKeys.value) |
| | | return listData.value.filter(row => selectedKeySet.has(row.id)) |
| | | } |
| | | |
| | | function escapeCsvCell(value: unknown) { |
| | | const text = String(value ?? '').replace(/"/g, '""') |
| | | return `"${text}"` |
| | | } |
| | | |
| | | function buildStationCsvContent(rows: any[]) { |
| | | const headers = [ |
| | | '场站ID', |
| | | '场站名称', |
| | | '点位数量', |
| | | '限停时长', |
| | | '状态', |
| | | '更新人', |
| | | '更新时间', |
| | | '创建人', |
| | | '创建时间', |
| | | ] |
| | | |
| | | const records = rows.map((row) => { |
| | | const parkingTimeLimit = row.parkingTimeLimit ? `${row.parkingTimeLimit}分钟` : '-' |
| | | return [ |
| | | row.stationNumber || '-', |
| | | row.stationName || '-', |
| | | `${row.pointCount || 0}站点`, |
| | | parkingTimeLimit, |
| | | getStationStatusText(row), |
| | | row.updateBy || '-', |
| | | row.updateTime ? dayjs(row.updateTime).format('YYYY/MM/DD HH:mm') : '-', |
| | | row.createBy || '-', |
| | | row.createTime ? dayjs(row.createTime).format('YYYY/MM/DD HH:mm') : '-', |
| | | ].map(escapeCsvCell).join(',') |
| | | }) |
| | | |
| | | return [`\uFEFF${headers.map(escapeCsvCell).join(',')}`, ...records].join('\n') |
| | | } |
| | | |
| | | function handleStationBatchExport() { |
| | | async function handleStationBatchExport() { |
| | | if (checkedRowKeys.value.length === 0) { |
| | | message.warning('请先选择需要导出的点位') |
| | | message.warning('请先选择需要导出的场站') |
| | | return |
| | | } |
| | | |
| | | const selectedRows = getSelectedStationRows() |
| | | const csvContent = buildStationCsvContent(selectedRows) |
| | | const csvBlob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }) |
| | | const fileName = `RT运营管理后台-场站列表_${dayjs().format('YYYY-MM-DD')}.csv` |
| | | |
| | | downloadFile(csvBlob, fileName) |
| | | message.success('导出成功') |
| | | try { |
| | | const res = await exportStationExcel({ ids: checkedRowKeys.value }) |
| | | if (res instanceof Blob) { |
| | | downloadFile(res, '场站列表.xlsx') |
| | | message.success('导出成功') |
| | | } |
| | | else { |
| | | message.error('导出失败') |
| | | } |
| | | } |
| | | catch { |
| | | message.error('导出失败') |
| | | } |
| | | } |
| | | |
| | | function handleStationDisable(row: any) { |