shuishen
2024-03-22 fdef23064b801a06bbf369785dbbc14db14b707f
subPackage/workbench/views/cscj.vue
@@ -2,6 +2,15 @@
   <view class="container">
      <view class="wrap">
         <u-form labelWidth="70" :model="form" :rules="rules" ref="form">
            <view class="top item flex j-c-s-b a-i-c" @click="onScan()" v-if="!currentId">
               <view class="flex a-i-c">
                  <u-icon name="/static/icon/nav-05.png" width="90rpx" height="90rpx"></u-icon>
                  <text class="f-28 ml-10">扫码获取信息</text>
               </view>
               <u-icon name="arrow-right" size="20"></u-icon>
            </view>
            <view class="item">
               <!-- u-form-item v-if="!currentId" @click="showPicker = true" class="form-item" labelWidth="100" label="楼栋:"
               :required="isRequired" :disabled="isDisabled" prop="buildingCode">
@@ -81,6 +90,17 @@
               </u-form-item>
               <u-form-item label="三级消防单位" labelWidth="100" prop="threeFireProtection" :required="isRequired">
                  <u-radio-group v-model="form.threeFireProtection" v-if="!currentId">
                     <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in statusList"
                        :key="index" :label="item.name" :name="item.id">
                     </u-radio>
                  </u-radio-group>
                  <view class="f-30" v-if="currentId">
                     {{form.threeFireProtection == 1?"否":"是"}}
                  </view>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" label="备注:" prop="remark">
                  <u--input v-if="!currentId" border="none" v-model="form.remark" placeholder="请输入">
                  </u--input>
@@ -99,7 +119,7 @@
                        请选择地址
                     </view>
                     <view class="location-btn c-main f-24" @click="getLocation()"
                        v-if="(!currentId && !isView)   || (isView && !form.jwd)">
                        v-if="source == 3  || ((!currentId && !isView)   || (isView && !form.jwd))">
                        获取地址
                     </view>
                  </view>
@@ -111,9 +131,43 @@
                  </view>
               </u-form-item>
               <u-form-item v-if="!currentId" label="负责人信息和法人信息是否一致" labelWidth="100" :required="isRequired">
                  <u-radio-group v-model="isLegalSame">
                     <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in statusList"
                        :key="index" :label="item.name" :name="item.id">
                     </u-radio>
                  </u-radio-group>
                  <!-- <view class="f-30" v-if="currentId">
                     {{form.threeFireProtection == 1?"是":"否"}}
                  </view> -->
               </u-form-item>
            </view>
            <view class="item">
               <view class="box-title">
                  <box-title title="法人信息"></box-title>
               </view>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="姓名:" prop="legalPerson">
                  <u--input border="none" v-model="form.placeExtEntity.legalPerson" placeholder="请输入">
                  </u--input>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="身份证号:" prop="legalIdCard">
                  <u--input border="none" type="idcard" v-model="form.placeExtEntity.legalIdCard"
                     placeholder="请输入">
                  </u--input>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="手机号:" prop="legalTel">
                  <u--input border="none" type="number" v-model="form.placeExtEntity.legalTel" placeholder="请输入">
                  </u--input>
               </u-form-item>
            </view>
            <view class="item" v-if="isLegalSame != 1 && !currentId">
               <view class="box-title">
                  <box-title title="负责人信息"></box-title>
               </view>
@@ -134,6 +188,38 @@
               </u-form-item>
            </view>
            <view class="item">
               <view class="box-title">
                  <box-title title="房东信息"></box-title>
               </view>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="姓名:" prop="landlordName">
                  <u--input border="none" v-model="form.placeExtEntity.landlordName" placeholder="请输入">
                  </u--input>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="身份证号:" prop="landlordIdCard">
                  <u--input border="none" type="idcard" v-model="form.placeExtEntity.landlordIdCard"
                     placeholder="请输入">
                  </u--input>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="手机号:" prop="landlordPhone">
                  <u--input border="none" type="number" v-model="form.placeExtEntity.landlordPhone"
                     placeholder="请输入">
                  </u--input>
               </u-form-item>
               <u-form-item class="form-item" labelWidth="100" :required="isRequired" :disabled="isDisabled"
                  label="微信号:" prop="landlordWxAccount">
                  <u--input border="none" v-model="form.placeExtEntity.landlordWxAccount" placeholder="请输入">
                  </u--input>
               </u-form-item>
            </view>
            <view class="item pic" v-if="(currentId && form.images.length) || !currentId ">
               <view class="box-title">
                  <box-title title="场所照片"></box-title>
