index.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {extend name="layout/content" /} {block name="header"}
  2. <title>角色管理</title>
  3. {/block}
  4. {block name="content"}
  5. <div class="x-body">
  6. <div class="toolWrap">
  7. <a href="{:url('roleadd')}" class="layui-btn layui-btn-radius">
  8. <i class="layui-icon">&#xe654;</i>添加角色
  9. </a>
  10. </div>
  11. <table class="layui-table">
  12. <thead>
  13. <tr>
  14. <th>ID</th>
  15. <th>角色名称</th>
  16. <th>角色描述</th>
  17. <th>状态</th>
  18. <th>创建时间</th>
  19. <th>操作</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. {foreach name="roles" item="vo"}
  24. <tr>
  25. <td>{$vo.id}</td>
  26. <td style="text-align: left !important;">{$vo.name}</td>
  27. <td>{$vo.remark}</td>
  28. <td>
  29. {if condition="$vo['status'] eq 1"}
  30. <font color="red">√</font>
  31. {else /}
  32. <font color="red">╳</font>
  33. {/if}
  34. </td>
  35. <td>{:date('Y-m-d H:i:s',$vo.create_time)}</td>
  36. <td>
  37. <a href="{:url('roleadd',['id'=>$vo.id])}" class="layui-btn">
  38. <i class="layui-icon">&#xe642;</i>新增下级角色</a>
  39. <a href="{:url('roleedit',['id'=>$vo.id])}" class="layui-btn">
  40. <i class="layui-icon">&#xe642;</i>编辑</a>
  41. <a href="{:url('authorize',['id'=>$vo.id])}" class="layui-btn layui-btn-normal">
  42. <i class="layui-icon">&#xe614;</i>权限设置</a>
  43. <a href="javascript:;" class="layui-btn layui-btn-danger delete" data-id ="{$vo.id}">
  44. <i class="layui-icon">&#xe640;</i>删除</a>
  45. </td>
  46. </tr>
  47. {/foreach}
  48. </tbody>
  49. </table>
  50. </div>
  51. {/block}
  52. {block name="footer"}
  53. <script>
  54. $(".delete").click(function(){
  55. var id = $(this).data("id");
  56. var url = "{:url('roledelete')}?id=" + id;
  57. console.log(id,url);
  58. layer.confirm('确认要删除吗?', {
  59. shade: 0.4
  60. }, function (index) {
  61. $.getJSON(url, function (res) {
  62. if (res.code) {
  63. if ( res.msg == '删除成功!') {
  64. layer.msg(res.msg, {
  65. icon: 1,
  66. shade: 0.4,
  67. time: 1000
  68. }, function () {
  69. location.href = res.url;
  70. });
  71. }else{
  72. /*console.log('{:url(\'roledelete\')}?id='+id+'&type=1');
  73. return;*/
  74. del_roleinfo(this,'{:url(\'roledelete\')}?id='+id+'&type=1');
  75. }
  76. } else {
  77. layer.msg(res.msg, {
  78. icon: 5,
  79. shade: 0.4,
  80. time: 1000
  81. });
  82. }
  83. });
  84. });
  85. })
  86. function del_roleinfo(obj, url) {
  87. layer.confirm('是否删除该角色?删除后它的所有下级角色也将被删除。', {
  88. shade: 0.4
  89. }, function (index) {
  90. $.getJSON(url, function (res) {
  91. if (res.code) {
  92. layer.msg(res.msg, {
  93. icon: 1,
  94. shade: 0.4,
  95. time: 1000
  96. }, function () {
  97. location.href = res.url;
  98. });
  99. } else {
  100. layer.msg(res.msg, {
  101. icon: 5,
  102. shade: 0.4,
  103. time: 1000
  104. });
  105. }
  106. });
  107. });
  108. }
  109. </script>
  110. {/block}