|
@@ -18,6 +18,8 @@
|
|
|
:on-progress="onProgress"
|
|
|
:on-success="onSuccess"
|
|
|
:on-error="onError"
|
|
|
+ :width="width"
|
|
|
+ :height="height"
|
|
|
>
|
|
|
<!-- <el-button v-if="listType !== 'picture-card'" :type="type" ref="upload"> -->
|
|
|
<el-button
|
|
@@ -104,11 +106,11 @@ export default {
|
|
|
},
|
|
|
// 图片尺寸
|
|
|
width: {
|
|
|
- type: Number,
|
|
|
+ type: String,
|
|
|
default: null,
|
|
|
},
|
|
|
height: {
|
|
|
- type: Number,
|
|
|
+ type: String,
|
|
|
default: null,
|
|
|
},
|
|
|
// 文件大小
|
|
@@ -179,20 +181,17 @@ export default {
|
|
|
var platformId = this.$props.platformId;
|
|
|
this.form.platformId = platformId;
|
|
|
this.data.platformId = platformId;
|
|
|
+
|
|
|
if (this.width && this.height) {
|
|
|
+ var w = Number(this.width);
|
|
|
+ var h = Number(this.height);
|
|
|
const data = await this.readerImg(file);
|
|
|
let _width =
|
|
|
- data.width % this.width === 0 || this.width % data.width === 0
|
|
|
- ? true
|
|
|
- : false;
|
|
|
+ data.width % w === 0 || w % data.width === 0 ? true : false;
|
|
|
let _height =
|
|
|
- data.height % this.height === 0 || this.height % data.height === 0
|
|
|
- ? true
|
|
|
- : false;
|
|
|
+ data.height % h === 0 || h % data.height === 0 ? true : false;
|
|
|
if (!_width || !_height) {
|
|
|
- this.$message.error(
|
|
|
- `请上传${this.width}x${this.height}尺寸或同比例倍数的图片`
|
|
|
- );
|
|
|
+ this.$message.error(`请上传${w}x${h}尺寸或同比例倍数的图片`);
|
|
|
return Promise.reject(false);
|
|
|
}
|
|
|
}
|