17.远程加载修改表,执行修改:使用easyui的form表单ajax方式提交,提交表格数据表和拿form表格数据+分页显示

   ==========1.ajax方式设置参数前奏========================    

1.easyui  ajax方式:1.load异步拿到编辑数据,放到<form id="modifyForm" method="post"></form>中

         2.ajax方式form表单设置参数:

//为表单 设置 参数
function initMoifyForm() {
   $('#modifyForm').form({
     url: "/admin/sys/editpermission",
     onSubmit: function () { 

       //点提交做什么事情

   },

   success: function (data) {

               alert(data)  //成功后做什么事

           }
  });
}

==========================

====

1.使普通表单成为ajax提交方式的表单。参照:jQuery Easyui form表单

2.ajax方式拿数据,所以这个不需要了:@using(Html.BeginForm())

 这个页是权限表单数据
@{ Layout = null; }
<!DOCTYPE html> <html> <head> <title>123</title> <link href="~/EasyUI/themes/icon.css" rel="stylesheet" /> <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" /> <script type="text/javascript" src="~/Scripts/jquery.min.js"></script> <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script> <script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script> @*<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>*@ <script src="~/Scripts/jquery.msgProcess.js"></script> <script type="text/javascript"> //=====================1.加载数据====================== $(function () { $('#editWindow').window('close');//编辑默认关闭 $("#tbList").datagrid({ width: 'auto', height: 300, striped: true, singleSelect: true, url: '/admin/sys/GetPermData', queryParams:{}, loadMsg: '数据加载中请稍后……', pagination: true, rownumbers: true, fitColumns:true, pageSize: 5, pageList:[5,10,15,20,25,30], columns: [[ { field: 'pid', title: 'ID', width: 100, align: "center" }, { field: 'pName', title: '权限名', width: 100, align: "center" }, { field: 'pAreaName', title: '区域名', width: 100, align: "center" }, { field: 'pControllerName', title: '控制名', width: 100, align: "center" }, { field: 'pActionName', title: 'Action', width: 100, align: "center" }, { field: 'pFormMethod', title: '请求方式', width: 100, align: "center", formatter: function (value) { return value == "1" ? "Get" : "post"; } }, { field: 'pOperationType', title: '操作类型', width: 100, align: "center" } ]], toolbar: [{ iconCls: 'icon-edit', text:"编辑", handler: editRow }, '-', { iconCls: 'icon-add', text: "新增", handler: function () { alert('新增按钮3') } }], //设置选中行 onSelect: function (rowI, rD) { selectRowIndex = rowI;//1.1将中的行设置为全局变量 设置给全局变量 } }); initMoifyForm(); }) //为表单 设置 参数 ajax方式拿数据 function initMoifyForm() { $('#modifyForm').form({ url: "/admin/sys/editpermission", onSubmit: function () { }, success: function (data) { alert(data); } }); } //1.将中的行设置为全局变量 var selectRowIndex = -1; //编辑按钮方法 function editRow() { //1.获取选中行里的数据! var rowData = $("#tbList").datagrid("getSelected");//getSelected返回一个选中的行 $('#editWindow').window('open');//打开 //load发送异步请求权限修改页面。并直接加载到 当前的 修改窗体中 $("#modifyForm").load("/admin/sys/EditPermission/" + rowData.pid, null, function () {//1路径、2data、3回调函数 }); } </script> </head> <body> <table id="tbList" style="width:400px;height:250px"> </table> <div id="editWindow" class="easyui-window" title="用户权限编辑" style="width:600px;height:400px;" resizable="true" data-options="iconCls:'icon-save',modal:true"> <form id="modifyForm" method="post">//准备放修改数据 </form> </div> </body> </html>

修改页和后台代码

@model MODEL.ViewModel.Permission

@*<script src="~/Scripts/jquery-1.7.1.min.js"></script>*@
@*<script src="~/Scripts/jquery.validate.min.js"></script>验证的*@
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>@*//它不验证,只负责读属性*@
<style type="text/css">
    #modityTb{width:400px;border:1px solid #0094ff;margin:10px auto;}
     #modityTb td, #modityTb th{border:1px solid #ffffff;padding:0px;}
