因为业务需求,删除已存在的图片需要确认是否删除,以进行下一步的处理
<template>
<el-upload action=" " list-type="picture" multiple :limit="3" :before-remove="handleBeforeRemove" >
</el-upload>
</template>
handleBeforeRemove(file, fileList) {
const param = {
fileId: file.name
};
//根据id移除图片
//需要判断当前是修改还是新增状态
//已上传文件删除前提醒确认
return this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//删除业务
removeBrandFile(file.name).then(response => {
if (response.code === 200) {
this.hideUploadAdd = false;
reject(true);
this.$message({
type: 'success',
message: '删除成功'
});
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
reject(false);
});
}
}