优化代码

This commit is contained in:
wuxw 2024-09-14 14:11:06 +08:00
parent 9013154f49
commit 14b8a68b0f

View File

@ -1,15 +1,23 @@
<template>
<view>
<view class="block__title">基本信息</view>
<view class="cu-form-group">
<view class="title">人员角色</view>
<picker :value="personRoleIndex" :range="personRoles" range-key="name" @change="_changePersonRole">
<view class="picker">
{{personRoleIndex == -1 ?'请选择':personRoles[personRoleIndex].name}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">姓名</view>
<input v-model="name" placeholder="必填,请输入成员名称"></input>
</view>
<view class="cu-form-group">
<view class="cu-form-group" >
<view class="title">身份证</view>
<input v-model="idCard" placeholder="选填,请输入身份证"></input>
</view>
<view class="cu-form-group">
<view class="cu-form-group" >
<view class="title">性别</view>
<picker bindchange="PickerChange" :value="index" :range="sexArr" @change="sexChange">
<view class="picker">
@ -17,24 +25,21 @@
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">人员类型</view>
<picker :value="typeCdIndex" :range="typeCds" range-key="name" @change="_changeTypeCd">
<view class="picker">
{{typeCdIndex == -1 ?'请选择':typeCds[typeCdIndex].name}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">房屋</view>
<input v-model="roomName" placeholder="必填,请输入房屋楼栋-单元-房屋"></input>
</view>
<view class="cu-form-group">
<view class="title">家庭住</view>
<input type="text" v-model="address" placeholder="选填,请输入家庭住址"></input>
<view class="title">地址</view>
<input type="text" v-model="address" placeholder="选填,请输入地址"></input>
</view>
<view class="block__title">联系信息</view>
<view class="cu-form-group" v-if="personType == 'C'">
<view class="title">联系人</view>
<input v-model="concactPerson" placeholder="必填,请输入联系人"></input>
</view>
<view class="cu-form-group">
<view class="title">手机号</view>
<input v-model="link" placeholder="必填,请输入手机号(没有手机号随便写一个)"></input>
@ -75,29 +80,32 @@
sex: "0",
link: "",
remark: "",
typeCds: [{
value: '1001',
name: '业主'
},
{
value: '1002',
personRoles: [{
value: '3',
name: '家庭成员'
},
{
value: '1003',
value: '2',
name: '租客'
},
{
value: '1005',
value: '4',
name: '公司员工'
},
{
value: '99',
name: '其他'
}
],
typeCdIndex: -1,
ownerTypeCd: "",
personRoleIndex: -1,
personRole:'',
personType:'P',
ownerTypeCd: "2002",
idCard: "",
address: "",
roomName: "",
communityId:'',
concactPerson:'',
photos: [],
uploadImage: {
maxPhotoNum: 1,
@ -129,6 +137,8 @@
"link": this.link,
"remark": this.remark,
"ownerTypeCd": this.ownerTypeCd,
"personRole":this.personRole,
"personType":this.personType,
"roomName": this.roomName,
"communityId": this.getCommunityId(),
"idCard": this.idCard,
@ -138,9 +148,7 @@
}
let msg = "";
if (obj.ownerId == "") {
msg = "请填写业主";
} else if (obj.name == "") {
if (obj.name == "") {
msg = "请填写姓名";
} else if (obj.link == "") {
msg = "请填写手机号";
@ -166,9 +174,13 @@
uni.navigateBack()
})
},
_changeTypeCd: function(e) {
this.typeCdIndex = e.detail.value;
this.ownerTypeCd = this.typeCds[this.typeCdIndex].value;
_changePersonRole: function(e) {
this.personRoleIndex = e.detail.value;
this.personRole = this.personRoles[this.personRoleIndex].value;
},
_changePersonType: function(e) {
this.personTypeIndex = e.detail.value;
this.personType = this.personTypes[this.personTypeIndex].value;
},
}
};