You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										102
									
								
								hyhproject/admin/view/menus/list.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										102
									
								
								hyhproject/admin/view/menus/list.html
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,102 @@
 | 
			
		||||
{extend name="base" /}
 | 
			
		||||
{block name="css"}
 | 
			
		||||
<link href="__ADMIN__/js/ztree/css/zTreeStyle/zTreeStyle.css?v={$v}" rel="stylesheet" type="text/css" />
 | 
			
		||||
<link rel="stylesheet" type="text/css" href="__ADMIN__/js/mmgrid/mmGrid.css?v={$v}" />
 | 
			
		||||
{/block}
 | 
			
		||||
{block name="js"}
 | 
			
		||||
<script src="__ADMIN__/js/ztree/jquery.ztree.all-3.5.js?v={$v}"></script>
 | 
			
		||||
<script src="__ADMIN__/js/mmgrid/mmGrid.js?v={$v}" type="text/javascript"></script>
 | 
			
		||||
<script src="__ADMIN__/menus/menu.js?v={$v}" type="text/javascript"></script>
 | 
			
		||||
{/block}
 | 
			
		||||
{block name="main"}
 | 
			
		||||
<div id='alertTips' class='alert alert-success alert-tips fade in'>
 | 
			
		||||
  <div id='headTip' class='head'><i class='fa fa-lightbulb-o'></i>操作说明</div>
 | 
			
		||||
  <ul class='body'>
 | 
			
		||||
    <li>左侧为菜单栏,点击菜单,然后再点击右键添加菜单,菜单中的图标使用<a href='http://fontawesome.dashgame.com/' target='_blank'>Fontawesome</a>图标,不需要fa-前缀。</li>
 | 
			
		||||
    <li>右侧为菜单对应的操作权限。若想为系统添加一个菜单则要一个设置为“菜单权限”的权限,该菜单才能显示。</li>
 | 
			
		||||
    <li>该功能为开发者功能,普通使用者请勿随意修改,以免影响系统使用。</li>
 | 
			
		||||
  </ul>
 | 
			
		||||
</div>
 | 
			
		||||
<div class="j-layout">
 | 
			
		||||
    <div class='j-layout-left'>
 | 
			
		||||
        <div class='j-layout-panel layui-colla-title'>菜单管理</div>
 | 
			
		||||
        <ul id="menuTree" class="ztree" style='overflow:auto'></ul>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class='j-layout-center' style='border:1px solid #ccc;float:left;margin-left:5px;'>
 | 
			
		||||
      <div class='j-layout-panel layui-colla-title'>权限管理</div>
 | 
			
		||||
      {if WSTGrant('QXGL_01')}
 | 
			
		||||
      <div class="wst-toolbar" style='display:none'>
 | 
			
		||||
          <button class="btn btn-success btn-sm f-right" onclick='javascript:toEdit(0)'><i class='fa fa-plus'></i>新 增</button>
 | 
			
		||||
          <div style='clear:both'></div>
 | 
			
		||||
      </div>
 | 
			
		||||
      {/if}
 | 
			
		||||
      <div id="maingrid"  style='display:none'>
 | 
			
		||||
        <div id="mmg" class="mmg"></div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div style='clear:both;'></div>
 | 
			
		||||
</div>
 | 
			
		||||
<div id='menuBox' style='display:none'>
 | 
			
		||||
<form id='menuForm'>
 | 
			
		||||
  <input type='hidden' id='parentId' class='ipt2' maxLength='20'/>
 | 
			
		||||
  <table class='wst-form wst-box-top'>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>菜单名称<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='menuName' class='ipt2' maxLength='20' data-rule="菜单名称: required;"/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>菜单图标<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='menuIcon' class='ipt2' maxLength='20'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>菜单排序<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='menuSort' class='ipt2' maxLength='5'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
  </table>
 | 
			
		||||
</form>
 | 
			
		||||
</div>
 | 
			
		||||
