<el-form-item label="桌台二维码" prop="coverPic" ref="image">
<el-upload
:http-request="uploadFile"
action=""
:on-success="handleSuccessForm"
:show-file-list="false"
accept=".png,.jpg,.jpeg,.gif"
:before-upload="beforeAvatarUpload"
>
<img width="200" height="150" v-if="ruleForm.coverPic" :src="ruleForm.coverPic" class="radius10" />
<div v-else>
<div class="imgUploadWraper">
<el-button slot="trigger" size="mini" type="primary">上传二维码</el-button>
</div>
</div>
</el-upload>
<p style="margin: 0">格式支持jpg/png/gif,最大5MB,建议尺寸60*60</p>
</el-form-item>



let valiIcon = (rule, value, callback) => {
if (!this.valiIconFlag) {
callback(new Error('请上传分类图'))
} else {
callback()
}
}



coverPic: [{ required: true, validator: valiIcon }],



//上传成功
handleSuccessForm() {
this.valiIconFlag = true
this.$refs.image.clearValidate()
this.$message.success('上传成功')
},



//删除成功
handleRemove(file) {
this.valiIconFlag = false;
this.$refs.image.validate();
}