Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/apps/data_training/api/data_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from apps.data_training.models.data_training_model import DataTrainingInfo
from common.core.config import settings
from common.core.deps import SessionDep, CurrentUser, Trans
from common.core.file import FileRequest
from common.utils.data_format import DataFormat

router = APIRouter(tags=["DataTraining"], prefix="/system/data-training")
Expand Down Expand Up @@ -214,11 +215,12 @@ def inner():
return await asyncio.to_thread(inner)


@router.get("/download-fail-info/{filename}")
async def download_excel(filename: str, trans: Trans):
@router.post("/download-fail-info")
async def download_excel(req: FileRequest):
"""
根据文件路径下载 Excel 文件
"""
filename = req.file
file_path = os.path.join(path, filename)

# 检查文件是否存在
Expand Down
4 changes: 4 additions & 0 deletions backend/common/core/file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pydantic import BaseModel

class FileRequest(BaseModel):
file: str
12 changes: 8 additions & 4 deletions frontend/src/api/training.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export const trainingApi = {
requestOptions: { customError: true },
}),
downloadError: (path: any) =>
request.get(`/system/data-training/download-fail-info/${path}`, {
responseType: 'blob',
requestOptions: { customError: true },
}),
request.post(
`/system/data-training/download-fail-info`,
{ file: path },
{
responseType: 'blob',
requestOptions: { customError: true },
}
),
}
2 changes: 1 addition & 1 deletion frontend/src/views/system/training/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const onSuccess = (response: any) => {
})
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = `${t('training.data_training')}_error.xlsx`
link.download = response.data.error_excel_filename
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
Expand Down