jqh 4 years ago
parent
commit
a597862b9c

+ 175 - 171
resources/assets/dcat/extra/Grid/Tree.js

@@ -1,171 +1,175 @@
-/**
- * 树形表格
- */
-
-export default class Tree {
-    constructor(Helper, opts) {
-        this.options = $.extend({
-            button: null,
-            table: null,
-            url: '',
-            perPage: '',
-            showNextPage: '',
-            pageQueryName: '',
-            parentIdQueryName: '',
-            depthQueryName: '',
-            showIcon: 'fa-angle-right',
-            hideIcon: 'fa-angle-down',
-            loadMoreIcon: '<i class="feather icon-more-horizontal"></i>',
-        }, opts);
-
-        this.helper = Helper;
-        
-        this.key = this.depth = this.row = this.data = this._req = null;
-
-        this._init();
-    }
-
-    // 绑定点击事件
-    _init () {
-        var _this = this,
-            opts = _this.options;
-
-        $(opts.button).off('click').click(function () {
-            if (_this._req) {
-                return;
-            }
-
-            var $this = $(this),
-                _i = $("i", this),
-                shown = _i.hasClass(opts.showIcon);
-
-            _this.key = $this.data('key');
-            _this.depth = $this.data('depth');
-            _this.row = $this.closest('tr');
-
-            if ($this.data('inserted') == '0') {
-                _this.request(1);
-                $this.data('inserted', 1);
-            }
-
-            _i.toggleClass(opts.showIcon + ' ' + opts.hideIcon);
-
-            var children = [];
-
-            _this.helper.getChildren(_this.row.nextAll(), _this.row).forEach(function (v) {
-                if (_this.helper.getDepth(v) !== (_this.depth + 1)) {
-                    return;
-                }
-
-                children.push(v);
-
-                shown ? $(v).show() : $(v).hide();
-            });
-
-            children.forEach(function (v) {
-                if (shown) {
-                    return
-                }
-
-                var icon = $(v).find('a[data-depth=' + _this.helper.getDepth(v) + '] i');
-
-                if (icon.hasClass(opts.hideIcon)) {
-                    icon.parent().click();
-                }
-            })
-        })
-    }
-
-    // 发起请求
-    request (page, after) {
-        var _this = this,
-            row = _this.row,
-            key = _this.key,
-            depth = _this.depth,
-            tableSelector = _this.options.table;
-
-        if (_this._req) {
-            return;
-        }
-        _this._req = 1;
-        Dcat.loading();
-
-        var data = {};
-
-        data[_this.options.parentIdQueryName] = key;
-        data[_this.options.depthQueryName] = depth + 1;
-        data[_this.options.pageQueryName.replace(':key', key)] = page;
-
-        $.ajax({
-            url: _this.options.url,
-            type: 'GET',
-            data: data,
-            headers: {'X-PJAX': true},
-            success: function (resp) {
-                after && after();
-                Dcat.loading(false);
-                _this._req = 0;
-
-                // 获取最后一行
-                var children = _this.helper.getChildren(row.nextAll(), row);
-                row = children.length ? $(children.pop()) : row;
-
-                var _body = $('<div>'+resp+'</div>'),
-                    _tbody = _body.find(tableSelector + ' tbody'),
-                    lastPage = _body.find('last-page').text(),
-                    nextPage = _body.find('next-page').text();
-
-                // 标记子节点行
-                _tbody.find('tr').each(function (_, v) {
-                    $(v).attr('data-depth', depth + 1)
-                });
-
-                if (
-                    _this.options.showNextPage
-                    && _tbody.find('tr').length == _this.options.perPage
-                    && lastPage >= page
-                ) {
-                    // 加载更多
-                    let loadMore = $(
-                        `<tr data-depth="${depth + 1}" data-page="${nextPage}">
-                                <td colspan="${row.find('td').length}" align="center" style="cursor: pointer"> 
-                                    <a href="#" style="font-size: 1.5rem">${_this.options.loadMoreIcon}</a> 
-                                </td>
-                            </tr>`
-                    );
-
-                    row.after(loadMore);
-
-                    // 加载更多
-                    loadMore.click(function () {
-                        var _t = $(this);
-                        _this.request(_t.data('page'), function () {
-                            _t.remove();
-                        });
-                    });
-                }
-
-                // 附加子节点
-                row.after(_tbody.html());
-
-                // 附加子节点js脚本以及触发子节点js脚本执行
-                _body.find('script').each(function (_, v) {
-                    row.after(v);
-                });
-                // 主动触发ready事件,执行子节点附带的js脚本
-                Dcat.triggerReady();
-            },
-            error:function(a, b, c){
-                after && after();
-
-                Dcat.loading(false);
-
-                _this._req = 0;
-
-                if (a.status != 404) {
-                    Dcat.handleAjaxError(a, b, c);
-                }
-            }
-        });
-    }
-}
+/**
+ * 树形表格
+ */
+
+export default class Tree {
+    constructor(Helper, opts) {
+        this.options = $.extend({
+            button: null,
+            table: null,
+            url: '',
+            perPage: '',
+            showNextPage: '',
+            pageQueryName: '',
+            parentIdQueryName: '',
+            depthQueryName: '',
+            showIcon: 'fa-angle-right',
+            hideIcon: 'fa-angle-down',
+            loadMoreIcon: '<i class="feather icon-more-horizontal"></i>',
+        }, opts);
+
+        this.helper = Helper;
+
+        this.key = this.depth = this.row = this.data = this._req = null;
+
+        this._init();
+    }
+
+    // 绑定点击事件
+    _init () {
+        var _this = this,
+            opts = _this.options;
+
+        $(opts.button).off('click').click(function () {
+            if (_this._req) {
+                return;
+            }
+
+            var $this = $(this),
+                _i = $("i", this),
+                shown = _i.hasClass(opts.showIcon);
+
+            _this.key = $this.data('key');
+            _this.depth = $this.data('depth');
+            _this.row = $this.closest('tr');
+
+            if ($this.data('inserted') == '0') {
+                _this.request(1);
+                $this.data('inserted', 1);
+            }
+
+            _i.toggleClass(opts.showIcon + ' ' + opts.hideIcon);
+
+            var children = [];
+
+            _this.helper.getChildren(_this.row.nextAll(), _this.row).forEach(function (v) {
+                if (_this.helper.getDepth(v) !== (_this.depth + 1)) {
+                    return;
+                }
+
+                children.push(v);
+
+                shown ? $(v).show() : $(v).hide();
+            });
+
+            children.forEach(function (v) {
+                if (shown) {
+                    return
+                }
+
+                var icon = $(v).find('a[data-depth=' + _this.helper.getDepth(v) + '] i');
+
+                if (icon.hasClass(opts.hideIcon)) {
+                    icon.parent().click();
+                }
+            })
+        })
+    }
+
+    // 发起请求
+    request (page, after) {
+        var _this = this,
+            row = _this.row,
+            key = _this.key,
+            depth = _this.depth,
+            tableSelector = _this.options.table;
+
+        if (_this._req) {
+            return;
+        }
+        _this._req = 1;
+        Dcat.loading();
+
+        var data = {};
+
+        data[_this.options.parentIdQueryName] = key;
+        data[_this.options.depthQueryName] = depth + 1;
+        data[_this.options.pageQueryName.replace(':key', key)] = page;
+
+        $.ajax({
+            url: _this.options.url,
+            type: 'GET',
+            data: data,
+            headers: {'X-PJAX': true},
+            success: function (resp) {
+                after && after();
+                Dcat.loading(false);
+                _this._req = 0;
+
+                // 获取最后一行
+                var children = _this.helper.getChildren(row.nextAll(), row);
+                row = children.length ? $(children.pop()) : row;
+
+                var _body = $('<div>'+resp+'</div>'),
+                    _tbody = _body.find(tableSelector + ' tbody'),
+                    lastPage = _body.find('last-page').text(),
+                    nextPage = _body.find('next-page').text();
+
+                // 标记子节点行
+                _tbody.find('tr').each(function (_, v) {
+                    $(v).attr('data-depth', depth + 1)
+                });
+
+                if (
+                    _this.options.showNextPage
+                    && _tbody.find('tr').length == _this.options.perPage
+                    && lastPage >= page
+                ) {
+                    // 加载更多
+                    let loadMore = $(
+                        `<tr data-depth="${depth + 1}" data-page="${nextPage}">
+                                <td colspan="${row.find('td').length}" align="center" style="cursor: pointer">
+                                    <a href="#" style="font-size: 1.5rem">${_this.options.loadMoreIcon}</a>
+                                </td>
+                            </tr>`
+                    );
+
+                    row.after(loadMore);
+
+                    // 加载更多
+                    loadMore.click(function () {
+                        var _t = $(this);
+                        _this.request(_t.data('page'), function () {
+                            _t.remove();
+                        });
+                    });
+                }
+
+                // 附加子节点
+                row.after(_tbody.html());
+
+                // 附加子节点js脚本以及触发子节点js脚本执行
+                _body.find('script').each(function (_, v) {
+                    row.after(v);
+                });
+
+                // 附加的HTML
+                $('body .extra-html').html(_body.find('.extra-html').html());
+
+                // 主动触发ready事件,执行子节点附带的js脚本
+                Dcat.triggerReady();
+            },
+            error:function(a, b, c){
+                after && after();
+
+                Dcat.loading(false);
+
+                _this._req = 0;
+
+                if (a.status != 404) {
+                    Dcat.handleAjaxError(a, b, c);
+                }
+            }
+        });
+    }
+}

