Prechádzať zdrojové kódy

增加企业认证校验

guochao 6 rokov pred
rodič
commit
4e41e24063

+ 45 - 38
src/components/authen/EnterpriseAuthentication.vue

@@ -3,7 +3,7 @@
     <div class="create-body" v-loading="loading">
     <div class="create-body" v-loading="loading">
       <div class="title">企业信息认证</div>
       <div class="title">企业信息认证</div>
       <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
       <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
-        <el-form-item label="公司名" prop="name">
+        <el-form-item label="公司名" prop="enterpriseName">
           <el-input v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <el-input v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <span v-if="!isModifyMode">{{authentication.enterpriseName}}</span>
           <span v-if="!isModifyMode">{{authentication.enterpriseName}}</span>
         </el-form-item>
         </el-form-item>
@@ -40,19 +40,19 @@
           <el-link v-if="authentication.explain==null || authentication.explain==''" type="danger" disabled>管理员未填写
           <el-link v-if="authentication.explain==null || authentication.explain==''" type="danger" disabled>管理员未填写
           </el-link>
           </el-link>
         </el-form-item>
         </el-form-item>
-        <el-form-item label="公司法人姓名" prop="name">
+        <el-form-item label="公司法人姓名" prop="legalPersonName">
           <el-input v-if="isModifyMode" v-model="authentication.legalPersonName"></el-input>
           <el-input v-if="isModifyMode" v-model="authentication.legalPersonName"></el-input>
           <span v-if="!isModifyMode">{{authentication.legalPersonName}}</span>
           <span v-if="!isModifyMode">{{authentication.legalPersonName}}</span>
         </el-form-item>
         </el-form-item>
-        <el-form-item label="对公账户" prop="name">
+        <el-form-item label="对公账户" prop="bankAccount">
           <el-input v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
           <el-input v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
           <span v-if="!isModifyMode">{{authentication.bankAccount}}</span>
           <span v-if="!isModifyMode">{{authentication.bankAccount}}</span>
         </el-form-item>
         </el-form-item>
-        <el-form-item label="统一社会信用代码" prop="name">
+        <el-form-item label="统一社会信用代码" prop="unifiedSocialCreditCode">
           <el-input v-if="isModifyMode" v-model="authentication.unifiedSocialCreditCode"></el-input>
           <el-input v-if="isModifyMode" v-model="authentication.unifiedSocialCreditCode"></el-input>
           <span v-if="!isModifyMode">{{authentication.unifiedSocialCreditCode}}</span>
           <span v-if="!isModifyMode">{{authentication.unifiedSocialCreditCode}}</span>
         </el-form-item>
         </el-form-item>
-        <el-form-item label="公司地址" prop="name">
+        <el-form-item label="公司地址" prop="address">
           <el-input v-if="isModifyMode" v-model="authentication.address"></el-input>
           <el-input v-if="isModifyMode" v-model="authentication.address"></el-input>
           <span v-if="!isModifyMode">{{authentication.address}}</span>
           <span v-if="!isModifyMode">{{authentication.address}}</span>
         </el-form-item>
         </el-form-item>
@@ -98,28 +98,27 @@ export default {
         businessLicensePhoto: defaultValue.image,
         businessLicensePhoto: defaultValue.image,
         unifiedSocialCreditCode: '',
         unifiedSocialCreditCode: '',
         address: '',
         address: '',
-        authStatus: {},
+        authStatus: {text:"审核中", style:"warning"},
         explain: ''
         explain: ''
       },
       },
