调整字段名称

This commit is contained in:
weipengfei 2023-07-28 17:39:29 +08:00
parent 249cbcae1e
commit 1829751e1a
2 changed files with 44 additions and 43 deletions

View File

@ -3,7 +3,7 @@
<view class="">
<u--form labelPosition="left" :model="residents" :rules="rules" ref="uForm">
<block value="人口">
<block value="人员信息" v-for="(item, index) in residents.userList" :key="'user'+index">
<block value="人员信息" v-for="(item, index) in residents.family" :key="'user'+index">
<u-form-item label="姓名" required prop="residents.nickname" borderBottom>
<u--input v-model="item.nickname" placeholder="请输入姓名"></u--input>
</u-form-item>
@ -22,26 +22,26 @@
<u-form-item labelWidth="auto" label="技能特长" required prop="residents.nickname" borderBottom>
<u--input v-model="item.skill" placeholder="请输入技能特长"></u--input>
</u-form-item>
<button type="primary" v-if="residents.userList.length>1" class="delete"
@click="removeUserList(index)">删除以上信息</button>
<button type="primary" v-if="residents.family.length>1" class="delete"
@click="removeFamily(index)">删除以上信息</button>
</block>
<button type="primary" class="plus" @click="pushUserList">+</button>
<button type="primary" class="plus" @click="pushFamily">+</button>
</block>
<block value="婴幼儿信息">
<u-form-item labelWidth="auto" label="是否存在学生、婴幼儿" required prop="residents.infant" borderBottom>
<u-radio-group v-model="residents.infant" style="margin: 16rpx;">
<u-form-item labelWidth="auto" label="是否存在学生、婴幼儿" required prop="residents.child" borderBottom>
<u-radio-group v-model="residents.child" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<block value="是" v-if="residents.infant>0" v-for="(item,index) in residents.infantList" :key="'infant'+index">
<u-form-item label="年龄" required prop="residents.infantList.age" borderBottom>
<block value="是" v-if="residents.child>0" v-for="(item,index) in residents.child_arr" :key="'child'+index">
<u-form-item label="年龄" required prop="residents.child_arr.age" borderBottom>
<u--input v-model="item.age" placeholder="请输入年龄" type="number"></u--input>
</u-form-item>
<block v-if="item.age<4">
<u-form-item labelWidth="auto" label="喂养方式" required prop="residents.infant" borderBottom>
<u-form-item labelWidth="auto" label="喂养方式" required prop="residents.child" borderBottom>
<u-radio-group v-model="item.wyfs" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'母乳'},{value:0,label:'奶粉'}]" :key="index" :label="item.label"
@ -51,10 +51,10 @@
</u-form-item>
</block>
<block v-else>
<u-form-item label="年级" required prop="residents.infantList.age" borderBottom>
<u-form-item label="年级" required prop="residents.child_arr.age" borderBottom>
<u--input v-model="item.grade" placeholder="请输入年级"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="是否补课" required prop="residents.infant" borderBottom>
<u-form-item labelWidth="auto" label="是否补课" required prop="residents.child" borderBottom>
<u-radio-group v-model="item.is_course" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
@ -62,19 +62,19 @@
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item v-if="item.is_course>0" label-width="auto" labelPosition="top" label="补课内容" prop="residents.infantList.age"
<u-form-item v-if="item.is_course>0" label-width="auto" labelPosition="top" label="补课内容" prop="residents.child_arr.age"
borderBottom>
<u--textarea v-model="item.course" autoHeight placeholder="请输入需要的课程" border="surround"
count></u--textarea>
</u-form-item>
<u-form-item label-width="auto" labelPosition="top" label="备注" prop="residents.infantList.age" borderBottom>
<u-form-item label-width="auto" labelPosition="top" label="备注" prop="residents.child_arr.age" borderBottom>
<u--textarea v-model="item.remark" autoHeight placeholder="请输入备注" border="surround" count></u--textarea>
</u-form-item>
</block>
<button type="primary" v-if="residents.infantList.length>1" class="delete"
@click="removeInfantList(index)">删除以上信息</button>
<button type="primary" v-if="residents.child_arr.length>1" class="delete"
@click="removeChildArr(index)">删除以上信息</button>
</block>
<button type="primary" class="plus" @click="pushInfantList">+</button>
<button type="primary" class="plus" @click="pushChildArr">+</button>
</block>
</u--form>
@ -88,14 +88,14 @@
jobTypeList: ['公务员','国企事业单位','民营企业','自由职业','其他'],
//
residents: {
userList: [{
family: [{
nickname: '',
birthday: '',
jobType: '', //
skill: '', //
}],
infant: '', //
infantList: [ //
child: '', //
child_arr: [ //
{
age: '',
wsfy: '', //
@ -115,16 +115,16 @@
//
changeBirthday(e){
let index = e.currentTarget.dataset.index;
this.residents.userList[index].birthday = e.detail.value;
this.residents.family[index].birthday = e.detail.value;
},
//
changeJobType(e){
let index = e.currentTarget.dataset.index;
this.residents.userList[index].jobType = this.jobTypeList[e.detail.value];
this.residents.family[index].jobType = this.jobTypeList[e.detail.value];
},
//
pushUserList() {
this.residents.userList.push({
pushFamily() {
this.residents.family.push({
nickname: '',
birthday: '',
jobType: '',
@ -132,20 +132,20 @@
})
},
//
removeUserList(index) {
removeFamily(index) {
uni.showModal({
confirmColor: '#f56c6c',
content: '确定删除吗?',
success: (res) => {
if (res.confirm) {
this.residents.userList.splice(index, 1);
this.residents.family.splice(index, 1);
}
}
})
},
//
pushInfantList() {
this.residents.infantList.push({
pushChildArr() {
this.residents.child_arr.push({
age: '',
wsfy: '', //
grade: '', //
@ -154,13 +154,13 @@
})
},
//
removeInfantList(index) {
removeChildArr(index) {
uni.showModal({
confirmColor: '#f56c6c',
content: '确定删除吗?',
success: (res) => {
if (res.confirm) {
this.residents.infantList.splice(index, 1);
this.residents.child_arr.splice(index, 1);
}
}
})

View File

@ -4,8 +4,8 @@
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm">
<view class="item">
<view class="title">基本信息</view>
<u-form-item labelWidth="auto" label="户主姓名" required prop="nickname" borderBottom>
<u--input v-model="formData.nickname" placeholder="请输入姓名"></u--input>
<u-form-item labelWidth="auto" label="户主姓名" required prop="name" borderBottom>
<u--input v-model="formData.name" placeholder="请输入姓名"></u--input>
</u-form-item>
<u-form-item label="性别" required prop="sex" borderBottom>
<u-radio-group v-model="formData.sex" style="margin: 16rpx;">
@ -18,8 +18,8 @@
<u-form-item labelWidth="auto" label="身份证号" required prop="id_card" borderBottom>
<u--input v-model="formData.id_card" placeholder="请输入身份证号" type="idcard"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="联系方式" required prop="account" borderBottom>
<u--input v-model="formData.account" placeholder="请输入手机号" type="number"></u--input>
<u-form-item labelWidth="auto" label="联系方式" required prop="phone" borderBottom>
<u--input v-model="formData.phone" placeholder="请输入手机号" type="number"></u--input>
</u-form-item>
</view>
<view class="item">
@ -28,8 +28,8 @@
<u-form-item labelWidth="auto" label="详细地址" required prop="address" borderBottom>
<u--input v-model="formData.address" placeholder="请输入详细地址"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="汽车是否能到家" required prop="formData.infant" borderBottom>
<u-radio-group v-model="formData.is_car" style="margin: 16rpx;">
<u-form-item labelWidth="auto" label="汽车是否能到家" required prop="residents.infant" borderBottom>
<u-radio-group v-model="formData.highway" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
:name="item.value">
@ -38,14 +38,14 @@
</u-form-item>
<block value="智能手机">
<u-form-item labelWidth="auto" label="是否使用智能手机" required prop="formData.infant" borderBottom>
<u-radio-group v-model="formData.is_smartphone" style="margin: 16rpx;">
<u-radio-group v-model="formData.smart_phone" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<block v-if="formData.is_smartphone>0">
<block v-if="formData.smart_phone>0">
<u-form-item labelWidth="auto" label="微信号" required prop="formData.infantList.age" borderBottom>
<u--input v-model="formData.wechat" placeholder="请输入微信号"></u--input>
</u-form-item>
@ -80,14 +80,15 @@
formData: {
id_card: '',
sex: '',
nickname: '',
account: '', //
is_car: '',//
is_smartphone: '',//使
name: '',
phone: '', //
highway: '',//
smart_phone: '',//使
wechat: '', //
address: '',//
},
rules: {
account: {
phone: {
required: true,
pattern: /^(1[3456789]\d{9})$/,
message: '请输入正确的手机号码',
@ -106,7 +107,7 @@
message: '请选择男或女',
trigger: ['blur', 'change']
},
nickname: {
name: {
type: 'string',
required: true,
message: '姓名不能为空',