aliyun0758874076 1 year ago
parent
commit
5db6d607f6

+ 8 - 1
src/components/Tinymce/components/EditorImage.vue

@@ -13,7 +13,8 @@
       <el-upload
         :multiple="true" :file-list="fileList" :show-file-list="true" :on-remove="handleRemove"
         :on-success="handleSuccess" :before-upload="beforeUpload" class="editor-slide-upload" :action="action"
-        :headers="headers" :data="dataObj" list-type="picture-card"
+        :headers="headers" :data="dataObj" list-type="picture-card" :on-change="changeFiles"
+        :drag="true"
       >
         <el-button size="small" type="primary">
           <!-- Click upload -->
@@ -111,6 +112,12 @@ export default {
         }
         resolve(true)
       })
+    },
+    changeFiles(file, fileList) {
+      // let fileName = file.name;
+      // let uid = file.uid
+      console.log(file)
+      console.log(fileList)
     }
   }
 }

+ 16 - 0
src/views/commodity/commoditySystem/addComponent.vue

@@ -3,10 +3,12 @@
     <el-form-item label="商品图片" />
     <div class="upload-wrap">
       <el-upload
+        ref="upImagesFiles"
         list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"
         :headers="headers" :data="dataObj" :file-list="form.imgs" :limit="20"
         :on-success="handleImageSuccess"
         :action="action"
+        :before-upload="changeFiles"
       >
         <i slot="default" class="el-icon-plus" />
         <div slot="file" slot-scope="{ file }">
@@ -549,6 +551,20 @@ export default {
         }
         return selectMap
       })
+    },
+    changeFiles(file, fileList) {
+      // console.log(file)
+      // console.log(fileList)
+      // eslint-disable-next-line prefer-const
+      let uid = file.uid
+      const isLt =
+        file.size / 1024 / 5 >= 1 && file.size / 1024 / 1024 / 2 <= 1
+      if (!isLt) {
+        // this.$refs.upImagesFiles.abort()
+        this.$message.error('上传文件大小不得小于5KB,不得大于2MB!')
+        return false
+      }
+      // console.log(fileList)
     }
   }
 }