mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
文件上传组件 FileUpload 上传报错的问题
This commit is contained in:
parent
b6cb6469f1
commit
1f36af8e6a
@ -28,7 +28,7 @@
|
|||||||
<!-- 文件列表 -->
|
<!-- 文件列表 -->
|
||||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
<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">
|
<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>
|
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||||
</el-link>
|
</el-link>
|
||||||
<div class="ele-upload-list__item-content-action">
|
<div class="ele-upload-list__item-content-action">
|
||||||
@ -72,11 +72,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
number: 0,
|
number: 0,
|
||||||
uploadList: [],
|
uploadList: [],
|
||||||
baseUrl: process.env.VUE_APP_BASE_API,
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
|
||||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
|
||||||
headers: {
|
|
||||||
Authorization: "Bearer " + getAccessToken(),
|
|
||||||
},
|
|
||||||
fileList: [],
|
fileList: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -121,8 +118,7 @@ export default {
|
|||||||
}
|
}
|
||||||
const isTypeOk = this.fileType.some((type) => {
|
const isTypeOk = this.fileType.some((type) => {
|
||||||
if (file.type.indexOf(type) > -1) return true;
|
if (file.type.indexOf(type) > -1) return true;
|
||||||
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
return !!(fileExtension && fileExtension.indexOf(type) > -1);
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
if (!isTypeOk) {
|
if (!isTypeOk) {
|
||||||
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||||
@ -152,7 +148,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 上传成功回调
|
// 上传成功回调
|
||||||
handleUploadSuccess(res) {
|
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) {
|
if (this.uploadList.length === this.number) {
|
||||||
this.fileList = this.fileList.concat(this.uploadList);
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
this.uploadList = [];
|
this.uploadList = [];
|
||||||
@ -181,7 +178,7 @@ export default {
|
|||||||
for (let i in list) {
|
for (let i in list) {
|
||||||
strs += list[i].url + separator;
|
strs += list[i].url + separator;
|
||||||
}
|
}
|
||||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
return strs !== '' ? strs.substr(0, strs.length - 1) : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,8 @@
|
|||||||
<el-input v-model="form.name" placeholder="请输入应用名" />
|
<el-input v-model="form.name" placeholder="请输入应用名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="应用图标">
|
<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>
|
||||||
<el-form-item label="应用描述">
|
<el-form-item label="应用描述">
|
||||||
<el-input type="textarea" v-model="form.description" placeholder="请输入应用名" />
|
<el-input type="textarea" v-model="form.description" placeholder="请输入应用名" />
|
||||||
@ -104,10 +105,12 @@ import { createOAuth2Client, updateOAuth2Client, deleteOAuth2Client, getOAuth2Cl
|
|||||||
import ImageUpload from '@/components/ImageUpload';
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
import Editor from '@/components/Editor';
|
import Editor from '@/components/Editor';
|
||||||
import {CommonStatusEnum} from "@/utils/constants";
|
import {CommonStatusEnum} from "@/utils/constants";
|
||||||
|
import FileUpload from "@/components/FileUpload";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OAuth2Client",
|
name: "OAuth2Client",
|
||||||
components: {
|
components: {
|
||||||
|
FileUpload,
|
||||||
ImageUpload,
|
ImageUpload,
|
||||||
Editor,
|
Editor,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user