提交
This commit is contained in:
parent
15ad33aa82
commit
41fa04d9c9
|
@ -308,18 +308,43 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="附件">
|
||||
<div class="upload-file">
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
action="https://jsonplaceholder.typicode.com/posts/"
|
||||
:file-list="fileList2"
|
||||
multiple
|
||||
:action="uploadFileUrl"
|
||||
:before-upload="handleBeforeUpload1"
|
||||
:file-list="fileList1"
|
||||
:limit="limit"
|
||||
:on-error="handleUploadError1"
|
||||
:on-exceed="handleExceed1"
|
||||
:on-success="handleUploadSuccess1"
|
||||
:show-file-list="false"
|
||||
class="upload-file-uploader"
|
||||
ref="fileUpload1"
|
||||
>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
>
|
||||
上传
|
||||
</el-button>
|
||||
<!-- 上传按钮 -->
|
||||
<el-button size="small" type="primary">上传</el-button>
|
||||
<!-- 上传提示 -->
|
||||
<div class="el-upload__tip" slot="tip" v-if="isShowTip">
|
||||
请上传
|
||||
<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 fileList1">
|
||||
<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">
|
||||
<el-link :underline="false" @click="handleDelete1(index)" type="danger">删除</el-link>
|
||||
</div>
|
||||
</li>
|
||||
</transition-group>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item style="text-align: center;border-top:1rem solid #B0B0B0;padding: 20rem 0rem">
|
||||
|
@ -442,6 +467,7 @@ export default {
|
|||
fieldType: [],
|
||||
advantageConcept: '',
|
||||
cooperationIntention: '',
|
||||
imageurl: ''
|
||||
},
|
||||
formRules: {
|
||||
companyName: [
|
||||
|
@ -512,20 +538,23 @@ export default {
|
|||
relevantQualifications: [],
|
||||
advantageConcept: '',
|
||||
cooperationIntention: '',
|
||||
imageurl: ''
|
||||
},
|
||||
// 数量限制
|
||||
limit: 10,
|
||||
// 大小限制(MB)
|
||||
fileSize: 10,
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: ["doc", "docx", "xls","xlsx", "ppt", "txt", "pdf"],
|
||||
fileType: ["doc", "docx", "xls","xlsx", "ppt","pptx", "txt", "pdf"],
|
||||
// 是否显示提示
|
||||
isShowTip: true,
|
||||
number: 0,
|
||||
uploadList: [],
|
||||
uploadList1: [],
|
||||
// 上传文件服务器地址
|
||||
uploadFileUrl: process.env.VUE_APP_API_TARGET_URL + "/system/oss/upload",
|
||||
uploadFileUrl: process.env.VUE_APP_API_TARGET_URL + "system/oss/addFilesUpload",
|
||||
fileList: [],
|
||||
fileList1: [],
|
||||
loadingModal: undefined,
|
||||
};
|
||||
},
|
||||
|
@ -564,6 +593,7 @@ export default {
|
|||
this.$refs["Partnerform"].validate(valid => {
|
||||
if (valid) {
|
||||
this.form1.fieldType = this.form1.fieldType.toString();
|
||||
this.form1.imageurl = this.fileList.map(item => item.url).toString();
|
||||
this.$request.post(
|
||||
'/official/companymessage/add',
|
||||
this.form1,
|
||||
|
@ -578,7 +608,9 @@ export default {
|
|||
fieldType: [],
|
||||
advantageConcept: '',
|
||||
cooperationIntention: '',
|
||||
imageurl: ''
|
||||
}
|
||||
this.fileList = []
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -595,6 +627,7 @@ export default {
|
|||
this.form.productCertification = this.form.productCertification.toString();
|
||||
this.form.qualitySystem = this.form.qualitySystem.toString();
|
||||
this.form.relevantQualifications = this.form.relevantQualifications.toString();
|
||||
this.form.imageurl = this.fileList1.map(item => item.url).toString()
|
||||
this.$request.post(
|
||||
'/official/companymessage/add',
|
||||
this.form,
|
||||
|
@ -619,7 +652,9 @@ export default {
|
|||
relevantQualifications: [],
|
||||
advantageConcept: '',
|
||||
cooperationIntention: '',
|
||||
imageurl: ''
|
||||
}
|
||||
this.fileList1 = []
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -661,7 +696,7 @@ export default {
|
|||
},
|
||||
// 上传失败
|
||||
handleUploadError(err) {
|
||||
this.$message.error(`上传文件失败,请重试`);
|
||||
this.$message.error(`上传文件失败,请重试`, err);
|
||||
this.loadingModal.close();
|
||||
},
|
||||
// 上传成功回调
|
||||
|
@ -679,8 +714,8 @@ export default {
|
|||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
let ossId = this.fileList[index].ossId;
|
||||
delOss(ossId);
|
||||
// let ossId = this.fileList[index].ossId;
|
||||
// delOss(ossId);
|
||||
this.fileList.splice(index, 1);
|
||||
},
|
||||
// 上传结束处理
|
||||
|
@ -701,6 +736,70 @@ export default {
|
|||
return name;
|
||||
}
|
||||
},
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload1(file) {
|
||||
// 校检文件类型
|
||||
if (this.fileType) {
|
||||
const fileName = file.name.split('.');
|
||||
const fileExt = fileName[fileName.length - 1];
|
||||
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
|
||||
if (!isTypeOk) {
|
||||
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 校检文件大小
|
||||
if (this.fileSize) {
|
||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||
if (!isLt) {
|
||||
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.loadingModal = this.$loading({
|
||||
lock: true,
|
||||
text: '正在上传文件,请稍候...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.number++;
|
||||
return true;
|
||||
},
|
||||
// 文件个数超出
|
||||
handleExceed1() {
|
||||
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||
},
|
||||
// 上传失败
|
||||
handleUploadError1(err) {
|
||||
this.$message.error(`上传文件失败,请重试`, err);
|
||||
this.loadingModal.close();
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess1(res, file) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList1.push({ name: res.data.fileName, url: res.data.url, ossId: res.data.ossId });
|
||||
this.uploadedSuccessfully1();
|
||||
} else {
|
||||
this.number--;
|
||||
this.loadingModal.close();
|
||||
this.$message.error(res.msg);
|
||||
this.$refs.fileUpload1.handleRemove(file);
|
||||
this.uploadedSuccessfully1();
|
||||
}
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete1(index) {
|
||||
this.fileList1.splice(index, 1);
|
||||
},
|
||||
// 上传结束处理
|
||||
uploadedSuccessfully1() {
|
||||
if (this.number > 0 && this.uploadList1.length === this.number) {
|
||||
this.fileList1 = this.fileList1.concat(this.uploadList1);
|
||||
this.uploadList1 = [];
|
||||
this.number = 0;
|
||||
this.loadingModal.close();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -822,9 +921,6 @@ export default {
|
|||
font-size: 12rem;
|
||||
border-radius: 3rem;
|
||||
}
|
||||
/deep/.el-upload-list{
|
||||
display: inline-flex;
|
||||
}
|
||||
/deep/.el-upload-list__item-name {
|
||||
margin-right: 40rem;
|
||||
padding-left: 4rem;
|
||||
|
@ -877,7 +973,6 @@ export default {
|
|||
margin-bottom: 5rem;
|
||||
}
|
||||
.upload-file-list .el-upload-list__item {
|
||||
border: 1rem solid #e4e7ed;
|
||||
line-height: 2rem;
|
||||
margin-bottom: 10rem;
|
||||
position: relative;
|
||||
|
|
Loading…
Reference in New Issue
Block a user