-      rules: {
-        // name: [
-        //   {required: true, message: '请输入报告名称', trigger: 'blur'}
-        //   // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
-        // ],
-        // abstract: [
-        //   {
-        //     required: true,
-        //     message: '请输入摘要信息',
-        //     trigger: 'change'
-        //   }
-        // ],
-        // type: [
-        //   {required: true, message: '请选择报告类型', trigger: 'change'}
-        // ],
-        // conclusion: [
-        //   {required: true, message: '请输入报告结论', trigger: 'blur'}
-        // ]
-      }
+        rules: {
+            enterpriseName: [
+                {required: true, message: '请输入公司名称', trigger: 'blur'},
+                {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
+            ],
+            legalPersonName: [
+                {required: true, message: '请输入公司法人姓名', trigger: 'blur'}
+            ],
+            bankAccount: [
+                {required: true, message: '请输入对公账户', trigger: 'blur'}
+            ],
+            unifiedSocialCreditCode: [
+                {required: true, message: '请输入统一社会信用代码', trigger: 'blur'}
+            ],
+            address: [
+                {required: true, message: '请输入公司地址', trigger: 'blur'}
+            ]
+        }
     }
     }
   },
   },
   mounted () {
   mounted () {
@@ -139,14 +138,14 @@ export default {
       getCurrentEnterpriseAuthInfo(this.user.userVO.id, this.getAuthInfoSuccess, this.getAuthInfoFail)
       getCurrentEnterpriseAuthInfo(this.user.userVO.id, this.getAuthInfoSuccess, this.getAuthInfoFail)
     },
     },
     getAuthInfoSuccess (res) {
     getAuthInfoSuccess (res) {
-      this.hideLoading()
+        this.hideLoading()
       this.authentication.enterpriseName = res.enterpriseName == null ? '暂未填写' : res.enterpriseName
       this.authentication.enterpriseName = res.enterpriseName == null ? '暂未填写' : res.enterpriseName
       this.authentication.legalPersonName = res.legalPersonName == null ? '暂未填写' : res.legalPersonName
       this.authentication.legalPersonName = res.legalPersonName == null ? '暂未填写' : res.legalPersonName
       this.authentication.businessLicensePhoto = res.businessLicensePhoto == null ? defaultValue.image : res.businessLicensePhoto
       this.authentication.businessLicensePhoto = res.businessLicensePhoto == null ? defaultValue.image : res.businessLicensePhoto
       this.authentication.unifiedSocialCreditCode = res.unifiedSocialCreditCode == null ? '暂未填写' : res.unifiedSocialCreditCode
       this.authentication.unifiedSocialCreditCode = res.unifiedSocialCreditCode == null ? '暂未填写' : res.unifiedSocialCreditCode
       this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
       this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
       this.authentication.address = res.address == null ? '暂未填写' : res.address
       this.authentication.address = res.address == null ? '暂未填写' : res.address
-      this.authentication.authStatus = res.authentication
+      this.authentication.authStatus = res.authStatus
       this.authentication.explain = res.explain
       this.authentication.explain = res.explain
       console.log(this.authentication)
       console.log(this.authentication)
     },
     },
@@ -161,17 +160,25 @@ export default {
     //提交认证信息
     //提交认证信息
     updateAuthInfo () {
     updateAuthInfo () {
       //this.isModifyMode = false
       //this.isModifyMode = false
-      this.showLoading()
-      const newAuthentication = {
-        userId: this.user.userVO.id,
-        enterpriseName: this.authentication.enterpriseName,
-        legalPersonName: this.authentication.legalPersonName,
-        businessLicensePhoto: this.authentication.businessLicensePhoto,
-        unifiedSocialCreditCode: this.authentication.unifiedSocialCreditCode,
-        bankAccount: this.authentication.bankAccount,
-        address: this.authentication.address,
-      }
-      updateEnterpriseAuthInfo(this.user.userVO.id, newAuthentication, this.updateAuthInfoSuccess, this.updateAuthInfoFail)
+      this.$refs['authentication'].validate(valid => {
+          if (valid) {
+              this.showLoading()
+              const newAuthentication = {
+                  userId: this.user.userVO.id,
+                  enterpriseName: this.authentication.enterpriseName,
+                  legalPersonName: this.authentication.legalPersonName,
+                  businessLicensePhoto: this.authentication.businessLicensePhoto,
+                  unifiedSocialCreditCode: this.authentication.unifiedSocialCreditCode,
+                  bankAccount: this.authentication.bankAccount,
+                  address: this.authentication.address,
+              }
+              updateEnterpriseAuthInfo(this.user.userVO.id, newAuthentication, this.updateAuthInfoSuccess, this.updateAuthInfoFail)
+          } else {
+              notify('error', '表单填写错误!')
+              return false
+          }
+      })
+
     },
     },
     updateAuthInfoSuccess (res) {
     updateAuthInfoSuccess (res) {
       this.hideLoading()
       this.hideLoading()

+ 64 - 34
src/components/authen/EnterpriseAuthenticationCreate.vue

@@ -3,7 +3,7 @@
     <div class="create-body">
     <div class="create-body">
       <div class="title">企业信息认证</div>
       <div class="title">企业信息认证</div>
       <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
       <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
-        <el-form-item label="公司名" prop="name">
+        <el-form-item label="公司名" prop="enterpriseName">
           <el-input size="small" v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <el-input size="small" v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
         </el-form-item>
@@ -23,19 +23,19 @@
           <!--{{authentication.photo}}</a>-->
           <!--{{authentication.photo}}</a>-->
           <!--</div>-->
           <!--</div>-->
         </el-form-item>
         </el-form-item>
-        <el-form-item label="公司法人姓名" prop="name">
+        <el-form-item label="公司法人姓名" prop="legalPersonName">
           <el-input size="small" v-if="isModifyMode" v-model="authentication.legalPersonName"></el-input>
           <el-input size="small" v-if="isModifyMode" v-model="authentication.legalPersonName"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
         </el-form-item>
-        <el-form-item label="对公账户" prop="name">
+        <el-form-item label="对公账户" prop="bankAccount">
           <el-input size="small" v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
           <el-input size="small" v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
         </el-form-item>
-        <el-form-item label="统一社会信用代码" prop="name">
+        <el-form-item label="统一社会信用代码" prop="unifiedSocialCreditCode">
           <el-input size="small" v-if="isModifyMode" v-model="authentication.unifiedSocialCreditCode"></el-input>
           <el-input size="small" v-if="isModifyMode" v-model="authentication.unifiedSocialCreditCode"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.bankAccount}}</span>-->
           <!--<span v-if="!isModifyMode">{{authentication.bankAccount}}</span>-->
         </el-form-item>
         </el-form-item>
-        <el-form-item label="公司地址" prop="name">
+        <el-form-item label="公司地址" prop="address">
           <el-input size="small" v-if="isModifyMode" v-model="authentication.address"></el-input>
           <el-input size="small" v-if="isModifyMode" v-model="authentication.address"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.address}}</span>-->
           <!--<span v-if="!isModifyMode">{{authentication.address}}</span>-->
         </el-form-item>
         </el-form-item>
