123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- @{
- ViewBag.Title = "分配权限";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- @using MES.Production.Service;
- @using Central.Control.Domain;
- @using Ant.Service.Common;
- @using Ant.Service.Common.Enums;
- <style type="text/css">
- body {
- background-color: #fff;
- }
- .tn {
- text-align: center !important;
- }
- .ckcenter {
- margin: 6px auto !important;
- }
- .table tbody tr td {
- padding: 5px 3px !important;
- vertical-align: middle;
- text-align: left;
- }
- .table tbody tr td a {
- margin-left: 10px;
- }
- .permissionlist span {
- margin-right: 5px;
- margin-bottom: 2px;
- color: #1ab394;
- vertical-align: middle;
- text-align: center;
- line-height: 25px;
- cursor: pointer;
- }
- .permissionlist span input[type=checkbox] {
- margin-top: -4px;
- }
- </style>
- <!-- table star -->
- <div class="row col-lg-12" style="height:420px; overflow-y:scroll;">
- <!-- search star -->
- @using (Ajax.BeginForm("PerAllocation", null, new AjaxOptions() { }, new { @id = "form1", @class = "form-horizontal", @method = "post" }))
- {
- @Html.Hidden("tp", ViewData["PermissionType"])
- @Html.Hidden("id", ViewData["objId"])
- <div class="form-horizontal clearfix">
- <div class="col-lg-4 col-sm-3 pl0" style="width:50%;">
- <div class="form-group">
- <label class="control-label" style="width:70px; float:left;">系统:</label>
- <div class="col-lg-8 col-sm-7" style="width:300px !important;">
- <select id="System" name="System" class="form-control" onchange="submit()">
- @{
- foreach (var item in ViewData["Systemlist"] as dynamic)
- {
- <option value="@item.ID" @(ViewData["System"] != null && ViewData["System"].ToString() != "" && ViewData["System"].ToString() == item.ID ? "selected=\"selected\"" : "")>@item.NAME</option>
- }
- }
- </select>
- </div>
- </div>
- </div>
- <div class="col-lg-4 col-sm-4">
- <div class="form-group">
- <div class="col-lg-12 col-sm-12 input-group">
- @Html.TextBox("Search", ViewData["Search"], new { @class = "input-sm form-control", @placeholder = "请输入查询模块关键词" })
- <span class="input-group-btn">
- <button type="button" onclick="submit()" class="btn btn-sm btn-primary"> 搜索</button>
- </span>
- </div>
- </div>
- </div>
- </div>
- }
- <!-- search end -->
- <div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
- <table class="table table-striped table-bordered table-hover dataTables-example dataTable" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th class="tn">@*<input id="checkall" class="ckcenter" type="checkbox" value="">*@</th>
- <th style="width:150px !important;">模块名称</th>
- <th>权限</th>
- </tr>
- </thead>
- <tbody>
- @{
- var module = ViewData["ModuleList"] as dynamic;
- var permission = ViewData["PermissionList"] as List<SYS_PERMISSION>;
- var selectper = ViewData["selectper"] as List<string>;
- if (module != null)
- {
- foreach (var item in module)
- {
- <tr>
- <td class="tn">
- <input name="ckb_module" class="ckcenter" type="checkbox" value="@item.ID" data-parent="@item.PARENTID" data-level="@item.LEVELS">
- </td>
- <td><a href="javascript:void(0)"><i class="@item.ICON"></i>@item.ID@Html.Raw(item.MODULENAME)</a></td>
- <td>
- <div class="permissionlist">
- @{
- if (permission != null && permission.Count > 0 && permission.FindAll(p => p.MODULEID == item.ID).Count > 0)
- {
- foreach (var per in permission.FindAll(p => p.MODULEID == item.ID))
- {
- var sel = selectper.Find(p => p == per.ID.ToString());
- <span>
- <input name="ckb_per" type="checkbox" value="@per.ID" @(sel != null ? "checked" : "") />
- <i class="@per.ICON"></i>@per.NAME
- </span>
- }
- }
- }
- </div>
- </td>
- </tr>
- }
- }
- }
- </tbody>
- </table>
- </div>
- </div>
- <div class="hr-line-dashed">
- <div class="form-group" style="margin-top:10px !important;">
- <div class="col-sm-2 col-sm-offset-2">
- <button class="btn btn-primary btn-save" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
- <button class="btn btn-warning" id="btn-dig-close" type="button"><i class="im-undo2"></i> 取消返回</button>
- </div>
- </div>
- </div>
- <!-- table end -->
- @section scripts{
- <script type="text/javascript">
- $('#btn-dig-close').click(function () {
- dig.remove();
- });
- $(function () {
- //全选 反选
- $('input[id="checkall"]').change(function () {
- if ($(this).prop("checked")) {
- $("input[name='ckb_module']:checkbox,input[id='checkall']:checkbox").each(function () {
- if ($(this).prop("checked") == false) {
- $(this).prop("checked", true);
- $('.ckcenter').each(function () {
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]:checkbox').prop('checked', true);
- });
- }
- });
- }
- else {
- $("input[name='ckb_module']:checkbox,input[id='checkall']:checkbox").each(function () {
- if ($(this).prop("checked") == true) {
- $(this).prop("checked", false);
- $('.ckcenter').each(function () {
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]:checkbox').prop('checked', false);
- });
- }
- });
- }
- });
- //权限 选中 反选
- $('.permissionlist span').click(function () {
- var ckb = $(this).find('input[name="ckb_per"]');
- if (ckb.prop('checked') == true) {
- ckb.prop('checked', false);
- } else {
- ckb.prop('checked', true);
- }
- });
- //递归子节点的ParentId
- function GetParentModuleId(t, s) {
- $('input[name="ckb_module"]').each(function () {
- if ($(this).attr('data-parent') == t) {
- s += $(this).attr('value') + ',';
- GetParentModuleId($(this).attr('value'), s);
- }
- });
- //alert(s);
- return s;
- }
- //选择模块 选中权限
- $('.ckcenter').bind('change', function () {
- //选中
- if ($(this).prop('checked') == true) {
- //选中当前模块下的权限
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]').prop('checked', true);
- //选中当前模块下级模块的权限
- var moduleId = $(this).attr('value') + ',';
- moduleId = GetParentModuleId($(this).attr('value'), moduleId);
- //alert(moduleId);
- $('input[name="ckb_module"]').each(function () {
- var parentId = $(this).attr('data-parent');
- if (parentId != '') {
- var arr = moduleId.split(',');
- for (var i = 0; i < arr.length; i++) {
- if (arr[i] == parentId) {
- $(this).prop('checked', true);
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]').prop('checked', true);
- }
- }
- }
- });
- } else {
- //取消选中当前模块下的权限
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]').prop('checked', false);
- //取消选中当前模块下级模块的权限
- var moduleId = $(this).attr('value') + ',';
- moduleId = GetParentModuleId($(this).attr('value'), moduleId);
- $('input[name="ckb_module"]').each(function () {
- var parentId = $(this).attr('data-parent');
- if (parentId != '') {
- var arr = moduleId.split(',');
- for (var i = 0; i < arr.length; i++) {
- if (arr[i] == parentId) {
- $(this).prop('checked', false);
- $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]').prop('checked', false);
- }
- }
- }
- //上面更改,下面原来的有Bug,自增长id会存在23,和3,判断会进去,改进之后就不存在
- //if (parentId != '' && moduleId.indexOf(parentId) > -1) {
- // $(this).prop('checked', false);
- // $(this).parent().next().next().find('.permissionlist').find('input[name="ckb_per"]').prop('checked', false);
- //}
- });
- }
- });
- //提交保存
- $('.btn-save').click(function () {
- var perid = '';
- $('input[name="ckb_per"]:checked').each(function () {
- perid += $(this).attr('value') + ',';
- });
- $.post('/Sys/Permission/SaveAllocation', {
- tp: $('#tp').val(),
- id: $('#id').val(),
- system: $('#System').val(),
- perid: perid
- }, function (result) {
- if (result.Status == 'y') {
- dig.alertSuccess("提示", result.Msg, function () {
- var dialog = top.dialog.get(window);
- dialog.close('yes').remove();
- });
- } else {
- dig.alertError("提示:", result.Msg);
- }
- }, 'json');
- });
- });
- </script>
- }
|