feat(pl): add cert batch ZIP download on self-vehicle list.

Reuse vehicle cert zip packing on the Shanxia owned-vehicle toolbar.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-08 20:39:37 +08:00
1 parent 55abe614f8
commit 6d8e5578c9
1 file changed
+37
@@ -61,6 +61,15 @@
filename="自有车列表.xlsx"
/>
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
:loading="certZipLoading"
@click="handleBatchDownloadCertZip"
>
<el-icon><Download /></el-icon>批量下载证书 ZIP
</el-button>
<ListToolbarEndActions
:loading="loading"
:column-defs="listColumnDefs"
@@ -530,6 +539,7 @@ import {
previewListPhoto,
resolvePhotoDisplayUrl
} from '@/utils/pl-photo'
import { buildAndSaveVehicleCertZip } from '@/utils/pl-vehicle-cert-zip'
const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw)
const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw)
@@ -650,6 +660,7 @@ const { handlePersonnelFormSaved } = usePlVehiclePersonnelQuickCreate({
onSelect: handlePersonnelSelect
})
const selectedRows = ref<Vehicle[]>([])
const certZipLoading = ref(false)
function buildListQueryParams(): Record<string, any> {
const params: Record<string, any> = {
@@ -1001,6 +1012,32 @@ function handleSelectionChange(rows: Vehicle[]) {
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() {
if (selectedRows.value.length !== 1) {
ElMessage.warning('请选择一条车辆记录')