jiangping
2024-05-31 6be28040e74e1ff7764478174a9b5d706fe4fc39
h5/pages/staff/visitorReport.vue
@@ -6,7 +6,14 @@
               <text>*</text>
               <text>被访人姓名</text>
            </view>
            <view class="list_item_content"><input type="text" placeholder="请输入姓名" v-model="form1.receptMemberName" @blur="getUser" placeholder-style="color: #999999;" /></view>
        <view class="list_item_content" @click="showName = true">
          <text :style="{ color: form1.receptMemberName ? '#000000' : '' }">{{
            form1.receptMemberName
              ? form1.receptMemberName + " " + form1.receptCompanyName
              : "请选择"
          }}</text>
          <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
        </view>
         </view>
         <view class="list_item">
            <view class="list_item_label">
@@ -14,7 +21,9 @@
               <text>入厂时间</text>
            </view>
            <view class="list_item_content" @click="show4 = true">
               <text :style="{ color: form1.starttime ? '#000000' : '' }">{{ form1.starttime ? form1.starttime : '请选择' }}</text>
          <text :style="{ color: form1.starttime ? '#000000' : '' }">{{
            form1.starttime ? form1.starttime : "请选择"
          }}</text>
               <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
            </view>
         </view>
@@ -24,7 +33,9 @@
               <text>离厂时间</text>
            </view>
            <view class="list_item_content" @click="openLC">
               <text :style="{ color: form1.endtime ? '#000000' : '' }">{{ form1.endtime ? form1.endtime : '请选择' }}</text>
          <text :style="{ color: form1.endtime ? '#000000' : '' }">{{
            form1.endtime ? form1.endtime : "请选择"
          }}</text>
               <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
            </view>
         </view>
@@ -34,7 +45,13 @@
               <text>*</text>
               <text>联系人</text>
            </view>
            <view class="list_item_content"><input type="text" v-model="form1.reason" placeholder="请输入联系人姓名" placeholder-style="color: #999999;" /></view>
        <view class="list_item_content"
          ><input
            type="text"
            v-model="form1.name"
            placeholder="请输入联系人姓名"
            placeholder-style="color: #999999;"
        /></view>
         </view>
         <view class="list_item">
            <view class="list_item_label">
@@ -44,8 +61,8 @@
            <view class="list_item_content">
               <input
                  type="number"
                  maxlength="11"
                  v-model="form1.phone1"
            maxlength="13"
            v-model="form1.phone"
                  :placeholder="'请输入联系人手机号'"
                  placeholder-style="color: #999999;"
               />
@@ -56,7 +73,13 @@
               <text>*</text>
               <text>来访单位</text>
            </view>
            <view class="list_item_content"><input type="text" v-model="form1.reason" placeholder="请输入来访单位的全称" placeholder-style="color: #999999;" /></view>
        <view class="list_item_content"
          ><input
            type="text"
            v-model="form1.companyName"
            placeholder="请输入来访单位的全称"
            placeholder-style="color: #999999;"
        /></view>
         </view>
         <view class="list_item">
            <view class="list_item_label">
@@ -64,7 +87,9 @@
               <text>入园车辆</text>
            </view>
            <view class="list_item_content" @click="openInput(1)">
               <text :style="{ color: form1.carNos ? '#000000' : '' }">{{ form1.carNos ? form1.carNos : '请输入车牌号码' }}</text>
          <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>
@@ -73,20 +98,40 @@
               <text>*</text>
               <text>随车人数</text>
            </view>
            <view class="list_item_content"><input type="text" v-model="form1.reason" placeholder="请输入随车人员总数" placeholder-style="color: #999999;" /></view>
        <view class="list_item_content"
          ><input
            type="number"
            v-model="form1.memberNum"
            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"><input type="text" v-model="form1.reason" placeholder="请输入来访事由" placeholder-style="color: #999999;" /></view>
        <view class="list_item_content"
          ><input
            type="text"
            v-model="form1.reason"
            placeholder="请输入来访事由"
            placeholder-style="color: #999999;"
        /></view>
         </view>
      </view>
      <view class="zw"></view>
      <view class="footer"><view class="footer_btn" @click="submit">提交</view></view>
    <view class="footer"
      ><view class="footer_btn" @click="submit">提交</view></view
    >
      <!-- 入场时间 -->
      <u-datetime-picker :show="show4" :minDate="new Date().getTime()" mode="datetime" @cancel="show4 = false" @confirm="setinDate"></u-datetime-picker>
    <u-datetime-picker
      :show="show4"
      :minDate="new Date().getTime()"
      mode="datetime"
      @cancel="show4 = false"
      @confirm="setinDate"
    ></u-datetime-picker>
      <!-- 离场时间 -->
      <u-datetime-picker
         v-if="form1.starttime"
