Browse Source

新增银行卡、户口本Ocr

sunkuosheng 1 week ago
parent
commit
4a8944fa7e

+ 87 - 1
ruoyi-ui-gljt/src/components/ImageUpload/index.vue

@@ -13,6 +13,7 @@
       :on-remove="handleDelete"
       :show-file-list="true"
       :headers="headers"
+      :disabled="disabled"
       :file-list="fileList"
       :on-preview="handlePictureCardPreview"
       :class="{hide: this.fileList.length >= this.limit,ocrStyle:isOcr}"
@@ -66,11 +67,21 @@
         type: Boolean,
         default: true
       },
+      // 是否禁用
+      disabled: {
+        type: Boolean,
+        default: false
+      },
       // 是否使用OCR识别
       isOcr: {
         type: Boolean,
         default: false
       },
+      //有值就进行校验、无值就不进行校验
+      opt:{
+        type: Object,
+        default: () => {},
+      },
       ocrType:{
         type: String,
         default:'front'
@@ -153,6 +164,35 @@
           })
         })
       },
+      bankcardIdentify(bankCardImg){
+        return new Promise((resolve, reject) => {
+          var params = new FormData()
+          params.append('image', bankCardImg)//转Base64后的编码
+          params.append('access\_token', this.accessToken);
+          axios.post(
+            '/baiduApi/rest/2.0/ocr/v1/bankcard?', params,
+            {headers: {'Content-Type': 'application/x-www-form-urlencoded'}}
+          ).then((res) => {
+            resolve(res.data)
+            // resolve(res.data.words_result)
+          })
+        })
+      },
+      household_registerIdentify(household_registerImg){
+        return new Promise((resolve, reject) => {
+          var params = new FormData()
+          params.append('image', household_registerImg)//转Base64后的编码
+          params.append('access\_token', this.accessToken);
+          params.append('household\_register\_side', this.ocrType)
+          axios.post(
+            '/baiduApi/rest/2.0/ocr/v1/household_register?', params,
+            {headers: {'Content-Type': 'application/x-www-form-urlencoded'}}
+          ).then((res) => {
+            resolve(res.data)
+            // resolve(res.data.words_result)
+          })
+        })
+      },
       toBase64(file) {
         return new Promise((resolve, reject) => {
           const reader = new FileReader();
@@ -215,6 +255,46 @@
           this.formCard={};
           let imageBase64 = await this.toBase64(file);
           this.$modal.loading("验证中...");
+          if(this.ocrType==='bankcard')
+          {
+            let qur = await this.bankcardIdentify(imageBase64.split(',')[1]);
+            console.log(qur,'<--银行卡')
+            this.$modal.closeLoading();
+            if(qur.result&&qur.result.bank_card_number&&qur.result.bank_card_type!='0'){
+              this.formCard={
+                yhzh:qur.result.bank_card_number.replace(/\s*/g,'')
+              }
+            }else{
+              this.$modal.msgError(`请上传正确的银行卡照片`);
+              return Promise.reject();
+            }
+          }else if(this.ocrType==='subpage'||this.ocrType==='homepage'){
+            let qur = await this.household_registerIdentify(imageBase64.split(',')[1]);
+            this.$modal.closeLoading();
+            console.log(qur,'<--户口本')
+            if(this.ocrType==='subpage')
+            {
+              if(qur.words_result&&qur.words_result['CardNo']&&qur.words_result['Name']){
+                if(this.opt&&this.opt.sqrZjhm&&this.opt.sqrXm&&(this.opt.sqrZjhm!= qur.words_result['CardNo'].words||this.opt.sqrXm!=qur.words_result['Name'].words)){
+                  this.$modal.msgError(`申请人证件信息与户口本信息不一致`);
+                  return Promise.reject();
+                }
+                this.formCard={
+                  cardNo:qur.words_result['CardNo'].words,
+                  name:qur.words_result['Name'].words,
+                }
+              }else{
+                this.$modal.msgError(`请上传正确的户口本本人页`);
+                return Promise.reject();
+              }
+            }else{
+              if(!qur.words_result){
+                this.$modal.msgError(`请上传正确的户口本首页`);
+                return Promise.reject();
+              }
+            }
+
+          }else{
           let qur = await this.idCardIdentify(imageBase64.split(',')[1]);
           this.$modal.closeLoading();
           // console.log(qur,'qur<-----');
@@ -222,7 +302,7 @@
             this.$modal.msgError(`请上传正确的身份证照片`);
             return Promise.reject();
           }
-          console.log(qur,'<-------qur');
+          // console.log(qur,'<-------qur');
           if(this.ocrType==='front')
           {
           if(qur.idcard_number_type!='1'){
@@ -230,6 +310,11 @@
             return Promise.reject();
 
           }else{
+            // console.log(this.opt,'<------this.opt');
+            if(this.opt&&this.opt.cardNo&&this.opt.hkbName&&(this.opt.cardNo!= qur.words_result['公民身份号码'].words||this.opt.hkbName!=qur.words_result['姓名'].words)){
+              this.$modal.msgError(`申请人证件信息与户口本信息不一致`);
+              return Promise.reject();
+            }
               this.formCard={
                 sqrZjhm: qur.words_result['公民身份号码'].words,
                 csrq:qur.words_result['出生'].words,
@@ -253,6 +338,7 @@
           this.$modal.loading("正在上传图片,请稍候...");
           this.number++;
           return fileNew;
+          }
         }
         this.$modal.loading("正在上传图片,请稍候...");
         this.number++;

+ 16 - 10
ruoyi-ui-gljt/src/views/gljt/gljtBg/index.vue

@@ -184,11 +184,11 @@
                <span style="margin-top: 10px">证件人像面</span>
              </div>
              <div class="flexCount">
-               <el-form-item label="" label-width="0" prop="hkbzm" class="uploadStyleFx"  :rules="form.isImport&&form.isImport=='1'?norules.hkbzm:rules.hkbzm">
-                 <image-upload  v-model="form.hkbzm" :limit="form.lrId?1:0" :isShowTip="false"></image-upload>
-                 <!--<image-preview class="imgStyle" :src="form.sqrZjzm" ></image-preview>-->
-                 <span>户口首页</span>
-               </el-form-item>
+               <!--<el-form-item label="" label-width="0" prop="hkbzm" class="uploadStyleFx"  :rules="form.isImport&&form.isImport=='1'?norules.hkbzm:rules.hkbzm">-->
+                 <!--<image-upload  v-model="form.hkbzm" :limit="form.lrId?1:0" :isShowTip="false"></image-upload>-->
+                 <image-preview class="imgStyleHk" :src="form.hkbzm" ></image-preview>
+                 <span style="margin-top: 10px">户口首页</span>
+               <!--</el-form-item>-->
              </div>
            </div>
            <div style="flex: 1;display: flex;flex-direction: column">
@@ -197,10 +197,11 @@
                <span style="margin-top: 10px">证件国徽面</span>
              </div>
              <div class="flexCount">
-               <el-form-item label="" label-width="0" prop="hkbbm" class="uploadStyleFx" :rules="form.isImport&&form.isImport=='1'?norules.hkbbm:rules.hkbbm">
-                 <image-upload :isShowTip="false" v-model="form.hkbbm" :limit="form.lrId?1:0"></image-upload>
-                 <span>户口本人页</span>
-               </el-form-item>
+               <!--<el-form-item label="" label-width="0" prop="hkbbm" class="uploadStyleFx" :rules="form.isImport&&form.isImport=='1'?norules.hkbbm:rules.hkbbm">-->
+                 <!--<image-upload :isShowTip="false" v-model="form.hkbbm" :limit="form.lrId?1:0"></image-upload>-->
+               <image-preview class="imgStyleHk" :src="form.hkbbm" ></image-preview>
+                 <span style="margin-top: 10px">户口本人页</span>
+               <!--</el-form-item>-->
              </div>
            </div>
            <div style="flex: 1" class="flexCount">
@@ -864,12 +865,14 @@ export default {
       if (data && data.sqrZjhm) {
         this.form.dbrZjhm = data.sqrZjhm;
         this.form.dbrXm = data.sqrXm;
+        this.form.dbrJzdz = data.hjdz;
       }
     },
     getCardJh(data) {
       if (data && data.sqrZjhm) {
         this.form.jhrZjhm = data.sqrZjhm;
         this.form.jhrXm = data.sqrXm;
+        this.form.jhrJzdz = data.hjdz;
       }
     },
     clearJh() {
@@ -1198,7 +1201,10 @@ export default {
     width: 260px;
     height: 148px;
   }
-
+  .imgStyleHk {
+    width: 260px;
+    height: 180px;
+  }
   .tableStyle {
     width: 100%;
     border: none;

+ 91 - 22
ruoyi-ui-gljt/src/views/gljt/gljtSq/index.vue

@@ -181,7 +181,7 @@
                 <div class="flexCount">
                   <el-form-item prop="sqrZjzm" label-width="0" class="uploadStyle">
                     <!--<el-input v-model="form.sqrZjzm" placeholder="请输入申请人证件照正面"/>-->
-                    <image-upload :isShowTip="false" v-model="form.sqrZjzm" :accessToken="accessToken"
+                    <image-upload :opt="{cardNo:this.cardNo,hkbName:hkbName}" :isShowTip="false" v-model="form.sqrZjzm" :accessToken="accessToken"
                                   @getCard="getCard" @clear="clear"
                                   :limit="1" :isOcr="true" ocrType="front"></image-upload>
                     <span>证件人像面</span>
@@ -189,7 +189,7 @@
                 </div>
                 <div class="flexCount">
                   <el-form-item label="" label-width="0" prop="hkbzm" class="uploadStyleFx">
-                    <image-upload v-model="form.hkbzm" :limit="1" :isShowTip="false"></image-upload>
+                    <image-upload v-model="form.hkbzm" :limit="1" :isShowTip="false" :isOcr="true" ocrType="homepage" :accessToken="accessToken"></image-upload>
                     <span>户口首页</span>
                   </el-form-item>
                 </div>
@@ -205,7 +205,7 @@
                 </div>
                 <div class="flexCount">
                   <el-form-item label="" label-width="0" prop="hkbbm" class="uploadStyleFx">
-                    <image-upload :isShowTip="false" v-model="form.hkbbm" :limit="1"></image-upload>
+                    <image-upload :opt="form" :isShowTip="false"  v-model="form.hkbbm" :limit="1" :accessToken="accessToken" @getCard="getSubpage"  :isOcr="isOcrHkb" ocrType="subpage" @clear="clearHkb" ></image-upload>
                     <span>户口本人页</span>
                   </el-form-item>
                 </div>
@@ -272,7 +272,7 @@
               <div style="flex: 1;display:flex;">
                 <!--<div class="labelStyle">银行卡正面照</div>-->
                 <el-form-item label="银行卡正面照" style="display: flex" label-width="98" prop="yhzjz" class="uploadStyle">
-                  <image-upload :isShowTip="false" v-model="form.yhzjz" :limit="1"></image-upload>
+                  <image-upload :isShowTip="false" v-model="form.yhzjz" :accessToken="accessToken" :limit="1"  :isOcr="true" ocrType="bankcard" @getCard="getCardYhk"></image-upload>
                 </el-form-item>
               </div>
               <div style="flex: 2" class="grid2">
@@ -297,7 +297,7 @@
             <div style="display: flex">
               <div style="flex: 1;display:flex;flex-direction: column">
                 <el-form-item label="证件人像面" style="display: flex" prop="jhrZjzm" label-width="98" class="uploadStyle">
-                  <image-upload :isShowTip="false" v-model="form.jhrZjzm" :accessToken="accessToken" @getCard="getCardJh"
+                  <image-upload  :isShowTip="false" v-model="form.jhrZjzm" :accessToken="accessToken" @getCard="getCardJh"
                                 @clear="clearJh"
                                 :limit="1" :isOcr="true" ocrType="front"></image-upload>
                 </el-form-item>
@@ -407,6 +407,7 @@
                                 placeholder="请输入始发年月" :picker-options="ffyfPickerOptions">
                 </el-date-picker>
               </el-form-item>
+
               <el-form-item label="补发月数" prop="sqbfys">
                 <el-input disabled v-model="form.sqbfys" placeholder="请输入补发月数"/>
               </el-form-item>
@@ -610,6 +611,9 @@
       return {
         // 遮罩层
         formXq: '',
+        cardNo:'',
+        hkbName:'',
+        isOcrHkb:true,
         loading: true,
         submitFormLoading: false,
         // 选中数组
@@ -746,6 +750,7 @@
             {required: true, message: "监护人详情居住地址不能为空", trigger: "blur"},
           ],
           ffyf: [
+            {required: true, message: "始发年月不能为空", trigger: "blur"},
             {max: 8, message: '开始发放月份不能超过8个字符', trigger: 'blur'},
           ],
           dbrZjzm: [
@@ -912,6 +917,26 @@
           this.isJy = false
         }
       },
+      async getQxBfPz2() {
+        if (!this.form.csrq) {
+          return
+        }
+        let res = await getQxBfPz({csrq: this.form.csrq,isdb:this.form.isdb});
+        this.form.pc=res.data.pc;
+        this.isJy = false;
+        if (res.data.default) {
+          if (res.data.upper && res.data.upper.length >= 6) {
+            console.log(this.upper, 'this.upper时间');
+            if (res.data.default === res.data.upper) {
+              this.isJy = true
+            }
+          } else {
+            this.isJy = false
+          }
+        } else {
+          this.isJy = false
+        }
+      },
       changeDb(){
         this.form.dbzh='';
         this.form.dbzm='';
@@ -959,26 +984,37 @@
         });
       },
       getCard(data) {
-        console.log(data, '<--------data');
+        console.log(data, '<--------身份证正面');
         if (data && data.sqrZjhm) {
-          ocrQuery({sqrZjhm:data.sqrZjhm}).then(
-            ()=>{
-              this.form.sqrZjhm = data.sqrZjhm;
-              this.form.xb = this.dict.type.C0007.filter(e => e.label.includes(data.xb))[0].value;
-              this.form.csrq = data.csrq;
-              this.form.sqrXm = data.sqrXm;
-              this.form.khmc= data.sqrXm;
-              this.form.hjdz = data.hjdz;
-              this.getBfys();
-              this.getQxBfPz();
-            }
-          ).catch(e=>{
-            this.form.sqrZjzm='';
-            console.log(e,'我是异常')
-          })
+          // if(this.cardNo&&this.hkbName&&(data.sqrZjhm!= this.cardNo||data.sqrXm!=this.name))
+          // {
+          //   this.$modal.msgError(`申请人证件信息与户口本信息不一致`);
+          //   this.$nextTick(()=>{
+          //   this.form.sqrZjzm='';})
+          // }else{
+            this.ocrSelect(data)
+          // }
 
         }
       },
+      ocrSelect(data){
+        ocrQuery({sqrZjhm:data.sqrZjhm}).then(
+          async ()=>{
+            this.form.sqrZjhm = data.sqrZjhm;
+            this.form.xb = this.dict.type.C0007.filter(e => e.label.includes(data.xb))[0].value;
+            this.form.csrq = data.csrq;
+            this.form.sqrXm = data.sqrXm;
+            this.form.khmc= data.sqrXm;
+            this.form.hjdz = data.hjdz;
+            await this.getQxBfPz();
+            await this.getBfys();
+          }
+        ).catch(e=>{
+          this.form.sqrZjzm='';
+          console.log(e,'我是异常')
+        })
+
+      },
       getBack(data) {
         if (data) {
           this.form.fzjg = data.fzjg;
@@ -988,20 +1024,52 @@
         if (data && data.sqrZjhm) {
           this.form.dbrZjhm = data.sqrZjhm;
           this.form.dbrXm = data.sqrXm;
+          this.form.dbrJzdz = data.hjdz;
         }
       },
       getCardJh(data) {
         if (data && data.sqrZjhm) {
           this.form.jhrZjhm = data.sqrZjhm;
           this.form.jhrXm = data.sqrXm;
+          this.form.jhrJzdz = data.hjdz;
+        }
+      },
+      getCardYhk(data){
+        if (data && data.yhzh) {
+          this.form.yhzh = data.yhzh;
         }
       },
+      getSubpage(data){
+        console.log(data,'户口本');
+        if(data && data.cardNo){
+          this.cardNo=data.cardNo;
+          this.hkbName=data.name;
+          // if(this.form.sqrZjhm&&this.form.sqrXm){
+          //   if(this.form.sqrZjhm!= data.cardNo||this.form.sqrXm!=data.name)
+          //   {
+          //     this.$modal.msgError(`申请人证件信息与户口本信息不一致`);
+          //     this.$nextTick(()=>{
+          //       this.form.hkbbm='';
+          //     })
+          //
+          //   }
+          // }
+        }
+      },
+      clearHkb(){
+        this.cardNo='';
+        this.hkbName='';
+      },
       clear() {
         this.form.sqrZjhm = '';
         this.form.xb = '';
         this.form.csrq = '';
         this.form.sqrXm = '';
         this.form.hjdz = '';
+        this.form.pc = '';
+        this.form.ffyf = '';
+        this.form.sqbfys = '';
+        this.form.sqbfje = '';
       },
       clear2() {
         this.form.dbrXm = '';
@@ -1106,6 +1174,7 @@
           xjdxzqh: null, // 现居地行政区划
           khwd: null,   // 开户网点
         };
+        this.clearHkb();
         this.resetForm("form");
       },
       /** 搜索按钮操作 */
@@ -1185,7 +1254,7 @@
             if (this.status == '4' || this.status == '0'|| this.status == '50') {
               this.getAccessToken();
             }
-            this.getQxBfPz();
+            this.getQxBfPz2();
             this.getBfys();
             this.open = true;
           }