<div id='privilegeBox' style='display:none'>
 | 
			
		||||
  <form id='privilegeForm' autocomplete='off'>
 | 
			
		||||
  <table class='wst-form wst-box-top'>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>权限名称<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='privilegeName' class='ipt' maxLength='20' data-rule="权限名称: required;"/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th>权限代码<font color='red'>*</font>:</th>
 | 
			
		||||
        <td>
 | 
			
		||||
        <input type='hidden' id='privilegeId' value="0" />
 | 
			
		||||
        <input type='text' id='privilegeCode' class='ipt' maxLength='30' onblur='javascript:checkPrivilegeCode(this)' data-rule="权限代码: required;"/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th>是否菜单权限<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='24'>
 | 
			
		||||
           <label>
 | 
			
		||||
              <input type="radio" id="isMenuPrivilege1" name="isMenuPrivilege" class="ipt" value="1">是
 | 
			
		||||
           </label>
 | 
			
		||||
           <label>
 | 
			
		||||
              <input type="radio" id="isMenuPrivilege1" name="isMenuPrivilege" class="ipt" value="0" checked>否
 | 
			
		||||
           </label>
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th>权限资源:</th>
 | 
			
		||||
        <td><input type='text' id='privilegeUrl' class='ipt' maxLength='100' style='width:90%'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th>关联资源:<br/>(以,号分隔)   </th>
 | 
			
		||||
        <td>
 | 
			
		||||
        <textarea id='otherPrivilegeUrl' class='ipt' style='width:90%;height:60px;'></textarea>
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
  </table>
 | 
			
		||||
  </form>
 | 
			
		||||
</div>
 | 
			
		||||
<div id="rMenu">
 | 
			
		||||
  <ul>
 | 
			
		||||
    {if WSTGrant('CDGL_01')}<li id="m_add" >新增菜单</li>{/if}
 | 
			
		||||
    {if WSTGrant('CDGL_02')}<li id="m_edit">编辑菜单</li>{/if}
 | 
			
		||||
    {if WSTGrant('CDGL_03')}<li id="m_del" style='border-bottom:0px;'>删除菜单</li>{/if}
 | 
			
		||||
  </ul>
 | 
			
		||||
</div>
 | 
			
		||||
{/block}
 | 
			
		||||
							
								
								
									
										252
									
								
								hyhproject/admin/view/menus/menu.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										252
									
								
								hyhproject/admin/view/menus/menu.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,252 @@
 | 
			
		||||
var zTree,mmg,rMenu;
 | 
			
		||||
function layout(){
 | 
			
		||||
	var h = WST.pageHeight();
 | 
			
		||||
	var w = WST.pageWidth();
 | 
			
		||||
	$('.j-layout').width(w-8);
 | 
			
		||||
	$('.j-layout-left').width(200).height(h-113);
 | 
			
		||||
	$('.j-layout-center').width(w-220).height(h-113);
 | 
			
		||||
	$('#headTip').WSTTips({width:90,height:35,callback:function(v){
 | 
			
		||||
		 var diff = v?113:53;
 | 
			
		||||
		 $('.j-layout-left').height(h-diff);
 | 
			
		||||
		 $('#menuTree').height(h-diff-40);
 | 
			
		||||
		 $('.j-layout-center').height(h-diff);
 | 
			
		||||
    }});
 | 
			
		||||
}
 | 
			
		||||
