Browse Source

修改bug

Jing 1 day ago
parent
commit
4d37e06fc2
2 changed files with 15 additions and 6 deletions
  1. 4 2
      src/views/news/addNcomplaint.vue
  2. 11 4
      src/views/news/addNotice.vue

+ 4 - 2
src/views/news/addNcomplaint.vue

@@ -46,7 +46,9 @@
           </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
+              v-if="file && (fileType == 'pdf' || fileType == 'word' || fileType == 'zip' || fileType == 'doc' || fileType == 'docx')"
+              class="chooseImgDiv1">
 
               <div> {{ file }}
                 <div></div>
@@ -768,4 +770,4 @@ export default {
   }
 }
 
-//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>
+//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>

+ 11 - 4
src/views/news/addNotice.vue

@@ -41,7 +41,9 @@
           </el-form-item>
           <!-- {{ hovering }}{{ file }} -->
           <el-form-item label="附件:" class="custom-align-right" prop="">
-            <div v-if="file && (fileType == 'pdf' || fileType == 'word' || fileType == 'zip')" class="chooseImgDiv1">
+            <div
+              v-if="file && (fileType == 'pdf' || fileType == 'word' || fileType == 'zip' || fileType == 'doc' || fileType == 'docx')"
+              class="chooseImgDiv1">
 
               <div> {{ file }}
                 <div></div>
@@ -50,7 +52,8 @@
             <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">
+                <img v-if="file && (fileType == 'jpeg' || fileType == 'png' || fileType == 'jpg' || fileType == 'jpg')"
+                  :src="file" class="avatar">
 
                 <div v-else class="chooseImgDiv">
                   <div>
@@ -61,7 +64,7 @@
               </el-upload>
               <input type="hidden" v-model="form.file">
               <span class="photo_tips">支持文件形式pdf,word,jpg,zip文件最大2M。</span>
-              <div v-if="hovering && file" class="delete-button" @click="handleDelete">
+              <div v-if="hovering && form.file" class="delete-button" @click="handleDelete">
                 <i class="el-icon-delete"></i>
               </div>
             </div>
@@ -97,6 +100,7 @@ import '@/styles/global.less';
 import { formatLocalDate } from '@/utils/public';
 //引入富文本编辑器
 import myEditor from '../../components/edit/myEditor.vue';
+import { file } from 'jszip/lib/object';
 export default {
   components: {
     myEditor,
@@ -336,6 +340,7 @@ export default {
     },
     //1.提交表单 start ------------------------------------------------------------>
     beforeAvatarUpload(file) {
+      console.log(file.type, '--------------------------------');
       const isJPG = file.type === 'image/jpeg';
       const isPNG = file.type === 'image/png';
       //word  pdf
@@ -343,6 +348,7 @@ export default {
       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(file.type, 'file.type--1--');
       if (!isJPG && !isPNG && !isWord && !isPdf && !isZip) {
         this.$message.error('上传文件只能是 JPG、PNG、WORD、PDF 、ZIP 格式!');
         return false;
@@ -365,6 +371,7 @@ export default {
           type: 'success',
           message: '上传成功!文件类型' + res.data.fileType
         });
+        console.log(res.data, 'res.data--1--');
         this.file = res.data.imgUrl;//提供表单地址
         this.form.file = res.data.imgUrl;
         this.fileType = res.data.fileType;
@@ -691,4 +698,4 @@ export default {
 
 }
 
-//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>
+//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>