form.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
  2. <div class="layui-card-body">
  3. <div class="layui-form-item">
  4. <label class="layui-form-label label-required-next">上级菜单</label>
  5. <div class="layui-input-block">
  6. <select name='pid' class='layui-select' lay-search>
  7. {foreach $menus as $menu}{eq name='menu.id' value='$vo.pid|default=0'}
  8. <option selected value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
  9. {else}
  10. <option value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
  11. {/eq}{/foreach}
  12. </select>
  13. <p class="help-block"><b>必选</b>,请选择上级菜单或顶级菜单(目前最多支持三级菜单)</p>
  14. </div>
  15. </div>
  16. <div class="layui-form-item">
  17. <label class="layui-form-label">菜单名称</label>
  18. <div class="layui-input-block">
  19. <input name="title" value='{$vo.title|default=""}' required placeholder="请输入菜单名称" class="layui-input">
  20. <p class="help-block"><b>必选</b>,请填写菜单名称(如:系统管理),建议字符不要太长,一般4-6个汉字</p>
  21. </div>
  22. </div>
  23. <div class="layui-form-item">
  24. <label class="layui-form-label">菜单链接</label>
  25. <div class="layui-input-block">
  26. <input onblur="this.value=this.value === ''?'#':this.value" name="url" required placeholder="请输入菜单链接" value="{$vo.url|default='#'}" class="layui-input">
  27. <p class="help-block">
  28. <b>必选</b>,请填写链接地址或选择系统节点(如:https://domain.com/admin/user/index.html 或 admin/user/index)
  29. <br>当填写链接地址时,以下面的“权限节点”来判断菜单自动隐藏或显示,注意未填写“权限节点”时将不会隐藏该菜单哦
  30. </p>
  31. </div>
  32. </div>
  33. <div class="layui-form-item">
  34. <label class="layui-form-label">链接参数</label>
  35. <div class="layui-input-block">
  36. <input name="params" placeholder="请输入链接参数" value="{$vo.params|default=''}" class="layui-input">
  37. <p class="help-block">可选,设置菜单链接的GET访问参数(如:name=1&age=3)</p>
  38. </div>
  39. </div>
  40. <div class="layui-form-item">
  41. <label class="layui-form-label">权限节点</label>
  42. <div class="layui-input-block">
  43. <input name="node" placeholder="请输入权限节点" value="{$vo.node|default=''}" class="layui-input">
  44. <p class="help-block">可选,请填写系统权限节点(如:admin/user/index),未填写时默认解释"菜单链接"判断是否拥有访问权限;</p>
  45. </div>
  46. </div>
  47. <div class="layui-form-item">
  48. <label class="layui-form-label">菜单图标</label>
  49. <div class="layui-input-block">
  50. <div class="layui-input-inline">
  51. <input placeholder="请输入或选择图标" name="icon" value='{$vo.icon|default=""}' class="layui-input">
  52. </div>
  53. <span style="padding:0 12px;min-width:45px" class='layui-btn layui-btn-primary'>
  54. <i style="font-size:1.2em;margin:0;float:none" class='{$vo.icon|default=""}'></i>
  55. </span>
  56. <button data-icon='icon' type='button' class='layui-btn layui-btn-primary'>选择图标</button>
  57. <p class="help-block">可选,设置菜单选项前置图标,目前只支持 Font Awesome 5.2.0 字体图标</p>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="hr-line-dashed"></div>
  62. {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
  63. <div class="layui-form-item text-center">
  64. <button class="layui-btn" type='submit'>保存数据</button>
  65. <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
  66. </div>
  67. </form>
  68. {block name='script'}
  69. <script>
  70. layui.form.render();
  71. require(['jquery.autocompleter'], function () {
  72. $('[name="icon"]').on('change', function () {
  73. $(this).parent().next().find('i').get(0).className = this.value
  74. });
  75. $('input[name=url]').autocompleter({
  76. limit: 6, highlightMatches: true, template: '{{ label }} <span> {{ title }} </span>', callback: function (node) {
  77. $('input[name=node]').val(node);
  78. }, source: (function (subjects, data) {
  79. for (var i in subjects) data.push({value: subjects[i].node, label: subjects[i].node, title: subjects[i].title});
  80. return data;
  81. })(JSON.parse('{$nodes|raw|json_encode}'), [])
  82. });
  83. $('input[name=node]').autocompleter({
  84. limit: 5, highlightMatches: true, template: '{{ label }} <span> {{ title }} </span>', source: (function (subjects, data) {
  85. for (var i in subjects) data.push({value: subjects[i].node, label: subjects[i].node, title: subjects[i].title});
  86. return data;
  87. })(JSON.parse('{$auths|raw|json_encode}'), [])
  88. });
  89. });
  90. </script>
  91. {/block}