rule_add.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. {include file="common/header"/}
  2. <style> .layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}</style>
  3. <div class="LM-container">
  4. <div class="LM-main">
  5. <div class="admin-main layui-anim layui-anim-upbit">
  6. <fieldset class="layui-elem-field layui-field-title">
  7. <legend>{:lang('add')}权限节点</legend>
  8. </fieldset>
  9. <blockquote class="layui-elem-quote">
  10. 1、控制器/方法 例如 Wechat/index
  11. </blockquote>
  12. <form class="layui-form layui-form-pane" lay-filter="form">
  13. <div class="layui-form-item">
  14. <label class="layui-form-label">父级</label>
  15. <div class="layui-input-inline">
  16. <select name="pid" lay-verify="required" lay-filter="pid">
  17. <option value="0">默认顶级</option>
  18. {volist name="ruleList" id="vo"}
  19. <option value="{$vo.id}" {if $rule and $rule['id']==$vo.id}selected
  20. {/if}>{$vo.lefthtml}{$vo.title}</option>
  21. {/volist}
  22. </select>
  23. </div>
  24. </div>
  25. <div class="layui-form-item">
  26. <label class="layui-form-label">权限名称</label>
  27. <div class="layui-input-inline">
  28. <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}权限名称"
  29. class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-form-item">
  33. <label class="layui-form-label">控制器/方法</label>
  34. <div class="layui-input-inline">
  35. <input type="text" name="href" lay-verify="required" placeholder="{:lang('pleaseEnter')}控制器/方法"
  36. class="layui-input">
  37. </div>
  38. </div>
  39. <div class="layui-form-item">
  40. <label class="layui-form-label">图标名称</label>
  41. <div class="layui-input-inline">
  42. <input type="text" name="icon" id="iconPicker" lay-filter="iconPicker" class="hide">
  43. </div>
  44. <div class="layui-form-mid layui-word-aux"><a target="_blank" href="http://www.fontawesome.com.cn/">点击查看图标</a></div>
  45. </div>
  46. <div class="layui-form-item">
  47. <label class="layui-form-label">菜单状态</label>
  48. <div class="layui-input-inline">
  49. <input type="radio" name="menu_status" lay-filter="menu_status" checked value="1" title="开启">
  50. <input type="radio" name="menu_status" lay-filter="menu_status" value="0" title="关闭">
  51. </div>
  52. </div>
  53. <div class="layui-form-item">
  54. <label class="layui-form-label">排序</label>
  55. <div class="layui-input-inline">
  56. <input type="text" name="sort" value="50" placeholder="{:lang('pleaseEnter')}排序编号"
  57. class="layui-input">
  58. <input type="hidden" name="id">
  59. </div>
  60. </div>
  61. <div class="layui-form-item">
  62. <div class="layui-input-inline">
  63. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
  64. <a href="{:url('adminRule')}" class="layui-btn layui-btn-primary">返回</a>
  65. </div>
  66. </div>
  67. </form>
  68. </div>
  69. </div>
  70. </div>
  71. {include file="common/footer"/}
  72. <script>
  73. layui.config({
  74. base: '/static/plugins/layui/extend/'
  75. }).extend({
  76. iconPickerFa: 'iconPicker/iconPickerFa'
  77. }).use(['form', 'layer','iconPickerFa'], function () {
  78. var form = layui.form,layer = layui.layer,$= layui.jquery;
  79. var iconPickerFa = layui.iconPickerFa;
  80. var info = {:json_encode($info)};
  81. var url = "{:url('ruleAdd')}";
  82. var icon = '';
  83. if(info){
  84. form.val('form',info);
  85. url = "{:url('ruleEdit')}";
  86. icon= info.icon;
  87. }
  88. iconPickerFa.render({
  89. // 选择器,推荐使用input
  90. elem: '#iconPicker',
  91. // fa 图标接口
  92. url: "/static/plugins/font-awesome-4.7.0/less/variables.less",
  93. // 是否开启搜索:true/false,默认true
  94. search: true,
  95. // 是否开启分页:true/false,默认true
  96. page: true,
  97. // 每页显示数量,默认12
  98. limit: 20,
  99. // 点击回调
  100. click: function (data) {
  101. $('#iconPicker').val('fa '+ data.icon);
  102. },
  103. // 渲染成功后的回调
  104. success: function (d) {
  105. $('#iconPicker').val('fa '+ d.icon);
  106. }
  107. });
  108. form.on('submit(submit)', function (data) {
  109. // 提交到方法 默认为本身
  110. console.log(data.field);
  111. if(data.field.icon=='fa undefined'){
  112. data.field.icon = icon;
  113. }
  114. $.post(url,data.field,function(res){
  115. if(res.code > 0){
  116. layer.msg(res.msg,{time:1000,icon:1},function(){
  117. location.href = res.url;
  118. });
  119. }else{
  120. layer.msg(res.msg,{time:1000,icon:2});
  121. }
  122. });
  123. })
  124. });
  125. </script>