居民管理

This commit is contained in:
liuye
2022-02-07 16:38:43 +08:00
parent 96f4ab331a
commit c1bca8536d
3 changed files with 389 additions and 6 deletions

View File

@@ -0,0 +1,345 @@
<template>
<div class="add">
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">是否户主</span>
<span class="value" @click="clickSelect('yesOrNo', 'householdName')">
<span v-if="form.householdName === ''" class="color-999">请选择</span>
<span v-else>{{$dict.getLabel('yesOrNo', form.householdName)}}</span>
<img src="./components/img/right-icon.png" alt="">
</span>
</div>
</div>
<div class="item" v-if="form.householdName != 1">
<span class="tips">*</span>
<div class="border">
<span class="label">户主身份证</span>
<span class="value">
<input type="idcard" placeholder="请输入" v-model="form.householdIdNumber" maxlength="18">
</span>
</div>
</div>
<div class="item" v-if="form.householdName != 1">
<span class="tips">*</span>
<div class="border">
<span class="label">与户主关系</span>
<span class="value" @click="clickSelect('householdRelation', 'householdRelation')">
<span v-if="form.householdRelation === ''" class="color-999">请选择</span>
<span v-else>{{$dict.getLabel('householdRelation', form.householdRelation)}}</span>
<img src="./components/img/right-icon.png" alt="">
</span>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">姓名</span>
<span class="value">
<input type="text" placeholder="请输入" v-model="form.name" maxlength="10">
</span>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">身份证号</span>
<span class="value">
<input type="idcard" placeholder="请输入" v-model="form.idNumber" maxlength="18" @input="changeIdNumber">
</span>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">性别</span>
<span class="value">
<span v-if="form.sex === ''" class="color-999">请选择</span>
<span v-else>{{$dict.getLabel('sex', form.sex)}}</span>
<img src="./components/img/right-icon.png" alt="">
</span>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">出生日期</span>
<span class="value">
<span :class="form.birthDate == '' ? 'color-999' : ''">{{form.birthDate || '请选择'}}</span>
<img src="./components/img/right-icon.png" alt="">
</span>
</div>
</div>
<div class="item">
<span class="tips"></span>
<div class="border">
<span class="label">联系电话</span>
<span class="value">
<input type="text" placeholder="请输入" @input="changePhone" v-model="form.phone" maxlength="11">
</span>
</div>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">现住址</span>
<span class="value">
<AiAreaPicker ref="address" class="aiArea" :fullName.sync="form.currentAreaName" :value="form.currentAreaId" :areaId="$areaId" mode="custom" all @select="onCurrentAreaChange">
<div class="aiArea">
<span class="label" v-if="form.currentAreaName">{{ form.currentAreaName }}</span>
<span v-else class="color-999">请选择</span>
<img src="./components/img/right-icon.png" alt="">
</div>
</AiAreaPicker>
</span>
</div>
</div>
<div class="item mar-b0">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">详细地址</span>
</div>
</div>
<div class="text-area">
<textarea placeholder="请输入" maxlength="30" v-model="form.currentAddress"></textarea>
</div>
<div class="item">
<span class="tips">*</span>
<div class="border">
<span class="label">户籍地址</span>
<span class="value">
<AiAreaPicker ref="address" class="aiArea" :fullName.sync="form.householdAreaName" :value="form.householdAreaId" :areaId="$areaId" mode="custom" all @select="onHouseAreaChange">
<div class="aiArea">
<span class="label" v-if="form.householdAreaName">{{ form.householdAreaName }}</span>
<span v-else class="color-999">请选择</span>
<img src="./components/img/right-icon.png" alt="">
</div>
</AiAreaPicker>
</span>
</div>
</div>
<div class="item mar-b0">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">详细地址</span>
</div>
</div>
<div class="text-area">
<textarea placeholder="请输入" maxlength="30" v-model="form.householdAddress"></textarea>
</div>
<div class="pad-b152"></div>
<div class="add-btn" @click="submit">
<div>保存</div>
</div>
<!-- <u-picker mode="time" v-model="dateShow" :params="deteParams" start-year="2010" @confirm="dateConfirm">请选择</u-picker> -->
<u-select v-model="showSelect" :list="selectList" label-name="dictName" value-name="dictValue" @confirm="confirmSelect"/>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'add',
data() {
return {
form: {
householdName: '',
householdIdNumber: '',
householdRelation: '',
name: '',
idNumber: '',
sex: '',
birthDate: '',
phone: '',
currentAreaId: '',
currentAreaName: '',
currentAddress: '',
householdAreaId: '',
householdAreaName: '',
householdAddress: '',
},
showSelect: false,
formName: '',
selectList: []
}
},
onLoad() {
document.title = '新增居民'
this.$dict.load('yesOrNo', 'sex', 'householdRelation', 'nation', 'education', 'maritalStatus', 'politicsStatus', 'militaryStatus', 'faithType')
},
computed: {
...mapState(['user']),
},
methods: {
submit() {
if(this.form.householdName === '') {
return this.$u.toast('请选择是否户主')
}
if(this.form.householdName != 1 && !this.form.householdIdNumber) {
return this.$u.toast('请输入户主身份证')
}
if(this.form.householdName != 1 && this.form.householdRelation === '') {
return this.$u.toast('请选择与户主关系')
}
if(!this.form.name) {
return this.$u.toast('请输入姓名')
}
if(!this.form.idNumber) {
return this.$u.toast('请输入身份证号')
}
if(!this.form.sex) {
return this.$u.toast('请选择性别')
}
if(!this.form.birthDate) {
return this.$u.toast('请选择出生日期')
}
if(!this.form.currentAreaId) {
return this.$u.toast('请选择现住址')
}
if(!this.form.currentAddress) {
return this.$u.toast('请输入现住址详细地址')
}
if(!this.form.householdAreaId) {
return this.$u.toast('请选择户籍地址')
}
if(!this.form.householdAddress) {
return this.$u.toast('请输入户籍地址详细地址')
}
this.$http.post('/app/appresident/addOrUpdate', this.form).then(res => {
if (res.code === 0) {
this.$u.toast('新增成功')
uni.$emit('reload')
uni.navigateBack({
delta: 1
})
}
})
},
confirmSelect(e) {
this.form[this.formName] = e[0].value
},
clickSelect(dictName, formName) {
this.selectList = this.$dict.getDict(dictName)
this.formName = formName
this.showSelect = true
},
changeIdNumber() {
let reg = /^[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]$/;
if (this.form.idNumber.length == 18 && !reg.test(this.form.idNumber)) {
return this.$u.toast('请输入正确的身份证号码')
}
var info = this.$idCardNoUtil.getIdCardInfo(this.form.idNumber)
this.form.birthDate = info.birthday
this.form.sex = info.gender
},
changePhone() {
let regTel = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
if (this.form.phone.length == 11 && !regTel.test(this.form.phone)) {
return this.$u.toast('请输入正确的手机号')
}
},
onCurrentAreaChange(e) {
this.form.currentAreaId = e
},
onHouseAreaChange(e) {
this.form.householdAreaId = e
},
},
}
</script>
<style scoped lang="scss">
.add {
.item{
width: 100%;
padding-left: 14px;
background: #FFF;
box-sizing: border-box;
display: flex;
margin-bottom: 16px;
.tips{
width: 18px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #FF4466;
line-height: 44px;
padding: 34px 0 34px 0;
}
.border{
width: calc(100% - 18px);
padding: 34px 32px 34px 0;
line-height: 44px;
border-bottom: 1px solid #D8DDE6;
line-height: 44px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #333;
display: flex;
box-sizing: border-box;
.label{
width: 170px;
}
.value{
width: calc(100% - 170px);
text-align: right;
img{
width: 32px;
height: 32px;
margin-left: 8px;
vertical-align: middle;
}
}
.color-999{
color: #999;
}
}
.not-border{
border-bottom: 0;
}
}
.mar-b0{
margin-bottom: 0;
}
.text-area{
width: 100%;
background-color: #fff;
padding: 0 32px;
margin-bottom: 16px;
box-sizing: border-box;
textarea{
width: 100%;
height: 88px;
padding-bottom: 32px;
}
}
.pad-b152{
width: 100%;
padding-bottom: 152px;
background-color: #f5f5f5;
}
.add-btn{
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
height: 112px;
line-height: 112px;
background: #3975C6;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
div{
text-align: center;
}
}
}
</style>

