<el-upload
class="upload-demo"
id="upload"
action
:limit="10"
multiple
:http-request="handleUpload"
:on-preview="handlePreview"
:on-remove="handleRemove"
:file-list="fileList">
<el-button size="mini" type="primary">上传附件</el-button>
</el-upload>
//上传方法
handleUpload(file) {
let formData = new FormData()
formData.append('File', file.file)//上传的文件
formData.append('CandidateID', this.Customerform.CandidateID)//参数
formData.append('UploadPeopleID', this.$userInfo.EmployeeID) //参数
this.$api.post('Candidate/UploadFile', formData).then(res => {
if (res.Code == '1001') {
this.GetCandidateAttachment()
this.$message.success(res.Msg)
} else {
this.$message.error(res.Msg)
}
})
},
//查看附件方法
handlePreview(file) {
var url = 'http://www.*******.com/' + file.url
window.open(url, '_blank')
},
//删除附件的方法
handleRemove(file) {
var filelist = {
CAID: file.CAID,//删除附件需要的ID
UploadPeopleID: this.$userInfo.EmployeeID //操作人
}
this.$api.post('Candidate/DelCandidateAttachment', filelist).then(res => {
if (res.Code == '1001') {
this.$message.success(res.Msg)
} else {
this.$message.error(res.Msg)
}
})
},
//详情页面后台返回的附件数据
GetCandidateAttachment() {
this.$api.get('Candidate/GetCandidateAttachment',
{CandidateID: this.Customerform.CandidateID})
.then(res => {
var fileListneed = []
for (let index = 0; index < res.Data.length; index++) {
const element = res.Data[index]
var list = {
name: element.AttachmentName,
CandidateID: element.CandidateID,
CAID: element.CAID,
url: element.AttachmentUrl
}
fileListneed.push(list)
}
this.fileList = fileListneed
})
}
element框架 上传附件功能
最新推荐文章于 2023-10-29 21:11:42 发布