a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
1
|
<template>
|
03f63ab4
wuxw
优化到商户信息
|
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<el-dialog
:title="$t('scheduleClassesPage.selectOrg')"
:visible.sync="dialogVisible"
width="60%"
>
<el-tree
ref="orgTree"
:data="chooseOrgInfo.orgs"
:props="defaultProps"
node-key="id"
highlight-current
@node-click="handleNodeClick"
/>
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
15
|
<span slot="footer" class="dialog-footer">
|
03f63ab4
wuxw
优化到商户信息
|
16
17
|
<el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="_doChooseOrg">{{ $t('common.confirm') }}</el-button>
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
18
19
20
|
</span>
</el-dialog>
</template>
|
03f63ab4
wuxw
优化到商户信息
|
21
|
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
22
|
<script>
|
03f63ab4
wuxw
优化到商户信息
|
23
24
|
import { getCommunityId } from '@/api/community/communityApi'
import { listOrgTree } from '@/api/org/orgApi'
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
25
26
27
28
29
|
export default {
name: 'ChooseOrgTree',
data() {
return {
|
03f63ab4
wuxw
优化到商户信息
|
30
31
32
33
34
35
|
dialogVisible: false,
chooseOrgInfo: {
orgs: [],
orgId: '',
curOrg: {}
},
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
36
37
|
defaultProps: {
children: 'children',
|
56732765
wuxw
修改员工界面部分bug
|
38
|
label: 'text'
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
39
40
41
42
|
}
}
},
methods: {
|
03f63ab4
wuxw
优化到商户信息
|
43
44
45
|
open() {
this.dialogVisible = true
this._loadChooseOrgs()
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
46
|
},
|
03f63ab4
wuxw
优化到商户信息
|
47
|
async _loadChooseOrgs() {
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
48
|
try {
|
03f63ab4
wuxw
优化到商户信息
|
49
50
51
52
|
const params = {
communityId: getCommunityId()
}
const { data } = await listOrgTree(params)
|
56732765
wuxw
修改员工界面部分bug
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// 确保数据是数组格式
let treeData = data
// 如果返回的是对象而不是数组,尝试提取数组
if (Array.isArray(treeData)) {
this.chooseOrgInfo.orgs = treeData
} else if (treeData && Array.isArray(treeData.children)) {
this.chooseOrgInfo.orgs = treeData.children
} else if (treeData && Array.isArray(treeData.data)) {
this.chooseOrgInfo.orgs = treeData.data
} else if (treeData && Array.isArray(treeData.list)) {
this.chooseOrgInfo.orgs = treeData.list
} else {
// 如果都不是数组,转换为数组格式
this.chooseOrgInfo.orgs = Array.isArray(treeData) ? treeData : [treeData]
}
// 确保每个节点都有 children 属性且为数组
this.processTreeData(this.chooseOrgInfo.orgs)
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
73
|
} catch (error) {
|
03f63ab4
wuxw
优化到商户信息
|
74
|
console.error('获取组织树失败:', error)
|
56732765
wuxw
修改员工界面部分bug
|
75
|
this.chooseOrgInfo.orgs = []
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
76
77
|
}
},
|
56732765
wuxw
修改员工界面部分bug
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
processTreeData(nodes) {
if (!Array.isArray(nodes)) return
nodes.forEach(node => {
// 确保每个节点都有 children 属性且为数组
if (!node.children) {
node.children = []
} else if (!Array.isArray(node.children)) {
node.children = []
}
// 递归处理子节点
if (node.children && node.children.length > 0) {
this.processTreeData(node.children)
}
})
},
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
95
|
handleNodeClick(data) {
|
03f63ab4
wuxw
优化到商户信息
|
96
97
|
this.chooseOrgInfo.curOrg = data
this.chooseOrgInfo.curOrg.orgId = data.id
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
98
|
},
|
03f63ab4
wuxw
优化到商户信息
|
99
100
101
|
_doChooseOrg() {
this.$emit('switchOrg', this.chooseOrgInfo.curOrg)
this.dialogVisible = false
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
102
103
104
105
|
}
}
}
</script>
|
03f63ab4
wuxw
优化到商户信息
|
106
|
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
107
|
<style lang="scss" scoped>
|
03f63ab4
wuxw
优化到商户信息
|
108
109
110
|
::v-deep .el-dialog__body {
padding: 20px;
max-height: 60vh;
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
111
112
113
|
overflow-y: auto;
}
</style>
|