nidapeng
2024-03-20 142eac0ef7640add5362eed3afb595596793f24d
h5/pages/visitorApplication/visitorApplication.vue
@@ -35,7 +35,7 @@
               <text>离厂时间</text>
               <text>*</text>
            </view>
            <view class="list_item_content" @click="show5 = true">
            <view class="list_item_content" @click="openLC">
               <text :style="{color: form1.endtime ? '#000000' : ''}">{{form1.endtime ? form1.endtime : '请选择'}}</text>
               <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
            </view>
@@ -45,6 +45,7 @@
               <text>访问门禁</text>
               <text>*</text>
            </view>
             <!-- @click="show6 = true" -->
            <view class="list_item_content">
               <text :style="{color: form1.doorSelectName ? '#000000' : ''}">{{form1.doorSelectName ? form1.doorSelectName : '请选择'}}</text>
               <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
@@ -53,14 +54,24 @@
         <view class="list_item">
            <view class="list_item_label">
               <text>拜访事由</text>
               <text></text>
               <text>*</text>
            </view>
            <view class="list_item_content">
               <input type="text" v-model="form1.reason" placeholder="请输入来访事由,您来做什么的" placeholder-style="color: #999999;" />
            </view>
         </view>
         <view class="list_item">
            <view class="list_item_label">
               <text>随行车辆</text>
               <text></text>
            </view>
            <view class="list_item_content" @click="openInput(1)">
               <text :style="{color: form1.carNos ? '#000000' : ''}">{{form1.carNos ? form1.carNos : '请输入车牌号码'}}</text>
               <!-- <input type="text" placeholder="请输入车牌号" v-model="form1.carNos" maxlength="8" placeholder-style="color: #999999;" /> -->
            </view>
         </view>
      </view>
      <view class="cate">
      <!-- <view class="cate">
         <view class="cate_head">车辆信息</view>
         <view class="cate_list">
            <view class="cate_list_item" v-for="(item, index) in cars" :key="index">
@@ -69,7 +80,7 @@
            </view>
         </view>
         <view class="cate_add" @click="show2 = true">+添加车辆</view>
      </view>
      </view> -->
      <view class="cate">
         <view class="cate_head">随访人员信息</view>
         <view class="cate_list">
@@ -94,14 +105,16 @@
      ></u-datetime-picker>
      <!-- 离场时间 -->
      <u-datetime-picker
         v-if="form1.starttime"
         :show="show5"
         :minDate="new Date().getTime()"
         :minDate="formatTimeStamp(form1.starttime)"
         :maxDate="formatTimeStamp(maxTime)"
         mode="datetime"
         @cancel="show5 = false"
         @confirm="setoutDate"
      ></u-datetime-picker>
      <!-- 门禁 -->
      <u-popup :show="show" :round="10" :safeAreaInsetBottom="true" :closeable="true" mode="bottom" @close="show = false">
      <u-popup :show="show" :round="10" :safeAreaInsetBottom="true" :closeable="true" mode="bottom" @close="closeMJ">
         <view class="menjin">
            <view class="respondent-title">
               选择门禁
@@ -109,12 +122,12 @@
            <scroll-view scroll-y class="list">
               <view class="list_item" v-for="(item, index) in columns" :key="index" @click="seleMJ(index)">
                  <text>{{item.name}}</text>
                  <image src="@/static/video@2x.png" mode="widthFix" v-show="!item.active"></image>
                  <image src="@/static/video_sel@2x.png" mode="widthFix" v-show="item.active"></image>
                  <image src="@/static/checkbox@2x.png" mode="widthFix" v-show="!item.active"></image>
                  <image src="@/static/checkbo1x_sel@2x.png" mode="widthFix" v-show="item.active"></image>
               </view>
            </scroll-view>
            <view class="menjin_footer">
               <view class="menjin_footer_item" @click="show = false">取消</view>
               <view class="menjin_footer_item" @click="closeMJ">取消</view>
               <view class="menjin_footer_item" @click="submitMJ">确认</view>
            </view>
         </view>
@@ -211,13 +224,13 @@
                     <text>*</text>
                  </view>
                  <view class="adduser_list_item_ipt">
                     <input type="text" v-model="withUserList.idcardNo" placeholder-style="color: #999999;font-size: 28rpx;" placeholder="请输入证件号码" />
                     <input type="text" v-model="withUserList.idcardNo" maxlength="18" placeholder-style="color: #999999;font-size: 28rpx;" placeholder="请输入证件号码" />
                  </view>
               </view>
               <view class="adduser_list_item">
                  <view class="adduser_list_item_label">
                     <text>公司</text>
                     <text></text>
                     <text>*</text>
                  </view>
                  <view class="adduser_list_item_ipt">
                     <input type="text" v-model="withUserList.companyName" placeholder-style="color: #999999;font-size: 28rpx;" placeholder="请输入公司名称" />
