?select '{'+'"id":'+'"'+MenuID+'",'+'"parent":"'+ParentID+'",'+'"FirstLvMenu":'+'"'+FirstLvMenu+'",
?"text":"'+MenuName+'","url":"'+MenuUrl+'","enable":"'+ltrim(rtrim(str(MDeep)))+'","HaveChild":"'+HaveChild+'","state":"{opened: true }","icon":"'+MICO_Path+'"'+'},'
?from T_Menu
?//--where? menuID in ('','')
order by MenuID
?//注意: "HaveChild": "0" 的才控制权限,=1说明有子节点,不控制权限
_menuid_list=当前操作员的权限
for (i = 0; i < menulist.length; i++) {
???? var _m_i = "," + menulist[i].id + ",";
???? menulist[i].tip = "";//空=显示
???? $('#' + menulist[i].id).removeClass("sr-only");//默认节点显示
???? if (menulist[i].HaveChild == "0") {//menulist[i].parent != "#" &&
???????? if (_menuid_list.indexOf(_m_i) >= 0) {//|| _rule == "超级管理员"
???????????? $('#' + menulist[i].id).attr('href', menulist[i].url);
?????? ? }
???????? else {
???????????? if (menulist[i].enable == "0") {
???????????????? //待开发中
???????????????? $('#' + menulist[i].id).attr('href', 'javascript:show_ahref("' + menulist[i].text + '",1)');
???????????????? menulist[i].tip = "1";
???????????????? $('#' + menulist[i].id).addClass("sr-only");
???????????? }
???????????? else {
???????????????? //无权限
???????????????? $('#' + menulist[i].id).attr('href', 'javascript:show_ahref("' + menulist[i].text + '",0)');
???????????????? menulist[i].tip = "0";
???????????????? $('#' + menulist[i].id).addClass("sr-only");
???????????? }
???????? }
???? }
?? ?
?}
?set_parents_menu(menulist);
/**
?* 设置父节点的显示隐藏,放在设置权限之后...
?* @param {所有节点列表} menulist
?*/
function set_parents_menu(menulist) {
??? //tip=""(显示),其他=隐藏
??? var lst = menulist.filter(function (item) {
??????? return item.HaveChild == "1";//找到所有父节点
??? });
??? for (var i = 0; i < lst.length; i++) {
??????? var id = lst[i].id;
??????? var lst_child = menulist.filter(function (item) {
??????????? return item.HaveChild == "1" && parent == id;
??????? });
??????? if (lst_child.length > 0) {
??????????? //当前节点下有子节点且子节点下还有子节点(多层子节点)
?????????? get_menu_parents(lst_child);
??????? }
??????? lst_child = menulist.filter(function (item) {
??????????? return item.tip=="" && item.parent == id;//子菜单有显示
??????? });
??????? var index = -1;//当前节点id在menulist里的索引
??????? menulist.filter(function (item, itemindex) {
??????????? if (item.id == id) { index = itemindex; }
??????????? return item.id == id;
??????? });
??????? if (index >= 0) {
?????????? menulist[index].tip = lst_child.length > 0 ? "" : "0";
?????????? if (lst_child.length > 0) {
??????????????? //显示
??????????????? $('#' + id).remove("sr-only");
??????????? }
??????????? else {
??????????????? $('#' + id).addClass("sr-only");
??????????? }
??????? }
??? }
};