<%@ page language="C#" autoeventwireup="true" inherits="disk__admin_manager_disk_AuthoritySet, App_Web_nrfe0pyq" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作</title>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/jquery.min.js?v=1.7.2")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/jquery.easyui.min.js?v=1.3")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/locale/easyui-lang-zh_CN.js?v=1.0")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/jquery.load.js?v=1.0")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/jquery.json.js?v=1.0")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/easy_ui/jquery.easyui.validtor.js?v=1.0")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/disk/control/js/PageDialog.js?v=1.0")%>"></script>
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/disk/control/easy_ui/themes/gray/easyui.css?v=1.0")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/disk/control/easy_ui/themes/icon.css?v=1.0")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/disk/control/easy_ui/load.css?v=1.0")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/disk/control/css/main.css?v=1.0")%>" />
    <script language="javascript" type="text/javascript">


    var add = <%=add %>;
    var edit = <%=edit %>;
    var remove = <%=remove %>;
    
    $(function(){
 
        $("#dataview").datagrid({
            toolbar:"#toolbar",
            fit:true,
            idfield:"id",
            border:false,
            pageSize:30,
            resizable:true,
            pagination:true,
            rownumbers:true,
            fitColumns:false,
  
            url:"disk_AuthoritySet/disk_AuthoritySet_dataview.aspx",
            onLoadSuccess:function(){ $('#dataview').datagrid("unselectAll"); }
          
        });
        if(!add)
        $("#add").linkbutton('disable');
        if(!remove)
        $("#remove").linkbutton('disable')
        
         $("body").css("visibility","visible");
    });
    		
    function OperFormat(value,row,index){
       var str = "";
       str +=edit?"<a href='javascript:void(0)' onclick=\"editItem('"+value+"')\" >编辑</a>&nbsp;&nbsp;":"<span class='disabled'>编辑</span>&nbsp;&nbsp;";
       str+=remove?"<a href='javascript:void(0)' onclick=\"deleteItem('"+value+"')\">删除</a>":"<span class='disabled'>删除</span>";
        return str;
    }
    
//    function nameFormat(value,row,index){
//        if(select){
//            return "<a href='javascript:void(0)' onclick =\"selectAuthoritySet('"+row.id+"','"+value+"')\">"+value+"</a>";
//        }else{
//        return value;
//        }
//    }
//	function selectAuthoritySet(key,value){
//	    window.opener.setAuthoritySet(key,value);
//	    window.close();
//	}						             
	  function deleteItem(key){
         $.messager.confirm('确认','确定要删除选中吗?',function(r){
                 if(!r){ return }
                 load("删除中...");
                 $.ajax({
                    type: "POST",
                    url:"disk_AuthoritySet/disk_AuthoritySet_Delete.aspx",
                    dataType:"json",
                    data: {"deleteKey": key},
                    success: function(data){
                      unload();
                      if(data.state==1){
                          $.messager.show({title: '提示', msg: data.data});
                          $('#dataview').datagrid('reload').datagrid("unselectAll");
                      }
                      else{
                         $.messager.alert('错误',data.data,'message');
                      }
                   }
                });
         });
	   }

	   function editItem(key){

		    ShowDialog("asetedit","disk_AuthoritySet/disk_AuthorityTree_Edit.aspx?asid="+key,400,400,100,100); 
	   }
	   function deleteList(){
	         var row = $('#dataview').datagrid('getSelections');
	         if(row==null){
	             $.messager.alert('提示',"请选择删除项！",'message');
	             return;
	         }
	         $.messager.confirm('确认','确定要删除选中吗?',function(r){
	                 if(r){
	                     load("删除中...");
	                     var list = new Array();
	                     for(var index =0; index<row.length;index++){
	                        list.push(row[index].id);
	                     }
	                     $.ajax({
	                        type: "POST",
	                        url:"disk_AuthoritySet/disk_AuthoritySet_Delete.aspx",
	                        dataType:"json",
	                        data: {"deleteList": list.join(",")}, 
	                        success: function(data){
	                          unload();
	                          if(data.state==1){
	                              $.messager.show({ title: '提示', msg: "总共删除"+data.data+"条信息" });
	                              $('#dataview').datagrid('reload').datagrid("unselectAll");
	                          }else{
                                 $.messager.alert('错误',data.data,'message');
                              }
	                  
	                       }
	                    });
	                 }
	         });
       }

	   function Add(){

		 	ShowDialog("addaset","disk_AuthoritySet/disk_AuthorityTree.aspx",400,400,100,100);
	   }
       function reload(param){
            if(param=='last'){
                var grid = $('#dataview'); 
                var gridOptions = grid.datagrid("options"); 
                var options = grid.datagrid('getPager').data("pagination").options;  
                var pagenumber = options.total==0?1:Math.ceil( options.total/options.pageSize);
                gridOptions.pageNumber = pagenumber 
                options.pageNumber = pagenumber;
                $('#dataview').datagrid('reload');
            }
            $('#dataview').datagrid('reload');
       }
       function query(){
	        var query = $("#txtQuery").val();
	        $("#dataview").datagrid("load",{
	             as_name: query  
	        });
   	   }
   </script>
   
   
</head>
<body class="easyui-layout" style="visibility: hidden" >
    <div region="center" border="false">
        <table id="dataview">
            <thead>
                <tr>  
					<th field="ck" checkbox="true"></th>
					
					<th field="as_name" width="150">权限集(用户组)</th>
					<th field="as_cdate" width="150">创建日期</th>
					<th field="as_note" width="300" >备注</th>
					
			        <th field="id" width="80" formatter='OperFormat'>操作</th>
					
                </tr>
            </thead>
        </table>
    </div>
    <div id="toolbar">
        <a href="#" id="add" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="Add()" >添 加</a>
        <a href="#" id="remove" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="deleteList()">删除</a>         
         查询 ： 
        <input id="txtQuery" name="name" type="text" maxlength="255" onkeydown= "if(event.keyCode==13)query()"/>
        <a href="#" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="query()" >查询</a>
    </div>
    
</body>
</html>