@@ -228,15 +241,16 @@
                     <text>随行车辆</text>
                     <text></text>
                  </view>
                  <view class="adduser_list_item_ipt">
                     <input type="text" v-model="withUserList.carNos" placeholder-style="color: #999999;font-size: 28rpx;" placeholder="请输入车牌号" />
                  <view class="adduser_list_item_ipt" @click="openInput(2)">
                     <text :style="{color: withUserList.carNos ? '#000000' : ''}">{{withUserList.carNos ? withUserList.carNos : '请输入车牌号码'}}</text>
                     <!-- <input type="text" v-model="withUserList.carNos" disabled placeholder-style="color: #999999;font-size: 28rpx;" placeholder="请输入车牌号" /> -->
                  </view>
               </view>
               <view class="adduser_list_item">
                  <view class="adduser_list_item_label1">
                     <text class="cc">人脸照片<b>*</b></text>
                     <text class="aa">1、请提供五官清晰,人脸居中的正面人脸免</text>
                     <text class="aa">2、照片无逆光、无PS、无过度美颜处理</text>
                     <text class="aa">1、请提供五官清晰,人脸居中的正面人脸免冠照片;</text>
                     <text class="aa">2、照片无逆光、无PS、无过度美颜处理;</text>
                  </view>
                  <view class="adduser_list_item_ipt">
                     <view class="adduser_list_item_ipt1_upload" @click="upload('faceImg')" v-if="!withUserList.faceImgUrl">
@@ -269,13 +283,23 @@
         </view>
      </u-popup>
      <u-picker keyName="name" :show="show6" :columns="columns1" @confirm="seleIdcard" @cancel="show6 = false"></u-picker>
      <!-- <tly-picture-cut ref="tlyPictureCut" :pictureSrc="photoSrc" @createImg="uploadImg"></tly-picture-cut> -->
      <keyboardInput ref="keyboard" @export="setPlate" @close="closeInput" />
      <qf-image-cropper ref="cropper" :width="280" :height="280" :radius="30" @crop="uploadImg"></qf-image-cropper>
   </view>