</style><td>@Html.HiddenFor(model => model.pid)</td>@*\\权限id*@
        <table id="modityTb">
            <tr>
                <td>@Html.LabelFor(model => model.pParent)</td>
                <td >@Html.TextBoxFor(model => model.pParent)</td>
                <td>@Html.ValidationMessageFor(model => model.pParent)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pName)</td>
                <td>@Html.TextBoxFor(model => model.pName)</td>
                <td >@Html.ValidationMessageFor(model => model.pName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pAreaName)</td>
                <td >@Html.TextBoxFor(model => model.pAreaName)</td>
                <td >@Html.ValidationMessageFor(model => model.pAreaName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pControllerName)</td>
                <td >@Html.TextBoxFor(model => model.pControllerName)</td>
                <td >@Html.ValidationMessageFor(model => model.pControllerName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pActionName)</td>
                <td >@Html.TextBoxFor(model => model.pActionName)</td>
                <td >@Html.ValidationMessageFor(model => model.pActionName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pFormMethod)</td>  
                <td >@Html.DropDownListFor(model => model.pFormMethod, ViewBag.httpMethopList as IEnumerable<SelectListItem>)</td>
                <td>@Html.ValidationMessageFor(model => model.pFormMethod)</td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.pOperationType)</td>   
                <td>@Html.DropDownListFor(model => model.pOperationType, ViewBag.OperationTypeList as IEnumerable<SelectListItem>)</td>
                <td>@Html.ValidationMessageFor(model => model.pOperationType)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pOrder)</td>
                <td>@Html.TextBoxFor(model => model.pOrder)</td>
                <td >@Html.ValidationMessageFor(model => model.pOrder)</td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.pIsShow)</td>
                <td>@Html.TextBoxFor(model => model.pIsShow)</td>
                <td>@Html.ValidationMessageFor(model => model.pIsShow)</td>
            </tr>
           
            <tr>
                <td >@Html.LabelFor(model => model.pRemark)</td>
                <td>@Html.TextBoxFor(model=>model.pRemark)</td>
            </tr>
            <tr>
                <td colspan="5"><input type="submit" value="保存" /></td>
            </tr>
      </table>
editpermission后台代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MVCOA.Helper;

namespace MVCOA.Login.Admin
{
    /// <summary>
    /// 系统管理
    /// </summary>
    public class SysController : Controller
    {
        #region 1.0 权限列表 视图 +Permission()
        [HttpGet]
        /// <summary>
        /// 权限列表 视图
        /// </summary>
        /// <returns></returns>
        public ActionResult Permission()
        {
            return View();
        } 
        #endregion

        #region 1.1 权限列表 数据 +GetPermData()
        [HttpPost]
        /// <summary>
        /// 权限列表 视图
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPermData()
        {
            //获取页容量
            int pageSize = int.Parse(Request.Form["rows"]);
            //获取请求的页面
            int pageIndex = int.Parse(Request.Form["page"]);
          
            //查询分页数据
            var list = OperateContext.Current.BLLSession.IOu_PermissionBLL.GetPagedList(pageIndex, pageSize, p => p.pIsDel == false, p => p.pid).Select(p => p.ToPOCO());
            //总行数
            var rowCount = OperateContext.Current.BLLSession.IOu_PermissionBLL.GetListBy(p => p.pIsDel == false).Count();
            MODEL.EasyUIModel.DataGridModel dgModel = new MODEL.EasyUIModel.DataGridModel()
            {
                total = rowCount,
                rows = list,
                footer = null
            };
            return Json(dgModel);
        }
        #endregion

