文件上传组件 FileUpload 上传报错的问题

This commit is contained in:
YunaiV 2022-05-11 12:40:54 +08:00
parent b6cb6469f1
commit 1f36af8e6a
2 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@
<!-- 文件列表 -->
<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">
<el-link :href="`${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">
@ -72,11 +72,8 @@ export default {
return {
number: 0,
uploadList: [],
baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", //
headers: {
Authorization: "Bearer " + getAccessToken(),
},
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", //
headers: { Authorization: "Bearer " + getAccessToken() }, //
fileList: [],
};
},
@ -121,8 +118,7 @@ export default {
}
const isTypeOk = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
return !!(fileExtension && fileExtension.indexOf(type) > -1);
});
if (!isTypeOk) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
@ -152,7 +148,8 @@ export default {
},
//
handleUploadSuccess(res) {
this.uploadList.push({ name: res.fileName, url: res.fileName });
// edit by
this.uploadList.push({ name: res.data, url: res.data });
if (this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
@ -181,7 +178,7 @@ export default {
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) : '';
}
}
};

View File

@ -70,7 +70,8 @@
<el-input v-model="form.name" placeholder="请输入应用名" />
</el-form-item>
<el-form-item label="应用图标">
<imageUpload v-model="form.logo" :limit="1"/>
<!-- <imageUpload v-model="form.logo" :limit="1"/>-->
<file-upload v-model="form.logo" :limit="1"/>
</el-form-item>
<el-form-item label="应用描述">
<el-input type="textarea" v-model="form.description" placeholder="请输入应用名" />
@ -104,10 +105,12 @@ import { createOAuth2Client, updateOAuth2Client, deleteOAuth2Client, getOAuth2Cl
import ImageUpload from '@/components/ImageUpload';
import Editor from '@/components/Editor';
import {CommonStatusEnum} from "@/utils/constants";
import FileUpload from "@/components/FileUpload";
export default {
name: "OAuth2Client",
components: {
FileUpload,
ImageUpload,
Editor,
},