edit.blade.php 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.update',array('id'=>$model->id))}}" method="post" id="form-create">
  6. <!-- 图片 -->
  7. <ui-input-text label="菜单名称" name="menu_name" value="{{$model->menu_name}}" placeholder="请输入菜单名称" maxlength="255"
  8. autofocus="true"></ui-input-text>
  9. <ui-input-text label="菜单图标" value="{{$model->label_name}}" v-if="level*1==0" name="label_name"
  10. 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" value="{{$model->url_name}}" name="url_name"
  16. placeholder="请输入需要绑定的路由地址" maxlength="255"
  17. autofocus="true"></ui-input-text>
  18. <ui-input-number label="排序" checked="checked" value="{{$model->sort}}" name="sort" min="1" max="1000000" ></ui-input-number>
  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. }
  48. },
  49. });
  50. jQuery.validator.setDefaults({
  51. debug: false, // 调试模式true不会提交,false允许提交
  52. success: "success", // 匹配成功的class样式名称
  53. errorElement: 'div' // 兼容el标签时使用(兼容el Vue组件label.error标签问题)
  54. });
  55. // 前台数据验证 验证需要设置window.form全局变量
  56. window.form = $('#form-create').validate({
  57. rules: {
  58. image: {
  59. required: true,
  60. maxlength: 255,
  61. normalizer: function (value) {
  62. return $.trim(value);
  63. }
  64. },
  65. // link: {
  66. // required: true,
  67. // maxlength: 255,
  68. // normalizer: function ( value ) {
  69. // return $.trim(value);
  70. // }
  71. // },
  72. show: {
  73. required: true
  74. },
  75. sort: {
  76. required: true,
  77. normalizer: function (value) {
  78. return $.trim(value);
  79. }
  80. }
  81. }
  82. });
  83. // 编辑保存变量
  84. window.formDatum = $('form').serialize();
  85. });
  86. </script>
  87. @include('layouts.admin.form_script')