|
1
2
3
4
5
6
|
import {getFileAccessHttpUrl} from '@/api/manage'
const getFileName = (path) => {
if (path.lastIndexOf("\\") >= 0) {
let reg = new RegExp("\\\\", "g");
path = path.replace(reg, "/");
|
|
7
|
}
|
|
8
|
return path.substring(path.lastIndexOf("/") + 1);
|
|
9
10
|
}
|
|
11
12
|
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10);
|
|
13
14
|
}
|
|
15
|
const getFilePaths = (uploadFiles) => {
|
|
16
|
let arr = [];
|
|
17
|
if (!uploadFiles) {
|
|
18
19
|
return ""
}
|
|
20
|
for (let a = 0; a < uploadFiles.length; a++) {
|
|
21
22
|
arr.push(uploadFiles[a].response.message)
}
|
|
23
|
if (arr && arr.length > 0) {
|
|
24
25
26
27
28
|
return arr.join(",")
}
return ""
}
|
|
29
30
|
const getUploadFileList = (paths) => {
if (!paths) {
|
|
31
32
33
34
|
return [];
}
let fileList = [];
let arr = paths.split(",")
|
|
35
36
|
for (let a = 0; a < arr.length; a++) {
if (!arr[a]) {
|
|
37
|
continue
|
|
38
|
} else {
|
|
39
|
fileList.push({
|
|
40
41
|
uid: uidGenerator(),
name: getFileName(arr[a]),
|
|
42
43
|
status: 'done',
url: getFileAccessHttpUrl(arr[a]),
|
|
44
45
46
|
response: {
status: "history",
message: arr[a]
|
|
47
48
49
50
51
52
|
}
})
}
}
return fileList;
}
|
|
53
|
export {getFilePaths, getUploadFileList}
|