@@ -98,28 +143,52 @@
         @confirm="setoutDate"
      ></u-datetime-picker>
      <!-- 车辆 -->
      <u-popup :show="show2" :round="10" :safeAreaInsetBottom="true" :closeable="true" mode="bottom" @close="show2 = false">
    <u-popup
      :show="show2"
      :round="10"
      :safeAreaInsetBottom="true"
      :closeable="true"
      mode="bottom"
      @close="show2 = false"
    >
         <view class="addcar">
            <view class="addcar_head">添加车辆</view>
            <view class="addcar_ipt"><input type="text" v-model="carName" placeholder="请输入车牌号" /></view>
        <view class="addcar_ipt"
          ><input type="text" v-model="carName" placeholder="请输入车牌号"
        /></view>
            <view class="addcar_footer">
               <view class="addcar_footer_item" @click="show2 = false">取消</view>
               <view class="addcar_footer_item t" @click="submitCart">提交</view>
            </view>
         </view>
      </u-popup>
      <u-picker keyName="name" :show="show6" :columns="columns1" @confirm="seleIdcard" @cancel="show6 = false"></u-picker>
    <u-picker
      keyName="name"
      :show="showName"
      closeOnClickOverlay
      :columns="memberList"
      @confirm="seleteName"
      @cancel="showName = false"
      @close="showName = 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>
    <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';
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'
import { createVisit, getVisitedMember } from '@/api'
export default {
   data() {
      return {
@@ -130,10 +199,10 @@
         show2: false,
         show4: false,
         show5: false,
         show6: false,
         show7: false,
      showName: false,
         fileList: [],
         columns1: [[{ name: '身份证', id: 0 }, { name: '港澳证件', id: 1 }, { name: '护照', id: 2 }]],
      memberList: [[{ name: '身份证', id: 0 }, { name: '港澳证件', id: 1 }, { name: '护照', id: 2 }]],
         columnsNames: [[{ name: '张三', id: 0 }, { name: '张三', id: 1 }, { name: '张三', id: 2 }]],
         columns: [],
         cars: [],
@@ -143,128 +212,128 @@
         personnel: [],
         userAnswerId: '',
         form1: {
            phone1: '',
            receptMemberId: '',
            receptMemberName: '',
            starttime: '',
            endtime: '',
            doors: '',
            doorSelectName: '',
            reason: '',
            carNos: ''
         },
         withUserList: {
            name: '',
            phone: '',
            idcardType: '',
            idcardTypeName: '',
            companyName: '',
            idcardNo: '',
            faceImg: '',
            faceImgUrl: '',
            imgurl: '',
            imgurlUrl: ''
         },
         visit: '',
         form: {},
         accessControl: '',
         verify: ''
      };
    }
   },
   components: { tlyPictureCut, keyboardInput, QfImageCropper },
   onLoad(options) {
      if (options.data) {
         this.form = JSON.parse(options.data);
      this.form = JSON.parse(options.data)
      }
    this.getUser()
    const userInfo = uni.getStorageSync('userInfo') || {}
    this.$set(this.form1, 'receptMemberName', userInfo.realname)
    this.$set(this.form1, 'receptMemberId', userInfo.id || '')
    this.$set(this.form1, 'receptCompanyName', userInfo.company.companyName || '')
      // this.getvisit()
      // this.getVisit1()
      // this.getUserValid()
   },
   methods: {
      openInput(type) {
         this.inputType = type;
         this.$refs.keyboard.open();
      this.inputType = type
      this.$refs.keyboard.open()
      },
      setPlate(e) {
         if (this.inputType === 1) {
            this.form1.carNos = e;
        this.form1.carNos = e
         } else if (this.inputType === 2) {
            this.withUserList.carNos = e;
        this.withUserList.carNos = e
         }
         this.$forceUpdate();
         this.closeInput();
      this.$forceUpdate()
      this.closeInput()
    },
    seleteName(e) {
      this.$set(this.form1, 'receptMemberName', e.value[0].name)
      this.$set(this.form1, 'receptMemberId', e.value[0].id)
      this.$set(this.form1, 'receptCompanyName', e.value[0].companyName)
      this.showName = false
    },
    getUser() {
      getVisitedMember().then(res => {
        this.memberList = [res.data || []]
      })
      },
      closeInput() {
         this.$refs.keyboard.close();
      },
      uploadImg(file) {
         this.$refs.cropper.close();
         uni.showLoading({ title: '上传中', mask: true });
         uni.uploadFile({
            url: `${this.$baseUrl}visitsAdmin/cloudService/web/public/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();
            }
         });
      this.$refs.keyboard.close()
      },
      submit() {
      const { form1 } = this
         if (!this.form1.receptMemberId)
            return uni.showToast({
               title: '请填写有效的访问人',
          title: '请选择有效的被访人',
               icon: 'none'
            });
        })
         if (!this.form1.starttime)
            return uni.showToast({
               title: '入场时间不能为空',
               icon: 'none'
            });
        })
         if (!this.form1.endtime)
            return uni.showToast({
               title: '离场时间不能为空',
               icon: 'none'
            });
         if (!this.form1.doorSelectName && this.accessControl == 1)
            return uni.showToast({
               title: '访问门禁不能为空',
        })
      if (!this.form1.name) return uni.showToast({
        title: '联系人不能为空',
               icon: 'none'
            });
         if (!this.form1.reason)
            return uni.showToast({
      })
      if (!this.form1.phone) return uni.showToast({
        title: '手机号不能为空',
        icon: 'none'
      })
      if (!this.form1.companyName) return uni.showToast({
        title: '来访单位不能为空',
        icon: 'none'
      })
      if (!this.form1.carNos) return uni.showToast({
        title: '入园车辆不能为空',
        icon: 'none'
      })
      if (!this.form1.memberNum) return uni.showToast({
        title: '随车人数不能为空',
        icon: 'none'
      })
      if (!this.form1.reason) return uni.showToast({
               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,
      let data = JSON.parse(JSON.stringify(this.form1))
      data.starttime = data.starttime + ':00'
      data.endtime = data.endtime + ':00'
      createVisit({
               ...data,
               openid: this.$store.state.openId,
               withUserList: this.personnel
        type: '2',
        openid: this.$store.state.openId
            })
            .then(res => {
               if (res.code === 200) {
            setTimeout(() => {
              uni.showToast({
                title: '提交成功',
                icon: 'success'
              })
            })
                  uni.reLaunch({
                     url: `/pages/appointmentDetails/appointmentDetails?id=${res.data}`
                  });
              url: `/pages/staff/index`
            })
               }
            });
        })
      },
      deleUser(i) {
         this.personnel.splice(i, 1);
      this.personnel.splice(i, 1)
      },
      getVisit1() {
         // 是否需要答题
@@ -275,9 +344,9 @@
            })
            .then(res => {
               if (res.code === 200) {
                  this.visit = res.data.code;
            this.visit = res.data.code
               }
            });
        })
         // 起始时间时长
         this.$u.api
            .getSystemDictData({
@@ -286,132 +355,54 @@
            })
            .then(res => {
               if (res.code === 200) {
                  this.day = Number(res.data.code);
            this.day = Number(res.data.code)
                  // console.log(nextDay('after', true, this.day))
               }
            });
      },
      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({
                     url: `${this.$baseUrl}visitsAdmin/cloudService/web/public/uploadFtp.do`,
                     filePath: chooseImageRes.tempFilePaths[i],
                     name: 'file',
                     formData: {
                        folderCode: 'MEMBER_IMG'
                     },
                     success: uploadFileRes => {
                        let res = JSON.parse(uploadFileRes.data);
                        if (type === 'faceImg') {
                           this.withUserList.faceImg = res.data.halfPath;
                           this.withUserList.faceImgUrl = res.data.prefixPath + res.data.folder + res.data.halfPath;
                        } else {
                           this.withUserList.imgurl = res.data.halfPath;
                           this.withUserList.imgurlUrl = res.data.prefixPath + res.data.folder + res.data.halfPath;
                        }
                     },
                     complete() {
                        if (i === chooseImageRes.tempFilePaths.length - 1) {
                           uni.hideLoading();
                        }
                     }
                  });
               }
            }
         });
      },
      seleIdcard(e) {
         this.withUserList.idcardType = e.value[0].id;
         this.withUserList.idcardTypeName = e.value[0].name;
         this.show6 = false;
        })
      },
      submitCart() {
         if (!this.carName)
            return uni.showToast({
               title: '请输入车牌号码',
               icon: 'none'
            });
         this.cars.push(this.carName);
         this.form1.carNos = this.cars.join(',');
         this.carName = '';
         this.show2 = false;
        })
      this.cars.push(this.carName)
      this.form1.carNos = this.cars.join(',')
      this.carName = ''
      this.show2 = false
      },
      deleCars(i) {
         this.cars.splice(i, 1);
         this.form1.carNos = this.cars.join(',');
      this.cars.splice(i, 1)
      this.form1.carNos = this.cars.join(',')
      },
      seleMJ(i) {
         this.columns.forEach((item, index) => {
            if (index === i) {
               item.active = !item.active;
          item.active = !item.active
            }
         });
      })
      },
      openLC() {
         if (!this.form1.starttime)
            return uni.showToast({
               title: '请先选择入厂时间',
               icon: 'none'
            });
         this.show5 = true;
        })
      this.show5 = true
      },
      setinDate(e) {
         this.form1.starttime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
      this.form1.starttime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
         // this.maxTime = getDaysAfterDate(uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM'), this.day)
         this.maxTime = this.form1.starttime.slice(0, 11) + '23:59'
         this.form1.endtime = ''
         this.show4 = false;
      this.show4 = false
      },
      setoutDate(e) {
         this.form1.endtime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
         this.show5 = false;
      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() {
         if (this.verify === '0') {
            if (this.form1.phone1) {
               this.$u.api
                  .getVisitedMember({
                     mobile: this.form1.phone1
                  })
                  .then(res => {
                     if (res.code === 200) {
                        this.form1.receptMemberId = res.data.id;
                        this.form1.receptMemberName = res.data.name;
                     }
                  });
            }
         } else {
            if (this.form1.phone1 && this.form1.receptMemberName) {
               this.$u.api
                  .getVisitedMember({
                     mobile: this.form1.phone1,
                     name: this.form1.receptMemberName
                  })
                  .then(res => {
                     if (res.code === 200) {
                        this.form1.receptMemberId = res.data.id;
                        this.form1.receptMemberName = res.data.name;
                     }
                  });
            }
         }
      return Date.parse(new Date(`${date}`)) || Date.parse(new Date(`${date.replace(/-/g, '/')}`))
      },
      // 被拜访人信息校验方式(0手机号单独校验 1手机号和姓名组合校验)
      getUserValid() {
@@ -422,9 +413,9 @@
            })
            .then(res => {
               if (res.code === 200) {
                  this.verify = res.data.code;
            this.verify = res.data.code
               }
            });
        })
      },
      // 获取是否需要选择门禁/门禁列表
      getvisit() {
@@ -435,21 +426,21 @@
            })
            .then(res => {
               if (res.code === 200) {
                  this.accessControl = res.data.code;
            this.accessControl = res.data.code
                  if (res.data.code === '1') {
                     this.$u.api.deviceRoleList({ type: 1 }).then(device => {
                        if (device.code === 200) {
                           if (device.data.length > 0) {
                              device.data.forEach(item => {
                                 item.active = false;
                              });
                              this.columns = device.data;
                      item.active = false
                    })
                    this.columns = device.data
                           }
                        }
                     });
              })
                  }
               }
            });
        })
      }
   }
};