</template>
<script>
   import tlyPictureCut from "@/components/tly-picture-cut/tlyPictureCut.vue";
   import keyboardInput from "@/components/keyboard-input/keyboard-input.vue";
   import QfImageCropper from '@/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.vue';
   import { getDaysAfterDate } from '@/utils/utils.js'
   export default {
      data() {
         return {
            photoSrc: '',
            type: '',
            inputType: '',
            show: false,
            show1: false,
            show2: false,
@@ -283,10 +307,13 @@
            show4: false,
            show5: false,
            show6: false,
            show7: false,
            fileList: [],
            columns1: [[{name: '身份证', id: 0}, {name: '港澳证件', id: 1},{name: '护照', id: 2}]],
            columns: [],
            cars: [],
            day: null,
            maxTime: '',
            carName: '',
            personnel: [],
            userAnswerId: '',
@@ -319,16 +346,61 @@
            verify: ''
         };
      },
      components: { tlyPictureCut, keyboardInput, QfImageCropper },
      onLoad(options) {
         this.form = JSON.parse(options.data)
         if (options.data) {
            this.form = JSON.parse(options.data)
         }
         this.getvisit()
         this.getVisit1()
         this.getUserValid()
      },
      methods: {
         openInput(type) {
            this.inputType = type
            this.$refs.keyboard.open()
         },
         setPlate(e) {
            if (this.inputType === 1) {
               this.form1.carNos = e
            } else if (this.inputType === 2) {
               this.withUserList.carNos = e
            }
            this.$forceUpdate()
            this.closeInput()
         },
         closeInput() {
            this.$refs.keyboard.close()
         },
         uploadImg(file) {
            this.$refs.cropper.close()
            uni.showLoading({ title: '上传中', mask: true });
            uni.uploadFile({
               url: `${this.$baseUrl}public/api/uploadFtp.do`,
               filePath: file.tempFilePath,
               name: 'file',
               formData: {
                  folderCode: 'MEMBER_IMG'
               },
               success: (uploadFileRes) => {
                  let res = JSON.parse(uploadFileRes.data)
                  this.withUserList.faceImg = res.data.halfPath
                  this.withUserList.faceImgUrl = res.data.prefixPath + res.data.folder + res.data.halfPath
               },
               complete() {
                  uni.hideLoading();
               }
            });
         },
         closeMJ() {
            this.show = false
            this.columns.forEach(item => {
               item.active = false
            })
         },
         submit() {
            if (!this.form1.receptMemberId) return uni.showToast({
               title: '被访人不能为空',
               title: '请填写有效的访问人',
               icon: 'none'
            })
            if (!this.form1.starttime) return uni.showToast({
@@ -339,7 +411,7 @@
               title: '离场时间不能为空',
               icon: 'none'
            })
            if (!this.form1.doorSelectName) return uni.showToast({
            if (!this.form1.doorSelectName && this.accessControl == 1) return uni.showToast({
               title: '访问门禁不能为空',
               icon: 'none'
            })
@@ -347,14 +419,21 @@
               title: '拜访事由不能为空',
               icon: 'none'
            })
            // this.form1.starttime = this.form1.starttime + ':00'
            // this.form1.endtime = this.form1.endtime + ':00'
            let data = JSON.parse(JSON.stringify(this.form1))
            data.starttime = data.starttime + ':00'
            data.endtime = data.endtime + ':00'
            this.$u.api.createFk({
               ...this.form,
               ...this.form1,
               ...data,
               openid: this.$store.state.openId,
               withUserList: this.personnel
            }).then(res => {
               if (res.code === 200) {
                  console.log(res)
                  uni.reLaunch({
                     url: `/pages/appointmentDetails/appointmentDetails?id=${res.data}`
                  })
               }
            })
         },
@@ -371,6 +450,16 @@
                  this.visit = res.data.code
               }
            })
            // 起始时间时长
            this.$u.api.getSystemDictData({
               dictCode: 'VISIT_CONFIG',
               label: 'VALIDATE_VISIT'
            }).then(res => {
               if (res.code === 200) {
                  this.day = Number(res.data.code)
                  // console.log(nextDay('after', true, this.day))
               }
            })
         },
         submitUser() {
            if (!this.withUserList.name) return uni.showToast({
@@ -381,12 +470,28 @@
               title: '手机号不能为空',
               icon: 'none'
            })
            const regExp = /^1[3456789]\d{9}$/;
            if (!regExp.test(this.withUserList.phone)) return uni.showToast({
               title: '手机号格式错误',
               icon: 'none'
            })
            if (!String(this.withUserList.idcardType)) return uni.showToast({
               title: '证件类型不能为空',
               icon: 'none'
            })
            if (!this.withUserList.idcardNo) return uni.showToast({
               title: '证件号码不能为空',
               icon: 'none'
            })
            if (this.withUserList.idcardType === 0) {
               const regex = /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}[\dxX]$/;
               if (!regex.test(this.withUserList.idcardNo)) return uni.showToast({
                  title: '证件号码格式错误',
                  icon: 'none'
               })
            }
            if (!this.withUserList.companyName) return uni.showToast({
               title: '公司不能为空',
               icon: 'none'
            })
            if (!this.withUserList.faceImg) return uni.showToast({
@@ -414,8 +519,18 @@
            this.withUserList.imgurlUrl = ''
         },
         upload(type) {
            this.type = type
            if (type === 'faceImg') {
               this.$refs.cropper.open()
               return
            }
            uni.chooseImage({
               success: (chooseImageRes) => {
                  // if (type === 'faceImg') {
                  //    this.photoSrc = chooseImageRes.tempFilePaths[0];
                  //    this.$refs.tlyPictureCut.showPop();
                  //    return
                  // }
                  uni.showLoading({ title: '上传中', mask: true });
                  for (let i = 0; i < chooseImageRes.tempFilePaths.length; i++) {
                     uni.uploadFile({
@@ -488,19 +603,27 @@
               }
            })
         },
         openLC() {
            if (!this.form1.starttime) return uni.showToast({
               title: '请先选择入厂时间',
               icon: 'none'
            })
            this.show5 = true
         },
         setinDate(e) {
            this.form1.starttime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
            this.form1.starttime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
            this.maxTime = getDaysAfterDate(uni.$u.timeFormat(e.value, 'yyyy-mm-dd'), this.day)
            this.show4 = false
         },
         setoutDate(e) {
            this.form1.endtime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
            this.form1.endtime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
            this.show5 = false
         },
         formatTimeStamp(date) {
             return Date.parse(new Date(`${date}`)) || Date.parse(new Date(`${date.replace(/-/g,'/')}`))
         },
         // 查询用户
         getUser() {
            console.log(this.verify)
            console.log(this.form1.phone1)
            console.log(this.form1.receptMemberName)
            if (this.verify === '0') {
               if (this.form1.phone1) {
                  this.$u.api.getVisitedMember({
@@ -533,7 +656,6 @@
               label: 'BEVISITED_USER_VALID'
            }).then(res => {
               if (res.code === 200) {
                  console.log(res)
                  this.verify = res.data.code
               }
            })
@@ -658,7 +780,7 @@
               align-items: center;
               justify-content: space-between;
               .adduser_list_item_label1 {
                  flex-shrink: 0;
                  flex: 1;
                  display: flex;
                  flex-direction: column;
                  .cc {
@@ -700,7 +822,7 @@
                  }
               }
               .adduser_list_item_ipt {
                  flex: 1;
                  flex-shrink: 0;
                  text-align: right;
                  font-size: 28rpx;
                  font-family: PingFangSC, PingFang SC;