x-admin 菜单栏 数据组装

var data_list  = [
		       	{
		    		"id": 1,
		    		"parentid": -1,
		    		"title": "管理员",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 2,
		    				"parentid": 1,
		    				"title": "管理导航",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "admin.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 3,
		    				"parentid": 1,
		    				"title": "数据统计",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "echarts/echarts_list.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 4,
		    				"parentid": 1,
		    				"title": "账号操作",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "account_management.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 5,
		    				"parentid": 1,
		    				"title": "账号管理",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "echarts/echarts_list.aspx",
		    				"children": [
		    					{
		    						"id": 6,
		    						"parentid": 5,
		    						"title": "账号删除",
		    						"icon": null,
		    						"spread": "true",
		    						"href": "Delete_lists.aspx",
		    						"children": []
		    					},
		    					{
		    						"id": 7,
		    						"parentid": 5,
		    						"title": "等级管理",
		    						"icon": null,
		    						"spread": "true",
		    						"href": "Delete_lists.aspx",
		    						"children": []
		    					}
		    				]
		    			}
		    		]
		    	},
		    	{
		    		"id": 8,
		    		"parentid": -1,
		    		"title": "订单管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 9,
		    				"parentid": 8,
		    				"title": "新建订单",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "create.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 10,
		    				"parentid": 8,
		    				"title": "订单列表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "Order_list/Order_list.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 11,
		    		"parentid": -1,
		    		"title": "生产管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 12,
		    				"parentid": 11,
		    				"title": "生产录入",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "production_list.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 13,
		    				"parentid": 11,
		    				"title": "生产汇总",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "ProductionSummary.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 14,
		    		"parentid": -1,
		    		"title": "品质管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 15,
		    				"parentid": 14,
		    				"title": "品质不良录入",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "quality.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 16,
		    				"parentid": 14,
		    				"title": "不良列表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "quality_bad.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 17,
		    		"parentid": -1,
		    		"title": "市场管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 18,
		    				"parentid": 17,
		    				"title": "出货管理",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "Shipments_list.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 19,
		    				"parentid": 17,
		    				"title": "已出报表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "ShipmentReport.aspx",
		    				"children": []
		    			},
		    			{
		    				"id": 20,
		    				"parentid": 17,
		    				"title": "欠交列表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "SubdueReport.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 21,
		    		"parentid": -1,
		    		"title": "仓储管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 22,
		    				"parentid": 21,
		    				"title": "仓储列表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "Web_cangchu.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 23,
		    		"parentid": -1,
		    		"title": "图号信息管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 24,
		    				"parentid": 23,
		    				"title": "图号信息列表",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "thLists.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 25,
		    		"parentid": -1,
		    		"title": "密码管理",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 26,
		    				"parentid": 25,
		    				"title": "重置密码",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "reset.aspx",
		    				"children": []
		    			}
		    		]
		    	},
		    	{
		    		"id": 27,
		    		"parentid": -1,
		    		"title": "操作手册",
		    		"icon": null,
		    		"spread": "true",
		    		"href": "#",
		    		"children": [
		    			{
		    				"id": 28,
		    				"parentid": 27,
		    				"title": "操作手册",
		    				"icon": null,
		    				"spread": "true",
		    				"href": "manual.aspx",
		    				"children": []
		    			}
		    		]
		    	}
		    ];
		
		//组装成菜单栏
		var table1 = "";
		for( var a = 0; a < data_list.length; a++){
			table1+='<li>';
			table1+='<a href="javascript:;">';
			table1+='<i class="iconfont left-nav-li" lay-tips='+data_list[a].title+'>'+data_list[a].icon+'</i>';
			table1+='<cite>'+data_list[a].title+'</cite>';
			table1+='<i class="iconfont nav_right">&#xe697;</i>';
			table1+='</a>';
			var two_list = data_list[a].children; //二级菜单
			if(two_list != undefined){
				table1+='<ul class="sub-menu">';
				for(var b=0;b<two_list.length;b++){
					table1+='<li>';
					if(two_list[b].href != ""){ //通过href 判断当前权限是否是需要添加事件
						table1+='<a onclick="xadmin.add_tab('+two_list[b].title+','+two_list[b].href+')">';
					}else{
						table1+='<a>';
					}
					if(two_list[b].children != undefined){ //通过判断当前权限是否有下级菜单 添加
						table1+='<i class="iconfont">'+two_list[b].icon+'</i>';
						table1+='<cite>'+two_list[b].title+'</cite>';
						table1+='<i class="iconfont nav_right">&#xe697;</i>';
					}else{
						table1+='<i class="iconfont">&#xe6a7;</i>';
						table1+='<cite>'+two_list[b].title+'</cite>';
					}
					table1+='</a>';
					var three_list = two_list[b].children; //三级菜单
					if(three_list != undefined){
						table1+='<ul class="sub-menu">';
						for ( var c = 0; c < three_list.length; c++) {
							table1+='<li>';
							table1+='<a onclick="xadmin.add_tab('+three_list[c].title+','+three_list[c].href+')">';
							table1+='<i class="iconfont">&#xe6a7;</i>';
							table1+='<cite>'+three_list[c].title+'</cite>';
							table1+='</a>';
							table1+='</li>';
						}
						table1+='</ul>';
					}
					table1+'</li>';
				}
				table1+='</ul>';
			}
			table1+='</li>';
		}
		
		$("#nav").append(table1);

 

posted @ 2022-08-04 19:13  码奴生来只知道前进~  阅读(18)  评论(0编辑  收藏  举报