前五章均是从整体上讲述了Web应用程序的多用户权限控制实现流程,本章讲述Web权限管理系统的基本模块-栏目模块。栏目模块涉及到的数据表为目录表。

1.1栏目域

为了更规范和方便后期系统的二次开发和维护,对应特定的业务模块采用Area(域)的方式开发,栏目模块的开发域如下图所示:

Web应用程序系统的多用户权限控制设计及实现-栏目模块【8】

由于在Areas下还建立了一个新的目录SystemManage,故需要改变原来的路由。栏目模块的路由文件名称为pageGroupAreaRegistration。改变路由代码的文件名称为如下:

using System.Web.Mvc;
namespace CodeForMvcTest.Areas.pageGroup
{
    public class pageGroupAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "SystemManage/pageGroup";
            }
        }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "SystemManage_pageGroup_default",
                "SystemManage/pageGroup/{controller}/{action}/{id}",  //"{controller}/{action}/{id}"
                new { action = "PageGroupManage", id = UrlParameter.Optional }
            );
        }
    }
}

 1.2Model

栏目模块的Model可参看第三章项目架构的系统共有类,对应model为Catalog.cs。文件路径为Areas/SystemManage/Models。

 1.3视图

栏目模块的视图包含在栏目域中,文件路径为Areas/SystemManage/OperatorManage/Views/PageGroupManage,视图名称为PageGroupMange.cshtml。视图的完整代码如下:

  1 @{
  2     ViewBag.Title = "栏目管理";
  3     Layout = "~/Views/Shared/_BaseLayout.cshtml";
  4 }
  5 
  6 <div class="easyui-layout" data-options="fit:true">
  7 
  8     <div data-options="region:'north',split:true" style="height: 50px;">
  9         @using (Ajax.BeginForm("PageGroupManage", "PageGroupManage", new AjaxOptions
 10         {
 11             HttpMethod = "POST",
 12             OnSuccess = "selectNode",
 13             OnBegin = "searchStart",
 14             OnFailure = "searchFailure"
 15         }))
 16         {
 17             <!--属性组筛选栏-->
 18             <table style="margin-left: 5px; margin-top: 5px;">
 19                 <tr>
 20                     <td><span style="margin-left: 10px;">栏目名称:</span></td>
 21                     <td>
 22                         <input id="groupName" name="groupName" />
 23                     </td>
 24                     <td>
 25                         <input type="submit" value="查找" id="btn_submit" style="margin-left: 10px; margin-right: 10px;" />
 26                     </td>
 27                 </tr>
 28             </table>
 29         }
 30     </div>
 31 
 32     <div data-options="region:'center',split:true" style="padding-bottom: 10px;">
 33         <ul id="catalogTree">
 34         </ul>
 35         <br />
 36         <br />
 37         <div id="mm" class="easyui-menu" style="width: 120px;">
 38             <div onclick="openCategoryEditWin()" iconcls="icon-edit">修改节点</div>
 39             <div onclick="openCategoryAddWin()" iconcls="icon-add">添加节点</div>
 40             <div onclick="deleteCatalog()" iconcls="icon-remove">删除节点</div>
 41         </div>
 42     </div>
 43 </div>
 44 
 45 
 46 <!--目录编辑窗体-->
 47 <div id="categoryWin"  title="修改栏目信息" style="width: 480px; height: 380px; padding: 20px; text-align: center;">
 48     <form id="categoryForm" method="POST" action="@Url.Action("UpdateCategory", "PageGroupManage")">
 49         <table style="margin: auto;">
 50             <tr>
 51                 <td style="text-align: right;"><span>名称:</span></td>
 52                 <td style="text-align: left;">
 53                     <input class="easyui-validatebox" id="e_categoryName" name="CatalogName" data-options="required:true" />
 54                 </td>
 55             </tr>
 56             <tr style="height: 40px;">
 57                 <td style="text-align: right;"><span>图标:</span></td>
 58                 <td style="text-align: left;">
 59                     <input class="easyui-validatebox" id="e_categoryPicurl" name="PictureUrl" />
 60                 </td>
 61             </tr>
 62             <tr style="height: 40px;">
 63                 <td style="text-align: right;"><span>备注:</span></td>
 64                 <td>                  
 65                     <input class="easyui-validatebox" id="e_categoryRemark" name="Remark" />
 66                 </td>
 67             </tr>
 68             <tr style="height: 40px;">
 69                 <td style="text-align: right;"><span>排序值:</span></td>
 70                 <td style="text-align: left;">
 71                 
 72                     <input class="easyui-numberbox" data-options="required:true" id="e_categoryShownum" name="ShowNo" />
 73                 </td>
 74             </tr>
 75             <tr style="height: 40px;">
 76                 <td style="text-align: right;"><span>状态:</span></td>
 77                 <td style="text-align: left;">
 78                     <select class="easyui-combobox" name="IsAvailable" id="e_categoryState" style="width: 150px;"
 79                         data-options="editable:false">
 80                         <option value="0">禁用</option>
 81                         <option value="1">启用</option>
 82                     </select>
 83                 </td>
 84             </tr>
 85             <tr style="height: 50px;">
 86                 <td colspan="2" style="text-align: center;">
 87                     <input type="hidden" id="parentId" name="ParentId" />
 88                     <input type="hidden" id="categoryId" name="CatalogId" />
 89                     <input type="reset" style="display: none" />
 90                     <input type="submit" value="提交" id="btn_editsubmit" style="margin-left: 10px; margin-right: 10px;" />
 91                     <input type="button" value="取消" id="btn_editCancel" onclick="javascript: return $('#categoryWin').window('close');"
 92                         style="margin-left: 10px; margin-right: 10px;" />
 93                 </td>
 94             </tr>
 95         </table>
 96     </form>
 97 </div>
 98 
 99 @section scripts
100 {
101     <script type="text/javascript"  src="/Areas/SystemManage/SystemJS/pageGroupManage.js"></script>
102 }
PageGorupManage.cshtml

相关文章:

  • 2021-06-13
  • 2021-12-05
  • 2021-08-17
猜你喜欢
  • 2021-07-26
  • 2021-11-23
  • 2021-10-06
  • 2022-01-12
  • 2022-02-01
  • 2021-08-03
  • 2022-01-07
相关资源
相似解决方案