Files
dvcp_v2_wxcp_app/src/components/pages/selectResident.vue

185 lines
4.1 KiB
Vue
Raw Normal View History

2021-12-24 10:38:11 +08:00
<template>
<div class="selectResident">
<AiTopFixed>
2021-12-31 18:11:13 +08:00
<u-search placeholder="搜索" v-model="name" :show-action="false" @change="getList"></u-search>
2021-12-24 10:38:11 +08:00
</AiTopFixed>
<div class="user-list">
2022-02-11 18:26:42 +08:00
<template v-if="list.length>0">
<div class="item" v-for="(item, index) in list" :key="index">
<div class="select-img" @click="checkClick(index)">
<img :src="item.isCheck ? checkIcon : cirIcon" alt="">
</div>
<div class="user-info">
<img :src="item.photo" alt="" v-if="item.photo">
<img src="./img/user-img.png" alt="" v-else>{{ item.name }}
</div>
2021-12-24 10:38:11 +08:00
</div>
2022-02-11 18:26:42 +08:00
</template>
2022-03-10 12:17:44 +08:00
<template v-else>
<AiEmpty />
<div class="pad-b118"/>
</template>
2021-12-24 10:38:11 +08:00
</div>
2022-03-10 12:17:44 +08:00
<div class="pad-b118"/>
2021-12-24 10:38:11 +08:00
<div class="footer">
<div class="btn" @click="confirm">确定选择</div>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
2021-12-24 12:05:40 +08:00
name: "selectResident",
appName: "人员选择器(居民档案)",
2021-12-24 10:38:11 +08:00
data() {
return {
current: 1,
name: '',
list: [],
2022-02-11 11:20:57 +08:00
cirIcon: require('./img/xz.png'),
checkIcon: require('./img/xzh.png'),
2021-12-24 12:05:40 +08:00
selected: []
2021-12-24 10:38:11 +08:00
}
},
2022-03-10 12:17:44 +08:00
computed: {
...mapState(['user']),
isSingle() {
return this.$route.query.single
}
},
2021-12-24 12:05:40 +08:00
onLoad(query) {
if (query.selected) {
this.selected = query.selected?.split(",") || []
}
2021-12-24 10:38:11 +08:00
this.getList()
},
methods: {
getList() {
this.$http.post(`/app/appresident/list`, null, {
params: {
current: this.current,
size: 20,
areaId: this.user.areaId,
con: this.name
}
}).then(res => {
if (res?.data) {
res.data.records.forEach(e => {
2021-12-24 13:58:43 +08:00
e.isCheck = this.selected.includes(e.idNumber)
2021-12-24 10:38:11 +08:00
})
if (this.current > 1 && this.current > res.data.pages) {
return
}
this.list = this.current > 1 ? [...this.list, ...res.data.records] : res.data.records
}
})
},
checkClick(index) {
2022-03-10 12:17:44 +08:00
if (this.isSingle) {
this.list.map((e, i) => {
e.isCheck = i == index;
})
} else this.list[index].isCheck = !this.list[index].isCheck
2021-12-24 10:38:11 +08:00
},
confirm() {
2021-12-24 12:05:40 +08:00
let checkList = []
2021-12-24 10:38:11 +08:00
this.list.map((item) => {
2021-12-24 12:05:40 +08:00
if (item.isCheck) {
2021-12-24 10:38:11 +08:00
checkList.push(item)
}
})
2021-12-24 12:05:40 +08:00
if (!checkList.length) {
2021-12-24 10:38:11 +08:00
return this.$u.toast('请先选择人员')
2021-12-24 12:05:40 +08:00
} else {
uni.navigateBack({
success: () => {
uni.$emit("pagePicker", checkList)
}
})
2021-12-24 10:38:11 +08:00
}
}
},
onReachBottom() {
this.current++
this.getList()
},
}
</script>
<style lang="scss" scoped>
.selectResident {
2021-12-24 12:05:40 +08:00
::v-deep .AiTopFixed .u-search {
margin-bottom: 0 !important;
2021-12-24 10:38:11 +08:00
}
2021-12-24 12:05:40 +08:00
.pad-b118 {
2021-12-24 10:38:11 +08:00
padding-bottom: 118px;
}
2021-12-24 12:05:40 +08:00
.user-list {
2021-12-24 10:38:11 +08:00
background-color: #fff;
2021-12-24 12:05:40 +08:00
.item {
.select-img {
2021-12-24 10:38:11 +08:00
display: inline-block;
2021-12-24 12:05:40 +08:00
img {
2021-12-24 10:38:11 +08:00
width: 48px;
height: 48px;
margin: 12px 36px 12px 30px;
vertical-align: middle;
}
}
2021-12-24 12:05:40 +08:00
.user-info {
2021-12-24 10:38:11 +08:00
display: inline-block;
padding: 20px 0 20px 0;
width: calc(100% - 114px);
height: 100%;
border-bottom: 1px solid #E4E5E6;
font-size: 36px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333;
line-height: 74px;
2021-12-24 12:05:40 +08:00
img {
2021-12-24 10:38:11 +08:00
width: 74px;
height: 74px;
border-radius: 8px;
margin-right: 34px;
vertical-align: bottom;
}
}
}
}
2021-12-24 12:05:40 +08:00
.footer {
2021-12-24 10:38:11 +08:00
width: 100%;
height: 118px;
background: #F4F8FB;
position: fixed;
left: 0;
bottom: 0;
text-align: right;
2021-12-24 12:05:40 +08:00
.btn {
2021-12-24 10:38:11 +08:00
display: inline-block;
width: 192px;
height: 80px;
line-height: 80px;
background: #1365DD;
border-radius: 4px;
text-align: center;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #FFF;
margin: 20px 34px 0 0;
}
}
}
</style>