From e8c62bd430b9697d3f954125b7ec9f61f18347a2 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 20 十月 2025 11:19:34 +0800
Subject: [PATCH] 测试完成
---
src/components/FileUpload/index.vue | 57 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue
index 6c583cf..cfc8070 100644
--- a/src/components/FileUpload/index.vue
+++ b/src/components/FileUpload/index.vue
@@ -1,3 +1,4 @@
+<!-- 涓婁紶鏂囦欢 -->
<template>
<div class="upload-file">
<el-upload
@@ -19,20 +20,38 @@
<!-- 涓婁紶鎻愮ず -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
璇蜂笂浼�
- <template v-if="fileSize"> 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
- <template v-if="fileType"> 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
+ <template v-if="fileSize">
+ 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b>
+ </template>
+ <template v-if="fileType">
+ 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
+ </template>
鐨勬枃浠�
</div>
</el-upload>
<!-- 鏂囦欢鍒楄〃 -->
- <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="`${baseUrl}${file.url}`" :underline="false" target="_blank">
+ <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="`${baseUrl}${file.url}`"
+ :underline="false"
+ target="_blank"
+ >
<span class="el-icon-document"> {{ getFileName(file.name) }} </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)" type="danger"
+ >鍒犻櫎</el-link
+ >
</div>
</li>
</transition-group>
@@ -65,8 +84,8 @@
// 鏄惁鏄剧ず鎻愮ず
isShowTip: {
type: Boolean,
- default: true
- }
+ default: true,
+ },
},
data() {
return {
@@ -86,9 +105,9 @@
if (val) {
let temp = 1;
// 棣栧厛灏嗗�艰浆涓烘暟缁�
- const list = Array.isArray(val) ? val : this.value.split(',');
+ const list = Array.isArray(val) ? val : this.value.split(",");
// 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁�
- this.fileList = list.map(item => {
+ this.fileList = list.map((item) => {
if (typeof item === "string") {
item = { name: item, url: item };
}
@@ -101,8 +120,8 @@
}
},
deep: true,
- immediate: true
- }
+ immediate: true,
+ },
},
computed: {
// 鏄惁鏄剧ず鎻愮ず
@@ -115,11 +134,13 @@
handleBeforeUpload(file) {
// 鏍℃鏂囦欢绫诲瀷
if (this.fileType) {
- const fileName = file.name.split('.');
+ const fileName = file.name.split(".");
const fileExt = fileName[fileName.length - 1];
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
if (!isTypeOk) {
- this.$modal.msgError(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!`);
+ this.$modal.msgError(
+ `鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!`
+ );
return false;
}
}
@@ -142,7 +163,7 @@
// 涓婁紶澶辫触
handleUploadError(err) {
this.$modal.msgError("涓婁紶鏂囦欢澶辫触锛岃閲嶈瘯");
- this.$modal.closeLoading()
+ this.$modal.closeLoading();
},
// 涓婁紶鎴愬姛鍥炶皟
handleUploadSuccess(res, file) {
@@ -187,9 +208,9 @@
for (let i in list) {
strs += list[i].url + separator;
}
- return strs != '' ? strs.substr(0, strs.length - 1) : '';
- }
- }
+ return strs != "" ? strs.substr(0, strs.length - 1) : "";
+ },
+ },
};
</script>
--
Gitblit v1.9.3