-
Notifications
You must be signed in to change notification settings - Fork 3
/
jOrgChart-tree.html
155 lines (144 loc) · 5.31 KB
/
jOrgChart-tree.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jOrgChart - A jQuery OrgChart Plugin</title>
<link rel="stylesheet" href="asset/jquery.jOrgChart-tree.css"/>
<style>
a {
text-decoration: none;
color: #fff;
font-size: 12px;
}
.jOrgChart .node {
width: 120px;
height: 30px;
line-height: 30px;
border-radius: 4px;
background: #35363b;
}
</style>
</head>
<body>
<div id="jOrgChart" ></div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="asset/jquery.jOrgChart-tree.js"></script>
<script>
var data = {
"data": [{
"id": 1,
"name": "企业主体信用得分",
"pid": null,
"childrens": [{
"id": 2,
"name": "企业素质",
"pid": 1,
"childrens": [{
"id": 5,
"name": "基本信息",
"pid": 2,
"childrens": [{
"id": 10,
"name": "企业主体信息识别",
"pid": 5,
"childrens": []
},
{
"id": 11,
"name": "企业持续注册时间",
"pid": 5,
"childrens": []
},
{
"id": 12,
"name": "注册资本",
"pid": 5,
"childrens": []
}
]
},
{
"id": 6,
"name": "管理认证",
"pid": 2,
"childrens": [{
"id": 13,
"name": "国际性管理认证",
"pid": 6,
"childrens": []
}]
}
]
},
{
"id": 3,
"name": "履约记录",
"pid": 1,
"childrens": [{
"id": 7,
"name": "税务执行情况",
"pid": 3,
"childrens": [{
"id": 14,
"name": "是否按时缴纳税款",
"pid": 7,
"childrens": []
}]
},
{
"id": 8,
"name": "网贷情况",
"pid": 3,
"childrens": [{
"id": 15,
"name": "网贷逾期",
"pid": 8,
"childrens": []
}]
}
]
},
{
"id": 4,
"name": "公共监督",
"pid": 1,
"childrens": [{
"id": 9,
"name": "行政处罚",
"pid": 4,
"childrens": [{
"id": 16,
"name": "处罚信息",
"pid": 9,
"childrens": []
}]
}]
}
]
}]
}
function showall(menu_list, parent) {
$.each(menu_list, function (index, val) {
console.log(val);
if (val.childrens.length > 0) {
var li = $("<li></li>");
li.append("<a href='javascript:void(0)' onclick=getOrgId(" + val.id + ");>" + val.name +
"</a>").append("<ul></ul>").appendTo(parent);
//递归显示
showall(val.childrens, $(li).children().eq(1));
} else {
$("<li></li>").append("<a href='javascript:void(0)' onclick=getOrgId(" + val.id + ");>" +
val.name + "</a>").appendTo(parent);
}
});
}
var showlist = $("<ul id='org' style='display:none'></ul>");
showall(data.data, showlist);
$("#jOrgChart").append(showlist);
jQuery(document).ready(function() {
$("#org").jOrgChart({
chartElement : '#jOrgChart',
dragAndDrop : true
});
});
</script>
</body>
</html>