1.0.41 上传文件组件优化

dev
yinq 2 months ago
parent 8feb75f750
commit 87421d02ee

@ -33,10 +33,9 @@
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li v-for="(file, index) in fileList" :key="file.uid" class="el-upload-list__item ele-upload-list__item-content">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
<div class="ele-upload-list__item-content-action">
<el-button type="primary" link @click="handleDownload(file)"></el-button>
<el-button type="danger" v-if="!disabled" link @click="handleDelete(index)"></el-button>
</div>
</li>
@ -93,7 +92,8 @@ watch(
if (Array.isArray(val)) {
list = val;
} else {
const res = await listByIds(val);
const ossIdParam = typeof val === 'string' || typeof val === 'number' ? val : String(val);
const res = await listByIds(ossIdParam);
list = res.data.map((oss) => {
return {
name: oss.originalName,
@ -174,6 +174,15 @@ const handleUploadSuccess = (res: any, file: UploadFile) => {
}
};
//
const handleDownload = (file: any) => {
if (file.ossId) {
proxy?.$download.oss(file.ossId);
} else {
proxy?.$modal.msgWarning('文件ID不存在无法下载');
}
};
//
const handleDelete = (index: number) => {
const ossId = fileList.value[index].ossId;

Loading…
Cancel
Save