|
@@ -38,8 +38,9 @@ func BuildTree(root string, treeSrcs []map[string]interface{}) ([]*models.TreeNo
|
|
|
text := toString(params[textFiled], "")
|
|
text := toString(params[textFiled], "")
|
|
|
//json,_ := xorm.JSONString(params, true)
|
|
//json,_ := xorm.JSONString(params, true)
|
|
|
// 如果根节点root为空,则从parent为空中获取root节点数组
|
|
// 如果根节点root为空,则从parent为空中获取root节点数组
|
|
|
- // 如果root不为空,则获取id等于的节点为root节点数组
|
|
|
|
|
- if (parentValue == "" && parent == "") || value == parentValue {
|
|
|
|
|
|
|
+ // 如果root不为空且treeSrcs中包含id为root的,则获取id等于的节点为root节点数组(相当于显示root节点的树)
|
|
|
|
|
+ // 如果root不为空且treeSrcs中不包含id为root的,则获取parent等于的节点为root节点数组(相当于不显示root节点的树)
|
|
|
|
|
+ if (parentValue == "" && parent == "") || value == parentValue || parent == parentValue {
|
|
|
node := &models.TreeNode{
|
|
node := &models.TreeNode{
|
|
|
Id: value,
|
|
Id: value,
|
|
|
Text: text,
|
|
Text: text,
|