From 0edf2cc107cd03e8e007f97f38387d66f480cd3d Mon Sep 17 00:00:00 2001
From: linwenling <3256558519@qq.com>
Date: 星期二, 26 九月 2023 16:54:53 +0800
Subject: [PATCH] 修改家大事记 的图片文件上传 直调接口

---
 ruoyi-ui/src/views/bignote/index.vue |  129 +++++++++++++++++++++++++++----------------
 1 files changed, 81 insertions(+), 48 deletions(-)

diff --git a/ruoyi-ui/src/views/bignote/index.vue b/ruoyi-ui/src/views/bignote/index.vue
index 22a487f..0ffa7b8 100644
--- a/ruoyi-ui/src/views/bignote/index.vue
+++ b/ruoyi-ui/src/views/bignote/index.vue
@@ -250,40 +250,39 @@
         <h4 class="form-header">鐩稿叧鍥剧墖 </h4>
         <el-upload
           action="#"
+          accept="image/jpeg, image/png,image/jpg, image/WMF,image/gif"
           list-type="picture-card"
           multiple
           :http-request="requestUpload"
           :file-list="fileList"
         >
-
-          <i  slot="default" class="el-icon-plus"></i>
-          <div slot="file" slot-scope="{file}">
-            <img
-              class="el-upload-list__item-thumbnail"
-              :src="file.url"
-              alt=""
-              style="width: 126px; height: 126px"
-              fit="cover"
-              :preview-src-list="[file.url]"
-            >
+          <i slot="default" class="el-icon-plus"></i>
+          <div slot="file" slot-scope="{ file }">
+            <template v-if="fileList">
+              <img
+                class="el-upload-list__item-thumbnail"
+                :src="file.url"
+                alt=""
+                style="width: 100%; height: 100%; object-fit: cover;"
+                fit="cover"
+                :preview-src-list="[file.url]"
+              >
+            </template>
             <span class="el-upload-list__item-actions">
-          <span
-            class="el-upload-list__item-preview"
-            @click="handlePictureCardPreview(file)"
-          >
-            <i class="el-icon-zoom-in"></i>
-          </span>
-
-          <span
-            v-if="!disabled"
-            class="el-upload-list__item-delete"
-            @click="handleRemove(file)"
-          >
-            <i class="el-icon-delete"></i>
-          </span>
-        </span>
-
-
+      <span
+        class="el-upload-list__item-preview"
+        @click="handlePictureCardPreview(file)"
+      >
+        <i class="el-icon-zoom-in"></i>
+      </span>
+      <span
+        v-if="!disabled"
+        class="el-upload-list__item-delete"
+        @click="handleRemove(file)"
+      >
+        <i class="el-icon-delete"></i>
+      </span>
+    </span>
           </div>
         </el-upload>
         <h4 class="form-header">鍏朵粬闄勪欢 </h4>
@@ -294,7 +293,7 @@
           multiple
 
           :on-remove="handleRemoveFile"
-          :http-request="requestUpload"
+          :http-request="requestUpload1"
           :show-file-list="true"
         >
 
@@ -369,7 +368,8 @@
       // 鏃ユ湡鑼冨洿
       dateRange: [],
       // 鏁版嵁鑼冨洿閫夐」
-      fot:[".jpg",".jif"],
+      fot:['.bmp','.jpg','.jpeg','.png','.tif','.gif','.pcx','.tga','.exif','.fpx',
+        '.svg','.psd','.cdr','.pcd','.dxf','.ufo','.eps','.ai','.aw','.WMF','.webp','.apng'],
       fileList:[],
       fileListOther:[],
       dsb:true,
@@ -444,6 +444,13 @@
 
   },
   methods: {
+
+    isImage(fileType) {
+      return fileType.startsWith('image/');
+    },
+    isInFot(fileName) {
+      return this.fot.includes(fileName);
+    },
     // 鍙栨秷鎸夐挳
     cancelData() {
       this.open = false;
@@ -568,6 +575,7 @@
       {
         if(this.fileList[i].url==file.url)
           this.$delete(this.fileList,i);
+
       }
     },
     handleRemoveFile(file) {
@@ -597,23 +605,47 @@
           addFamilyevent(this.formDat).then(response => {
             this.$modal.msgSuccess("鏂板鎴愬姛");
             this.open = false;
+            // 娓呯┖formDat瀵硅薄鐨勬暟鎹�
+            Object.keys(this.formDat).forEach(key => {
+              this.formDat[key] = '';
+            });
+            for(let i = 0; i <= this.fileList.length; i++)
+            {
+              this.handleRemove(this.fileList[0]);
+            }
+            for(let i = 0; i < this.fileListOther.length; i++){
+              this.handleRemoveFile(this.fileListOther[0]);
+            }
             this.getList();
           });
         }
       });
-      // 娓呯┖formDat瀵硅薄鐨勬暟鎹�
-      Object.keys(this.formDat).forEach(key => {
-        this.formDat[key] = '';
-      });
-      for(let i = 0; i <= this.fileList.length; i++)
-      {
-        this.handleRemove(this.fileList[0]);
-      }
-      for(let i = 0; i < this.fileListOther.length; i++){
-        this.handleRemoveFile(this.fileListOther[0]);
-      }
+
     },
-    requestUpload(params)
+    requestUpload(params) {
+
+      var file = params.file;
+      var formData = new FormData();
+      formData.append('uploadFile', file);
+      let _this = this
+      this.uploading1 = true;
+      uploadPic(formData).then(response => {
+        let pth = response.data.originalFilename.substr(response.data.originalFilename.length-4, response.data.originalFilename.length)
+        this.uploading1 = false;
+        this.$modal.msgSuccess("涓婁紶鎴愬姛");
+        if(_this.fot.includes(pth) === true)
+        {
+          _this.fileList.push({name:response.data.fileName, "url":response.data.url})
+
+        }
+
+        else{
+          // _this.fileListOther.push({name:response.data.fileName, url:response.data.url})
+
+        }
+      })
+    },
+    requestUpload1(params)
     {
       var file = params.file;
       var formData = new FormData();
@@ -624,16 +656,17 @@
         let pth = response.data.originalFilename.substr(response.data.originalFilename.length-4, response.data.originalFilename.length)
         this.uploading = false;
         this.$modal.msgSuccess("涓婁紶鎴愬姛");
-        if(_this.fot.includes(pth) === true)
+        if(_this.fot.includes(pth) !== true)
         {
-          _this.fileList.push({name:response.data.fileName, "url":response.data.url})
-
-        }
-
-        else{
+          // _this.fileList.push({name:response.data.fileName, "url":response.data.url})
           _this.fileListOther.push({name:response.data.fileName, url:response.data.url})
 
         }
+
+        // else{
+        //   _this.fileListOther.push({name:response.data.fileName, url:response.data.url})
+        //
+        // }
       })
 
     },

--
Gitblit v1.9.1