tree.blade.php 7.6 KB
<div class="box">

    <div class="box-header">

        <div class="btn-group">
            <a class="btn btn-primary btn-sm {{ $id }}-tree-tools" data-action="expand" title="{{ trans('admin.expand') }}">
                <i class="fa fa-plus-square-o"></i>&nbsp;{{ trans('admin.expand') }}
            </a>
            <a class="btn btn-primary btn-sm {{ $id }}-tree-tools" data-action="collapse" title="{{ trans('admin.collapse') }}">
                <i class="fa fa-minus-square-o"></i>&nbsp;{{ trans('admin.collapse') }}
            </a>
        </div>

        @if($useSave)
        <div class="btn-group">
            <a class="btn btn-info btn-sm {{ $id }}-save" title="{{ trans('admin.save') }}"><i class="fa fa-save"></i><span class="hidden-xs">&nbsp;{{ trans('admin.save') }}</span></a>
        </div>
        @endif

        @if($useRefresh)
        <div class="btn-group">
            <a class="btn btn-warning btn-sm {{ $id }}-refresh" title="{{ trans('admin.refresh') }}"><i class="fa fa-refresh"></i><span class="hidden-xs">&nbsp;{{ trans('admin.refresh') }}</span></a>
        </div>
        @endif

        <div class="btn-group">
            {!! $tools !!}
        </div>

        @if($useCreate)
        <div class="btn-group pull-right">
            <a class="btn btn-success btn-sm" href="{{ url($path) }}/create"><i class="fa fa-save"></i><span class="hidden-xs">&nbsp;{{ trans('admin.new') }}</span></a>
        </div>
        @endif

    </div>
    <!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <div class="dd" id="{{ $id }}">
            <ol class="dd-list">
               {{-- @php
                dump($items);
                @endphp--}}
                @each($branchView, $items, 'branch')
            </ol>
        </div>
    </div>
    <!-- /.box-body -->
</div>

 <script>
     $(function () {
         $('.tree_branch_recommend').click(function() {
             var id = $(this).data('id');
             var url = $(this).data('url');
             swal({
                 title: "{{__('recommend_confirm')}}",
                 type: "info",
                 showCancelButton: true,
                 confirmButtonColor: "#DD6B55",
                 confirmButtonText: "{{__('confirm')}}",
                 showLoaderOnConfirm: true,
                 cancelButtonText: "{{__('cancel')}}",
                 preConfirm: function() {
                     return new Promise(function(resolve) {
                         $.ajax({
                             method: 'put',
                             url: url +'/' + id + '/recommended',
                             data: {
                                 _token:LA.token,
                             },
                             success: function (data) {
                                 $.pjax.reload('#pjax-container');
                                 toastr.success('操作成功');
                                 resolve(data);
                             }
                         });
                     });
                 }
             }).then(function(result) {
                 var data = result.value;
                 if (typeof data === 'object') {
                     if (data.status) {
                         // swal_success(data.message);
                     } else {
                         swal_error(data.message);
                     }
                 }
             });
     });

     $('.tree_branch_unrecommend').click(function() {
         var id = $(this).data('id');
         var url = $(this).data('url');
         swal({
             title: "{{__('cancel_recommend_confirm')}}",
             type: "warning",
             showCancelButton: true,
             confirmButtonColor: "#DD6B55",
             confirmButtonText: "{{__('confirm')}}",
             showLoaderOnConfirm: true,
             cancelButtonText: "{{__('cancel')}}",
             preConfirm: function() {
                 return new Promise(function(resolve) {
                     $.ajax({
                         method: 'put',
                         url: url +'/' + id + '/unrecommended',
                         data: {
                             _token:LA.token,
                         },
                         success: function (data) {
                             $.pjax.reload('#pjax-container');
                             toastr.success('操作成功');
                             resolve(data);
                         }
                     });
                 });
             }
         }).then(function(result) {
             var data = result.value;
             if (typeof data === 'object') {
                 if (data.status) {
                     // swal_success(data.message);
                 } else {
                     swal_error(data.message);
                 }
             }
         });
     });

     $('.tree_branch_homepage').click(function() {
         var id = $(this).data('id');
         var url = $(this).data('url');
         swal({
             title: "{{__('homepage_confirm')}}",
             type: "info",
             showCancelButton: true,
             confirmButtonColor: "#DD6B55",
             confirmButtonText: "{{__('confirm')}}",
             showLoaderOnConfirm: true,
             cancelButtonText: "{{__('cancel')}}",
             preConfirm: function() {
                 return new Promise(function(resolve) {
                     $.ajax({
                         method: 'put',
                         url: url +'/' + id + '/homepage',
                         data: {
                             _token:LA.token,
                         },
                         success: function (data) {
                             $.pjax.reload('#pjax-container');
                             toastr.success('操作成功');
                             resolve(data);
                         }
                     });
                 });
             }
         }).then(function(result) {
             var data = result.value;
             if (typeof data === 'object') {
                 if (data.status) {
                     // swal_success(data.message);
                 } else {
                     swal_error(data.message);
                 }
             }
         });
     });

     $('.tree_branch_unhomepage').click(function() {
         var id = $(this).data('id');
         var url = $(this).data('url');
         swal({
             title: "{{__('cancel_homepage_confirm')}}",
             type: "warning",
             showCancelButton: true,
             confirmButtonColor: "#DD6B55",
             confirmButtonText: "{{__('confirm')}}",
             showLoaderOnConfirm: true,
             cancelButtonText: "{{__('cancel')}}",
             preConfirm: function() {
                 return new Promise(function(resolve) {
                     $.ajax({
                         method: 'put',
                         url: url +'/' + id + '/unhomepage',
                         data: {
                             _token:LA.token,
                         },
                         success: function (data) {
                             $.pjax.reload('#pjax-container');
                             toastr.success('操作成功');
                             resolve(data);
                         }
                     });
                 });
             }
         }).then(function(result) {
             var data = result.value;
             if (typeof data === 'object') {
                 if (data.status) {
                     // swal_success(data.message);
                 } else {
                     swal_error(data.message);
                 }
             }
         });
     });
 });

 </script>