form.html 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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>
  5. <div class="layui-input-block">
  6. <select name='pid' class='layui-select' lay-search>
  7. <!--{foreach $menus as $menu}-->
  8. <!--{eq name='menu.id' value='$vo.pid|default=0'}-->
  9. <option selected value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
  10. <!--{else}-->
  11. <option value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
  12. <!--{/eq}-->
  13. <!--{/foreach}-->
  14. </select>
  15. <p class="help-block">必选,请选择上级菜单或顶级菜单(目前最多支持三级菜单)</p>
  16. </div>
  17. </div>
  18. <div class="layui-form-item">
  19. <label class="layui-form-label">菜单名称</label>
  20. <div class="layui-input-block">
  21. <input name="title" value='{$vo.title|default=""}' required placeholder="请输入菜单名称" class="layui-input">
  22. <p class="help-block">必填,请填写菜单名称(如:系统管理),建议字符不要太长,一般4-6个汉字</p>
  23. </div>
  24. </div>
  25. <div class="layui-form-item">
  26. <label class="layui-form-label">菜单链接</label>
  27. <div class="layui-input-block">
  28. <input onblur="this.value=this.value === ''?'#':this.value" name="url" required placeholder="请输入菜单链接" value="{$vo.url|default='#'}" class="layui-input">
  29. <p class="help-block">
  30. 必填,请填写系统节点(如:admin/user/index),节点加入权限管理时菜单才会自动隐藏,非规则内的不会隐藏;
  31. <br>正常情况下,在输入的时候会有自动提示。如果是上级菜单时,请填写"#"符号,不要填写地址或节点地址
  32. </p>
  33. </div>
  34. </div>
  35. <div class="layui-form-item">
  36. <label class="layui-form-label">链接参数</label>
  37. <div class="layui-input-block">
  38. <input name="params" placeholder="请输入链接参数" value="{$vo.params|default=''}" class="layui-input">
  39. <p class="help-block">可选,设置菜单链接的GET访问参数(如:name=1&age=3)</p>
  40. </div>
  41. </div>
  42. <div class="layui-form-item">
  43. <label class="layui-form-label">菜单图标</label>
  44. <div class="layui-input-block">
  45. <div class="layui-input-inline">
  46. <input placeholder="请输入或选择图标" name="icon" value='{$vo.icon|default=""}' class="layui-input">
  47. </div>
  48. <span style="padding:0 12px;min-width:45px" class='layui-btn layui-btn-primary'>
  49. <i style="font-size:1.2em;margin:0" class='{$vo.icon|default=""}'></i>
  50. </span>
  51. <button data-icon='icon' type='button' class='layui-btn layui-btn-primary'>选择图标</button>
  52. <p class="help-block">可选,设置菜单选项前置图标,目前只支持 Font Awesome 5.2.0 字体图标</p>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="hr-line-dashed"></div>
  57. {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
  58. <div class="layui-form-item text-center">
  59. <button class="layui-btn" type='submit'>保存数据</button>
  60. <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
  61. </div>
  62. </form>
  63. {block name='script'}
  64. <script>
  65. require(['jquery.autocompleter'], function () {
  66. form.render();
  67. $('[name="icon"]').on('change', function () {
  68. $(this).parent().next().find('i').get(0).className = this.value
  69. });
  70. $('input[name=url]').autocompleter({
  71. limit: 6, highlightMatches: true, template: '{{ label }} <span> {{ title }} </span>', source: (function (subjects, data) {
  72. for (var i in subjects) data.push({value: subjects[i].node, label: subjects[i].node, title: subjects[i].title});
  73. return data;
  74. })(JSON.parse('{$nodes|raw|json_encode}'), [])
  75. });
  76. });
  77. </script>
  78. {/block}