140 lines
4.3 KiB
Vue
140 lines
4.3 KiB
Vue
<template>
|
||
<view class="pb-50 text grey " >
|
||
<tm-menubars title="访客申请" color="bg-gradient-blue-accent" ></tm-menubars>
|
||
|
||
<tm-sheet :shadow="24" :padding="[12,24]" :margin="[24,24]">
|
||
<view class="py-12 px-24 mx-12 round-3 border-b-1 grey text" >
|
||
<text class="text-size-n text-weight-b ">当前设备编号:{{sn}}</text>
|
||
</view>
|
||
<tm-input name="title" required title="访客姓名" v-model="reqData.userName"></tm-input>
|
||
<tm-input name="title" required title="访客手机号" v-model="reqData.tel"></tm-input>
|
||
<view class="mx-32 my-12 border-b-1 pb-12 flex-between" >
|
||
<text class="text-size-n ">性别</text>
|
||
<tm-groupradio >
|
||
|
||
<tm-radio :name="item.title" v-for="(item,index) in shifoushiguche" :key="index" v-model="item.checked" :label="item.title"></tm-radio>
|
||
</tm-groupradio>
|
||
</view>
|
||
<tm-input name="title" required title="接待人姓名" v-model="reqData.receiver"></tm-input>
|
||
<tm-input :vertical="true" required :height="150" input-type="textarea" bg-color="grey-lighten-5" :maxlength="200" title="访问事由" placeholder="请输入" v-model="reqData.reasonVisit" ></tm-input>
|
||
<view class="px-24">
|
||
<tm-button navtie-type="form" theme="bg-gradient-blue-accent" @click="submit" block >提交数据</tm-button>
|
||
<view class="py-32 text-size-s text-grey text-align-center">请注意资料的上传,必填项。</view>
|
||
</view>
|
||
</tm-sheet>
|
||
|
||
</view>
|
||
</template>
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
sn:'',
|
||
chelianglis:[
|
||
{title:"SUV",id:21},
|
||
{title:"面包车",id:31},
|
||
{title:"跑车",id:41},
|
||
{title:"轿车",id:51},
|
||
{title:"房车",id:61},
|
||
],
|
||
shifoushiguche:[
|
||
{title:"男",checked:false,value:0},
|
||
{title:"女",checked:false,value:1},
|
||
{title:"未知",checked:true,value:-1},
|
||
],
|
||
reqData:{
|
||
receiver:'',
|
||
reasonVisit:'',
|
||
tel:'',
|
||
userName:'',
|
||
gender:0,
|
||
}
|
||
}
|
||
},
|
||
mounted() {
|
||
this.$nextTick(function(){
|
||
// console.log(this.$refs.citypieek.getSelectedValue());
|
||
})
|
||
},
|
||
onLoad(options){
|
||
this.sn=options.sn
|
||
},
|
||
computed:{
|
||
cityDisplay:function(){
|
||
if(typeof this.reqData.city[0] ==='object'){
|
||
let ds = [];
|
||
this.reqData.city.forEach(item=>{
|
||
ds.push(item.text)
|
||
})
|
||
return ds.join('/')
|
||
}else if(typeof this.reqData.city[0] ==='string'){
|
||
|
||
return this.reqData.city.join('/')
|
||
}
|
||
}
|
||
},
|
||
methods: {
|
||
submit(){
|
||
|
||
if (!this.reqData.userName?.trim()){
|
||
uni.showToast({ title: '请输入访客姓名', icon: 'none' });
|
||
return
|
||
}
|
||
if (!this.reqData.tel?.trim()){
|
||
uni.showToast({ title: '请输入手机号', icon: 'none' });
|
||
return
|
||
}
|
||
if (!this.reqData.reasonVisit?.trim()){
|
||
uni.showToast({ title: '请输入访问事由', icon: 'none' });
|
||
return
|
||
}
|
||
if (!this.reqData.receiver?.trim()){
|
||
uni.showToast({ title: '请输入接待人姓名', icon: 'none' });
|
||
return
|
||
}
|
||
uni.request({
|
||
method:'post',
|
||
url:'http://114.218.158.24:9020/secret/visitor',
|
||
data:{...this.reqData,gender: this.shifoushiguche.find(x=>x.checked).value,sn:this.sn},
|
||
complete:(res)=>{
|
||
if (res.data.code===200){
|
||
uni.showToast({ title: '提交成功', icon: 'none' });
|
||
}else {
|
||
uni.showToast({ title: res.data.msg, icon: 'none' });
|
||
}
|
||
}
|
||
})
|
||
},
|
||
async getData(e){
|
||
let d = await this.$refs.formData.getFormData();
|
||
uni.showModal({
|
||
title:"数据如下",
|
||
content:JSON.stringify(d),
|
||
showCancel:false
|
||
})
|
||
},
|
||
success(e){
|
||
//提交成功 。
|
||
uni.$tm.toast(e.msg)
|
||
},
|
||
obTstr(o){
|
||
if(Array.isArray(o)){
|
||
if(o.length.length===0) return "";
|
||
return o.join(",")
|
||
}
|
||
return JSON.stringify(o)
|
||
},
|
||
obTstr2(o){
|
||
if(Array.isArray(o)){
|
||
if(o.length.length===0) return "";
|
||
return o[0]?.title??""
|
||
}
|
||
return ''
|
||
},
|
||
chuchangchange(e){
|
||
this.$set(this.reqData,'chuchangtime',e.year+"-"+e.month+"-"+e.day)
|
||
},
|
||
}
|
||
}
|
||
</script>
|