RoleCall.cshtml 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <style type="text/css">
  10. body {
  11. background-color: white;
  12. }
  13. </style>
  14. @model PageInfo
  15. @Html.Hidden("userId",ViewData["userId"])
  16. @Html.Hidden("roleId", ViewData["roleId"])
  17. <!-- table star -->
  18. <div class="row col-lg-12">
  19. <div class="wrapper wrapper-content animated fadeInUp" style="overflow-y:scroll;height:320px;">
  20. <div class="ibox">
  21. <div class="ibox-content" style="padding:0;">
  22. <div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  23. <table id="example" class="table table-striped table-bordered table-hover dataTables-example dataTable" cellspacing="0" width="100%">
  24. <thead>
  25. <tr>
  26. <th class="tn" style="width: 40px !important"><input name="checkall" id="checkall" type="checkbox" value=""></th>
  27. <th>角色名称</th>
  28. <th>角色备注</th>
  29. <th style="width: 70px !important">系统预定义</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. @{foreach (var item in Model.List)
  34. {
  35. <tr>
  36. <td class="tn"><input name="checkbox_name" type="checkbox" value="@item.ID"></td>
  37. <td>
  38. <a href="javascript:void(0)"> @item.ROLENAME</a>
  39. </td>
  40. <td>@item.ROLEDESC</td>
  41. <td>@item.ISCUSTOM</td>
  42. </tr>
  43. }
  44. }
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="hr-line-dashed">
  52. <div class="form-group" style="margin-top:10px !important;">
  53. <div class="col-sm-2 col-sm-offset-2">
  54. <button class="btn btn-primary btn-save" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
  55. <button class="btn btn-warning" id="btn-dig-close" type="button"><i class="im-undo2"></i> 取消返回</button>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- table end -->
  61. @section scripts{
  62. <script type="text/javascript">
  63. $(function () {
  64. var dialog = top.dialog.get(window);
  65. //设置选中用户角色
  66. var roleId = $('#roleId').val();
  67. if (roleId != '') {
  68. var r_id = roleId.split(',');
  69. $('input[name="checkbox_name"]').each(function() {
  70. for (var i = 0; i < r_id.length; i++) {
  71. if ($(this).val() == r_id[i]) {
  72. $(this).prop('checked', true);
  73. }
  74. }
  75. });
  76. }
  77. //保存用户角色
  78. $('.btn-save').click(function() {
  79. var v = '';
  80. $('input[name="checkbox_name"]:checked').each(function() {
  81. v += $(this).val() + ',';
  82. });
  83. $.post('/Sys/Role/UserRole', {
  84. userId: $('#userId').val(),
  85. roleId: v
  86. }, function(res) {
  87. if (res.Status === 'y') {
  88. dig.alertSuccess('提示', res.Msg, function () {
  89. dialog.close('yes').remove();
  90. });
  91. } else {
  92. dig.alertError('提示', res.Msg);
  93. }
  94. }, 'json');
  95. });
  96. });
  97. </script>
  98. }