|
@@ -41,15 +41,17 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="附件:" class="custom-align-right" prop="">
|
|
|
+ <div v-if="file && (fileType == 'pdf' || fileType == 'word' || fileType == 'zip')" class="chooseImgDiv1">
|
|
|
+
|
|
|
+ <div> {{ file }}
|
|
|
+ <div></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="uploaderBox" @mouseenter="hovering = true" mouseleave="hovering = false">
|
|
|
<el-upload class="avatar-uploader" action="#" :show-file-list="false" :before-upload="beforeAvatarUpload">
|
|
|
<!-- 预览图片 -->
|
|
|
<img v-if="file && (fileType == 'jpeg' || fileType == 'png')" :src="file" class="avatar">
|
|
|
- <div v-if="file && (fileType == 'pdf' || fileType == 'word')" class="chooseImgDiv1">
|
|
|
- <div>
|
|
|
- <div>{{ file }}</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+
|
|
|
<div v-else class="chooseImgDiv">
|
|
|
<div>
|
|
|
<img src="@/assets/public/upload/noImage.png">
|
|
@@ -58,7 +60,7 @@
|
|
|
</div>
|
|
|
</el-upload>
|
|
|
<input type="hidden" v-model="form.file">
|
|
|
- <span class="photo_tips">支持文件形式pdf,word,jpg,文件最大2M。</span>
|
|
|
+ <span class="photo_tips">支持文件形式pdf,word,jpg,zip文件最大2M。</span>
|
|
|
<div v-if="hovering && form.file" class="delete-button" @click="handleDelete">
|
|
|
<i class="el-icon-delete"></i>
|
|
|
</div>
|
|
@@ -336,12 +338,10 @@ export default {
|
|
|
//word pdf
|
|
|
const isWord = file.type === 'application/msword' || file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || file.type === 'application/vnd.ms-word' || file.type === 'doc';
|
|
|
const isPdf = file.type === 'application/pdf' || file.type === 'application/x-pdf' || file.type === 'application/acrobat' || file.type === 'pdf' || file.type === 'text/x-pdf' || file.type === 'application/x-download' || file.type === 'application/octet-stream';
|
|
|
+ const isZip = file.type === 'application/zip' || file.type === 'application/x-zip-compressed' || file.type === 'application/x-zip' || file.type === 'application/x-compress' || file.type === 'application/x-compressed' || file.type === 'multipart/x-zip' || file.type === 'multipart/x-zip-compressed' || file.type === 'zip';
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
- console.log(this.imgurl.length, '-0--------------------------------')
|
|
|
-
|
|
|
-
|
|
|
- if (!isJPG && !isPNG && !isWord && !isPdf) {
|
|
|
- this.$message.error('上传文件只能是 JPG、PNG、WORD、PDF 格式!');
|
|
|
+ if (!isJPG && !isPNG && !isWord && !isPdf && !isZip) {
|
|
|
+ this.$message.error('上传文件只能是 JPG、PNG、WORD、PDF 、ZIP 格式!');
|
|
|
return false;
|
|
|
}
|
|
|
if (!isLt2M) {
|
|
@@ -349,15 +349,22 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
const formData = new FormData();
|
|
|
formData.append('file', file);
|
|
|
|
|
|
this.$store.dispatch('pool/uploadFile', formData).then(res => {
|
|
|
+ if (res.code != 200) {
|
|
|
+ this.$message.error("上传失败,请稍后再试!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '上传成功!文件类型' + res.data.fileType
|
|
|
+ });
|
|
|
this.file = res.data.imgUrl;//提供表单地址
|
|
|
this.fileType = res.data.fileType;
|
|
|
this.oldFileName = res.data.oldFileName;
|
|
|
- this.form.file.push(res.data.imgUrl);//提供表单地址
|
|
|
- console.log(res.data.imgUrl, '00000')
|
|
|
})
|
|
|
// 阻止默认的上传行为
|
|
|
return false;
|
|
@@ -649,6 +656,12 @@ export default {
|
|
|
color: black !important;
|
|
|
}
|
|
|
|
|
|
+.photo_tips {
|
|
|
+ color: #999;
|
|
|
+ font-size: 12px;
|
|
|
+ margin-top: 5px;
|
|
|
+}
|
|
|
+
|
|
|
.formLabelFloatBox {
|
|
|
margin-bottom: 10px;
|
|
|
position: relative;
|
|
@@ -668,6 +681,8 @@ export default {
|
|
|
width: 38px;
|
|
|
height: 24px;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>
|