|
|
@@ -8,11 +8,13 @@
|
|
|
:on-error="uploadedSuccessfully"
|
|
|
:on-success="handleUploadSuccess"
|
|
|
:file-list="fileList"
|
|
|
-
|
|
|
+ :limit="limit"
|
|
|
:accept="accept"
|
|
|
:http-request="uploadFile"
|
|
|
:show-file-list="true"
|
|
|
:on-remove="handleDelete"
|
|
|
+ :on-exceed="handleExceed"
|
|
|
+ :on-preview="onPreview"
|
|
|
:headers="headers" class="upload-file-uploader" ref="fileUpload">
|
|
|
<i class="el-icon-upload"></i>
|
|
|
<!-- 上传按钮 -->
|
|
|
@@ -191,11 +193,11 @@ export default {
|
|
|
handleDelete(item) {
|
|
|
if (item && item.status === "success") {
|
|
|
console.log("handleDelete index",item)
|
|
|
- this.fileList.splice(item, 1);
|
|
|
- console.log("handleDelete",item,this.fileValueList)
|
|
|
+ //this.fileList.splice(item, 1);
|
|
|
+ // console.log("handleDelete",item,this.fileValueList)
|
|
|
|
|
|
let index = this.fileValueList.findIndex(x=>x.name==item.name);
|
|
|
- console.log("handleDelete",index,this.fileValueList)
|
|
|
+ // console.log("handleDelete",index,this.fileValueList)
|
|
|
if(index>-1)
|
|
|
{
|
|
|
this.fileValueList.splice(index, 1);
|
|
|
@@ -205,7 +207,6 @@ export default {
|
|
|
|
|
|
this.$emit("input", this.listToTagObj(this.fileValueList));
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
// 上传失败结束处理 必须调用,否则失败文件也会显示
|
|
|
uploadedSuccessfully(err,file,fileList) {
|
|
|
@@ -267,7 +268,19 @@ export default {
|
|
|
}
|
|
|
console.log("listToString2",tempArry);
|
|
|
return tempArry;
|
|
|
- }
|
|
|
+ },
|
|
|
+ onPreview(file) {
|
|
|
+ console.log(file);
|
|
|
+ var name = file.name;
|
|
|
+ let index = this.fileValueList.findIndex(x=>x.name==file.name);
|
|
|
+ this.fileValueList[index]
|
|
|
+ var url = process.env.VUE_APP_BASE_API + this.fileValueList[index].url;
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.setAttribute("download", name);
|
|
|
+ a.setAttribute("target", "_blank");
|
|
|
+ a.setAttribute("href", url);
|
|
|
+ a.click();
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|