在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
接上文希望从一张表(tb_role_info 用户角色表)的CRUD展开asp.net mvc的项目实战化魅力。 开发技术选型:asp.net mvc+bootstrap+sqlserver。 项目目录结构: (1)业务表 tb_role_info -- ---------------------------- -- Table structure for `tb_role_info` 用户角色表 -- ---------------------------- DROP TABLE IF EXISTS `tb_role_info`; CREATE TABLE `tb_role_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `role_name` varchar(32) NOT NULL DEFAULT '' COMMENT '角色名称', `role_mark` varchar(255) DEFAULT '' COMMENT '角色备注', `creater_id` int(11) NOT NULL DEFAULT '0' COMMENT '记录创建者id', `created_at` timestamp NULL DEFAULT NULL COMMENT '创建日期', `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新日期', `time_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间戳', PRIMARY KEY (`id`), KEY `tb_role_info_index` (`id`,`role_name`,`creater_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='角色信息表'; (2)业务界面 role.cshtml @model Aptamil.Areas.Admin.ViewModels.RoleViewModel @{ Layout = null; } <!DOCTYPE html> <html> <head> @{Html.RenderPartial("Header");} <link rel="stylesheet" type="text/css" href="@Url.Content("~/Contents/backend/plugs/bootstrap-table/src/bootstrap-table.css")?v[email protected]" /> </head> <body> @{Html.RenderPartial("Navbar");} <div id="page-container"> <!-- BEGIN SIDEBAR --> @{Html.RenderPartial("Menu");} <!-- END SIDEBAR --> <!-- BEGIN RIGHTBAR --> <!-- END RIGHTBAR --> <div id="page-content"> <div id="wrap"> <div id="page-heading"> <ol class="breadcrumb"> <li><a href="#" title="icons">系统管理</a></li> <li class="active">角色信息</li> </ol> </div> <!-- container 内容显示区域begin--> <div class="container"> <div class='data-loading'></div> <div class="row"> <div class="col-xs-12"> <div id="search_panel" class="search-panel-body"> <form id="search_form" class="form-horizontal"> <div class="row"> <div class="col-md-10"> <div class="form-group"> <label for="search_txt_roleName" class="col-sm-1 control-label">角色名称</label> <div class="col-sm-11"> <input id="search_txt_roleName" type="text" class="form-control" placeholder="请输入关键字..."> </div> </div> </div> <div class="col-md-2"> <div class="form-group"> <div class="btn-group"> <button id="btn_search_save" type="button" class="btn btn-primary" title="角色查询"> <i class="fa fa-search"></i></button> <button id="btn_search_expand" type="button" class="btn btn-primary" title="面板展开"> <i class="fa fa-angle-double-up"></i></button> </div> </div> </div> </div> <div class="row" id="search_more_panel" style="display:none;"> </div> </form> </div> <div class="panel panel-gray"> <div class="panel-heading"> <h4>角色信息 </h4> <div class="options"> <div class="btn-group"> <div class="btn-group" id="table_tools_bar"> <button type="button" class="btn btn-default dropdown-toggle btn-tools" data-toggle="dropdown" title="定制列显示"><i class="fa fa-th-list"></i> <span class="caret"></span></button> </div> <button id="btn_role_refresh" type="button" class="btn btn-default btn-tools" title="角色刷新"><i class="fa fa-refresh"></i></button> </div> </div> <div class="options options-groups"> <a href="javascript:;" id="btn_role_delete" title="角色删除"><i class="fa fa-times"></i> 删除</a> <a data-toggle="modal" href="#form_modal" id="btn_role_edit" title="角色编辑"><i class="fa fa-edit"></i> 编辑</a> <a data-toggle="modal" href="#form_modal" id="btn_role_add" title="角色添加"><i class="fa fa-pencil"></i> 添加</a> </div> </div> <div class="panel-body"> <div class="table-responsive"> <table id="role_table"></table> </div> <!-- add/edit modal-begin --> <div id="form_modal" class="modal fade md-trigger" data-modal="md-fade-in-scale-up" tabindex="-1" role="dialog" aria-labelledby="form_modal_title" data-keyboard="true" data-backdrop="static" aria-hidden="true"> <div id="form_modal_dialog" class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button> <h4 class="modal-title" id="form_modal_title"></h4> </div> <div class="modal-body"> <form id="modalForm" class="form-horizontal" role="form" enctype="multipart/form-data"> <!-- 隐藏值存放区域 begin--> <input name="id" id="form_hidden_id" type="hidden"> <input name="createrId" id="form_hidden_createrId" type="hidden"> <!-- 隐藏值存放区域 end--> <div class="form-group"> <label for="form_txt_roleName" class="col-sm-2 control-label">角色名称</label> <div class="col-sm-7"> <input id="form_txt_roleName" name="roleName" maxlength="32" placeholder="角色名称最多32个字符" required="" type="text" class="form-control"> </div> <div class="col-sm-3"> <p class="help-block">角色名称必填!</p> </div> </div> <div class="form-group"> <label for="form_txt_roleName" class="col-sm-2 control-label">角色权限</label> <div class="col-sm-10"> <table id="table_module" class="table table-bordered"> <thead> <tr> <th width="2%" style="padding: 10px"> </th> <th width="28%" style="padding: 10px"> 模块 </th> <th width="30%" style="padding: 10px"> 功能 </th> <th width="30%" style="padding: 10px"> 动作 </th> </tr> </thead> @if (null != Model.ModuleList) { <tbody> @foreach (var module in Model.ModuleList) { if (module.Id == 1 && Model.User.UserRoleId != 1) { } else { <tr> <td> <input type="checkbox" id="[email protected]" name="[email protected]" value="@module.Id" onclick="checkModule(@module.Id);" /> </td> <td> @module.ModuleCnName </td> <td> <table width="100%"> @if (null != module.Children) { foreach (var child in module.Children) { <tr> <td width="6%"><input type="checkbox" id="[email protected]" name="[email protected]" value="@child.Id" onclick="checkFun(@module.Id);" /></td> <td width="94%">@child.ModuleCnName</td> </tr> } } </table> </td> <td> <table width="100%"> @if (null != module.Children) { foreach (var child in module.Children) { if (null != child.Children) { foreach (var subChild in child.Children) { <tr> <td width="6%"><input type="checkbox" id="[email protected]" name="[email protected]" value="@subChild.Id" onclick="checkAction(@child.Id);" /></td> <td width="94%">@subChild.ModuleCnName</td> </tr> } } } } </table> </td> </tr> } } </tbody> } </table> </div> </div> <div class="form-group"> <label for="form_txt_roleMark" class="col-sm-2 control-label"> 角色描述 </label> <div class="col-sm-10"> <textarea id="form_txt_roleMark" name="roleMark" maxlength="255" placeholder="角色描述最多255个字符" class="form-control autosize"></textarea> </div> </div> </ |
请发表评论