function initGrid(){
 | 
			
		||||
	var cols = [
 | 
			
		||||
            {title:'权限名称', name:'privilegeName', width: 130},
 | 
			
		||||
            {title:'权限代码', name:'privilegeCode' ,width:60},
 | 
			
		||||
            {title:'是否菜单权限', name:'isMenuPrivilege' ,width:50,renderer: function(val){
 | 
			
		||||
                return (val==1)?"<span class='statu-yes'><i class='fa fa-check-circle'></i> 是 </span>":"<span class='statu-no'><i class='fa fa-ban'></i> 否 </span>";
 | 
			
		||||
            }},
 | 
			
		||||
            {title:'权限资源', name:'privilegeUrl' ,width:150},
 | 
			
		||||
            {title:'关联资源', name:'otherPrivilegeUrl' },
 | 
			
		||||
            {title:'操作', name:'' ,width:110, align:'center', renderer: function(val,item,rowIndex){
 | 
			
		||||
                var h = "";
 | 
			
		||||
			    if(WST.GRANT.QXGL_02)h += "<button  class='btn btn-blue' onclick='javascript:getForEdit(" + item['privilegeId'] + ")'><i class='fa fa-pencil'></i>编辑</button> ";
 | 
			
		||||
			    if(WST.GRANT.QXGL_03)h += "<button  class='btn btn-red' onclick='javascript:toDel(" + item['privilegeId'] + ")'><i class='fa fa-trash-o'></i>删除</button> ";
 | 
			
		||||
                return h;
 | 
			
		||||
            }}
 | 
			
		||||
            ];
 | 
			
		||||
 
 | 
			
		||||
    mmg = $('.mmg').mmGrid({height: 'auto',indexCol: true, cols: cols,method:'POST',nowrap: true,
 | 
			
		||||
        url: WST.U("admin/privileges/listQuery"), fullWidthRows: true, autoLoad: false
 | 
			
		||||
    });  
 | 
			
		||||
    $('#m_add').click(function(){
 | 
			
		||||
		treeNode = zTree.getSelectedNodes()[0];
 | 
			
		||||
        editMenu({menuId:0,menuName:'',menuIcon:'',parentId:treeNode.id,pnode:treeNode,menuSort:0});
 | 
			
		||||
	});
 | 
			
		||||
	$('#m_edit').click(function(){
 | 
			
		||||
		treeNode = zTree.getSelectedNodes()[0];
 | 
			
		||||
        getForEditMenu(treeNode.id);
 | 
			
		||||
        return false;
 | 
			
		||||
	});
 | 
			
		||||
	$('#m_del').click(function(){
 | 
			
		||||
		treeNode = zTree.getSelectedNodes()[0];
 | 
			
		||||
                  	layer.confirm('您确定要删除该菜单['+treeNode.name+']吗?', {btn: ['确定','取消']}, function(){
 | 
			
		||||
                  	    var loading = WST.msg('正在提交请求,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
                  	    $.post(WST.U('admin/menus/del'),{id:treeNode.id},function(data,textStatus){
 | 
			
		||||
                  		     layer.close(loading);
 | 
			
		||||
                  		     var json = WST.toAdminJson(data);
 | 
			
		||||
                  		     if(json.status=='1'){
 | 
			
		||||
                  		          WST.msg("操作成功",{icon:1});
 | 
			
		||||
                  		          zTree.reAsyncChildNodes(treeNode.getParentNode(), "refresh",true);
 | 
			
		||||
                  		     }else{
 | 
			
		||||
                  		          WST.msg(json.msg,{icon:2});
 | 
			
		||||
                  		     }
 | 
			
		||||
                  		 });
 | 
			
		||||
                      });
 | 
			
		||||
        return false;
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
$(window).resize(function(){layout();});
 | 
			
		||||
$(function(){
 | 
			
		||||
	layout();
 | 
			
		||||
	$('#menuTree').height(WST.pageHeight()-153);
 | 
			
		||||
	var setting = {
 | 
			
		||||
	      view: {
 | 
			
		||||
	           selectedMulti: false,
 | 
			
		||||
	           dblClickExpand:false
 | 
			
		||||
	      },
 | 
			
		||||
	      async: {
 | 
			
		||||
	           enable: true,
 | 
			
		||||
	           url:WST.U('admin/menus/listQuery'),
 | 
			
		||||
	           autoParam:["id", "name=n", "level=lv"]
 | 
			
		||||
	      },
 | 
			
		||||
	      callback:{
 | 
			
		||||
	           onRightClick: onRightClick,
 | 
			
		||||
	           onClick: onClick,
 | 
			
		||||
	           onAsyncSuccess: onAsyncSuccess
 | 
			
		||||
	      }
 | 
			
		||||
	};
 | 
			
		||||
	$.fn.zTree.init($("#menuTree"), setting);
 | 
			
		||||
	zTree = $.fn.zTree.getZTreeObj("menuTree");
 | 
			
		||||
	rMenu = $("#rMenu");
 | 
			
		||||
	initGrid();
 | 
			
		||||
})
 | 
			
		||||
function loadPrivileges(id){
 | 
			
		||||
    mmg.load({page:1,id:id});       
 | 
			
		||||
}
 | 
			
		||||
function onAsyncSuccess(event, treeId, treeNode, msg){
 | 
			
		||||
	var json = WST.toAdminJson(msg);
 | 
			
		||||
	if(json && json.id==0){
 | 
			
		||||
		var treeNode = zTree.getNodeByTId('menuTree_1');
 | 
			
		||||
		zTree.reAsyncChildNodes(treeNode, "refresh",true);
 | 
			
		||||
		zTree.expandAll(treeNode,true);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
function onClick(e,treeId, treeNode){
 | 
			
		||||
	if(treeNode.id>0){
 | 
			
		||||
	      $('.wst-toolbar').show();
 | 
			
		||||
	      $('#maingrid').show();
 | 
			
		||||
	}else{
 | 
			
		||||
	    $('.wst-toolbar').hide();
 | 
			
		||||
	    $('#maingrid').hide();
 | 
			
		||||
	}
 | 
			
		||||
	loadPrivileges(treeNode.id);
 | 
			
		||||
}
 | 
			
		||||
function onRightClick(event, treeId, treeNode) {
 | 
			
		||||
	if(!treeNode)return;
 | 
			
		||||
	if(!WST.GRANT.CDGL_01 && !WST.GRANT.CDGL_02 && !WST.GRANT.CDGL_03)return;
 | 
			
		||||
	if(!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) {
 | 
			
		||||
		zTree.cancelSelectedNode();
 | 
			
		||||
		showRMenu("root", event.clientX, event.clientY);
 | 
			
		||||
	}else if(treeNode && !treeNode.noR) {
 | 
			
		||||
		zTree.selectNode(treeNode);
 | 
			
		||||
		showRMenu("node", event.clientX, event.clientY);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
function showRMenu(type, x, y) {
 | 
			
		||||
	$("#rMenu ul").show();
 | 
			
		||||
    y += document.body.scrollTop;
 | 
			
		||||
    x += document.body.scrollLeft;
 | 
			
		||||
    rMenu.css({"top":y+"px", "left":x+"px", "visibility":"visible"});
 | 
			
		||||
	$("body").bind("mousedown", onBodyMouseDown);
 | 
			
		||||
}
 | 
			
		||||
function hideRMenu() {
 | 
			
		||||
	if (rMenu) rMenu.css({"visibility": "hidden"});
 | 
			
		||||
	$("body").unbind("mousedown", onBodyMouseDown);
 | 
			
		||||
}
 | 
			
		||||
function onBodyMouseDown(event){
 | 
			
		||||
	if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length>0)) {
 | 
			
		||||
		rMenu.css({"visibility" : "hidden"});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
function getForEditMenu(id){
 | 
			
		||||
	 var loading = WST.msg('正在获取数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
    $.post(WST.U('admin/menus/get'),{id:id},function(data,textStatus){
 | 
			
		||||
          layer.close(loading);
 | 
			
		||||
          var json = WST.toAdminJson(data);
 | 
			
		||||
          if(json.menuId){
 | 
			
		||||
          	  editMenu(json);
 | 
			
		||||
          }else{
 | 
			
		||||
          	  WST.msg(json.msg,{icon:2});
 | 
			
		||||
          }
 | 
			
		||||
   });
 | 
			
		||||
}	                    		
 | 
			
		||||
function editMenu(obj){
 | 
			
		||||
	WST.setValues(obj);
 | 
			
		||||
	var box = WST.open({ title:(obj.menuId==0)?'新增菜单':"编辑菜单",type: 1,area: ['430px', '230px'],
 | 
			
		||||
	                content:$('#menuBox'),
 | 
			
		||||
	                btn:['确定','取消'],
 | 
			
		||||
	                end:function(){$('#menuBox').hide()},
 | 
			
		||||
	                yes: function(index, layero){
 | 
			
		||||
	                	if(!$('#menuName').isValid())return;
 | 
			
		||||
		                var params = WST.getParams('.ipt2');
 | 
			
		||||
		                params.menuId = obj.menuId;
 | 
			
		||||
		                var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
		                $.post(WST.U('admin/menus/'+((params.menuId)?"edit":"add")),params,function(data,textStatus){
 | 
			
		||||
		                	layer.close(loading);
 | 
			
		||||
		                	var json = WST.toAdminJson(data);
 | 
			
		||||
		                	if(json.status=='1'){
 | 
			
		||||
		                	    WST.msg("操作成功",{icon:1});
 | 
			
		||||
		                		layer.close(box);
 | 
			
		||||
		                	    $('#menuForm')[0].reset();
 | 
			
		||||
		                		treeNode = zTree.getSelectedNodes()[0];
 | 
			
		||||
		                		if(params.menuId){
 | 
			
		||||
			                		zTree.reAsyncChildNodes(treeNode.getParentNode(), "refresh",true);
 | 
			
		||||
		                	    }else{
 | 
			
		||||
		                			zTree.reAsyncChildNodes(treeNode, "refresh",true);
 | 
			
		||||
		                		}
 | 
			
		||||
		                	}else{
 | 
			
		||||
		                			WST.msg(json.msg,{icon:2});
 | 
			
		||||
		                	}
 | 
			
		||||
		                });
 | 
			
		||||
	            }});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getForEdit(id){
 | 
			
		||||
	 var loading = WST.msg('正在获取数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
     $.post(WST.U('admin/privileges/get'),{id:id},function(data,textStatus){
 | 
			
		||||
           layer.close(loading);
 | 
			
		||||
           var json = WST.toAdminJson(data);
 | 
			
		||||
           if(json.privilegeId){
 | 
			
		||||
           		WST.setValues(json);
 | 
			
		||||
           		toEdit(json.privilegeId);
 | 
			
		||||
           }else{
 | 
			
		||||
           		WST.msg(json.msg,{icon:2});
 | 
			
		||||
           }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toEdit(id){
 | 
			
		||||
	var title = "新增权限";
 | 
			
		||||
	if(id>0){
 | 
			
		||||
		title = "编辑权限";
 | 
			
		||||
	}else{
 | 
			
		||||
		$('#privilegeForm')[0].reset();
 | 
			
		||||
	}
 | 
			
		||||
	$("#privilegeId").val(id);
 | 
			
		||||
	var box = WST.open({title:title,type:1,content:$('#privilegeBox'),area: ['450px', '350px'],btn:['确定','取消'],
 | 
			
		||||
              end:function(){$('#privilegeBox').hide()},
 | 
			
		||||
		      yes:function(){
 | 
			
		||||
		            if(!$('#privilegeName').isValid())return;
 | 
			
		||||
		            if(!$('#privilegeCode').isValid())return;
 | 
			
		||||
	                var params = WST.getParams('.ipt');
 | 
			
		||||
	                params.menuId = zTree.getSelectedNodes()[0].id;
 | 
			
		||||
	                params.id = id;
 | 
			
		||||
	                var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	           		$.post(WST.U('admin/privileges/'+((id==0)?"add":"edit")),params,function(data,textStatus){
 | 
			
		||||
	           			  layer.close(loading);
 | 
			
		||||
	           			  var json = WST.toAdminJson(data);
 | 
			
		||||
	           			  if(json.status=='1'){
 | 
			
		||||
	           			    	WST.msg("操作成功",{icon:1});
 | 
			
		||||
	           			    	$('#privilegeForm')[0].reset();
 | 
			
		||||
	           			    	layer.close(box);
 | 
			
		||||
	           		            loadPrivileges(params.menuId);
 | 
			
		||||
	           			  }else{
 | 
			
		||||
	           			        WST.msg(json.msg,{icon:2});
 | 
			
		||||
	           			  }
 | 
			
		||||
	           		});
 | 
			
		||||
	          }});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toDel(id){
 | 
			
		||||
	var box = WST.confirm({content:"您确定要删除该权限吗?",yes:function(){
 | 
			
		||||
	           var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	           	$.post(WST.U('admin/privileges/del'),{id:id},function(data,textStatus){
 | 
			
		||||
	           			  layer.close(loading);
 | 
			
		||||
	           			  var json = WST.toAdminJson(data);
 | 
			
		||||
	           			  if(json.status=='1'){
 | 
			
		||||
	           			    	WST.msg("操作成功",{icon:1});
 | 
			
		||||
	           			    	layer.close(box);
 | 
			
		||||
	           		            loadPrivileges(zTree.getSelectedNodes()[0].id);
 | 
			
		||||
	           			  }else{
 | 
			
		||||
	           			    	WST.msg(json.msg,{icon:2});
 | 
			
		||||
	           			  }
 | 
			
		||||
	           		});
 | 
			
		||||
	            }});
 | 
			
		||||
}
 | 
			
		||||
function checkPrivilegeCode(obj){
 | 
			
		||||
	var privilegeId = $("#privilegeId").val();
 | 
			
		||||
	if($.trim(obj.value)=='')return;
 | 
			
		||||
	var loading = WST.msg('正在检测代码是否存在,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	$.post(WST.U('admin/privileges/checkPrivilegeCode'),{privilegeId:privilegeId,code:obj.value},function(data,textStatus){
 | 
			
		||||
		layer.close(loading);
 | 
			
		||||
		var json = WST.toAdminJson(data);
 | 
			
		||||
		if(json.status!='1'){
 | 
			
		||||
			WST.msg(json.msg,{icon:2});
 | 
			
		||||
			$('#privilegeCode').val('');
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user