@@ -147,6 +233,27 @@
            </view>
         </u-form>
         <view class="practitioner">
            <view style="padding:20rpx 30rpx;">
               <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="title fw" style="text-align:center;">人员信息-#{{ index*1 + 1 }}</view>
                  <view>
                     <u-icon name="trash-fill" color="#ff0000" size="20" @click="deletePerson(index)" />
                  </view>
               </view>
               <formItem ref="formItemRef"></formItem>
            </view>
            <view class="" style="padding:20rpx 0;" v-if="personNum == 0  && currentId">
               未完善
            </view>
            <view class="add-person" style="padding:20rpx 30rpx;" v-if="!currentId">
               <u-button type="success" plain @click="addPerson">再加一人</u-button>
            </view>
         </view>
@@ -224,6 +331,16 @@
      <u-picker :show="isShowCatePicker" :defaultIndex="categoryIndex" ref="catePicker" keyName="categoryName"
         :columns="categoryList" @confirm="confirmCategory" @change="changeCategory"
         @cancel="isShowCatePicker = false"></u-picker>
      <u-picker :defaultIndex="nationTypeListIndex" :closeOnClickOverlay="true" :show="showNationPicker"
         :columns="[nationTypeList]" @close="showNationPicker = false" @cancel="showNationPicker = false"
         keyName="name" @confirm="confirmNation"></u-picker>
      <u-picker :defaultIndex="genderIndex" :closeOnClickOverlay="true" :show="showGenderPicker" :columns="[gender]"
         @close="showGenderPicker = false" @cancel="showGenderPicker = false" keyName="name"
         @confirm="confirmGender"></u-picker>
      <cate-selector ref="selector" @comfirm="comfirmNineType" />
   </view>
</template>
@@ -239,10 +356,8 @@
      getDoorplateAddressList
   } from "@/api/doorplateAddress/doorplateAddress";
   import {
      add,
      getPlaceDetail
   } from '@/api/place/place.js'
   import {
      add
   } from "@/api/place/place";
   import {
      format
@@ -258,12 +373,18 @@
   import cateSelector from "../components/cateSelector.vue"
   import {
      getQrCodeDetail
   } from "@/api/system/index"
   import formItem from '../components/formItem.vue'
   export default {
      mixins: [uploadMixin],
      components: {
         lineItem,
         boxTitle,
         cateSelector
         cateSelector,
         formItem
      },
      data() {
         return {
@@ -293,7 +414,19 @@
               isNine: "",
               isFront: "",
               frontType: "",
               nineType: ""
               nineType: "",
               threeFireProtection: "",
               placeExtEntity: {
                  landlordName: "",
                  landlordIdCard: "",
                  landlordPhone: "",
                  landlordWxAccount: "",
                  legalPerson: "",
                  legalTel: "",
                  legalIdCard: "",
                  placeId: "",
               }
            },
            rules: {
               // 'buildingCode': {
@@ -327,7 +460,7 @@
                  trigger: ['blur', 'change'],
               },
               'form.principalPhone': [{
                     required: false,
                     required: true,
                     message: '请输入手机号',
                     trigger: ['blur', 'change'],
                  },
@@ -501,14 +634,31 @@
            showFrontTypePicker: false,
            nineTypeValue: "",
            frontTypeValue: "",
            isView: false
            isView: false,
            source: "",
            nationTypeList: [], //民族
            nationTypeIndex: [0],
            nationValue: "",
            gender: [{ //性别
                  value: 1,
                  name: '男',
               },
               {
                  value: 0,
                  name: '女',
               }
            ],
            genderIndex: [0],
            genderValue: "",
            showNationPicker: false,
            showGenderPicker: false,
            personNum: 0,
            personNumArr: [],
            isLegalSame: 1 //法人信息是否与负责人一致  1是  2否
         }
      },
      created() {
         this.buildColumn()
      },
      options: {
         styleIsolation: 'shared', // 解除样式隔离
      },
@@ -556,71 +706,20 @@
            },
            immediate: true
         }
         // secondId:{
         //              handler(newVal,oldVal){
         //       this.getCategory(3,this.secondId);
         //    },
         //    immediate:true
         // }
      },
      onReady() {
         this.$refs.form.setRules(this.rules)
      },
      methods: {
         // getBuildingDetail(params = {}) {
         //    getDoorplateAddressDetail(Object.assign(params, {
         //       stdId: this.stdId
         //    })).then(res => {
         //       let data = res.data
         //       this.form.buildingCode = data.buildingCode
         //       let buildingNameArr = [data.townStreetName, data.neiName, data.streetRuName, data.aoiName,
         //          data.buildingName
         //       ]
         //       let arr = buildingNameArr.filter(e => {
         //          return e != null || e != ''
         //       })
         //       // 赋值
         //       // this.form.placeName = data['placeName']
         //       Object.keys(this.form).forEach(key => {
         //          if (!data[key]) {
         //             this.form[key] = data.place[key]
         //          } else {
         //             this.form[key] = data[key]
         //          }
         //       })
         //       this.form.building = arr.join("")
         //       Object.keys(this.comprehensiveData).forEach(key => {
         //          this.comprehensiveData[key].forEach(item => {
         //             if (!data[item.name]) {
         //                item.value = data.place[item.name] || '未完善'
         //             } else {
         //                item.value = data[item.name] || '未完善'
         //             }
         //          })
         //          this.publicData[key].forEach(item => {
         //             if (!data[item.name]) {
         //                item.value = data.place[item.name] || '未完善'
         //             } else {
         //                item.value = data[item.name] || '未完善'
         //             }
         //          })
         //       })
         //    })
         // },
         async getAllBizDict() {
            // 获取九小场所类型
            // await this.getBizDict('nineType', this.nineTypeList)
            // 获取阵地
            await this.getBizDict('frontType', this.frontTypeList)
            // 获取民族
            await this.getBizDict('nationType', this.nationTypeList);
         },
         // 获取业务字典
@@ -712,18 +811,11 @@
               // picker为选择器this实例,变化第二列对应的选项
               // picker.setColumnValues(1, this.categoryList[index])
               this.firstId = e.value[columnIndex].categoryNo;
               // this.secondId = this.categoryList[1][0].categoryNo;
               // this.getCategory(2,this.firstId);
            }
            // else if ( columnIndex === 1){
            // picker.setColumnValues(2, this.categoryList[index])
            // this.secondId = e.value[columnIndex].categoryNo;
            // this.getCategory(3,this.secondId)
            // }
         },
         getBuildingDetail(params = {}) {
            let idorCodeParams = {}
            if (this.houseCode) {
               idorCodeParams = {
@@ -757,6 +849,10 @@
                  })
                  return
               }
               const placePractitioner = data?.placePractitioner || []
               this.personNum = placePractitioner.length;
               this.personNumArr = placePractitioner;
               this.source = data.source;
               // this.houseCode = data.houseCode;
               const dpaEntity = data?.doorplateAddressEntity || {}
               const gridEntity = data?.grid || {}