        #region 1.2加载 权限修改 窗体html
        [HttpGet]
        /// <summary>
        /// 1.2加载 权限修改 窗体html
        /// </summary>
        /// <returns></returns>
        public ActionResult EditPermission(int id)//这个方法是点击编辑拿的数据
        {
          
           var listt= OperateContext.Current.BLLSession.IOu_PermissionBLL.GetListBy(c => c.pid == id).FirstOrDefault().ToViewModel();
        
           //准备请求方式下拉框数据
            ViewBag.httpMethopList = new List<SelectListItem>() { 
               new SelectListItem(){Text="Get",Value="1"},
                new SelectListItem(){Text="Post",Value="2"}
           };
            //操作方式
            ViewBag.OperationTypeList = new List<SelectListItem>() { 
               new SelectListItem(){Text="无操作",Value="0"},
                new SelectListItem(){Text="eastyui连接",Value="1"},
                  new SelectListItem(){Text="打开新窗体",Value="2"}
           };
            return PartialView(listt);
        } 
        #endregion
       
        //#endregion

        #region 1.2 权限修改 +EditPermission(MODEL.ViewModel.Permission model)
        [HttpPost]
        /// <summary>
        /// 1.2 权限修改
        /// </summary>
        /// <returns></returns>
        public ActionResult EditPermission(MODEL.Ou_Permission model)
        {
            int res = OperateContext.Current.BLLSession.IOu_PermissionBLL.Modify(model, "pName", "pAreaName", "pControllerName", "pActionName", "pFormMethod", "pOperationType", "pOrder", "pIsShow", "pRemark");

            if (res > 0)
                return Redirect("/admin/sys/Permission?ok");
                
            else
                return Redirect("/admin/sys/Permission?err");
        }
        #endregion

    }
}

效果图:

 单机保存后:弹出提交json格式数据

========================ajax提交的方式:给表格做验证=============================

 1.这些数据需要jQuery验证,这个提交方式注销掉:onSubmit: function () { },

 2.启用jQuery验证,给上面加条件:给Permission字段属性上加[Requird]特性。

注销掉:onSubmit: function () { },

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>123</title>
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>
    @*<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>*@
    <script src="~/Scripts/jquery.msgProcess.js"></script>
    <script type="text/javascript">
        //=====================1.加载数据======================
        $(function () {
            $('#editWindow').window('close');//编辑默认关闭
           
            $("#tbList").datagrid({
                width: 'auto',
                height: 300,
                striped: true,
                singleSelect: true,
                url: '/admin/sys/GetPermData',
                //queryParams:{},  
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                fitColumns:true,
                pageSize: 5,
                pageList:[5,10,15,20,25,30],
                columns: [[
                    { field: 'pid', title: 'ID', width: 100, align: "center" },
                    { field: 'pName', title: '权限名', width: 100, align: "center" },
                    { field: 'pAreaName', title: '区域名', width: 100, align: "center" },
                    { field: 'pControllerName', title: '控制名', width: 100, align: "center" },
                    { field: 'pActionName', title: 'Action', width: 100, align: "center" },
                    {
                        field: 'pFormMethod', title: '请求方式', width: 100, align: "center", formatter: function (value) {
                            return value == "1" ? "Get" : "post";
                        }
                    },
                    { field: 'pOperationType', title: '操作类型', width: 100, align: "center" }
                ]],
                toolbar: [{
                    iconCls: 'icon-edit',
                    text:"编辑",
                    handler: editRow
                }, '-', {
                    iconCls: 'icon-add',
                    text: "新增",
                    handler: function () { alert('新增按钮3') }
                }],
               //设置选中行
                onSelect: function (rowI, rD) {
                   
                    selectRowIndex = rowI;//1.1将中的行设置为全局变量 设置给全局变量
                }
            });
            initMoifyForm();
        })
        //为表单 设置 参数
        function initMoifyForm() {
            $('#modifyForm').form({
                url: "/admin/sys/editpermission",
               // onSubmit: function () {//注销掉或删除这个提交
                  //提交后做什么
               // },
                success: function (data) {
                    alert(data)//成功后做什么
                }
            });
        }
        //1.将中的行设置为全局变量
        var selectRowIndex = -1;
       
        //编辑按钮方法
        function editRow() {
            //1.获取选中行里的数据!
            var rowData = $("#tbList").datagrid("getSelected");//getSelected返回一个选中的行
            
            $('#editWindow').window('open');//打开
            //load发送异步请求权限修改页面。并直接加载到 当前的 修改窗体中
            $("#modifyForm").load("/admin/sys/EditPermission/" + rowData.pid, null, function () {//路径、data、回调函数
               
            }); 
        }
      
    </script>
