zoukankan      html  css  js  c++  java
  • js (jQuery)分组数据

    function getobjArr  (data) {
                    var result = [];
                    data.HELMET.system = '系统分类'
                    // console.log(data)
                    $.each(data.HELMET, function (index_h, elem_h) {
                        var h = {
                            id: index_h,
                            name: elem_h,
                            Projects: []
                        }
                        $(data.sonProjects).each(function (index_p, elem_p) {
                            elem_p.AppCategorys = [];
                            if (elem_p.sysCategory == 1) {
                                if (index_h == 'system') {
                                    h.Projects.push(elem_p);
                                }
                            } else {
                                if (index_h != 'system') {
                                    $(data.sonProjectAppCategorys).each(function (index_c, elem_c) {
                                        elem_c.childsList = [];
                                        if (elem_c.childs == '0') {
                                            if (elem_c.helmet == index_h && elem_c.spId == elem_p.spId && elem_c.pId == 0) {
                                                elem_p.AppCategorys.push(elem_c);
    
                                                // console.log(elem_p.AppCategorys)
                                            }
                                        } else {
                                            $(elem_c.childs.split(',')).each(function (index_ch, elem_ch) {
                                                var parent = $$.getobj(data.sonProjectAppCategorys, 'spacId', elem_ch);
                                                if (parent) {
                                                    parent.childsList = [];
                                                    if (parent.childs == '0') {
                                                        elem_c.childsList.push($.extend(true, {}, parent));
                                                    } else {
                                                        $(parent.childs.split(',')).each(function (index_cht, elem_cht) {
                                                            var child = $$.getobj(data.sonProjectAppCategorys, 'spacId', elem_cht);
                                                            parent.childsList.push($.extend(true, {}, child));
                                                        });
                                                        elem_c.childsList.push($.extend(true, {}, parent));
                                                    }
                                                }
                                            });
                                            if (elem_c.helmet == index_h && elem_c.spId == elem_p.spId && elem_c.pId == 0) { elem_p.AppCategorys.push(elem_c); }
                                        }
                                    })
    
                                    h.Projects.push(elem_p);
                                }
                            }
                        })
                        result.push($.extend(true, {}, h)); // 深复制
                    })
                    // console.log(result)
                    return result;
                };    
    

      

  • 相关阅读:
    全站301跳转 PHP
    linux flush memcache缓存
    php Memcache
    PHP MemCached win安装
    windows下安装memcache
    2013 年最好的 20 款免费 jQuery 插件
    License Manager 10.3启动失败解决方法
    .ecp认证文件(10.3版本)
    ArcGIS 10.3 安装及破解
    win7下安装MYSQL报错:"MYSQL 服务无法启动"的3534问题
  • 原文地址:https://www.cnblogs.com/Byme/p/8275185.html
Copyright © 2011-2022 走看看