You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1324 lines
38 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<page-meta :page-style="'overflow:'+(adminListShow||configshow||areaShow?'hidden':'visible')"></page-meta>
<view class="containers">
<!-- VIP先核验名单内姓名+手机号 -->
<view v-if="form.type==4 && !vipGatePassed" class="vip-gate-wrap">
<view class="formtext">VIP 访客身份核验</view>
<view class="vip-gate-tip">请填写与后台 VIP 客户名单中一致的姓名与手机号</view>
<uni-forms labelWidth="100px">
<uni-forms-item label="姓名" required>
<uni-easyinput v-model="vipGateForm.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="联系电话" required>
<uni-easyinput v-model="vipGateForm.mobile" placeholder="请输入手机号" type="number" maxlength="11" />
</uni-forms-item>
</uni-forms>
<button type="primary" style="background-color: #044ed7; margin-top: 24rpx;" @click="submitVipGate">验证并继续</button>
</view>
<block v-else>
<!-- 拜访须知 -->
<u-popup :show="configshow" :mask-close-able="false" class="configwrap" mode="bottom">
<view class="configtitle">
{{configInfo.name}}
</view>
<view class="configvalue">
<view v-html="configInfo.value">
</view>
<view style="text-align: center;">
<view class="configbtn" @click="closeConfig">
确认
</view>
</view>
</view>
</u-popup>
<!-- 普通访客 先选择区域 -->
<u-popup :show="areaShow" class="configwrap" mode="bottom">
<view class="configtitle">
前往区域
</view>
<block v-if="visitArea.length>0">
<view class="configvalue areavalue">
<uni-data-checkbox mode="button" @change='changeVisitArea' v-model="form.visit_area_id"
:localdata="visitArea" :map="{text:'name',value:'id'}" />
</view>
<button class="areabtn" @click="closeArea" size="large" type="primary">确认</button>
</block>
<view class="configvalue configload" v-else>
<text>数据加载中...</text>
<u-icon @click="getVisitArea" name="reload" color="#2979ff" size="28"></u-icon>
</view>
</u-popup>
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
<uni-forms ref="formdata" :model="form" :rules="rules" labelWidth="100px">
<view class="formtext">拜访信息</view>
<uni-forms-item label="到访日期" required name="date">
<uni-datetime-picker type="date" :start="toadyStart" return-type="string" v-model="form.date" />
</uni-forms-item>
<uni-forms-item label="到访时段" required name="visit_time_id">
<uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime"
:map="{text:'visitTimeRange',value:'id'}" />
</uni-forms-item>
<uni-forms-item label="前往区域" required name="visit_area_id">
<uni-data-checkbox @change='changeVisitArea' v-model="form.visit_area_id" :localdata="visitArea"
:map="{text:'name',value:'id'}" />
</uni-forms-item>
<uni-forms-item label="到访事由" v-if="form.type==1||form.type==4">
<uni-data-select v-model="form.reason" :localdata="reasonList">
</uni-data-select>
</uni-forms-item>
<uni-forms-item label="施工开始时段" v-if="form.type==2">
<uni-datetime-picker type="date" :start="toadyStart" return-type="string"
v-model="form.work_start_time" />
</uni-forms-item>
<uni-forms-item label="施工结束时段" v-if="form.type==2">
<uni-datetime-picker type="date" :start="toadyStart" return-type="string"
v-model="form.work_end_time" />
</uni-forms-item>
<!-- <uni-forms-item label="车牌号" v-if="form.type==3"> -->
<uni-forms-item label="车辆类型" required name="plate" v-if="form.type==3">
<uni-data-checkbox v-model="form.plate" :localdata="parkAreaList" :map="{text:'value',value:'value'}" />
</uni-forms-item>
<uni-forms-item label="备注">
<uni-easyinput type="textarea" v-model="form.remark" placeholder="请输入自我备注" />
</uni-forms-item>
<view class="formtext formtext-flex">
<text>拜访人信息</text>
<button v-if="form.type!=4" class="history-btn" type="primary" size="mini" @click="fillLatestVisitorInfo">拉取过往信息</button>
</view>
<uni-forms-item label="姓名" required name="name">
<uni-easyinput v-model="form.name" placeholder="请输入姓名" :disabled="form.type==4 && vipGatePassed" />
</uni-forms-item>
<uni-forms-item label="联系电话" required name="mobile">
<uni-easyinput v-model="form.mobile" placeholder="请输入联系电话" :disabled="form.type==4 && vipGatePassed" />
</uni-forms-item>
<uni-forms-item label="证件类型" required name="credent">
<uni-data-select v-model="form.credent" :localdata="credentList">
</uni-data-select>
</uni-forms-item>
<uni-forms-item label="证件号码" required name="idcard" v-if="form.credent==1">
<uni-easyinput type="idcard" v-model="form.idcard" placeholder="请输入证件号码" />
</uni-forms-item>
<uni-forms-item label="护照号码" required name="passcard" v-if="form.credent==2">
<uni-easyinput type="text" v-model="form.passcard" placeholder="请输入证件号码" />
</uni-forms-item>
<uni-forms-item label="单位名称" required name="company_name">
<uni-easyinput v-model="form.company_name" placeholder="请输入单位名称" />
</uni-forms-item>
<uni-forms-item label="CDA编号" required name="cda" v-if="(form.type==1||form.type==4)&&visitAreaText=='生产区'">
<uni-easyinput type='textarea' v-model="form.cda" placeholder="请输入CDA编号(如无注明原因)" />
</uni-forms-item>
<uni-forms-item label="到访车辆" v-if="form.type!=3">
<view style="text-align: right;">
<button style="background-color: #044ed7;" type="primary" size="mini"
@click="form.cars.push('')">新增车辆</button>
</view>
<view v-for='(item,index) in form.cars' class="justify-between align-center"
style="margin-bottom:20rpx">
<uni-easyinput disabled @tap="plateShow=true,carindex=index" v-model.trim="form.cars[index]"
placeholder="请输入到访车辆" />
<text @click="form.cars.splice(index,1)" style="color: red;margin-left:20rpx">删除</text>
</view>
<plate-input v-if="plateShow" :plate="form.cars[carindex]" @export="setCars"
@close="plateShow = false" />
</uni-forms-item>
<uni-forms-item label="到访车辆" required name="cars" v-else>
<view style="text-align: right;">
<button style="background-color: #044ed7;" type="primary" size="mini"
@click="form.cars.push('')">新增车辆</button>
</view>
<view v-for='(item,index) in form.cars' class="justify-between align-center"
style="margin-bottom:20rpx">
<uni-easyinput disabled @tap="plateShow=true,carindex=index" v-model.trim="form.cars[index]"
placeholder="请输入到访车辆" />
<text @click="form.cars.splice(index,1)" style="color: red;margin-left:20rpx">删除</text>
</view>
<plate-input v-if="plateShow" :plate="form.cars[carindex]" @export="setCars"
@close="plateShow = false" />
</uni-forms-item>
<template v-if="form.type!=3">
<view class="formtext" style="display: flex;justify-content: space-between;">
<text>随访人员</text>
<button style="background-color: #044ed7;" type="primary" size="mini"
@click="$refs.showRight.open(),follw_people_obj={credent:1},follow_people_index=-1">新增随访人员</button>
</view>
<!-- 随访人员表格 -->
<template>
<uni-table ref="table" border emptyText="暂无更多数据">
<uni-tr>
<uni-th width="160" align="center">操作</uni-th>
<uni-th width="120" align="center">姓名</uni-th>
<uni-th width="120" align="left">联系电话</uni-th>
<uni-th width="120" align="center">证件类型</uni-th>
<uni-th width="120" align="left">证件号码</uni-th>
</uni-tr>
<uni-tr style="vertical-align: middle;" v-for="(item, index) in form.follw_people" :key="index">
<uni-td>
<view class="uni-group">
<text @click="editFollwPeople(index)"
style="color: #044ed7;margin-right:8px">修改</text>
<text @click="form.follw_people.splice(index,1)"
style="color: red;margin-right:8px">删除</text>
</view>
</uni-td>
<uni-td>{{ item.name }}</uni-td>
<uni-td>
<view class="name">{{ item.mobile }}</view>
</uni-td>
<uni-td align="center">{{ item.credent==1?'身份证':"护照" }}</uni-td>
<uni-td align="center">{{ item.idcard }}</uni-td>
</uni-tr>
</uni-table>
</template>
</template>
<!-- <uni-forms-item label="长访客申请">
<uni-data-checkbox v-model="form.long_time" :localdata="longList" :map="{text:'value',value:'id'}" />
</uni-forms-item>
<template v-if="form.long_time==1">
<uni-forms-item label="开始日期">
<uni-datetime-picker type="date" :start="toadyStart" return-type="string"
v-model="form.start_date" />
</uni-forms-item>
<uni-forms-item label="结束日期">
<uni-datetime-picker type="date" :start="toadyStart" return-type="string" v-model="form.end_date" />
</uni-forms-item>
</template> -->
<view class="formtext" v-if="form.type==1||form.type==2||form.type==4">被访人信息</view>
<uni-forms-item label="被访人" required name="acceptName" v-if="form.type==1||form.type==2||form.type==4">
<uni-easyinput @clear="clearAccept('accept')" disabled v-model="form.acceptName"
@tap="adminListShowOpen('accept')" placeholder="请选择联系人员" />
</uni-forms-item>
<view class="formtext" v-if="form.type==3">收货人信息</view>
<uni-forms-item label="收货人" v-if="form.type==3" required name="goodsName">
<uni-easyinput @clear="clearAccept('goods')" disabled v-model="form.goodsName"
@tap="adminListShowOpen('goods')" placeholder="请选择联系人员" />
</uni-forms-item>
<view class="formtext" v-if="visitAreaText=='生产区'">陪同人信息</view>
<uni-forms-item label="陪同人" required name="accompanyName" v-if="visitAreaText=='生产区'">
<uni-easyinput @clear="clearAccept('accompany')" disabled v-model="form.accompanyName"
@tap="adminListShowOpen('accompany')" placeholder="请选择联系人员" />
</uni-forms-item>
<qianziyu-select :show="adminListShow" type="radio" :popupTitle="'联系人员'" name="cworkStationName"
:dataLists="adminList" placeholder="输入陪同人具体姓名或手机号搜索" @search="selectSearch" @submit="submitAccept"
@cancel="cancelAccept" />
</uni-forms>
<button type="primary" style="background-color: #044ed7;" @click="getStudy">{{goStudy}}</button>
<!-- 随访人员弹出 -->
<uni-drawer ref="showRight" mode="right" :mask-click="true">
<uni-forms ref="peopleform" :model="follw_people_obj" :rules="peoplerules" labelWidth="80px">
<uni-forms-item label="姓名" required name='name'>
<uni-easyinput v-model="follw_people_obj.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="联系电话" required name='mobile'>
<uni-easyinput v-model="follw_people_obj.mobile" placeholder="请输入联系电话" />
</uni-forms-item>
<uni-forms-item label="证件类型" required name='credent'>
<uni-data-select @change="chooseCredent" v-model="follw_people_obj.credent"
:localdata="credentList">
</uni-data-select>
</uni-forms-item>
<uni-forms-item label="证件号码" required name='idcard' v-if="follw_people_obj.credent==1">
<uni-easyinput type="idcard" v-model="follw_people_obj.idcard" placeholder="请输入证件号码" />
</uni-forms-item>
<uni-forms-item label="护照号码" required name='passcard' v-if="follw_people_obj.credent==2">
<uni-easyinput type="text" v-model="follw_people_obj.passcard" placeholder="请输入证件号码" />
</uni-forms-item>
</uni-forms>
<view class="uni-group" style="text-align: right;">
<button @click="closeDrawer" size="mini">取消</button>
<button @click="pushFollowPeople" size="mini" type="primary"
style="background-color: #044ed7;margin-left:8px">确认</button>
</view>
</uni-drawer>
</block>
</view>
</template>
<script>
import plateInput from '@/uni_modules/uni-plate-input/uni-plate-input.vue'
import qianziyuSelect from '@/components/qianziyu-select/qianziyu-select.vue'
export default {
components: {
plateInput,
qianziyuSelect
},
data() {
return {
steps: [{
title: '填报'
}, {
title: '学习'
}, {
title: '完成'
}],
stepActive: 0,
configshow: false,
areaShow: false,
configInfo: {},
configKey: "ptfk",
toadyStart: '',
carindex: 0,
plateShow: false,
adminListShow: false,
adminKeyword: '',
acceptType: "",
acceptName: "",
goodsName: '',
visitAreaText: '',
form: {
type: 1,
date: "",
visit_time_id: "",
visit_area_id: "",
reason: "",
plate: "",
remark: "",
name: "",
mobile: "",
credent: 1,
idcard: "",
passcard: "",
company_name: "",
cars: [],
follw_people: [],
long_time: 0,
start_date: "",
end_date: "",
accompany_id: '',
accpet_department_id: "",
accept_admin_id: "",
accept_goods_admin_id: "",
acceptName: "",
goodsName: '',
accompanyName: ''
},
follw_people_obj: {
name: "",
mobile: "",
credent: 1,
idcard: "",
},
follow_people_index: -1,
rules: {
date: {
rules: [{
required: true,
errorMessage: '请选择到访日期'
}]
},
visit_time_id: {
rules: [{
required: true,
errorMessage: '请选择拜访时段'
}]
},
visit_area_id: {
rules: [{
required: true,
errorMessage: '请选择前往区域'
}]
},
plate: {
rules: [{
required: true,
errorMessage: '请选择车辆类型'
}]
},
name: {
rules: [{
required: true,
errorMessage: '姓名不能为空'
}]
},
mobile: {
rules: [{
required: true,
errorMessage: '联系电话不能为空'
}, {
pattern: '^[1][3-9][\\d]{9}',
errorMessage: '联系号码格式错误'
}]
},
credent: {
rules: [{
required: true,
errorMessage: '请选择身份证类型'
}]
},
idcard: {
rules: [{
required: true,
errorMessage: '身份证号码不能为空'
}, {
pattern: '^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]',
errorMessage: '身份证格式错误'
}]
},
passcard: {
rules: [{
required: true,
errorMessage: '护照号码不能为空'
}, {
pattern: '/^([a-zA-z]|[0-9]){5,17}$/',
errorMessage: '护照格式错误'
}]
},
company_name: {
rules: [{
required: true,
errorMessage: '单位名称不能为空'
}]
},
cda: {
rules: [{
required: true,
errorMessage: 'CDA编号不能为空'
}]
},
cars: {
rules: [{
required: true,
errorMessage: '车牌号不能为空'
}]
},
acceptName: {
rules: [{
required: true,
errorMessage: '请选择被访人'
}]
},
accompanyName: {
rules: [{
required: true,
errorMessage: '请选择陪同人'
}]
},
goodsName: {
rules: [{
required: true,
errorMessage: '请选择收货人'
}]
}
},
peoplerules: {
name: {
rules: [{
required: true,
errorMessage: '随访人姓名不能为空'
}]
},
mobile: {
rules: [{
required: true,
errorMessage: '联系电话不能为空'
}, {
pattern: '^[1][3-9][\\d]{9}',
errorMessage: '联系号码格式错误'
}]
},
credent: {
rules: [{
required: true,
errorMessage: '请选择身份证类型'
}]
},
idcard: {
rules: [{
required: true,
errorMessage: '身份证号码不能为空'
}, {
pattern: '^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]',
errorMessage: '身份证格式错误'
}]
},
passcard: {
rules: [{
required: true,
errorMessage: '护照号码不能为空'
}, {
pattern: '/^([a-zA-z]|[0-9]){5,17}$/',
errorMessage: '护照格式错误'
}]
}
},
// 单选数据源
visitTime: [],
visitArea: [],
reasonList: [],
parkAreaList: [],
credentList: [{
value: 1,
text: "身份证"
},
{
value: 2,
text: "护照"
}
],
longList: [{
id: 0,
value: '否'
}, {
id: 1,
value: '是'
}],
adminList: [],
isCall: '', // 是否待邀约
goStudy: '提交',
isStudy: false,
vipGatePassed: true,
vipGateForm: {
name: '',
mobile: ''
}
}
},
onLoad(options) {
// uni.navigateTo({
// url:'/pages/visit/testStudy?type=3'
// })
// return
const now = new Date()
this.toadyStart =
now.getFullYear() +
'-' +
String(now.getMonth() + 1).padStart(2, '0') +
'-' +
String(now.getDate()).padStart(2, '0')
const visitType = parseInt(options.type || 1)
this.form.type = visitType
if (parseInt(visitType, 10) === 4) {
this.vipGatePassed = false
this.areaShow = false
} else {
// 普通 / 施工 / 物流:先选前往区域(列表来自接口)
this.areaShow = (visitType === 1 || visitType === 2 || visitType === 3)
}
// 须知 key 在确认区域后按访客身份与区域计算,此处仅占位
this.configKey =
visitType == 4 ? 'vipxz' :
visitType == 1 ? 'ptfk' :
visitType == 2 ? 'sgfk' : 'wlcl'
this.isCall = options.iscall ? options.iscall : ''
// this.goStudy = this.isCall == 'call' ? '提交' : ''
this.form.audit_status = this.isCall == 'call' ? 1 : 0
if (visitType !== 4) {
this.showStudy()
}
this.init()
if (uni.getStorageSync('formdata')) {
this.form = uni.getStorageSync('formdata')
}
if (parseInt(this.form.type, 10) === 4) {
this.vipGatePassed = false
this.areaShow = false
this.vipGateForm.name = (this.form.name || '').trim()
this.vipGateForm.mobile = (this.form.mobile || '').trim()
}
// 还原表单后按当前访客类型刷新区域列表
this.getVisitArea()
// this.getAdminList()
},
onShareAppMessage() {
return {
title: 'BD访客系统',
path: '/pages/index/index',
// imageUrl: this.logoIndex
}
},
onShareTimeline() {
return {
title: 'BD访客系统',
path: '/pages/index/index',
// imageUrl: this.logoIndex
}
},
onReady() {},
methods: {
init() {
this.getVisitTime()
this.getReason()
this.getPark()
},
adminListShowOpen(type) {
this.acceptType = type
this.adminKeyword = ""
// this.getAdminList()
this.adminListShow = true
},
cancelAccept() {
console.log('123')
this.adminKeyword = ""
this.adminList = []
this.adminListShow = false
},
selectSearch(e) {
this.adminKeyword = e
this.getAdminList()
},
clearAccept(type) {
if (type == 'accept') {
this.form.accept_admin_id = ''
this.form.acceptName = ''
} else if (type == 'goods') {
this.form.accept_goods_admin_id = ''
this.form.goodsName = ''
} else {
this.form.accompany_id = ''
this.form.accompanyName = ''
}
},
fillLatestVisitorInfo() {
const mobile = (this.form.mobile || '').trim()
const idcard = this.form.credent == 2 ? (this.form.passcard || '').trim() : (this.form.idcard || '').trim()
if (!mobile && !idcard) {
this.util.alert('请先填写手机号或证件号,再拉取过往信息')
return
}
let that = this
this.util.request({
api: '/api/mobile/visit/latest-visitor',
method: 'GET',
data: {
mobile: mobile,
idcard: idcard
},
utilSuccess: function(res) {
that.form.name = res.name || that.form.name
that.form.mobile = res.mobile || that.form.mobile
that.form.credent = res.credent || that.form.credent
if (parseInt(that.form.credent) === 2) {
that.form.passcard = res.idcard || that.form.passcard
that.form.idcard = res.idcard || that.form.idcard
} else {
that.form.idcard = res.idcard || that.form.idcard
}
that.form.company_name = res.company_name || that.form.company_name
that.form.cda = res.cda || that.form.cda
if (Array.isArray(res.cars)) {
that.form.cars = res.cars
}
uni.showToast({
title: '已回填最近一条信息',
icon: 'none',
duration: 1500
})
},
utilFail: function(errMsg) {
uni.showToast({
title: errMsg || '未获取到历史数据',
icon: 'none',
duration: 2000
})
}
})
},
submitAccept(e) {
console.log(e)
this.form.accompany_id = e.id
this.form.accompanyName = e.name
if (this.acceptType == 'accept') {
this.form.accept_admin_id = e.id
this.form.accpet_department_id = e.department_id
this.form.acceptName = e.name
// if (this.visitAreaText == '非生产区'||this.visitAreaText == '研发R&D') {
// this.form.accompany_id = e.id
// this.form.accompanyName = e.name
// }
} else if (this.acceptType == 'goods') {
this.form.accept_goods_admin_id = e.id
this.form.accept_admin_id = e.id
this.form.accpet_department_id = e.department_id
this.form.goodsName = e.name
// if (this.visitAreaText == '非生产区'||this.visitAreaText == '研发R&D') {
// this.form.accompany_id = e.id
// this.form.accompanyName = e.name
// }
} else {
this.form.accompany_id = e.id
this.form.accompanyName = e.name
}
this.adminListShow = false
},
setCars(e) {
this.form.cars[this.carindex] = e
this.plateShow = false
console.log(e, this.carindex)
},
closeConfig() {
this.configshow = false
},
submitVipGate() {
const name = (this.vipGateForm.name || '').trim()
const mobile = (this.vipGateForm.mobile || '').trim()
if (!name) {
uni.showToast({
title: '请输入姓名',
icon: 'none'
})
return
}
if (!mobile || !/^[1][3-9][\d]{9}$/.test(mobile)) {
uni.showToast({
title: '请输入正确手机号',
icon: 'none'
})
return
}
const that = this
this.util.request({
api: '/api/mobile/user/is-vip',
method: 'GET',
data: {
mobile,
name
},
customLoading: true,
utilSuccess: function(res) {
if (parseInt(res?.is_vip || 0) !== 1) {
uni.showModal({
title: '提示',
content: '您当前还不在vip客户名单中可先联系管理员录入',
showCancel: false,
success: function() {
uni.reLaunch({
url: '/pages/index/index'
})
}
})
return
}
that.vipGatePassed = true
that.form.name = name
that.form.mobile = mobile
that.areaShow = true
that.getVisitArea()
that.showStudy()
},
utilFail: function(err) {
uni.showToast({
title: err || '验证失败',
icon: 'none'
})
}
})
},
closeArea() {
if (!this.form.visit_area_id) {
this.util.alert("请先选择前往区域")
return
}
// VIP须知固定 vipxz
if (Number(this.form.type) === 4) {
this.configKey = 'vipxz'
this.getConfig()
this.areaShow = false
return
}
// 施工 / 物流:须知按访客身份对应后台配置 key
if (Number(this.form.type) === 2) {
this.configKey = 'sgfk'
this.getConfig()
this.areaShow = false
return
}
if (Number(this.form.type) === 3) {
this.configKey = 'wlcl'
this.getConfig()
this.areaShow = false
return
}
// 普通访客:须知按前往区域切换
if (this.visitAreaText == "生产区") {
this.configKey = 'cjfk'
this.getConfig()
this.areaShow = false
} else if (this.visitAreaText == "研发R&D") {
this.configKey = 'yffk'
this.getConfig()
this.areaShow = false
} else {
this.configKey = 'ptfk'
this.getConfig()
this.areaShow = false
}
},
async getConfig() {
let that = this
// util.request()
this.util.request({
api: '/api/mobile/user/config',
data: {
page: 1,
page_size: 99
},
// requestType: 'bd',
utilSuccess: function(res) {
console.log(res)
let data = Array.isArray(res) ? res : []
let found = null
for (let k of data) {
if (k.key == that.configKey) {
found = k
break
}
}
if (found) {
that.configInfo = {
name: found.name != null && found.name !== '' ? found.name : '访客须知',
value: found.value != null ? found.value : ''
}
} else {
that.configInfo = {
name: '访客须知',
value: '<p style="color:#999;"> key <strong>' + that.configKey +
'</strong> 的须知内容请在后台配置管理中新增后再试</p>'
}
}
that.configshow = true
},
utilFail: function(res) {}
})
},
// 获取单选数据
getVisitArea() {
const that = this
const visitType = parseInt(this.form.type, 10) || 1
this.util.request({
api: '/api/mobile/visit/visit-area',
data: {
type: visitType
},
utilSuccess: function(res) {
that.visitArea = Array.isArray(res) ? res : []
if (that.form.visit_area_id) {
const row = that.visitArea.find(a => String(a.id) === String(that.form.visit_area_id))
if (row) {
that.visitAreaText = row.name
}
}
if (that.visitArea.length === 0) {
uni.showToast({
title: '暂无可选前往区域',
icon: 'none'
})
}
},
utilFail: function() {
that.visitArea = []
}
})
},
changeVisitArea(e) {
console.log(e)
this.visitAreaText = e.detail.data.name
},
getVisitTime() {
let that = this
// util.request()
this.util.request({
api: '/api/mobile/visit/visit-time',
data: {},
utilSuccess: function(res) {
for (var m of res) {
m.visitTimeRange = m.start_time + "-" + m.end_time
}
console.log(res)
that.visitTime = res
},
utilFail: function(res) {}
})
},
getReason() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/parameter/show',
data: {
number: 'reasonList'
},
utilSuccess: function(res) {
let arr = []
console.log(res)
for (var m of res.detail) {
arr.push({
text: m.value,
value: m.value
})
}
that.reasonList = arr
},
utilFail: function(res) {}
})
},
getPark() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/parameter/show',
data: {
number: 'parkArea'
},
utilSuccess: function(res) {
that.parkAreaList = res.detail
},
utilFail: function(res) {}
})
},
async getAdminList() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/other/admin-user-list',
data: {
page_size: 99,
page: 1,
keyword: this.adminKeyword
},
utilSuccess: function(res) {
that.adminList = res.data
},
utilFail: function(res) {}
})
},
//
chooseCredent(e) {
console.log(e)
},
// 随访人员弹出
editFollwPeople(index) {
this.follow_people_index = index
this.follw_people_obj = this.form.follw_people[index]
this.$refs.showRight.open()
},
closeDrawer() {
this.follw_people_obj = {}
this.follow_people_index = -1
this.$refs.showRight.close()
},
pushFollowPeople() {
console.log('this.follw_people_obj', this.follw_people_obj)
if (this.follw_people_obj.credent == 2) {
this.follw_people_obj.idcard = this.follw_people_obj.passcard
}
this.$refs['peopleform'].validate().then(res => {
if (this.follow_people_index > -1) {
this.form.follw_people[this.follow_people_index] = this.follw_people_obj
} else {
this.form.follw_people.push(this.follw_people_obj)
}
this.follow_people_index = -1
this.$refs.showRight.close()
}).catch(err => {
console.log('err', err);
})
},
// 去学习
// 获取访客学习状态
async showStudy() {
this.util.alert("请确保每位访客都已通过学习培训,方可提交拜访")
// let that = this
// let id_arr = []
// id_arr.push(this.form.idcard)
// for(var k of this.form.follw_people){
// id_arr.push(k.idcard)
// }
// this.util.request({
// api: '/api/mobile/visit/ask-log',
// method: "post",
// data:{
// type:that.form.type
// },
// utilSuccess: function(res) {
// console.log("res",res)
// if(res.msg=='学习有效中'){
// uni.showToast({
// title: '请确保随访人员都已通过学习培训方可提交拜访',
// duration: 2000,
// icon: 'none'
// })
// that.isStudy = true
// that.goStudy = '提交'
// }
// },
// utilFail: function(res) {
// // console.log(res)
// // uni.showToast({
// // title: res,
// // duration: 2000,
// // icon: 'none'
// // })
// }
// })
},
// 获取随访人员的 学习记录
async getStudy() {
let that = this
let id_arr = []
id_arr.push(this.form.idcard)
for (var k of this.form.follw_people) {
id_arr.push(k.idcard)
}
this.$refs['formdata'].validate().then(res => {
// 录入后先按手机号匹配 VIP供学习流程判断「仅观看/需答题」
this.checkVipByMobile(this.form.mobile).then(vipRes => {
const isVip = parseInt(vipRes?.is_vip || 0) === 1 ? 1 : 0
uni.setStorageSync('studydata', {
type: this.form.type,
name: this.form.name,
mobile: this.form.mobile,
idcard: this.form.credent == 2 ? this.form.passcard : this.form.idcard,
is_vip: isVip
})
}).catch(() => {
uni.setStorageSync('studydata', {
type: this.form.type,
name: this.form.name,
mobile: this.form.mobile,
idcard: this.form.credent == 2 ? this.form.passcard : this.form.idcard
})
})
this.util.request({
api: '/api/mobile/visit/idcard-check',
method: "post",
data: {
idcard: id_arr,
type: that.form.type
},
utilSuccess: function(res) {
const missing = Array.isArray(res?.missing) ? res.missing : []
const expired = Array.isArray(res?.expired) ? res.expired : []
const invalidLegacy = Array.isArray(res?.invalid) ? res.invalid : (Array.isArray(res) ? res : [])
const hasInvalid = missing.length > 0 || expired.length > 0 || invalidLegacy.length > 0
if (hasInvalid) {
let messageArr = []
if (missing.length > 0) {
messageArr.push(`未学习:${missing.join("")}`)
}
if (expired.length > 0) {
messageArr.push(`已过期:${expired.join("")}`)
}
if (messageArr.length === 0 && invalidLegacy.length > 0) {
messageArr.push(`异常:${invalidLegacy.join("")}`)
}
let str = messageArr.join("") + '请先完成当前访客类型的学习流程'
that.util.alert(str)
uni.setStorageSync('formdata', that.form)
} else {
// 邀约
if (that.isCall === 'call') {
that.submitForm()
} else {
// 访客
that.submitNoStudy()
}
}
},
utilFail: function(res) {
// console.log(res)
uni.showToast({
title: res,
duration: 2000,
icon: 'none'
})
}
})
}).catch(err => {
console.log('err', err);
})
},
saveFormgoStudy() {
if (this.form.credent == 2) {
this.form.idcard = this.form.passcard
}
this.$refs['formdata'].validate().then(res => {
console.log("form", this.form)
// return
if (this.isCall === 'call') {
this.submitForm()
return
}
if (this.isStudy) {
this.submitNoStudy()
} else {
uni.setStorageSync('formdata', this.form)
this.checkVipByMobile(this.form.mobile).then(vipRes => {
const isVip = parseInt(vipRes?.is_vip || 0) === 1 ? 1 : 0
uni.setStorageSync('studydata', {
type: this.form.type,
name: this.form.name,
mobile: this.form.mobile,
idcard: this.form.credent == 2 ? this.form.passcard : this.form.idcard,
is_vip: isVip
})
uni.redirectTo({
url: '/pages/visit/study?type=' + this.form.type
})
}).catch(() => {
uni.setStorageSync('studydata', {
type: this.form.type,
name: this.form.name,
mobile: this.form.mobile,
idcard: this.form.credent == 2 ? this.form.passcard : this.form.idcard
})
uni.redirectTo({
url: '/pages/visit/study?type=' + this.form.type
})
})
}
}).catch(err => {
console.log('err', err);
})
},
checkVipByMobile(mobile) {
const that = this
return new Promise((resolve, reject) => {
if (!mobile) {
resolve({
is_vip: 0
})
return
}
const data = {
mobile: mobile
}
if (parseInt(this.form.type, 10) === 4) {
const n = (this.form.name || '').trim()
if (n) {
data.name = n
}
}
that.util.request({
api: '/api/mobile/user/is-vip',
method: 'GET',
data: data,
customLoading: true,
utilSuccess: function(res) {
resolve(res || {
is_vip: 0
})
},
utilFail: function(err) {
reject(err)
}
})
})
},
submitForm() {
let that = this
console.log("form",this.form)
// return
this.util.request({
api: '/api/admin/visit/save',
method: "POST",
requestType: 'bd',
data: that.form,
utilSuccess: function(res) {
uni.showToast({
title: res.msg,
duration: 2000,
icon: 'none'
})
uni.removeStorageSync('formdata')
uni.redirectTo({
url: '/pages/visit/successform?iscall=call'
})
},
utilFail: function(res) {
uni.showToast({
title: res,
duration: 2000,
icon: 'none'
})
}
})
},
submitNoStudy() {
let that = this
this.util.request({
api: '/api/mobile/visit/visit-save',
method: "POST",
data: that.form,
utilSuccess: function(res) {
uni.showToast({
title: res.msg,
duration: 2000,
icon: 'none'
})
uni.removeStorageSync('formdata')
that.newsSubscription()
},
utilFail: function(res) {
console.log(res)
uni.showToast({
title: res,
duration: 2000,
icon: 'none'
})
}
})
},
newsSubscription() {
uni.getSetting({
withSubscriptions: true, //是否获取用户订阅消息的订阅状态默认false不返回
success(res) {
if (res.authSetting['scope.subscribeMessage']) {
uni.redirectTo({
url: '/pages/visit/successform'
})
} else {
// 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
uni.requestSubscribeMessage({
tmplIds: [
'O898NDrqGUUeSR42uraqr2PLEg05sNbYVu46I0qLkhE',
'Caa0O6pPtQDHQMPsqE6PHyzueeI11JvlpenbgwkYC0s'
],
success(res) {
console.log("res", res)
uni.showToast({
title: '订阅成功'
})
uni.redirectTo({
url: '/pages/visit/successform'
})
}
})
}
}
});
},
}
}
</script>
<style scoped>
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
}
.steps {
margin-bottom: 40rpx
}
.formtext {
margin-bottom: 20rpx
}
.formtext-flex{
display:flex;
justify-content: space-between;
align-items: center;
}
.history-btn{
background-color:#044ed7 !important;
font-size:24rpx;
line-height:1.8;
padding:0 16rpx;
}
::v-deep .uni-table-td {
vertical-align: middle;
}
::v-deep .uni-drawer__content {
padding: 40rpx
}
.configtitle {
font-size: 40rpx;
text-align: center;
margin-top: 36rpx;
padding-bottom: 20rpx;
}
.configvalue {
padding: 40rpx;
font-size: 36rpx;
height: 600rpx;
overflow-y: auto;
}
.configbtn {
background: #044ed7;
padding: 20rpx;
/* display: inline-block; */
text-align: center;
margin: 20rpx auto;
color: #fff;
border-radius: 20rpx;
}
.configload {
display: flex;
justify-content: center;
align-items: center;
font-size: 50rpx;
color: #ddd;
}
.configload text {
margin-right: 20rpx
}
::v-deep .u-popup__content__close .u-icon__icon {
color: #fff !important
}
.areabtn {
background-color: #044ed7;
/* margin-left: 8px; */
width: 100%;
position: fixed;
bottom: 0;
left: 0;
border-radius: 0;
}
::v-deep .areavalue .uni-data-checklist .checklist-group .checklist-box.is--button {
padding: 30rpx
}
.vip-gate-wrap {
padding: 24rpx 12rpx;
}
.vip-gate-tip {
font-size: 28rpx;
color: #666;
margin-bottom: 32rpx;
line-height: 1.5;
}
</style>