feat(pl): add toolbar batch ZIP download for vehicle certs.

Wire selected rows to frontend JSZip packing on the third-party vehicle list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-08 20:26:46 +08:00
1 parent 31ef9d4053
commit a6dff669d4
1 file changed
+37
+37
View File
@@ -64,6 +64,15 @@
filename="车辆列表.xlsx" filename="车辆列表.xlsx"
/> />
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
:loading="certZipLoading"
@click="handleBatchDownloadCertZip"
>
<el-icon><Download /></el-icon>批量下载证书 ZIP
</el-button>
<ListToolbarEndActions <ListToolbarEndActions
:loading="loading" :loading="loading"
:column-defs="listColumnDefs" :column-defs="listColumnDefs"
@@ -542,6 +551,7 @@ import {
previewListPhoto, previewListPhoto,
resolvePhotoDisplayUrl resolvePhotoDisplayUrl
} from '@/utils/pl-photo' } from '@/utils/pl-photo'
import { buildAndSaveVehicleCertZip } from '@/utils/pl-vehicle-cert-zip'
const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw) const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw)
const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw) const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw)
@@ -665,6 +675,7 @@ const { handlePersonnelFormSaved } = usePlVehiclePersonnelQuickCreate({
onSelect: handlePersonnelSelect onSelect: handlePersonnelSelect
}) })
const selectedRows = ref<Vehicle[]>([]) const selectedRows = ref<Vehicle[]>([])
const certZipLoading = ref(false)
function buildListQueryParams(): Record<string, any> { function buildListQueryParams(): Record<string, any> {
const params: Record<string, any> = { const params: Record<string, any> = {
@@ -1047,6 +1058,32 @@ function handleSelectionChange(rows: Vehicle[]) {
selectedRows.value = rows selectedRows.value = rows
} }
async function handleBatchDownloadCertZip() {
if (!selectedRows.value.length || certZipLoading.value) return
certZipLoading.value = true
try {
const result = await buildAndSaveVehicleCertZip(selectedRows.value)
if (!result.zipName && result.okCount === 0 && result.failCount === 0) {
ElMessage.warning('无可下载附件')
return
}
if (!result.zipName && result.failCount > 0) {
ElMessage.error('下载失败,请稍后重试')
return
}
if (result.failCount > 0) {
ElMessage.warning(`已打包 ${result.okCount} 个文件,${result.failCount} 个失败`)
return
}
ElMessage.success(`下载成功(${result.okCount} 个文件)`)
} catch (e) {
console.error(e)
ElMessage.error('下载失败,请稍后重试')
} finally {
certZipLoading.value = false
}
}
function handleToolbarEdit() { function handleToolbarEdit() {
if (selectedRows.value.length !== 1) { if (selectedRows.value.length !== 1) {
ElMessage.warning('请选择一条车辆记录') ElMessage.warning('请选择一条车辆记录')