|
@@ -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)
|
|
|
}
|
|
|
}
|
|
|
}
|