File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js.map


+ 58 - 58
resources/views/layouts/content.blade.php

@@ -1,58 +1,58 @@
-@section('content-header')
-    <section class="content-header breadcrumbs-top">
-        @if($header || $description)
-            <h1 class=" float-left">
-                <span class="text-capitalize">{!! $header !!}</span>
-                <small>{!! $description !!}</small>
-            </h1>
-        @elseif($breadcrumb || config('admin.enable_default_breadcrumb'))
-            <div>&nbsp;</div>
-        @endif
-
-        @include('admin::partials.breadcrumb')
-
-    </section>
-@endsection
-
-@section('content')
-    @include('admin::partials.alerts')
-    @include('admin::partials.exception')
-
-    {!! $content !!}
-
-    @include('admin::partials.toastr')
-@endsection
-
-@section('app')
-    {!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
-
-    <div class="content-header">
-        @yield('content-header')
-    </div>
-
-    <div class="content-body" id="app">
-        {{-- 页面埋点--}}
-        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_BEFORE']) !!}
-
-        @yield('content')
-
-        {{-- 页面埋点--}}
-        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_AFTER']) !!}
-    </div>
-
-    {!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
-    {!! Dcat\Admin\Admin::html() !!}
-@endsection
-
-@if(! request()->pjax())
-    @include('admin::layouts.page')
-@else
-    <title>{{ Dcat\Admin\Admin::title() }} @if($header) | {{ $header }}@endif</title>
-
-    <script>Dcat.pjaxResponded()</script>
-
-    {!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
-    {!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
-
-    @yield('app')
-@endif
+@section('content-header')
+    <section class="content-header breadcrumbs-top">
+        @if($header || $description)
+            <h1 class=" float-left">
+                <span class="text-capitalize">{!! $header !!}</span>
+                <small>{!! $description !!}</small>
+            </h1>
+        @elseif($breadcrumb || config('admin.enable_default_breadcrumb'))
+            <div>&nbsp;</div>
+        @endif
+
+        @include('admin::partials.breadcrumb')
+
+    </section>
+@endsection
+
+@section('content')
+    @include('admin::partials.alerts')
+    @include('admin::partials.exception')
+
+    {!! $content !!}
+
+    @include('admin::partials.toastr')
+@endsection
+
+@section('app')
+    {!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
+
+    <div class="content-header">
+        @yield('content-header')
+    </div>
+
+    <div class="content-body" id="app">
+        {{-- 页面埋点--}}
+        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_BEFORE']) !!}
+
+        @yield('content')
+
+        {{-- 页面埋点--}}
+        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_AFTER']) !!}
+    </div>
+
+    {!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
+    <div class="extra-html">{!! Dcat\Admin\Admin::html() !!}</div>
+@endsection
+
+@if(! request()->pjax())
+    @include('admin::layouts.page')
+@else
+    <title>{{ Dcat\Admin\Admin::title() }} @if($header) | {{ $header }}@endif</title>
+
+    <script>Dcat.pjaxResponded()</script>
+
+    {!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
+    {!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
+
+    @yield('app')
+@endif

+ 26 - 26
resources/views/layouts/form-content.blade.php

@@ -1,26 +1,26 @@
-<script>Dcat.pjaxResponded();</script>
-
-<style>
-    .form-content .row {
-        margin-right: 0;
-        margin-left: 0;
-    }
-</style>
-
-{{--必须在静态资源加载前,用section先渲染 content--}}
-@section('content')
-    <section class="form-content">{!! $content !!}</section>
-@endsection
-
-{!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
-{!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
-
-{!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
-
-@yield('content')
-
-{!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
-{!! Dcat\Admin\Admin::html() !!}
-
-{{--select2下拉选框z-index必须大于弹窗的值--}}
-<style>.select2-dropdown {z-index: 99999999999}</style>
+<script>Dcat.pjaxResponded();</script>
+
+<style>
+    .form-content .row {
+        margin-right: 0;
+        margin-left: 0;
+    }
+</style>
+
+{{--必须在静态资源加载前,用section先渲染 content--}}
+@section('content')
+    <section class="form-content">{!! $content !!}</section>
+@endsection
+
+{!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
+{!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
+
+{!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
+
+@yield('content')
+
+{!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
+<div class="extra-html">{!! Dcat\Admin\Admin::html() !!}</div>
+
+{{--select2下拉选框z-index必须大于弹窗的值--}}
+<style>.select2-dropdown {z-index: 99999999999}</style>

+ 41 - 41
resources/views/layouts/full-content.blade.php

@@ -1,41 +1,41 @@
-@section('content')
-    <section class="content">
-        @include('admin::partials.alerts')
-        @include('admin::partials.exception')
-
-        {!! $content !!}
-
-        @include('admin::partials.toastr')
-    </section>
-@endsection
-
-@section('app')
-    {!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
-
-    <div class="content-body" id="app">
-        {{-- 页面埋点--}}
-        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_BEFORE']) !!}
-
-        @yield('content')
-
-        {{-- 页面埋点--}}
-        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_AFTER']) !!}
-    </div>
-
-    {!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
-    {!! Dcat\Admin\Admin::html() !!}
-@endsection
-
-
-@if(!request()->pjax())
-    @include('admin::layouts.full-page', ['header' => $header])
-@else
-    <title>{{ Dcat\Admin\Admin::title() }} @if($header) | {{ $header }}@endif</title>
-
-    <script>Dcat.pjaxResponded();</script>
-
-    {!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
-    {!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
-
-    @yield('app')
-@endif
+@section('content')
+    <section class="content">
+        @include('admin::partials.alerts')
+        @include('admin::partials.exception')
+
+        {!! $content !!}
+
+        @include('admin::partials.toastr')
+    </section>
+@endsection
+
+@section('app')
+    {!! Dcat\Admin\Admin::asset()->styleToHtml() !!}
+
+    <div class="content-body" id="app">
+        {{-- 页面埋点--}}
+        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_BEFORE']) !!}
+
+        @yield('content')
+
+        {{-- 页面埋点--}}
+        {!! admin_section(Dcat\Admin\Admin::SECTION['APP_INNER_AFTER']) !!}
+    </div>
+
+    {!! Dcat\Admin\Admin::asset()->scriptToHtml() !!}
+    <div class="extra-html">{!! Dcat\Admin\Admin::html() !!}</div>
+@endsection
+
+
+@if(!request()->pjax())
+    @include('admin::layouts.full-page', ['header' => $header])
+@else
+    <title>{{ Dcat\Admin\Admin::title() }} @if($header) | {{ $header }}@endif</title>
+
+    <script>Dcat.pjaxResponded();</script>
+
+    {!! Dcat\Admin\Admin::asset()->cssToHtml() !!}
+    {!! Dcat\Admin\Admin::asset()->jsToHtml() !!}
+
+    @yield('app')
+@endif

+ 15 - 8
src/Grid/Column.php

@@ -267,19 +267,17 @@ class Column
 
     /**
      * @example
-     *     $grid->config
-     *         ->if(function () {
-     *             return $this->config ? true : false;
+     *     $grid->column('...')
+     *         ->if(function ($column) {
+     *             return $column->getValue() ? true : false;
      *         })
      *         ->display($view)
      *         ->expand(...)
      *         ->else()
-     *         ->emptyString()
+     *         ->display('')
      *
-     *    $grid->config
-     *         ->if(function () {
-     *             return $this->config ? true : false;
-     *         })
+     *    $grid->column('...')
+     *         ->if()
      *         ->then(function (Column $column) {
      *             $column ->display($view)->expand(...);
      *         })
@@ -287,6 +285,15 @@ class Column
      *             $column->emptyString();
      *         })
      *
+     *     $grid->column('...')
+     *         ->if()
+     *         ->display($view)
+     *         ->expand(...)
+     *         ->else()
+     *         ->display('')
+     *         ->end()
+     *         ->modal()
+     *
      * @param \Closure $condition
      *
      * @return Column\Condition

Some files were not shown because too many files changed in this diff