This commit is contained in:
helloDy
2023-11-27 09:38:31 +08:00
parent 7f5b9d5228
commit b0efd66a75
16 changed files with 392 additions and 144 deletions

View File

@@ -29,10 +29,10 @@
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
<span class="el-icon-document"> {{ fileName }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
<el-link :underline="false" @click="handleDelete(index)" :disabled="disabled" type="danger">删除</el-link>
</div>
</li>
</transition-group>
@@ -71,6 +71,11 @@ export default {
disabled: {
type: Boolean,
default: false
},
//文件名称
fName: {
type: String,
default: ''
}
},
data() {
@@ -81,6 +86,7 @@ export default {
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
fileList: [],
fileName: ''
};
},
watch: {
@@ -105,6 +111,14 @@ export default {
},
deep: true,
immediate: true
},
fName: {
handler(val) {
if (val) {
console.log('11', val)
this.fileName = val
}
}
}
},
computed: {
@@ -117,6 +131,7 @@ export default {
// 上传前校检格式和大小
handleBeforeUpload(file) {
// 校检文件类型
this.fileName = file.name
if (this.fileType) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
@@ -150,7 +165,7 @@ export default {
},
// 上传失败
handleUploadError(err) {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.msgError("上传文件失败,请重试");
this.$modal.closeLoading()
},
// 上传成功回调
@@ -180,8 +195,12 @@ export default {
this.number = 0;
this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
this.returnFileName()
}
},
returnFileName() {
this.$emit('name', this.fileName)
},
// 获取文件名称
getFileName(name) {
console.log('你好', name)