create.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <div style="margin-top: 10px;" id="menus-app">
  2. <div style="text-align: center;margin-top: 5px;margin-bottom: 10px;font-size: 20px;">
  3. 新增 - 菜单
  4. </div>
  5. <el-form action="{{route('admin.menu.save')}}" method="post" id="form-create">
  6. <!-- image -->
  7. <!-- link -->
  8. <ui-input-text label="菜单名称" name="menu_name" placeholder="请输入菜单名称" maxlength="255"
  9. autofocus="true"></ui-input-text>
  10. <ui-input-text label="菜单图标" v-if="level*1==0" name="label_name" placeholder="请输入菜单图标class名称" maxlength="255"
  11. autofocus="true"></ui-input-text>
  12. <ui-select label="菜单层级:" value="{{$p_id>0?'1':'0'}}" @set-keys="setLevel" id="level" name="level" placeholder=""
  13. :options="level_list" :free="true"></ui-select>
  14. <ui-linkage label="父级菜单" v-if="level*1>0" :options="menu_list"></ui-linkage>
  15. <ui-input-text label="菜单路由" v-if="level*1==1" name="url_name" placeholder="请输入需要绑定的路由地址" maxlength="255"
  16. autofocus="true"></ui-input-text>
  17. <ui-input-number label="排序" checked="checked" value="50" name="sort" min="1" max="1000000" ></ui-input-number>
  18. <!-- show -->
  19. <ui-submit></ui-submit>
  20. </el-form>
  21. </div>
  22. <script type="application/javascript">
  23. $(function () {
  24. // 注意:Vue组件一定放在jQuery.validator前面验证
  25. new Vue({
  26. el: '#menus-app',
  27. data: function () {
  28. return {
  29. 'p_id':{{$p_id?:0}},
  30. 'level':{{$level}},
  31. 'level_list':{!! $level_list !!},
  32. menu_list: {
  33. 'tier_num': {{$level}},
  34. 'one_id': '{{$one_id}}',
  35. 'two_id': '{{$two_id}}',
  36. 'send_url': '{{route('admin.menu.parentMenu')}}',
  37. 'one_name':'one_name',
  38. 'two_name':'two_name',
  39. }
  40. }
  41. },
  42. methods: {
  43. setLevel: function (level) {
  44. console.log('数据变化:' + level);
  45. this.level = level;
  46. this.menu_list.tier_num=level;
  47. console.log('-------------'+this.menu_list.tier_num)
  48. }
  49. },
  50. });
  51. jQuery.validator.setDefaults({
  52. debug: false, // 调试模式true不会提交,false允许提交
  53. success: "success", // 匹配成功的class样式名称
  54. errorElement: 'div' // 兼容el标签时使用(兼容el Vue组件label.error标签问题)
  55. });
  56. // 前台数据验证 验证需要设置window.form全局变量
  57. window.form = $('#form-create').validate({
  58. rules: {
  59. image: {
  60. required: true,
  61. maxlength: 255,
  62. normalizer: function (value) {
  63. return $.trim(value);
  64. }
  65. },
  66. // link: {
  67. // required: true,
  68. // url:true,
  69. // maxlength: 255,
  70. // normalizer: function ( value ) {
  71. // return $.trim(value);
  72. // }
  73. // },
  74. show: {
  75. required: true
  76. },
  77. sort: {
  78. required: true,
  79. normalizer: function (value) {
  80. return $.trim(value);
  81. }
  82. }
  83. }
  84. });
  85. });
  86. </script>
  87. @include('layouts.admin.form_script')