group_access.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <div class="admin-main layui-anim layui-anim-upbit">
  5. <fieldset class="layui-elem-field layui-field-title">
  6. <legend>权限分配</legend>
  7. <blockquote class="layui-elem-quote">
  8. <button type="button" class="layui-btn layui-btn-sm" lay-demo="setChecked">全选</button>
  9. <button type="button" class="layui-btn layui-btn-sm layui-btn-warm" lay-demo="reload">取消</button>
  10. </blockquote>
  11. </fieldset>
  12. <div class="layui-form-item">
  13. <div id="tree" class="demo-tree-more"></div>
  14. </div>
  15. <form class="layui-form layui-form-pane" lay-filter="form">
  16. <div class="layui-form-item">
  17. <div class="layui-input-inline">
  18. <input type="hidden" name="id" >
  19. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  20. <a href="{:url('group')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  21. </div>
  22. </div>
  23. </form>
  24. </div>
  25. </div>
  26. </div>
  27. {include file="common/footer"/}
  28. <script>
  29. layui.use(['form', 'table','tree','form'], function () {
  30. var $ = layui.jquery,
  31. util = layui.util,
  32. form = layui.form,
  33. tree = layui.tree;
  34. var idList = {:json_encode($idList)};
  35. tree.render({
  36. elem: '#tree'
  37. ,data: {:json_encode($list)}
  38. ,showCheckbox: true //是否显示复选框
  39. ,id: 'treebox'
  40. // ,edit: ['add', 'update', 'del']
  41. ,showLine:true
  42. ,accordion:true//是否开启手风琴模式,默认 false
  43. ,isJump: false //是否允许点击节点时弹出新窗口跳转
  44. });
  45. //按钮事件
  46. util.event('lay-demo', {
  47. getChecked: function (othis) {
  48. var checkedData = tree.getChecked('treebox'); //获取选中节点的数据
  49. }
  50. , setChecked: function () {
  51. tree.setChecked('treebox', idList); //勾选指定节点
  52. }
  53. , reload: function () {
  54. //重载实例
  55. tree.reload('treebox', {});
  56. }
  57. })
  58. form.on('submit(submit)', function (data) {
  59. loading =layer.load(1, {shade: [0.1,'#fff']});
  60. var data = tree.getChecked('treebox');
  61. console.log(data);
  62. console.log(data);
  63. $.post("groupSetaccess", {rules:data,group_id:'{$group_id}'}, function (res) {
  64. layer.close(loading);
  65. if (res.code > 0) {
  66. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  67. location.href = res.url;
  68. });
  69. } else {
  70. layer.msg(res.msg, {time: 1800, icon: 2});
  71. }
  72. });
  73. });
  74. });
  75. </script>