Files
dvcp_v2_wxcp_app/src/apps/AppGridManagement/SetGird.vue

461 lines
12 KiB
Vue
Raw Normal View History

2022-01-13 14:41:10 +08:00
<template>
<div class="setGird">
<div class="header-middle">
<div class="hint">
<span v-for="(item, index) in slectList" :key="index"><span v-if="index" style="margin:0 4px;">/</span><span style="color:#3F8DF5" @click="girdNameClick(item, index)">{{item.girdName}}</span></span>
</div>
<div class="showTypes" v-if="!userList.length">
<div v-if="treeList.length > 0">
2022-01-14 10:56:52 +08:00
<div class="cards" v-for="(item, index) in treeList" :key="index">
2022-01-13 14:41:10 +08:00
<div class="imges">
2022-01-14 10:56:52 +08:00
<span v-if="item.girdRight == 1 && item.girdLevel != 2">
2022-01-13 14:41:10 +08:00
<img src="./components/img/xzh.png" alt="" class="imgselect" v-if="item.isChecked" @click.stop="girdClick(item, index)" />
<img src="./components/img/xz.png" alt="" class="imgselect" v-else @click.stop="girdClick(item, index)" />
</span>
2022-01-17 14:11:48 +08:00
<span v-else style="width:24px;"></span>
2022-01-13 14:41:10 +08:00
<img src="./components/img/gird--select-icon.png" alt="" class="avatras" />
</div>
<div class="rightes">
2022-01-14 10:56:52 +08:00
<div class="applicationNames" @click="showGirdInfo(item)">{{ item.girdName }}</div>
<img src="./components/img/right-icon.png" alt="" class="imgs" v-if="item.girdLevel != 2" @click="itemClick(item)" />
2022-01-13 14:41:10 +08:00
</div>
</div>
</div>
<AiEmpty description="暂无数据" class="emptyWrap" v-else></AiEmpty>
</div>
</div>
2022-01-14 14:41:52 +08:00
<!-- <div style="padding-bottom: 70px;"></div> -->
2022-01-13 14:41:10 +08:00
<div class="subBtn" @click="toAddGird">
<div>添加网格</div>
</div>
2022-01-14 11:43:17 +08:00
<u-popup v-model="show" mode="bottom" border-radius="14" height="1000">
2022-01-13 14:41:10 +08:00
<div class="popup">
<div class="bg"></div>
<div class="title">{{ form.girdName }}</div>
2022-01-14 10:56:52 +08:00
<div class="info-flex">
2022-01-13 14:41:10 +08:00
<span class="label">网格类型</span>
2022-01-14 10:56:52 +08:00
<span class="value">{{ $dict.getLabel('girdType', form.girdType) }}</span>
2022-01-13 14:41:10 +08:00
</div>
<div class="info-flex">
<span class="label">网格层级</span>
2022-01-14 10:56:52 +08:00
<span class="value">{{ $dict.getLabel('girdLevel', form.girdLevel) }}</span>
2022-01-13 14:41:10 +08:00
</div>
2022-01-14 10:56:52 +08:00
<div v-if="form.girdMemberManageList && form.girdMemberManageList.length">
<div class="info-flex" v-for="(item, index) in form.girdMemberManageList" :key="index">
2022-01-14 14:24:09 +08:00
<span class="label">网格长</span>
2022-01-14 10:56:52 +08:00
<span class="value">{{ item.name }}&nbsp;&nbsp;{{ item.phone }}
<img :src="$cdn + 'common/phone.png'" alt="" @click="callPhone(item.phone)" class="phone-icon"
v-if="item.phone">
</span>
</div>
2022-01-13 14:41:10 +08:00
</div>
2022-01-14 10:56:52 +08:00
<div v-if="form.girdMemberList && form.girdMemberList.length">
<div class="info-flex" v-for="(item, index) in form.girdMemberList" :key="index">
<span class="label">网格员</span>
<span class="value">{{ item.name }}&nbsp;&nbsp;{{ item.phone }}
<img :src="$cdn + 'common/phone.png'" alt="" @click="callPhone(item.phone)" class="phone-icon"
v-if="item.phone">
</span>
</div>
2022-01-13 14:41:10 +08:00
</div>
2022-01-14 13:46:06 +08:00
<div style="height:56px;"></div>
2022-01-14 10:56:52 +08:00
<div class="btn" v-if="form.girdRight == 1">
<span class="del" @click="del">删除网格</span>
<span class="edit" @click="edit">编辑网格</span>
2022-01-13 14:41:10 +08:00
</div>
</div>
</u-popup>
</div>
</template>
<script>
export default {
name: 'setGird',
data() {
return {
setGird: {},
allData: null,
treeList: [],
slectList: [],
userList: [],
2022-01-14 10:56:52 +08:00
show: false,
form: {},
2022-01-13 14:41:10 +08:00
}
},
onLoad() {
2022-01-14 10:56:52 +08:00
this.$dict.load('girdType', 'girdLevel')
this.isGirdUser()
2022-01-14 13:46:06 +08:00
uni.$on('update', () => {
this.show = false
this.getTree()
})
2022-01-13 14:41:10 +08:00
},
methods: {
2022-01-14 10:56:52 +08:00
isGirdUser() {
this.$http.post('/app/appgirdmemberinfo/checkLogOnUser').then((res) => {
if (res.code == 0) {
if (res.data.checkType) {
this.userGird = res.data
this.getTree()
} else {
this.$u.toast('当前人员不是网格员或网格管理员')
}
}
})
},
2022-01-13 14:41:10 +08:00
getTree() {
this.slectList = []
2022-01-14 10:56:52 +08:00
this.$http.post(`/app/appgirdinfo/queryAppGirdInfoByGirdLevel?girdLevel=0&girdMemberId=${this.userGird.girdMemberId}&parentGirdId=`).then((res) => {
2022-01-13 14:41:10 +08:00
if (res?.data) {
this.allData = res.data
this.treeInit()
}
})
},
treeInit() {
2022-01-14 10:56:52 +08:00
this.treeList = this.allData
this.treeList.map((item) => {
item.isChecked = false
})
2022-01-13 14:41:10 +08:00
var obj = {
2022-01-14 10:56:52 +08:00
girdName: '可选范围',
id: '',
girdLevel: ''
2022-01-13 14:41:10 +08:00
}
this.slectList.push(obj)
},
itemClick(row) {
2022-01-14 10:56:52 +08:00
if(row.girdLevel == 2) return
2022-01-13 14:41:10 +08:00
var obj = {
girdName: row.girdName,
id: row.id,
girdLevel: row.girdLevel
}
this.slectList.push(obj)
this.searckGird(row)
},
searckGird(row) {
2022-01-14 10:56:52 +08:00
if(row.girdLevel == 2) return
var girdLevel = Number(row.girdLevel)+1
this.$http.post(`/app/appgirdinfo/queryAppGirdInfoByGirdLevel?girdLevel=${girdLevel}&girdMemberId=${this.userGird.girdMemberId}&parentGirdId=${row.id}`).then((res) => {
if (res?.data) {
this.treeList = res.data
2022-01-17 14:11:48 +08:00
this.setGird = {}
2022-01-14 10:56:52 +08:00
}
})
2022-01-13 14:41:10 +08:00
},
girdNameClick(row, index) {
this.userList = []
if(!index) { //第一级别
this.slectList = []
this.treeInit()
}else {
var list = []
this.slectList.map((item, i) => {
if(i <= index) {
list.push(item)
}
})
this.slectList = list
this.searckGird(row)
}
},
girdClick(row, index) {
if (this.treeList[index].isChecked) {//取消
this.treeList[index].isChecked = false
this.setGird = {}
} else {
this.treeList.map((item) => {
item.isChecked = false
})
this.treeList[index].isChecked = true
this.setGird = row
}
this.$forceUpdate()
},
2022-01-14 10:56:52 +08:00
showGirdInfo(row) {
this.show = true
this.form = row
},
del() {
this.$confirm(`是否删除该网格?`).then(() => {
this.$http.post(`/app/appgirdinfo/delete?ids=${this.form.id}`).then((res) => {
if (res.code == 0) {
this.$u.toast('删除成功!')
2022-01-17 15:21:12 +08:00
this.show = false
this.form = {}
2022-01-14 10:56:52 +08:00
this.treeList = []
this.isGirdUser()
}
2022-01-17 14:56:19 +08:00
}).catch((err) => {
this.$u.toast(err)
2022-01-13 14:41:10 +08:00
})
2022-01-14 10:56:52 +08:00
})
2022-01-13 14:41:10 +08:00
},
2022-01-14 10:56:52 +08:00
edit() {
uni.navigateTo({url: `./AddGird?id=${this.form.id}&fromType=edit`})
2022-01-13 14:41:10 +08:00
},
callPhone(phone) {
uni.makePhoneCall({phoneNumber: phone})
},
toAddGird() {
2022-01-14 10:56:52 +08:00
if (this.setGird.id != null) {
uni.navigateTo({url: `./AddGird?id=${this.setGird.id}&fromType=add`})
} else {
return this.$u.toast('请选择网格')
}
2022-01-13 14:41:10 +08:00
}
}
}
</script>
<style scoped lang="scss">
.setGird {
height: 100%;
background: #fff;
2022-01-14 14:41:52 +08:00
padding-bottom: 140px;
2022-01-13 14:41:10 +08:00
.header-top {
background: #fff;
padding: 20px 32px;
}
.header-middle {
.hint {
padding: 28px 20px 28px 32px;
line-height: 56px;
box-shadow: 0px 1px 0px 0px #e4e5e6;
font-size: 30px;
font-weight: 500;
word-break: break-all;
}
.showTypes {
.empty-div {
height: 16px;
background: #f5f5f5;
}
.cards {
display: flex;
align-items: center;
height: 120px;
line-height: 120px;
// background: pink;
padding: 0 0 0 32px;
.imges {
display: flex;
align-items: center;
// width: 200px;
.imgselect {
width: 48px;
height: 48px;
vertical-align: middle;
}
.avatras {
width: 74px;
height: 74px;
border-radius: 8px;
margin-left: 36px;
}
}
img {
width: 74px;
height: 74px;
border-radius: 8px;
}
.rightes {
2022-01-17 14:11:48 +08:00
width: calc(100% - 140px);
2022-01-13 14:41:10 +08:00
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 32px;
border-bottom: 1px solid #e4e5e6;
.applicationNames {
2022-01-17 14:11:48 +08:00
width: calc(100% - 56px);
2022-01-13 14:41:10 +08:00
font-size: 36px;
font-weight: 500;
color: #333333;
2022-01-17 14:11:48 +08:00
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
2022-01-13 14:41:10 +08:00
}
.imgs {
width: 40px;
height: 40px;
margin-right: 20px;
}
}
}
}
.showUsers {
.cards {
display: flex;
align-items: center;
height: 120px;
line-height: 120px;
// background: pink;
padding: 0 0 0 32px;
.imges {
display: flex;
align-items: center;
width: 200px;
.imgselect {
width: 48px;
height: 48px;
}
.avatras {
width: 74px;
height: 74px;
border-radius: 8px;
margin-left: 36px;
}
}
.rights {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 32px;
border-bottom: 1px solid #e4e5e6;
padding-right: 40px;
.applicationNames {
font-size: 36px;
font-weight: 500;
color: #333333;
}
.idNumbers {
color: #666;
}
}
}
}
}
.subBtn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 118px;
background: #f4f8fb;
div {
width: 192px;
height: 80px;
line-height: 80px;
text-align: center;
background: #1365dd;
border-radius: 4px;
font-size: 32px;
color: #fff;
margin: 20px 34px 0 0;
float: right;
}
}
.popup {
padding: 0 32px 16px;
.bg {
width: 64px;
height: 10px;
background: #CCC;
border-radius: 6px;
margin: 32px 0 32px 344px;
}
.title {
font-size: 36px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
line-height: 50px;
margin-bottom: 24px;
}
.info-flex {
padding: 26px 0 30px 0;
width: 100%;
border-bottom: 1px solid #D8DDE6;
line-height: 40px;
font-size: 28px;
.label {
display: inline-block;
width: 160px;
font-weight: 800;
color: #333;
}
.value {
color: #666;
font-size: 26px;
.phone-icon {
width: 40px;
height: 40px;
vertical-align: sub;
margin-left: 16px;
}
}
}
.border-b0{
border-bottom: 0;
}
.btn{
2022-01-14 13:46:06 +08:00
width: 100%;
padding: 32px;
box-sizing: border-box;
2022-01-13 14:41:10 +08:00
background-color: #fff;
display: flex;
2022-01-14 13:46:06 +08:00
position: fixed;
bottom: 0;
left: 0;
2022-01-13 14:41:10 +08:00
span{
display: inline-block;
height: 92px;
line-height: 90px;
border-radius: 8px;
font-size: 34px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
box-sizing: border-box;
text-align: center;
}
.del{
color: #f46;
border: 1px solid #f46;
flex: 1;
margin-right: 32px;
}
.edit{
background-color: #3671EE;
color: #fff;
flex: 2;
}
}
}
}
</style>