View File

@@ -5,16 +5,16 @@
<AiAreaPicker v-model="areaId" :areaId="user.areaId" @select="seachObj"></AiAreaPicker>
<u-icon name="photo"></u-icon> -->
<!-- @select="areaSelect" -->
<u-form label-width="auto">
<!-- <u-form label-width="auto">
<u-form-item label="区域选择" right-icon="arrow-right" class="areaIds">
<AiAreaPicker v-model="areaId" :areaId="user.areaId" @select="seachObj" :name.sync="areaName"></AiAreaPicker>
</u-form-item>
</u-form>
</u-form> -->
</div>
<div class="line"></div>
<!-- <div class="line"></div> -->
<u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="96" @change="change"></u-tabs>
<u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="96" @change="change" :bar-width="196"></u-tabs>
<div class="seachObjs">
<u-search v-model="keyword" :clearabled="true" placeholder="姓名/联系方式/身份证后6位" :show-action="false" bg-color="#F5F5F5" search-icon-color="#E2E8F1" color="#666" height="58" @search="handerSearch" @clear="handerClear"></u-search>
@@ -37,8 +37,11 @@
</div>
</div>
</div>
<AiEmpty class="emptyWrap" v-else></AiEmpty>
<AiEmpty class="emptyWrap" v-else :noPermit="true" description="暂无居民<br/>信息点击按钮新增居民信息,也可在管理系统批量导入"></AiEmpty>
<div class="pad-b112"></div>
<div class="add-btn" @click="toAdd">
<div>新增居民</div>
</div>
</div>
</template>
@@ -77,6 +80,10 @@ export default {
this.areaId = this.user.areaId
this.areaName = this.user.areaName
this.getList()
uni.$on('reload', res => {
this.current = 1
this.getList()
})
},
onShow() {
document.title = '居民管理'
@@ -130,6 +137,9 @@ export default {
this.current = 1
this.getList()
},
toAdd() {
uni.navigateTo({url: './Add'})
}
},
onReachBottom() {
this.current = this.current + 1
@@ -221,10 +231,38 @@ uni-page-body {
}
}
}
.pad-b112{
width: 100%;
padding-bottom: 112px;
}
.emptyWrap {
background: #f5f5f5;
margin: 0;
}
::v-deep .emptyText{
text-align: center;
}
.add-btn{
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
height: 112px;
line-height: 112px;
background: #3975C6;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
div{
text-align: center;
}
}
::v-deep .u-tab-bar{
margin-bottom: -6px;
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B