Index.cshtml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. @{
  2. ViewBag.Title = "权限列表";
  3. Layout = "~/Views/Shared/_Layout.cshtml";
  4. }
  5. @using MES.Production.Service;
  6. @using Central.Control.Domain;
  7. @using Ant.Service.Common;
  8. @using Ant.Service.Common.Enums;
  9. @model List<SYS_PERMISSION>
  10. <!-- table star -->
  11. <div class="row col-lg-12">
  12. <div class="wrapper wrapper-content animated fadeInUp">
  13. <div class="ibox">
  14. @using (Ajax.BeginForm("Index", null, new AjaxOptions() { }, new { @id = "form1", @class = "form-horizontal", @method = "get" }))
  15. {
  16. <div class="ibox-title">
  17. @{
  18. if (ViewBag.Module != null)
  19. {
  20. SYS_MODULE module = ViewBag.Module as SYS_MODULE;
  21. if (module != null)
  22. {
  23. <h5>@(module.NAME) 权限</h5>
  24. @Html.Hidden("moduleId", module.ID)
  25. @Html.Hidden("moduleType", module.MODULETYPE)
  26. }
  27. <div class="ibox-tools rboor">
  28. <a class="btn btn-primary btn-xs p310" id="reset" action="reset"><i class="im-plus"></i> 初始化权限</a>
  29. <a class="btn btn-primary btn-xs p310" id="insert" action="add"><i class="im-plus"></i> 创建新权限</a>
  30. <a class="btn btn-primary btn-xs p310" id="modify" action="edit"><i class="im-pencil2"></i> 编辑</a>
  31. <a class="btn btn-primary btn-xs p310" id="delete" action="remove"><i class="im-remove4"></i> 删除</a>
  32. </div>
  33. }
  34. else
  35. {
  36. <h5>权限管理</h5>
  37. }
  38. }
  39. </div>
  40. <div class="ibox-content">
  41. <!-- search star -->
  42. <div class="form-horizontal clearfix">
  43. <div class="col-lg-4 col-sm-4">
  44. <div class="form-group">
  45. <div class="col-lg-12 col-sm-12 input-group">
  46. @Html.TextBox("Search", null, new { @class = "input-sm form-control", @placeholder = "请输入查询关键词" })
  47. <span class="input-group-btn">
  48. <button type="button" onclick="submit()" class="btn btn-sm btn-primary"> 搜索</button>
  49. </span>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- search end -->
  55. <div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  56. <table id="example" class="table table-striped table-bordered table-hover dataTables-example dataTable" cellspacing="0" width="100%">
  57. <thead>
  58. <tr>
  59. <th class="tn" style="width: 40px !important"><input name="checkall" id="checkall" type="checkbox" value=""></th>
  60. <th>权限名称</th>
  61. <th>权限动作</th>
  62. <th style="width:100px !important;">图标</th>
  63. <th style="width:100px !important;">顺序</th>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. @{
  68. if (Model != null)
  69. {
  70. @Html.Hidden("percount",Model.Count)
  71. foreach (var item in Model)
  72. {
  73. <tr>
  74. <td class="tn"><input name="checkbox_name" type="checkbox" value="@item.ID"></td>
  75. <td>
  76. <a href="javascript:modify('@item.ID')" listaction="detail"> @item.NAME</a>
  77. </td>
  78. <td>@item.PERVALUE</td>
  79. <td style="color:#1ab394; "><i class="@item.ICON"></i></td>
  80. <td>@item.SHOWORDER</td>
  81. </tr>
  82. }
  83. }
  84. }
  85. </tbody>
  86. </table>
  87. </div>
  88. </div>
  89. }
  90. </div>
  91. </div>
  92. </div>
  93. <!-- table end -->
  94. @section scripts{
  95. <script type="text/javascript">
  96. //点击修改
  97. function modify(n) {
  98. dig.addModel('添加/编辑权限', '/Sys/Permission/Detail/' + n, 500, 300, function () {
  99. if (this.returnValue == 'yes') {
  100. location.reload();
  101. }
  102. });
  103. }
  104. $(function () {
  105. //添加
  106. $('#insert').click(function () {
  107. var moduleId = $('#moduleId').val();
  108. var moduleType = $('#moduleType').val();
  109. if (moduleId == '' || moduleId == undefined) {
  110. dig.alertError('提示', '请先选择模块后再进行添加权限操作');
  111. return;
  112. }
  113. if (moduleType <= 1 || moduleType == '1') {
  114. dig.alertError('提示', '无页面的模块不能添加权限');
  115. return;
  116. }
  117. dig.addModel('添加/编辑权限', '/Sys/Permission/Detail?moduleId=' + moduleId, 500, 300, function () {
  118. if (this.returnValue == 'yes') {
  119. location.reload();
  120. }
  121. });
  122. });
  123. //修改
  124. $('#modify').click(function () {
  125. var vals = '';
  126. var num = 0;
  127. $('input[name="checkbox_name"]:checked').each(function () {
  128. vals = $(this).val();
  129. num++;
  130. });
  131. if (!vals) {
  132. dig.alertError("提示", "对不起,请选中您要操作的记录!");
  133. return;
  134. }
  135. if (num > 1) {
  136. dig.alertError("提示", "对不起,每次只能修改一条记录!");
  137. return;
  138. }
  139. dig.addModel('添加/编辑权限', '/Sys/Permission/Detail/' + vals, 500, 300, function () {
  140. if (this.returnValue == 'yes') {
  141. location.reload();
  142. }
  143. });
  144. });
  145. //初始化权限
  146. $('#reset').click(function () {
  147. if ($('#percount').val()>0) {
  148. dig.alertError("提示", "对不起,该模块已存在权限,无法初始化!");
  149. return;
  150. }
  151. dig.confirm('提示', '您确定要初始化权限吗?', function () {
  152. $.post('/Sys/Permission/Reset/' + $('#moduleId').val(), null, function (result) {
  153. if (result.Status == 'y') {
  154. dig.alertSuccess('提示', result.Msg, function () {
  155. location.reload();
  156. });
  157. } else {
  158. dig.alertError('提示', result.Msg);
  159. }
  160. }, 'json');
  161. });
  162. });
  163. });
  164. </script>
  165. }