@@ -830,6 +926,28 @@
                        }
                     }
                  }
                  if (key == "legalGender" && data.legalGender) {
                     let {
                        index,
                        name
                     } = this.$getIndex(this.gender, data.legalGender, "value",
                        "name");
                     this.genderIndex = index;
                     this.genderValue = name;
                  }
                  if (key == "ethnicity" && data.ethnicity) {
                     let {
                        index,
                        name
                     } = this.$getIndex(this.nationTypeList, data.ethnicity, "value",
                        "name");
                     this.nationTypeIndex = index;
                     this.nationValue = name;
                  }
               })
               this.$set(this.form, "jwd", `${Number(data.lng).toFixed(6)},${Number(data.lat).toFixed(6)}`)
               this.form.building = arr.join("")
@@ -871,6 +989,31 @@
                     } else {
                        item.value = data[item.name] || '未完善'
                     }
                  })
               })
               placePractitioner.forEach((item, index) => {
                  this.$nextTick(() => {
                     if (item.ethnicity) {
                        let obj = this.$getIndex(this.nationTypeList, item.ethnicity,
                           "value", "name")
                        this.$refs.formItemRef[index].nationValue = obj.name;
                        this.$refs.formItemRef[index].nationTypeIndex = obj.index;
                     }
                     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) {
                        item.employerImg = [];
                     } else {
                        item.employerImg = this.$setImageUrl(item.employerImg, 2)
                     }
                     this.$refs.formItemRef[index].form = item
                  })
               })
            })
