Diagram.vue
2.24 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
<template>
<transition name="el-zoom-in-center">
<div class="NCC-preview-main user-form">
<div class="NCC-common-page-header">
<el-page-header @back="goBack" content="组织架构图" />
<div class="options">
<el-button @click="goBack">{{$t('common.cancelButton')}} </el-button>
</div>
</div>
<div class="main" v-loading="loading">
<organization-chart :datasource="ds"></organization-chart>
</div>
</div>
</transition>
</template>
<script>
import { getDepartmentSelector } from '@/api/permission/department'
import OrganizationChart from 'vue-organization-chart'
import 'vue-organization-chart/dist/orgchart.css'
export default {
components: {
OrganizationChart
},
data() {
return {
loading: false,
ds: {}
}
},
methods: {
init() {
this.loading = true
getDepartmentSelector().then(res => {
let data = res.data.list
let _this = this
const loop = list => {
for (let i = 0; i < list.length; i++) {
_this.$set(list[i], 'name', list[i].fullName)
if (list[i].children && Array.isArray(list[i].children) && list[i].children.length) {
loop(list[i].children)
}
}
}
loop(data)
this.$nextTick(() => {
if (data.length >= 1) {
data = {
name: '组织架构图',
children: data
}
}
this.ds = data
this.loading = false
})
}).catch(() => { this.loading = false })
},
goBack() {
this.$emit('close')
}
}
}
</script>
<style lang="scss" scoped>
>>> .orgchart-container {
height: 95%;
border: none !important;
.orgchart {
background: none !important;
.node {
&:hover {
background-color: transparent !important;
}
.title {
background-color: #1890ff;
}
.content {
border: 1px solid #1890ff;
}
}
}
.orgchart .lines {
.rightLine {
border-right: 1px solid #1890ff;
}
.leftLine {
border-left: 1px solid #1890ff;
}
.topLine {
border-top: 2px solid #1890ff;
}
.downLine {
background-color: #1890ff;
}
}
}
</style>