zhangjf 7fe78d6c19 feat: 文件上传管理模块前端实现
前端实现:
- file.js: API接口封装(68行,6个接口)
  - uploadFile(): 上传文件(multipart/form-data)
  - getFileList(): 分页查询
  - getFileListByBusiness(): 按业务查询
  - getFileById(): 查询详情
  - deleteFile(): 删除文件
  - getFileUrl(): 获取URL

- file.vue: 文件管理页面(403行)
  - 搜索功能:文件名、业务类型、关联业务ID
  - 表格展示:文件ID、文件名(链接)、业务类型标签、关联ID、大小、类型、上传人、时间
  - 上传功能:el-upload组件、业务类型选择、关联ID输入
  - 预览功能:图片预览、PDF预览、其他文件提示
  - 下载功能:获取URL后下载
  - 删除功能:确认后删除

技术特点:
- 文件上传(multipart/form-data)
- 文件大小格式化(B/KB/MB/GB)
- 业务类型标签(合同/收款/支出/其他)
- 图片/PDF预览
- 文件选择对话框

模块状态: 完整(前端+后端)
2026-02-16 09:57:31 +08:00

68 lines
1.1 KiB
JavaScript

import request from '../utils/request'
/**
* 上传文件
*/
export const uploadFile = (data) => {
return request({
url: '/sys/api/v1/file/upload',
method: 'post',
data,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
/**
* 获取文件列表(分页)
*/
export const getFileList = (params) => {
return request({
url: '/sys/api/v1/file/list',
method: 'get',
params
})
}
/**
* 根据业务类型和ID查询文件列表
*/
export const getFileListByBusiness = (businessType, businessId) => {
return request({
url: '/sys/api/v1/file/list/business',
method: 'get',
params: { businessType, businessId }
})
}
/**
* 获取文件详情
*/
export const getFileById = (fileId) => {
return request({
url: `/sys/api/v1/file/${fileId}`,
method: 'get'
})
}
/**
* 删除文件
*/
export const deleteFile = (fileId) => {
return request({
url: `/sys/api/v1/file/${fileId}`,
method: 'delete'
})
}
/**
* 获取文件访问URL
*/
export const getFileUrl = (fileId) => {
return request({
url: `/sys/api/v1/file/${fileId}/url`,
method: 'get'
})
}