@@ -938,6 +1081,22 @@
            this.form.lng = Number(this.form.lng).toFixed(8)
            this.form.lat = Number(this.form.lat).toFixed(8)
            delete this.form.images;
            if (this.personNum > 0) {
               const placePractitioner = []
               this.$refs.formItemRef.forEach(item => {
                  item.form.placeId = this.form.placeId
                  item.form.employerImg = this.$formattingUrls(item.form.employerImg);
                  placePractitioner.push(item.form)
               })
               this.form.placePractitioner = placePractitioner
            }
            if (this.isLegalSame == 1) {
               this.form.principal = this.form.placeExtEntity.legalPerson;
               this.form.principalPhone = this.form.placeExtEntity.legalTel;
               this.form.principalIdCard = this.form.placeExtEntity.legalIdCard;
            }
            add(this.form).then(res => {
               uni.showToast({
                  icon: 'success',
@@ -956,28 +1115,6 @@
            // })
         },
         async buildColumn() {
            //设置街道
            const townStreet = await this.getDoorplateAddressList(null, "townStreet")
            this.setColumn(townStreet, 0)
            //设置社区
            const nei = await this.getDoorplateAddressList(townStreet[0]?.code, "nei")
            this.setColumn(nei, 1)
            //设置路
            const streetRu = await this.getDoorplateAddressList(nei[0]?.code, "streetRu")
            this.setColumn(streetRu, 2)
            //设置地区
            const district = await this.getDoorplateAddressList(streetRu[0]?.code, "district")
            this.setColumn(district, 3)
            //设置楼栋
            const building = await this.getDoorplateAddressList(district[0]?.code, "building")
            this.setColumn(building, 4)
         },
         setColumn(data, index) {
            this.$set(this.pickColumns, index, data)
         },
         //获取当前位置信息
         getCurrentLocation() {
@@ -986,7 +1123,6 @@
               success: (res) => {
                  // var latitude = res.latitude; // 维度
                  // var longitude = res.longitude; // 经度
                  // this.form.lng = longitude
                  // this.form.lat = latitude
                  // this.form.jwd =
@@ -1051,56 +1187,22 @@
            this.showFrontTypePicker = false;
         },
         async changeHandler(e) {
            const {
               columnIndex,
               index,
               // 微信小程序无法将picker实例传出来,只能通过ref操作
               picker = this.$refs.uPicker
            } = e
            let item = e.values[columnIndex][index]
            //街道
            if (columnIndex === 0) {
               //获取社区列表
               const nei = await this.getDoorplateAddressList(item.code, "nei")
               picker.setColumnValues(1, nei)
               const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 1) {
               const streetRu = await this.getDoorplateAddressList(item.code, "streetRu")
               picker.setColumnValues(2, streetRu)
               const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 2) {
               const district = await this.getDoorplateAddressList(item.code, "district")
               picker.setColumnValues(3, district)
               const building = await this.getDoorplateAddressList(district[0].code, "building")
               picker.setColumnValues(4, building)
            }
            if (columnIndex === 3) {
               const building = await this.getDoorplateAddressList(item.code, "building")
               picker.setColumnValues(4, building)
            }
         //选择民族
         confirmNation(e) {
            this.nationIndex = e.indexs;
            this.nationValue = e.value[0].name;
            this.form.ethnicity = e.value[0].value;
            this.showNationPicker = false;
         },
         //选择性别
         confirmGender(e) {
            this.genderIndex = e.indexs;
            this.genderValue = e.value[0].name;
            this.form.legalGender = e.value[0].value;
            this.showGenderPicker = false;
         },
         //弹出层打开
         popup() {
@@ -1115,6 +1217,58 @@
               urls: minioBaseUrl + [value],
            })
         },
         onScan() {
            uni.scanCode({
               success: (res) => {
                  let obj = this.getUrlParams(res.result);
                  this.getHouseType(obj.stdId);
               }
            })
         },
         getUrlParams(url) {
            let urlStr = url.split('?')[1]
            let obj = {};
            let paramsArr = urlStr.split('&')
            for (let i = 0, len = paramsArr.length; i < len; i++) {
               let arr = paramsArr[i].split('=')
               obj[arr[0]] = arr[1];
            }
            return obj
         },
         getHouseType(code) {
            getQrCodeDetail({
               roleName: uni.getStorageSync("activeRole").roleName,
               addressCode: code
            }).then(res => {
               let {
                  isJur,
                  doorplateType,
                  addressLevel
               } = res.data;
               if ((doorplateType == "中门牌" && addressLevel != 4) || doorplateType == "小门牌") {
                  if (res.data.addressType) {
                     this.addressType = res.data.addressType
                  }
                  this.houseCode = code;
                  this.form.houseCode = code;
                  this.isView = true;
                  this.getBuildingDetail()
               }
            })
         },
         addPerson() {
            this.personNum++
            this.personNumArr.push(1)
         },
         deletePerson(index) {
            this.personNum--;
            this.personNumArr.splice(index, 1)
         }
      }
   }
</script>
@@ -1251,4 +1405,14 @@
      background-color: #fff;
      text-align: center;
   }
   .top {
      padding: 20rpx !important;
   }
   .practitioner {
      background-color: #fff;
      border-radius: 8rpx;
      margin-top: 20rpx;
   }
</style>