|
@@ -4,40 +4,26 @@ import request from '@/utils/request';
|
|
|
* 上传文件
|
|
* 上传文件
|
|
|
* @param file 文件
|
|
* @param file 文件
|
|
|
*/
|
|
*/
|
|
|
-export async function uploadFile(file) {
|
|
|
|
|
|
|
+export async function uploadFile (data) {
|
|
|
const formData = new FormData();
|
|
const formData = new FormData();
|
|
|
- formData.append('file', file);
|
|
|
|
|
- const res = await request.post('/file/upload', formData);
|
|
|
|
|
- if (res.data.code === 0) {
|
|
|
|
|
- return res.data.data;
|
|
|
|
|
- }
|
|
|
|
|
- return Promise.reject(new Error(res.data.message));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 上传 base64 文件
|
|
|
|
|
- * @param base64 文件数据
|
|
|
|
|
- * @param fileName 文件名称
|
|
|
|
|
- */
|
|
|
|
|
-export async function uploadBase64File(base64, fileName) {
|
|
|
|
|
- const formData = new FormData();
|
|
|
|
|
- formData.append('base64', base64);
|
|
|
|
|
- if (fileName) {
|
|
|
|
|
- formData.append('fileName', fileName);
|
|
|
|
|
- }
|
|
|
|
|
- const res = await request.post('/file/upload/base64', formData);
|
|
|
|
|
- if (res.data.code === 0 && res.data.data) {
|
|
|
|
|
- return res.data.data;
|
|
|
|
|
|
|
+ formData.append('multiPartFile', data.multiPartFile);
|
|
|
|
|
+ formData.append('module', data.module);
|
|
|
|
|
+ const res = await request.post('/main/file/upload', formData);
|
|
|
|
|
+ if (res.data.code === '0') {
|
|
|
|
|
+ return res.data;
|
|
|
}
|
|
}
|
|
|
return Promise.reject(new Error(res.data.message));
|
|
return Promise.reject(new Error(res.data.message));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 分页查询文件上传记录
|
|
|
|
|
|
|
+ * 获取文件
|
|
|
*/
|
|
*/
|
|
|
-export async function pageFiles(params) {
|
|
|
|
|
- const res = await request.get('/file/page', { params });
|
|
|
|
|
- if (res.data.code === 0) {
|
|
|
|
|
|
|
+export async function getFile (params) {
|
|
|
|
|
+ const res = await request.get('/main/file/getFile', {
|
|
|
|
|
+ params,
|
|
|
|
|
+ headers: { requestType: 'blob' }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (res.data.code === '0') {
|
|
|
return res.data.data;
|
|
return res.data.data;
|
|
|
}
|
|
}
|
|
|
return Promise.reject(new Error(res.data.message));
|
|
return Promise.reject(new Error(res.data.message));
|
|
@@ -46,22 +32,12 @@ export async function pageFiles(params) {
|
|
|
/**
|
|
/**
|
|
|
* 删除文件
|
|
* 删除文件
|
|
|
*/
|
|
*/
|
|
|
-export async function removeFile(id) {
|
|
|
|
|
- const res = await request.delete('/file/remove/' + id);
|
|
|
|
|
- if (res.data.code === 0) {
|
|
|
|
|
- return res.data.message;
|
|
|
|
|
- }
|
|
|
|
|
- return Promise.reject(new Error(res.data.message));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 批量删除文件
|
|
|
|
|
- */
|
|
|
|
|
-export async function removeFiles(data) {
|
|
|
|
|
- const res = await request.delete('/file/remove/batch', {
|
|
|
|
|
|
|
+export async function removeFile (data) {
|
|
|
|
|
+ const res = await request.post(
|
|
|
|
|
+ `/main/file/delete?fileId=${data.fileId}`,
|
|
|
data
|
|
data
|
|
|
- });
|
|
|
|
|
- if (res.data.code === 0) {
|
|
|
|
|
|
|
+ );
|
|
|
|
|
+ if (res.data.code === '0') {
|
|
|
return res.data.message;
|
|
return res.data.message;
|
|
|
}
|
|
}
|
|
|
return Promise.reject(new Error(res.data.message));
|
|
return Promise.reject(new Error(res.data.message));
|