Bladeren bron

修改企业和个人照片校验

guochao 6 jaren geleden
bovenliggende
commit
bdd169707b

+ 17 - 2
src/components/authen/EnterpriseAuthentication.vue

@@ -7,7 +7,7 @@
           <el-input v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <span v-if="!isModifyMode">{{authentication.enterpriseName}}</span>
         </el-form-item>
-        <el-form-item label="公司营业执照" prop="file">
+        <el-form-item label="公司营业执照" prop="businessLicensePhoto">
           <el-upload
             v-if="isModifyMode"
             class="avatar-uploader"
@@ -106,6 +106,18 @@ export default {
                 {required: true, message: '请输入公司名称', trigger: 'blur'},
                 {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
             ],
+            businessLicensePhoto: [
+                {
+                    validator: (rule, value, callback) => {
+                        if (value == null || value == '') {
+                            callback(new Error('公司营业执照不能为空'))
+                        } else {
+                            callback()
+                        }
+                    },
+                    trigger: 'blur'
+                },
+            ],
             legalPersonName: [
                 {required: true, message: '请输入公司法人姓名', trigger: 'blur'}
             ],
@@ -251,6 +263,7 @@ export default {
     },
     //上传文件,此处为上传图片
     uploadFile (param) {
+      this.showLoading();
       const formData = new FormData()
       let config = {
         //添加请求头
@@ -258,11 +271,13 @@ export default {
       }
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
+        this.hideLoading();
         console.log('上传成功')
-        this.authentication.photoUrl = res.data
+        this.authentication.businessLicensePhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
       }).catch(error => {
+        this.hideLoading();
         notify('error', error.data.msg)
       })
     },

+ 20 - 2
src/components/authen/EnterpriseAuthenticationCreate.vue

@@ -7,7 +7,7 @@
           <el-input size="small" v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
-        <el-form-item label="公司营业执照" prop="file">
+        <el-form-item label="公司营业执照" prop="businessLicensePhoto">
           <el-upload
             class="avatar-uploader"
             action="https://jsonplaceholder.typicode.com/posts/"
@@ -86,6 +86,19 @@ export default {
               {required: true, message: '请输入公司名称', trigger: 'blur'},
               {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
           ],
+          businessLicensePhoto: [
+              {
+                  validator: (rule, value, callback) => {
+                      console.log(value);
+                      if (value == null || value == '') {
+                          callback(new Error('公司营业执照不能为空'))
+                      } else {
+                          callback()
+                      }
+                  },
+                  trigger: 'blue'
+              },
+          ],
           legalPersonName: [
               {required: true, message: '请输入公司法人姓名', trigger: 'blur'}
           ],
@@ -98,7 +111,8 @@ export default {
                       } else {
                           callback()
                       }
-                  }, trigger: 'blur'
+                  },
+                  trigger: 'blur'
               },
           ],
           unifiedSocialCreditCode: [
@@ -218,6 +232,7 @@ export default {
     },
     //上传文件,此处为上传图片
     uploadFile (param) {
+      this.showLoading();
       const formData = new FormData()
       let config = {
         //添加请求头
@@ -225,11 +240,14 @@ export default {
       }
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
+        this.hideLoading();
         console.log('上传成功')
         this.authentication.businessLicensePhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
+        this.$refs['authentication'].validateField('businessLicensePhoto');
       }).catch(error => {
+        this.hideLoading();
         notify('error', error.data.msg)
       })
     },

+ 19 - 1
src/components/authen/IndividualAuthentication.vue

@@ -104,6 +104,19 @@ export default {
         realName: [
           {required: true, message: '请输入身份证上的姓名', trigger: 'blur'},
         ],
+        IDCardPhoto: [
+            {
+                validator: (rule, value, callback) => {
+                    console.log(value);
+                    if (value == null || value == '') {
+                        callback(new Error('手持身份证照片不能为空'))
+                    } else {
+                        callback()
+                    }
+                },
+                trigger: 'blue'
+            },
+        ],
         bankAccount: [
           {required: true, message: '请输入银行卡账户', trigger: 'blur'},
           {
@@ -240,6 +253,7 @@ export default {
     },
     //上传文件,此处为上传图片
     uploadFile (param) {
+      this.showLoading()
       const formData = new FormData()
       let config = {
         //添加请求头
@@ -247,11 +261,15 @@ export default {
       }
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
+        this.hideLoading()
         console.log('上传成功')
-        this.authentication.photoUrl = res.data
+        this.authentication.IDCardPhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
+        this.$refs['authentication'].validateField('IDCardPhoto');
+
       }).catch(error => {
+        this.hideLoading()
         notify('error', error.data.msg)
       })
     },

+ 15 - 1
src/components/authen/IndividualAuthenticationCreate.vue

@@ -7,7 +7,7 @@
           <el-input size="small" v-if="isModifyMode" v-model="authentication.realName"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
-        <el-form-item prop="file" label="手持身份证照片">
+        <el-form-item prop="IDCardPhoto" label="手持身份证照片">
           <el-upload
             class="avatar-uploader"
             action=""
@@ -89,6 +89,19 @@ export default {
         realName: [
           {required: true, message: '请输入身份证上的姓名', trigger: 'blur'},
         ],
+        IDCardPhoto: [
+            {
+                validator: (rule, value, callback) => {
+                    console.log(value);
+                    if (value == null || value == '') {
+                        callback(new Error('手持身份证照片不能为空'))
+                    } else {
+                        callback()
+                    }
+                },
+                trigger: 'blue'
+            },
+        ],
         bankAccount: [
           {required: true, message: '请输入银行卡账户', trigger: 'blur'},
           {
@@ -220,6 +233,7 @@ export default {
         this.authentication.IDCardPhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
+        this.$refs['authentication'].validateField('IDCardPhoto');
       }).catch(error => {
         this.hideLoading()
         notify('error', error.data.msg)