<a-form-model ref="myForm" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="24">
<a-form-model-item label="签名图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signPath2">
<img :src="imageUrl" alt="" v-if="imageUrl" class="img-sign" />
<a-upload name="file" :showUploadList="false" :multiple="false" accept="image/*" ="handleSignUpload"
:action="uploadUrl" :headers="tokenHeader">
<a-button type="primary" v-if="!imageUrl">
<a-icon type="upload" class="fs-14"></a-icon>上传签名</a-button>
<a-button type="primary" v-else><a-icon type="upload" class="fs-14"></a-icon>更换签名</a-button>
<span class="tips line-2em ml10"> 可选择png/jpg/gif等图片,建议尺寸100*100px </span>
</a-upload>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
validatorRules: {
signPath2: [{ required: true, message: '请上传签名图片' }],
},
使用$set赋值给form的校验文件值:
handleSignUpload(info) {
this.loading = true;
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
this.loading = false;
const res = info.file.response;
if (res.errcode == 0) {
this.$message.success(res.message || `${info.file.name} 文件上传成功`)
this.$set(this.model, 'signPath2', res.data.url)//使用$set赋值给form的校验文件值
} else {
this.$message.error(`${info.file.name} ${res.errmsg}.`);
}
} else if (info.file.status === 'error') {
},