|
1
2
3
4
5
6
7
8
9
10
|
<template>
<div>
<a-modal
:title="fileType === 'image' ? '图片上传' : '文件上传'"
:width="width"
:visible="visible"
@ok="ok"
cancelText="取消"
@cancel="close">
<!--style="top: 20px;"-->
|
|
11
12
|
<j-upload :file-type="fileType" :value="filePath" @change="handleChange" :disabled="disabled"
:number="number"></j-upload>
|
|
13
14
15
16
17
|
</a-modal>
</div>
</template>
<script>
|
|
18
|
import {getFileAccessHttpUrl} from '@/api/manage';
|
|
19
|
|
|
20
21
22
23
|
const getFileName = (path) => {
if (path.lastIndexOf("\\") >= 0) {
let reg = new RegExp("\\\\", "g");
path = path.replace(reg, "/");
|
|
24
|
}
|
|
25
26
|
return path.substring(path.lastIndexOf("/") + 1);
}
|
|
27
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
export default {
name: 'JFilePop',
components: {},
props: {
title: {
type: String,
default: '',
required: false
},
position: {
type: String,
default: 'right',
required: false
},
height: {
type: Number,
default: 200,
required: false
},
width: {
type: Number,
default: 520,
required: false
},
|
|
52
|
|
|
53
54
55
56
57
58
59
60
61
|
popContainer: {
type: String,
default: '',
required: false
},
disabled: {
type: Boolean,
default: false,
required: false
|
|
62
|
},
|
|
63
64
65
66
67
68
69
70
71
72
73
74
|
number: {
type: Number,
required: false,
default: 0
}
},
data() {
return {
visible: false,
filePath: '',
id: '',
fileType: 'file'
|
|
75
|
|
|
76
77
78
79
80
|
}
},
methods: {
handleChange(value) {
this.filePath = value;
|
|
81
|
},
|
|
82
83
84
85
86
87
88
89
90
|
show(id, value, flag) {
this.id = id;
this.filePath = value;
this.visible = true
if (flag === 'img') {
this.fileType = 'image'
} else {
this.fileType = 'file'
}
|
|
91
|
|
|
92
93
94
95
96
97
98
99
100
101
102
103
104
|
},
ok() {
if (!this.filePath) {
this.$message.error("未上传任何文件")
return false;
}
let arr = this.filePath.split(",")
let obj = {
name: getFileName(arr[0]),
url: getFileAccessHttpUrl(arr[0]),
path: this.filePath,
status: 'done',
id: this.id
|
|
105
|
}
|
|
106
107
108
109
110
|
this.$emit('ok', obj)
this.visible = false
},
close() {
this.visible = false
|
|
111
112
|
}
}
|
|
113
|
}
|
|
114
115
116
117
118
|
</script>
<style scoped>
</style>
|