feat: 文件下载
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m54s

This commit is contained in:
sexygoat
2026-04-30 18:04:01 +08:00
parent 81155fd8e4
commit 950520635d
19 changed files with 438 additions and 44 deletions

View File

@@ -40,7 +40,7 @@
:total="pagination.total"
:marginTop="10"
:actions="getActions"
:actionsWidth="120"
:actionsWidth="180"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
@@ -614,9 +614,34 @@
}
}
const downloadTaskFile = async (row: DeviceImportTask) => {
const fileKey = row.file_name?.trim()
if (!fileKey) {
ElMessage.warning('当前任务没有可下载的原始文件')
return
}
try {
await StorageService.downloadFileByKey(fileKey)
ElMessage.success('原始文件下载已开始')
} catch (error) {
console.error('下载原始文件失败:', error)
ElMessage.error('下载原始文件失败')
}
}
// 获取操作按钮
const getActions = (row: DeviceImportTask) => {
const actions: any[] = []
const showDownloadFileAction = false
if (showDownloadFileAction && row.file_name?.trim() && hasAuth('device_task:download_file')) {
actions.push({
label: '下载文件',
handler: () => downloadTaskFile(row),
type: 'primary'
})
}
if (row.fail_count > 0 && hasAuth('device_task:download_fail_data')) {
actions.push({

View File

@@ -40,7 +40,7 @@
:total="pagination.total"
:marginTop="10"
:actions="getActions"
:actionsWidth="120"
:actionsWidth="180"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
@@ -237,6 +237,7 @@
import { StorageService } from '@/api/modules/storage'
import { generatePackageCode } from '@/utils/codeGenerator'
import { RoutesAlias } from '@/router/routesAlias'
import { CardCategory } from '@/types/api/card'
import type { IotCardImportTask, IotCardImportTaskStatus } from '@/types/api/card'
import type { Carrier } from '@/types/api'
@@ -253,7 +254,7 @@
const uploading = ref(false)
const importDialogVisible = ref(false)
const selectedCarrierId = ref<number>()
const selectedCardCategory = ref<'normal' | 'industry'>('normal') // 默认普通卡
const selectedCardCategory = ref<CardCategory>(CardCategory.NORMAL) // 默认普通卡
const carrierList = ref<Carrier[]>([])
const carrierLoading = ref(false)
const failDataDialogVisible = ref(false)
@@ -697,7 +698,7 @@
// 取消导入
const handleCancelImport = () => {
clearFiles()
selectedCardCategory.value = 'normal'
selectedCardCategory.value = CardCategory.NORMAL
importForm.batch_no = ''
importForm.realname_policy = ''
importDialogVisible.value = false
@@ -797,9 +798,34 @@
}
}
const downloadTaskFile = async (row: IotCardImportTask) => {
const fileKey = row.file_name?.trim()
if (!fileKey) {
ElMessage.warning('当前任务没有可下载的原始文件')
return
}
try {
await StorageService.downloadFileByKey(fileKey)
ElMessage.success('原始文件下载已开始')
} catch (error) {
console.error('下载原始文件失败:', error)
ElMessage.error('下载原始文件失败')
}
}
// 获取操作按钮
const getActions = (row: IotCardImportTask) => {
const actions: any[] = []
const showDownloadFileAction = false
if (showDownloadFileAction && row.file_name?.trim() && hasAuth('iot_card_task:download_file')) {
actions.push({
label: '下载文件',
handler: () => downloadTaskFile(row),
type: 'primary'
})
}
if (row.fail_count > 0 && hasAuth('iot_card_task:download_fail_data')) {
actions.push({