Files
dvcp_v2_wxcp_app/src/project/saas/AppResidentDocument/AppResidentDocument.vue
yanran200730 6756860301 bug
2022-08-18 17:09:20 +08:00

417 lines
8.7 KiB
Vue

<template>
<div class="AppResidentDocument">
<u-tabs class="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>
</div>
<div class="dataes" v-if="datas.length">
<u-swipe-action
:show="item.show"
:index="index"
v-for="(item, index) in datas"
:key="item.id"
@click="onClick"
@open="onOpen"
:disabled="item.doRight !== '1'"
@content-click="toDetailCard(item)"
:options="options">
<div class="datass">
<div class="left">
<img :src="item.photo" alt="" v-if="item.photo"/>
<img src="./components/img/4.png" alt="" v-else/>
</div>
<div class="right">
<div class="rightTop">
<span class="name">{{ item.name }}</span>
<div class="tags" v-if="item.labelNames">{{ item.labelNames }}</div>
</div>
<div class="rightBottom">
<span>{{ item.idNumber.replace(/^(\w{6})\w{8}(.*)$/, '$1********$2') }}</span>
<span>{{ item.phone }}</span>
</div>
</div>
</div>
</u-swipe-action>
</div>
<div class="empty" v-if="!datas.length && isMore">
<img src="https://cdn.cunwuyun.cn/dvcp/h5/no-data.png" alt="">
<p>暂无居民信息<br/>点击<span @click="edit('')">新增按钮</span>新增居民信息,也可在管理系统批量导入</p>
</div>
<div class="pad-b112"></div>
<div class="add-btn" @click="edit('')">
<div>新增居民</div>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'AppResidentDocument',
appName: '居民管理',
data () {
return {
keyword: '',
datas: [],
current: 1,
size: 20,
tabList: [
{
name: '本地居民',
},
{
name: '流动人员',
},
],
currentTabs: 0,
areaId: '',
isMore: false,
areaName: '',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
]
}
},
computed: {
...mapState(['user']),
},
onLoad () {
this.areaId = this.user.areaId
this.areaName = this.user.areaName
this.getList()
uni.$on('reload', () => {
this.current = 1
this.getList()
})
},
methods: {
onClick (index, i) {
if (i == 1) {
this.del(this.datas[index].id)
} else {
this.datas[index].show = false
this.edit(this.datas[index].id)
}
},
onOpen (index) {
this.datas[index].show = true
this.datas.map((val, i) => {
if(index != i) {
this.datas[i].show = false
}
})
},
getList() {
this.$loading()
this.$http.post('/app/appresident/list', null, {
params: {
size: this.size,
current: this.current,
con: this.keyword,
residentType: this.currentTabs == 0 ? '0' : '1',
}
}).then((res) => {
if (res.code == 0) {
this.datas = this.current > 1 ? [...this.datas, ...res.data.records.map(v => {
return {
...v,
show: false
}
})] : res.data.records.map(v => {
return {
...v,
show: false
}
})
this.pages = res.data.pages
if (this.current === 1 && !res.data.records.length) {
this.isMore = true
} else {
this.isMore = false
}
}
})
},
change(index) {
this.isMore = false
this.currentTabs = index
this.current = 1
this.datas = []
this.getList()
},
toDetailCard(item) {
uni.navigateTo({url: `./DetailCard?id=${item.id}`})
},
seachObj(e) {
this.areaId = e
this.current = 1
this.getList()
},
handerSearch(e) {
this.keyword = e
this.current = 1
this.getList()
},
handerClear() {
this.keyword = ''
this.current = 1
this.getList()
},
edit(id) {
uni.navigateTo({url: `./Add?id=${id}&type=${this.currentTabs}`})
},
del(id) {
this.$confirm('确定删除该数据?').then(() => {
uni.showLoading()
this.$http.post(`/app/appresident/delete?ids=${id}`).then((res) => {
if (res.code == 0) {
this.$u.toast('删除成功!')
this.current = 1
this.getList()
}
uni.hideLoading()
})
}).catch(() => {
})
}
},
onReachBottom() {
console.log("reachBottom")
this.current++
this.getList()
},
}
</script>
<style scoped lang="scss">
.AppResidentDocument {
height: 100%;
padding-top: 96rpx;
.tabs {
position: fixed;
left: 0;
top: 0;
z-index: 11;
width: 100%;
}
.areatop {
display: flex;
justify-content: space-between;
align-items: center;
}
.line {
height: 16px;
background: #f5f5f5;
}
.seachObjs {
border-bottom: 2px solid #f5f5f5;
border-top: 2px solid #f5f5f5;
padding: 20px 32px;
background: #fff;
}
::v-deep .u-form {
width: 100%;
.areaIds {
.u-form-item__body {
.u-form-item--right {
.u-form-item--right__content {
display: flex;
align-items: center;
.u-form-item--right__content__slot {
.AiAreaPicker {
width: 100%;
display: flex;
justify-content: flex-end;
.areaSelector {
.location {
opacity: 0;
}
}
}
}
.u-form-item--right__content__icon {
margin-bottom: 8px;
}
}
}
}
}
}
.dataes {
background: #fff;
.datass {
display: flex;
align-items: center;
height: 128rpx;
padding: 0 0 0 32px;
&:active {
background: #eee;
}
.left {
img {
width: 80px;
height: 80px;
border-radius: 50%;
}
}
.right {
display: flex;
justify-content: center;
flex-direction: column;
margin-left: 32px;
padding-right: 32px;
flex: 1;
height: 100%;
border-bottom: 1rpx solid #E4E5E6;
.rightTop {
font-size: 32px;
font-weight: 500;
color: #333333;
display: flex;
justify-content: space-between;
.btn {
img {
width: 48px;
height: 48px;
margin-left: 40px;
}
}
.tags {
max-width: 300px;
color: #999;
font-size: 28px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.rightBottom {
display: flex;
justify-content: space-between;
margin-top: 8px;
}
}
&:last-child {
.right {
border-bottom: none;
}
}
}
}
.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;
}
.empty {
height: 100%;
img {
width: 282px;
height: 306px;
margin: 168px 0 0 234px;
}
p {
text-align: center;
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
color: #999;
line-height: 44px;
span {
color: #467DFE;
}
}
}
}
</style>