js (jQuery)分组数据
2024-08-24 02:36:31
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;
};
最新文章
- 【超级干货】手机移动端WEB资源整合
- jQuery.is() 函数
- 使用Navicat导入导出表的数据做测试(转载)
- 第一次Sprint总结
- [C语言](一)第一个Windows 32 API的窗口程序
- poj 2507Crossed ladders <;计算几何>;
- 《VC++ 6简明教程》即VC++ 6.0入门精讲 学习进度及笔记
- mybatis 学习笔记(4) —— 批量新增数据
- EMV/PBOC 解析(一) 卡片文件结构
- linux 内核的spinlock
- [LeetCode] 二叉树相关题目(不完全)
- Linux配置文件系统及程序的限制 - ulimit
- laravel 【error】MethodNotAllowedHttpException No message
- django url 反响解析,视图
- IVIEW TREE问题总结
- 如何实现从 Redis 中订阅消息转发到 WebSocket 客户端
- C# asp.net webapi下支持文件下载输出接口
- win7 任务计划运行批处理,不能正常运行,需用绝对路径
- idea中使用tomcat 方式启动spring boot项目
- mysql中参数--init-file的作用是什么呢?
热门文章
- ubuntu18.04虚拟机安装docker
- Eclipse 在高分辨率4K显示器下图标按钮过小
- Python开发爆破字典
- Kali学习笔记8:四层发现
- spring cloud config配置记录
- 树莓派连接不上WiFi
- SpringDataJPA与Mybatis的优异性
- TypeError: Cannot red property &#39;style&#39; of null 错误解决
- spark最新源码下载并导入到开发环境下助推高质量代码(Scala IDEA for Eclipse和IntelliJ IDEA皆适用)(以spark2.2.0源码包为例)(图文详解)
- Selenuim自动化测试模型