selectAdminCommunity.vue
1.51 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
<template>
<div 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 communitys"
:key="index"
@click="handleSwatchCommunity(item)"
:class="{'vc-node-selected': communityId === item.communityId}"
>
{{item.name}}
</li>
</ul>
</div>
</div>
</template>
<script>
import { listAdminCommunitys } from '@/api/iot/adminInoutApi'
export default {
name: 'SelectAdminCommunity',
data() {
return {
communitys: [],
communityId: ''
}
},
created() {
this.loadAdminCommunitys()
},
methods: {
async loadAdminCommunitys() {
try {
const params = {
_uid: '123mlkdinkldldijdhuudjdjkkd',
page: 1,
row: 100
}
const res = await listAdminCommunitys(params)
this.communitys = [
{ name: this.$t('adminInout.allCommunities'), communityId: '' },
...res.data
]
this.handleSwatchCommunity(this.communitys[0])
} catch (error) {
console.error('Failed to load communities:', error)
}
},
handleSwatchCommunity(community) {
this.communityId = community.communityId
this.$emit('change-community', community)
}
}
}
</script>
<style scoped>
.vc-node-selected {
background-color: #f5f7fa;
color: #409eff;
}
</style>