25.加载角色数据

 

index.cshtml角色页

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>用户角色</title>
   
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script>
  
    <script type="text/javascript" src="~/Scripts/jquery.msgProcess.js"></script>
    <script type="text/javascript">
        //=====================1.加载数据======================
        $(function () {
            $('#Windowp').window('close');//编辑默认关闭

            $("#tbList").datagrid({
                width: 'auto',
                height: 400,
                striped: true,
                singleSelect: true,
                url: '/admin/Role/index',
                //queryParams:{},
                loadMsg: '数据加载中请稍后……',
                pagination: true,//启用分页,默认每页10行
                rownumbers: true,//显示页码,默认 提供 10 - 50 的页容量选择下拉框
                pageSize: 10,//设置 页容量为 5
                pageList: [10, 15, 20, 25, 30],//设置 页容量下拉框
                fitColumns:true,
                columns: [[
                     {
                         field: 'rIsShow', title: '显示', width:5,align: "center", formatter: function (value) {
                             return value ? "":"X";
                         }
                     },
                    { field: 'rId', title: 'ID', width: 20, align: "center" },
                    { field: 'Ou_Department', title: '部门', width: 20, align: "center", formatter: function (value) { return value.depName } },
                    { field: 'rName', title: '角色名', width: 20, align: "center" },
                 
                    {
                        field: 'rIsDel', title: '是否删除', width: 20, align: "center", formatter: function (value) {
                            switch (value.toString())
                            {
                                case "false":
                                    return "";
                                case "true":
                                    return "";
                            }
                        }
                    },
                        { field: 'rRemark', title: '备注', width: 20, align: "center" },
                  
                  
                ]],
                toolbar: ['-', {
                   iconCls: 'icon-search',
               text: "分配权限",
               handler: providePermission
            }
            ],
           //1.将中的行设置为全局变量
             var selectRowIndex = -1;


               //设置选中行
                onSelect: function (rowI, rD) {

                    selectRowIndex = rowI;//1.1将中的行设置为全局变量 设置给全局变量
                }
            });
            initMoifyForm();
        })
        ////为表单 设置 参数
        function initMoifyForm() {
           $('#modifyForm').form({
               url: "/admin/sys/EditPermission",

            });
        }
        //分配权限
       function  providePermission()
        {
           //获取选中 的 角色数据
           var roleData = $("#tbList").datagrid("getSelected");
           if (roleData) {
               //拿到角色id
               $.get("/admin/role/getroleTrue/" + roleData.rId, null, function (jsobj) {
                   if (jsobj.Statu)
                       $.procAjaxData(jsobj);
                   else
                    
                       $("#windowOper").html(jsobj);
                   
               });
           }
           else {
               $.alertMsg("请选中您要分配权限的角色数据", "系统提示");
           }
         
           $("#windowOper").wimdow("open");
        }
    </script>
</head>
<body>
    <table id="tbList" style="width:700px;height:250px"></table>
  
    <div id="Windowp" class="easyui-window" title="分配权限" style="width:600px; height:300px;" data-options="iconCls:'icon-save',modal:true,title:'分配权限'"><div id="windowOper" data-options="region:'center',style=" padding:10px;">

        </iv>
        <div data-options="region:'south',border:false," style="text-align:right;padding:5px;">
            <a class="easyui-linkbutton" data-options="iconCls:'icon-save'," href="javascript:void(0)" onclick="javascript:alert('ok')">保存</a>

            <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:alert('cancel')">取消</a>
        </div></div>
</body>
</html>

角色acton方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MVCOA.Helper;
using MODEL.ViewModel;

namespace MVCOA.Login.Admin
{
   public class RoleController:Controller
    {
        #region 1. 加载角色数据
        /// <summary>
        /// 角色 视图
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult index(FormCollection form)
        {
            //获取页容量
            int pageSize = int.Parse(Request.Form["rows"]);
            //获取请求的页面
            int pageIndex = int.Parse(Request.Form["page"]);
            var list = OperateContext.Current.BLLSession.IOu_RoleBLL.GetPagedList(pageIndex, pageSize, p => p.rIsDel == false, p => p.rId).Select(p => p.ToPOCO()).ToList();
            var rowcont = OperateContext.Current.BLLSession.IOu_RoleBLL.GetListBy(d => d.rIsDel == false).Count();
            return Json(new MODEL.EasyUIModel.DataGridModel() { rows = list, total = rowcont });
        } 
        #endregion
}
}

 

posted @ 2017-04-26 17:03  狼牙者.net  阅读(108)  评论(0编辑  收藏  举报