6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
1
|
<template>
|
f99ceb4f
wuxw
收据优化完成
|
2
3
4
5
6
|
<div class="upload-vedio-container">
<div v-if="progress > 0" class="progress-container">
<el-progress :percentage="progress" :stroke-width="2"></el-progress>
<div class="file-name">{{ fileName }}</div>
</div>
|
4afadb73
wuxw
v1.9 优化装修 上传视频失败问...
|
7
8
|
<el-button type="primary" size="small" @click="triggerUpload" :disabled="uploading">
|
f99ceb4f
wuxw
收据优化完成
|
9
10
11
|
<i class="el-icon-upload"></i>
{{ $t('uploadVedio.uploadButton') }}
</el-button>
|
4afadb73
wuxw
v1.9 优化装修 上传视频失败问...
|
12
|
<input type="file" ref="fileInput" accept="video/*" style="display: none" @change="handleFileChange" />
|
f99ceb4f
wuxw
收据优化完成
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
</div>
</template>
<script>
import { uploadVedio } from '@/api/fee/listApplyRoomDiscountRecordApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'UploadVedio',
data() {
return {
fileName: '',
realFileName: '',
progress: 0,
uploading: false
}
},
methods: {
triggerUpload() {
this.$refs.fileInput.click()
},
async handleFileChange(event) {
const file = event.target.files[0]
if (!file) return
if (file.size > 500 * 1024 * 1024) {
this.$message.error(this.$t('uploadVedio.sizeError'))
return
}
this.fileName = file.name
this.uploading = true
this.progress = 0
try {
const formData = new FormData()
formData.append('uploadFile', file)
formData.append('communityId', getCommunityId())
const res = await uploadVedio(formData, {
onUploadProgress: (progressEvent) => {
this.progress = Math.round((progressEvent.loaded * 90) / progressEvent.total)
}
})
|
4afadb73
wuxw
v1.9 优化装修 上传视频失败问...
|
58
|
if (res.realFileName) {
|
f99ceb4f
wuxw
收据优化完成
|
59
|
this.progress = 100
|
4afadb73
wuxw
v1.9 优化装修 上传视频失败问...
|
60
|
this.realFileName = res.realFileName
|
6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
61
|
this.$message.success(this.$t('common.operationSuccess'))
|
f99ceb4f
wuxw
收据优化完成
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
}
} catch (error) {
this.$message.error(this.$t('uploadVedio.uploadFailed'))
} finally {
this.uploading = false
event.target.value = null
}
},
getVideoName() {
return this.realFileName
},
clear() {
this.fileName = ''
this.realFileName = ''
this.progress = 0
this.uploading = false
}
}
}
</script>
<style lang="scss" scoped>
.upload-vedio-container {
.progress-container {
margin-bottom: 10px;
|
4afadb73
wuxw
v1.9 优化装修 上传视频失败问...
|
87
|
|
f99ceb4f
wuxw
收据优化完成
|
88
89
90
91
92
93
94
95
96
|
.file-name {
font-size: 12px;
color: #606266;
margin-top: 5px;
word-break: break-all;
}
}
}
</style>
|