</head>
<body>
    <table id="tbList" style="width:400px;height:250px">

      
    </table>
    <div id="editWindow" class="easyui-window" title="用户权限编辑" style="width:600px;height:400px;" resizable="true" data-options="iconCls:'icon-save',modal:true">
     <form id="modifyForm" method="post">

     </form>
      </div>
</body>
</html>

启用jQuery验证

前台代码导入:验证文件。

<script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

 ======2.ajax方式设置参数和验证:用户权限加载+load异步加载修改数据+ajax表单from方式提交修改后+验证+完成)==============

index.cshtml

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    @Scripts.Render("~/easyUIJS")
    <script type="text/javascript">
       
        $(function () {
            //1.加载菜单树
            $("#menuTree").tree({
                url: '/admin/admin/getMenuData', onLoadSuccess: function (node, data) {  //getMenuData加载权限树
                  /调用方法 统一处理 Ajax获取的 json数据!
                   // alert(node+"" +data.Msg);
                    $.procAjaxData(data);//加载数据
                } , onClick: function (node) {//加载node节点面板,显示到右边
                    newTab(node);//加载tab
                    //alert(node.id + "," + node.text + "," + node.attributes.url);
                }
            });
        })
        //追加一个新的 Tab
        function newTab(treeNode)
        {
            var $tbs = $("#tbs");//1.获取tab容器
            //新根据 标题 判断 是否以存在 同名tab
            if ($tbs.tabs("exists", treeNode.text)) {//2.指定的面板是否存在,不存在就创建一个,tab
                $tbs.tabs("select", treeNode.text);//3.选择一个选项卡面板,'which'参数可以是选项卡面板的标题或者索引。
            } else {
                $tbs.tabs("add", { //4.如果没有就添加一个tab
                    title: treeNode.text,
                    content: newIframe(treeNode.attributes.url),//5.这个是treeNode里配置好的的url地址。(区域名+控制器+action方法)
                    closable: true
                });
            }
        }/*返回一个iframe标签*/
        function newIframe(url)
        {
            var ifrStr = "<iframe src='" + url + "' style='width:100%;height:100%;border:1px solid #000;'></iframe>";
            return ifrStr;
        }
    </script>
</head>
<body class="easyui-layout">
    <div data-options="region:'north',split:true" style="height:100px; font-size:32px;">
        OA权限管理系统
    </div>
    <div data-options="region:'west',title:'菜单导航',split:true" style="width:240px;">
        <ul id="menuTree"></ul>
    </div>
    <div data-options="region:'center'" style="padding:5px;background:#eee;">//在右边显示
        <div id="tbs" class="easyui-tabs" data-options="fit:true,border:false">//tabs上添加iframe小浏览器
        </div>
        <div id="tb2">ddd</div>
        @*<iframe src="/admin/admin/login" style="width:300px;height:200px;border:1px solid #000;"></iframe>*@
    </div>
</body>  
</html>

