selectAdminCommunity.vue
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<el-card class="border-radius">
<div class="margin-xs-r treeview attendance-staff" style="height: 650px;">
<ul class="list-group text-center border-radius">
<li
class="list-group-item node-orgTree"
v-for="(item,index) in selectAdminCommunityInfo.communitys"
:key="index"
@click="_swatchAdminCommunity(item)"
:class="{'vc-node-selected': selectAdminCommunityInfo.communityId == item.communityId}"
>
{{item.name}}
</li>
</ul>
</div>
</el-card>
</template>
<script>
export default {
name: 'SelectAdminCommunity',
data() {
return {
selectAdminCommunityInfo: {
communitys: [],
communityId: ''
}
}
},
created() {
this._loadAdminCommunitys()
},
methods: {
async _loadAdminCommunitys() {
const param = {
params: {
_uid: '123mlkdinkldldijdhuudjdjkkd',
page: 1,
row: 100
}
}
const _communistys = [{
name: this.$t('adminMeterRecharge.allCommunities'),
communityId: ''
}]
this.selectAdminCommunityInfo.communitys = _communistys
try {
const res = await this.$api.listAdminCommunitys(param)
res.data.forEach(c => {
_communistys.push(c)
})
this.selectAdminCommunityInfo.communitys = _communistys
this._swatchAdminCommunity(_communistys[0])
} catch (error) {
console.error('请求失败处理', error)
}
},
_swatchAdminCommunity(_community) {
this.selectAdminCommunityInfo.communityId = _community.communityId
this.$emit('changeCommunity', _community)
}
}
}
</script>
<style scoped>
.border-radius {
border-radius: 4px;
}
.margin-xs-r {
margin-right: 5px;
}
.treeview {
overflow-y: auto;
}
.list-group {
padding-left: 0;
margin-bottom: 0;
}
.list-group-item {
position: relative;
display: block;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
cursor: pointer;
}
.list-group-item:hover {
background-color: #f5f5f5;
}
.vc-node-selected {
background-color: #409EFF;
color: white;
}
</style>