|
@@ -72,20 +72,25 @@ class ImgList extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
beforeUpload(file) {
|
|
beforeUpload(file) {
|
|
- const { isSupportPDF = false } = this.props
|
|
|
|
|
|
+ const { isSupportPDF = false, limitation = true } = this.props
|
|
const isLt2M = file.size / 1024 / 1024 < 20;
|
|
const isLt2M = file.size / 1024 / 1024 < 20;
|
|
- if (!isLt2M) {
|
|
|
|
|
|
+ if (!isLt2M && limitation) {
|
|
message.error('文件大小不能超过 20MB!');
|
|
message.error('文件大小不能超过 20MB!');
|
|
return isLt2M;
|
|
return isLt2M;
|
|
}
|
|
}
|
|
if (this.props.accept) {
|
|
if (this.props.accept) {
|
|
- if (isLt2M) {
|
|
|
|
- this.state.newUploadArr.push(file)
|
|
|
|
- this.setState({
|
|
|
|
- newUploadArr: this.state.newUploadArr
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- return isLt2M;
|
|
|
|
|
|
+ this.state.newUploadArr.push(file)
|
|
|
|
+ this.setState({
|
|
|
|
+ newUploadArr: this.state.newUploadArr
|
|
|
|
+ })
|
|
|
|
+ return true;
|
|
|
|
+ // if (isLt2M) {
|
|
|
|
+ // this.state.newUploadArr.push(file)
|
|
|
|
+ // this.setState({
|
|
|
|
+ // newUploadArr: this.state.newUploadArr
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // return isLt2M;
|
|
} else {
|
|
} else {
|
|
const isJPG = file.type.split('/');
|
|
const isJPG = file.type.split('/');
|
|
if (isSupportPDF) {
|
|
if (isSupportPDF) {
|
|
@@ -99,14 +104,22 @@ class ImgList extends Component {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (isJPG && isLt2M) {
|
|
|
|
|
|
+ if (isJPG) {
|
|
// 用于计算当次选择的图片数量
|
|
// 用于计算当次选择的图片数量
|
|
this.state.newUploadArr.push(file)
|
|
this.state.newUploadArr.push(file)
|
|
this.setState({
|
|
this.setState({
|
|
newUploadArr: this.state.newUploadArr
|
|
newUploadArr: this.state.newUploadArr
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- return isJPG && isLt2M;
|
|
|
|
|
|
+ return isJPG;
|
|
|
|
+ // if (isJPG && isLt2M) {
|
|
|
|
+ // // 用于计算当次选择的图片数量
|
|
|
|
+ // this.state.newUploadArr.push(file)
|
|
|
|
+ // this.setState({
|
|
|
|
+ // newUploadArr: this.state.newUploadArr
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // return isJPG && isLt2M;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|