You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
<template>
|
|
<div>
|
|
<!-- 弹窗, 上传文件 -->
|
|
<el-upload
|
|
@close="closeHandle"
|
|
:action="url"
|
|
:before-upload="beforeUploadHandle"
|
|
:on-success="successHandle"
|
|
multiple
|
|
:show-file-list="false"
|
|
>
|
|
<el-button type="primary">点击上传</el-button>
|
|
</el-upload>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
url: '',
|
|
num: 0,
|
|
successNum: 0,
|
|
fileList: {},
|
|
folder: '系统文件'
|
|
}
|
|
},
|
|
methods: {
|
|
init(id) {
|
|
this.url = this.$http.adornUrl(`/ftp/file/upload?token=${this.$cookie.get('token_plm')}&folder=` + this.folder)
|
|
this.visible = true
|
|
},
|
|
// 上传之前
|
|
beforeUploadHandle(file) {
|
|
// if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
|
|
// this.$message.error('只支持jpg、png、gif格式的图片!')
|
|
// return false
|
|
// }
|
|
this.num++
|
|
},
|
|
// 上传成功
|
|
successHandle(response, file, fileList) {
|
|
this.fileList = response.ossEntity
|
|
this.childClick()
|
|
return response.ossEntity
|
|
},
|
|
childClick() {
|
|
// childByValue是在父组件on监听的方法
|
|
this.$emit('childByValue', this.fileList)
|
|
this.$emit('refreshDataList')
|
|
},
|
|
// 弹窗关闭时
|
|
closeHandle () {
|
|
this.fileList = []
|
|
this.$emit('refreshDataList')
|
|
}
|
|
},
|
|
created() {
|
|
this.init()
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|