Lou
2024-04-16 b5d2ec149dbca8b8a44b9de0605aecc74cbddc1e
subPackage/workbench/views/editExamine.vue
@@ -91,8 +91,16 @@
            <view class="item bgc-ff mt-20">
               <view class="box-title">
                  <box-title title="房东信息"></box-title>
               <view class="flex j-c-s-b a-i-c" style="padding-top:12rpx;">
                  <view class="box-title" style="width:50%;">
                     <box-title title="房东信息"></box-title>
                  </view>
                  <ocr-navigator @onSuccess="recognizeSuccess($event)" certificateType="idCard" :opposite="false">
                     <view class="recognize-btn flex a-i-c">
                        <u-icon name="scan" color="#fff" size="24"></u-icon>
                        <text class="f-26 c-ff" style="margin-left: 10rpx;">身份证信息识别</text>
                     </view>
                  </ocr-navigator>
               </view>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="姓名:" prop="landlordName">
@@ -140,13 +148,31 @@
            </view>
         </view>
         <view class="practitioner">
            <box-title title="从业人员信息"></box-title>
            <view class="info" v-for="(item, index) in personNum" :key="index">
               <view class="title">人员信息-#{{ index*1 + 1 }}</view>
            <view>
               <box-title title="从业人员信息"></box-title>
            </view>
            <view class="info" v-for="(item, index) in personNumArr" :key="index">
               <view class="flex a-i-c j-c-s-b" style="padding:20rpx;">
                  <view class="flex j-c-s-b a-i-c">
                     <view class="title fw" style="text-align:center; mr-20">人员信息-#{{ index*1 + 1 }}</view>
                     <ocr-navigator @onSuccess="recognizePersonSuccess($event,index)" certificateType="idCard"
                        :opposite="false">
                        <view class="recognize-btn flex a-i-c">
                           <u-icon name="scan" color="#fff" size="24"></u-icon>
                           <text class="f-26 c-ff" style="margin-left: 10rpx;">身份证信息识别</text>
                        </view>
                     </ocr-navigator>
                  </view>
                  <view>
                     <u-icon name="trash-fill" color="#ff0000" size="20" @click="deletePerson(index)" />
                  </view>
               </view>
               <formItem ref="formItemRef"></formItem>
            </view>
            <view class="add-person">
            <view class="add-person" style="padding:20rpx 30rpx;" v-if="!currentId">
               <u-button type="success" plain @click="addPerson">再加一人</u-button>
            </view>
         </view>
@@ -270,7 +296,7 @@
                  }
               ]
            },
            personNum: 1,
            personNum: 0,
            curSelectSite: {},
            jwd: "",
            placeList: [],
@@ -292,7 +318,8 @@
            genderIndex: [0],
            genderValue: "",
            showNationPicker: false,
            showGenderPicker: false
            showGenderPicker: false,
            personNumArr: [],
         }
      },
      onShow() {
@@ -424,6 +451,7 @@
               }
               this.personNum = placePractitioner.length
               this.personNumArr = placePractitioner;
               // const componetns = this.$refs.formItemRef || []
               placePractitioner.forEach((item, index) => {
                  this.$nextTick(() => {
@@ -434,23 +462,17 @@
                        this.$refs.formItemRef[index].nationTypeIndex = obj.index;
                     }
                     if (item.gender) {
                     if (typeof(item.gender) == 'number') {
                        let obj = this.$getIndex(this.$refs.formItemRef[index].gender, item
                           .gender, "value", "name")
                        this.$refs.formItemRef[index].genderValue = obj.name;
                        this.$refs.formItemRef[index].genderIndex = obj.index;
                     }
                     if (item.employerImg == "" || item.employerImg == null) {
                        console.log(222222)
                        this.$refs.formItemRef[index].employerImg = []
                        item.employerImg = [];
                     } else {
                        this.$refs.formItemRef[index].employerImg = this.$setImageUrl(item
                           .employerImg, 2)
                        item.employerImg = this.$setImageUrl(item.employerImg, 2)
                     }
                     console.log(this.$refs.formItemRef[index].form);
                     this.$refs.formItemRef[index].form = item
                  })
               })
@@ -528,21 +550,19 @@
               })
            })
         },
         addPerson() {
            this.personNum++
         },
         submit() {
            if (this.personNum > 0) {
               const placePractitioner = []
               this.$refs.formItemRef.forEach(item => {
                  console.log("item====>", item);
                  item.form.placeId = this.form.placeId
                  // if (item.form.employerImg == null) {
                  //    item.form.employerImg = "";
                  // } else {
                  //    item.form.employerImg = this.$formattingUrls(item.form.employerImg);
                  // }
                  item.form.employerImg = "";
                  if (item.form.employerImg == null) {
                     item.form.employerImg = "";
                  } else {
                     item.form.employerImg = this.$formattingUrls(item.form.employerImg);
                  }
                  // item.form.employerImg = "";
                  placePractitioner.push(item.form)
               })
               this.form.placePractitioner = placePractitioner
@@ -561,7 +581,63 @@
         addPerson() {
            this.personNum++
            this.personNumArr.push(1)
         },
         deletePerson(index) {
            this.personNum--;
            this.personNumArr.splice(index, 1)
         },
         //识别成功
         recognizeSuccess(e, key) {
            let {
               detail: {
                  name,
                  id
               }
            } = e;
            this.form.landlordName = name.text;
            this.form.landlordIdCard = id.text;
         },
         //识别从业人员身份证信息
         recognizePersonSuccess(e, index) {
            let {
               detail: {
                  name,
                  id,
                  address,
                  gender,
                  nationality
               }
            } = e;
            this.$refs.formItemRef[index].form.name = name.text; //姓名
            this.$refs.formItemRef[index].form.idCard = id.text; //身份证号
            this.$refs.formItemRef[index].genderValue = gender.text; //性别
            this.$refs.formItemRef[index].nationValue = `${nationality.text}族`; //民族
            this.$refs.formItemRef[index].form.gender = this.getValue(this.gender, gender.text).value;
            this.$refs.formItemRef[index].form.ethnicity = this.getValue(this.nationTypeList, `${nationality.text}族`)
               .value;
            this.$refs.formItemRef[index].genderIndex = [this.getValue(this.gender, gender.text).index];
            this.$refs.formItemRef[index].nationTypeIndex = [this.getValue(this.nationTypeList, `${nationality.text}族`)
               .index
            ];
         },
         getValue(arr, name) {
            for (let i = 0, ii = arr.length; i < ii; i++) {
               if (arr[i].name == name) {
                  return {
                     index: i,
                     value: arr[i].value
                  }
               }
            }
         }
      }
   }
</script>
@@ -682,4 +758,11 @@
      padding: 0 30rpx;
      border-radius: 8rpx;
   }
   .recognize-btn {
      padding: 12rpx;
      border-radius: 6rpx;
      background-color: #3c9cff;
      margin-left: 30rpx;
   }
</style>