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

148 lines
4.5 KiB
Vue

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>
<view class="pb-50 text grey " >
<tm-menubars title="访客申请" color="bg-gradient-blue-accent" :showback="false"></tm-menubars>
<tm-message ref="toast"></tm-message>
<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
}
this.$refs.toast.show({model:'load',mask:true})
uni.request({
method:'post',
url:'https://erpapi.fontree.cn/secret/visitor',
data:{...this.reqData,gender: this.shifoushiguche.find(x=>x.checked).value,sn:this.sn},
complete:(res)=>{
this.$refs.toast.hide()
if (res.data.code===200){
uni.showToast({ title: '提交成功', icon: 'none' });
}else {
if (!res.data.msg){
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>