permission.cshtml

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>123</title>
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>

    @*自动为表单 添加验证功能的js文件---微软提供
        <script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
        *@
    <script src="~/Scripts/jquery.msgProcess.js"></script>
    <script type="text/javascript">
        //=====================1.加载数据======================
        $(function () {
            $('#editWindow').window('close');//编辑默认关闭
           
            $("#tbList").datagrid({
                width: 'auto',
                height: 300,
                striped: true,
                singleSelect: true,
                url: '/admin/sys/GetPermData',//1.加载权限列表到tabs上
                //queryParams:{},  
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                fitColumns:true,
                pageSize: 5,
                pageList:[5,10,15,20,25,30],
                columns: [[
                    { field: 'pid', title: 'ID', width: 100, align: "center" },
                    { field: 'pName', title: '权限名', width: 100, align: "center" },
                    { field: 'pAreaName', title: '区域名', width: 100, align: "center" },
                    { field: 'pControllerName', title: '控制名', width: 100, align: "center" },
                    { field: 'pActionName', title: 'Action', width: 100, align: "center" },
                    {
                        field: 'pFormMethod', title: '请求方式', width: 100, align: "center", formatter: function (value) {
                            return value == "1" ? "Get" : "post";
                        }
                    },
                    { field: 'pOperationType', title: '操作类型', width: 100, align: "center" }
                ]],
                toolbar: [{
                    iconCls: 'icon-edit',
                    text:"编辑",
                    handler: editRow
                }, '-', {
                    iconCls: 'icon-add',
                    text: "新增",
                    handler: function () { alert('新增按钮3') }
                }],
               //设置选中行
                onSelect: function (rowI, rD) {
                   
                    selectRowIndex = rowI;//1.1将中的行设置为全局变量 设置给全局变量
                }
            });
            initMoifyForm();
        })
        //3.为表单 设置 参数(post提交过去)
        function initMoifyForm() {
           $('#modifyForm').form({
               url: "/admin/sys/EditPermission",   //4.在EditPermission上验证,导入验证文件
               //onSubmit: function () {

               //},
               // success: function (data) {
               //   // alert(data)
               //}
            });
        }
        //1.将中的行设置为全局变量
        var selectRowIndex = -1;
       
        //编辑按钮方法
        function editRow() {
            //1.获取选中行里的数据!
            var rowData = $("#tbList").datagrid("getSelected");//getSelected返回一个选中的行
            
            $('#editWindow').window('open');//打开
            //2.load发送异步请求权限修改页面。并直接加载到 当前的 修改窗体中
            $("#modifyForm").load("/admin/sys/EditPermission/" + rowData.pid, null, function () {//路径、data、回调函数
               
            }); 
        }
      
    </script>
</head>
<body>
    <table id="tbList" style="width:400px;height:250px">

      
    </table>
    <div id="editWindow" class="easyui-window" title="用户权限编辑" style="width:600px;height:400px;" resizable="true" data-options="iconCls:'icon-save',modal:true">
     <form id="modifyForm" method="post">

     </form>
      </div>
</body>
</html>

 

 

@model MODEL.ViewModel.Permission      //权限编辑实体 强类型

@*<script src="~/Scripts/jquery-1.7.1.min.js"></script>*@
@*<script src="~/Scripts/jquery.validate.min.js"></script>验证的*@
<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>@*//它不验证,只负责读属性*@
<style type="text/css">
    #modityTb{
        width:400px;
        border:1px solid #0094ff;
        margin:10px auto;
    }
     #modityTb td, #modityTb th{
         border:1px solid #ffffff;
         padding:0px;
     }
</style>

@using(Html.BeginForm()){    //BeginForm方法 如果没有通过参数 设置 提交的路径,那么就会直接拿当前访问的路径 当 action
    @*//权限id*@
    <td>@Html.HiddenFor(model => model.pid)</td>
        <table id="modityTb">
            <tr>
                <td >@Html.LabelFor(model => model.pName)</td>
                <td>@Html.TextBoxFor(model => model.pName)</td>
                <td >@Html.ValidationMessageFor(model => model.pName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pAreaName)</td>
                <td >@Html.TextBoxFor(model => model.pAreaName)</td>
                <td >@Html.ValidationMessageFor(model => model.pAreaName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pControllerName)</td>
                <td >@Html.TextBoxFor(model => model.pControllerName)</td>
                <td >@Html.ValidationMessageFor(model => model.pControllerName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pActionName)</td>
                <td >@Html.TextBoxFor(model => model.pActionName)</td>
                <td >@Html.ValidationMessageFor(model => model.pActionName)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pFormMethod)</td>  
                <td >@Html.DropDownListFor(model => model.pFormMethod, ViewBag.httpMethopList as IEnumerable<SelectListItem>)</td>
                <td>@Html.ValidationMessageFor(model => model.pFormMethod)</td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.pOperationType)</td>   
                <td>@Html.DropDownListFor(model => model.pOperationType, ViewBag.OperationTypeList as IEnumerable<SelectListItem>)</td>
                <td>@Html.ValidationMessageFor(model => model.pOperationType)</td>
            </tr>
            <tr>
                <td >@Html.LabelFor(model => model.pOrder)</td>
                <td>@Html.TextBoxFor(model => model.pOrder)</td>
                <td >@Html.ValidationMessageFor(model => model.pOrder)</td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.pIsShow)</td>
                <td>@Html.TextBoxFor(model => model.pIsShow)</td>
                <td>@Html.ValidationMessageFor(model => model.pIsShow)</td>
            </tr>
           
            <tr>
                <td >@Html.LabelFor(model => model.pRemark)</td>
                <td>@Html.TextBoxFor(model=>model.pRemark)</td>
            </tr>
            <tr>
                <td colspan="5"><input type="submit" value="保存" /></td>
            </tr>
      </table>
 
