forked from dataease/dataease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonAjax.js
More file actions
38 lines (35 loc) · 714 Bytes
/
Copy pathcommonAjax.js
File metadata and controls
38 lines (35 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import request from '@/utils/request'
export function post(url, data) {
return request({
url: url,
method: 'post',
loading: true,
data
})
}
export function get(url) {
return request({
url: url,
method: 'get',
loading: true
})
}
export function fileUpload(url, file, files, param) {
const formData = new FormData()
if (file) {
formData.append('file', file)
}
if (files) {
files.forEach(f => {
formData.append('files', f)
})
}
formData.append('request', new Blob([JSON.stringify(param)], { type: 'application/json' }))
return request({
method: 'POST',
loading: true,
url: url,
data: formData
})
}
export default { fileUpload }