|
|
@ -15,26 +15,9 @@
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<i slot="default" class="el-icon-plus" />
|
|
|
|
<i slot="default" class="el-icon-plus" />
|
|
|
|
<div slot="file" slot-scope="{ file }" class="imgBox">
|
|
|
|
<div slot="file" slot-scope="{ file }" class="imgBox">
|
|
|
|
<img
|
|
|
|
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
|
|
|
v-if="typeImgShow(file)"
|
|
|
|
|
|
|
|
class="el-upload-list__item-thumbnail"
|
|
|
|
|
|
|
|
:src="file.url"
|
|
|
|
|
|
|
|
alt=""
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<svg-icon
|
|
|
|
|
|
|
|
v-else-if="typePdfShow(file)"
|
|
|
|
|
|
|
|
icon-class="PDF"
|
|
|
|
|
|
|
|
class="iconFont"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<svg-icon
|
|
|
|
|
|
|
|
v-else-if="typeExcelShow(file)"
|
|
|
|
|
|
|
|
icon-class="Excel"
|
|
|
|
|
|
|
|
class="iconFont"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="el-upload-list__item-actions">
|
|
|
|
<span class="el-upload-list__item-actions">
|
|
|
|
<span
|
|
|
|
<span
|
|
|
|
v-if="typeImgShow(file)"
|
|
|
|
|
|
|
|
class="el-upload-list__item-preview"
|
|
|
|
class="el-upload-list__item-preview"
|
|
|
|
@click="handlePictureCardPreview(file)"
|
|
|
|
@click="handlePictureCardPreview(file)"
|
|
|
|
>
|
|
|
|
>
|
|
|
@ -80,16 +63,7 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
value: {
|
|
|
|
type: Array,
|
|
|
|
type: Array | String
|
|
|
|
default: () => {
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
uploadType: {
|
|
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
|
|
default: () => {
|
|
|
|
|
|
|
|
return "img";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
@ -114,42 +88,15 @@ export default {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
|
|
value(val) {
|
|
|
|
|
|
|
|
this.echoUpload(val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.echoUpload(this.value);
|
|
|
|
this.echoUpload(this.value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
// 图片
|
|
|
|
|
|
|
|
typeImgShow(file) {
|
|
|
|
|
|
|
|
if (!file.fileType) return;
|
|
|
|
|
|
|
|
const fileType = file.fileType.toLowerCase();
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
fileType == "jpg" ||
|
|
|
|
|
|
|
|
fileType == "png" ||
|
|
|
|
|
|
|
|
fileType == "gif" ||
|
|
|
|
|
|
|
|
fileType == "icon"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// pdf
|
|
|
|
|
|
|
|
typePdfShow(file) {
|
|
|
|
|
|
|
|
if (!file.fileType) return;
|
|
|
|
|
|
|
|
const fileType = file.fileType.toLowerCase();
|
|
|
|
|
|
|
|
if (fileType == "pdf") {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// excel
|
|
|
|
|
|
|
|
typeExcelShow(file) {
|
|
|
|
|
|
|
|
if (!file.fileType) return;
|
|
|
|
|
|
|
|
const fileType = file.fileType.toLowerCase();
|
|
|
|
|
|
|
|
if (fileType == "xlsx" || fileType == "xls" || fileType == "csv") {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handleRemove(file) {
|
|
|
|
handleRemove(file) {
|
|
|
|
const fileList = [];
|
|
|
|
const fileList = [];
|
|
|
|
this.fileList.forEach(el => {
|
|
|
|
this.fileList.forEach(el => {
|
|
|
@ -185,6 +132,7 @@ export default {
|
|
|
|
// 回传出去
|
|
|
|
// 回传出去
|
|
|
|
change() {
|
|
|
|
change() {
|
|
|
|
const fileList = this.fileList;
|
|
|
|
const fileList = this.fileList;
|
|
|
|
|
|
|
|
console.log(fileList);
|
|
|
|
this.$emit("input", fileList);
|
|
|
|
this.$emit("input", fileList);
|
|
|
|
this.$emit("change", fileList);
|
|
|
|
this.$emit("change", fileList);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -214,18 +162,13 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 回显
|
|
|
|
// 回显
|
|
|
|
echoUpload(val) {
|
|
|
|
echoUpload(val) {
|
|
|
|
if (val && val.length > 0) {
|
|
|
|
console.log(val);
|
|
|
|
const fileList = [];
|
|
|
|
if (val) {
|
|
|
|
for (let i = 0; i < val.length; i++) {
|
|
|
|
this.fileList = [
|
|
|
|
const obj = {};
|
|
|
|
{
|
|
|
|
obj.url = val[i].urlPath || val[i].url;
|
|
|
|
url: val
|
|
|
|
obj.fileType = val[i].fileType;
|
|
|
|
|
|
|
|
obj.fileId = val[i].fileId;
|
|
|
|
|
|
|
|
fileList.push(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fileList.forEach((el, index) => {
|
|
|
|
];
|
|
|
|
this.$set(this.fileList, index, el);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.fileList = [];
|
|
|
|
this.fileList = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|