@@ -82,23 +82,40 @@ export default {
         address: ''
         address: ''
       },
       },
       rules: {
       rules: {
-        // name: [
-        //   {required: true, message: '请输入报告名称', trigger: 'blur'}
-        //   // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
-        // ],
-        // abstract: [
-        //   {
-        //     required: true,
-        //     message: '请输入摘要信息',
-        //     trigger: 'change'
-        //   }
-        // ],
-        // type: [
-        //   {required: true, message: '请选择报告类型', trigger: 'change'}
-        // ],
-        // conclusion: [
-        //   {required: true, message: '请输入报告结论', trigger: 'blur'}
-        // ]
+          enterpriseName: [
+              {required: true, message: '请输入公司名称', trigger: 'blur'},
+              {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
+          ],
+          legalPersonName: [
+              {required: true, message: '请输入公司法人姓名', trigger: 'blur'}
+          ],
+          bankAccount: [
+              {required: true, message: '请输入对公账户', trigger: 'blur'},
+              {
+                  validator: (rule, value, callback) => {
+                      if (!this.checkNumber(value)) {
+                          callback(new Error('对公账户输入有误'))
+                      } else {
+                          callback()
+                      }
+                  }, trigger: 'blur'
+              },
+          ],
+          unifiedSocialCreditCode: [
+              {required: true, message: '请输入统一社会信用代码', trigger: 'blur'},
+              {
+                  validator: (rule, value, callback) => {
+                      if (!this.checkNumberAndWord(value)) {
+                          callback(new Error('统一社会信用代码输入有误'))
+                      } else {
+                          callback()
+                      }
+                  }, trigger: 'blur'
+              },
+          ],
+          address: [
+              {required: true, message: '请输入公司地址', trigger: 'blur'}
+          ]
       }
       }
     }
     }
   },
   },
@@ -122,20 +139,27 @@ export default {
     //提交认证信息
     //提交认证信息
     submitInfo () {
     submitInfo () {
       //this.isModifyMode = false
       //this.isModifyMode = false
-      this.showLoading()
-      const newAuthentication = {
-        userId: this.user.userVO.id,
-        enterpriseName: this.authentication.enterpriseName,
-        legalPersonName: this.authentication.legalPersonName,
-        businessLicensePhoto: this.authentication.businessLicensePhoto,
-        unifiedSocialCreditCode: this.authentication.unifiedSocialCreditCode,
-        bankAccount: this.authentication.bankAccount,
-        address: this.authentication.address,
-      }
-      uploadEnterpriseAuthenticationInfo(this.user.userVO.id, newAuthentication, this.submitInfoSuccess, this.submitInfoFail)
+      this.$refs['authentication'].validate(valid => {
+          if (valid) {
+              this.showLoading()
+              const newAuthentication = {
+                  userId: this.user.userVO.id,
+                  enterpriseName: this.authentication.enterpriseName,
+                  legalPersonName: this.authentication.legalPersonName,
+                  businessLicensePhoto: this.authentication.businessLicensePhoto,
+                  unifiedSocialCreditCode: this.authentication.unifiedSocialCreditCode,
+                  bankAccount: this.authentication.bankAccount,
+                  address: this.authentication.address,
+              }
+              uploadEnterpriseAuthenticationInfo(this.user.userVO.id, newAuthentication, this.submitInfoSuccess, this.submitInfoFail)
+          } else {
+              notify('error', '表单填写错误!')
+              return false
+          }
+      })
     },
     },
     submitInfoSuccess (res) {
     submitInfoSuccess (res) {
-      this.hideLoading()
+      // this.hideLoading()
       console.log(res)
       console.log(res)
       getCurrentUser().then(res => {
       getCurrentUser().then(res => {
         storageSave('user', res)
         storageSave('user', res)
@@ -225,6 +249,12 @@ export default {
     },
     },
     sendBusMessage () {
     sendBusMessage () {
       this.$root.$emit('user', this.user)
       this.$root.$emit('user', this.user)
+    },
+    checkNumber(value){
+       return /^\d+$/.test(value);
+    },
+    checkNumberAndWord(value){
+        return /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]*$/.test(value);
     }
     }
   },
   },
 }
 }