EditPermission  权限编辑方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MVCOA.Helper;

namespace MVCOA.Login.Admin
{
    /// <summary>
    /// 系统管理
    /// </summary>
    public class SysController : Controller
    {
        #region 1.0 权限列表 视图 +Permission()
        [HttpGet]
        /// <summary>
        /// 权限列表 视图
        /// </summary>
        /// <returns></returns>
        public ActionResult Permission()
        {
            return View();
        } 
        #endregion

        #region 1.1 权限列表 数据 +GetPermData()
        [HttpPost]
        /// <summary>
        /// 权限列表 视图
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPermData()
        {
            //获取页容量
            int pageSize = int.Parse(Request.Form["rows"]);
            //获取请求的页面
            int pageIndex = int.Parse(Request.Form["page"]);
          
            //查询分页数据
            var list = OperateContext.Current.BLLSession.IOu_PermissionBLL.GetPagedList(pageIndex, pageSize, p => p.pIsDel == false, p => p.pid).Select(p => p.ToPOCO());
            //总行数
            var rowCount = OperateContext.Current.BLLSession.IOu_PermissionBLL.GetListBy(p => p.pIsDel == false).Count();
            MODEL.EasyUIModel.DataGridModel dgModel = new MODEL.EasyUIModel.DataGridModel()
            {
                total = rowCount,
                rows = list,
                footer = null
            };
            return Json(dgModel);
        }
        #endregion

        #region 1.2加载 权限修改 窗体html
        [HttpGet]
        /// <summary>
        /// 1.2加载 权限修改 窗体html
        /// </summary>
        /// <returns></returns>
        public ActionResult EditPermission(int id)//这个是留有
        {
          
           var listt= OperateContext.Current.BLLSession.IOu_PermissionBLL.GetListBy(c => c.pid == id).FirstOrDefault().ToViewModel();
        
           //准备请求方式下拉框数据
            ViewBag.httpMethopList = new List<SelectListItem>() { 
               new SelectListItem(){Text="Get",Value="1"},
                new SelectListItem(){Text="Post",Value="2"},
                 ///new SelectListItem(){Text="get,Post",Value="3"}
           };
            //操作方式
            ViewBag.OperationTypeList = new List<SelectListItem>() { 
               new SelectListItem(){Text="无操作",Value="0"},
                new SelectListItem(){Text="eastyui连接",Value="1"},
                  new SelectListItem(){Text="打开新窗体",Value="2"}
           };
            return PartialView(listt);
        } 
        #endregion
       
        //#endregion

        #region 1.2 权限修改 +EditPermission(MODEL.ViewModel.Permission model)
        [HttpPost]
        /// <summary>
        /// 1.2 权限修改
        /// </summary>
        /// <returns></returns>
        public ActionResult EditPermission(MODEL.Ou_Permission model)
        {
            int res = OperateContext.Current.BLLSession.IOu_PermissionBLL.Modify(model, "pName", "pAreaName", "pControllerName", "pActionName", "pFormMethod", "pOperationType", "pOrder", "pIsShow", "pRemark");

            if (res > 0)
                return Redirect("/admin/sys/Permission?ok");
                
            else
                return Redirect("/admin/sys/Permission?err");
        }
        #endregion

       
    }
}

效果:

  权限编辑:

     修改+easyui上微软验证+修改完成。修改功能完成了。

posted @ 2017-04-06 22:24  狼牙者.net  阅读(463)  评论(0)    收藏  举报