Jelajahi Sumber

Merge branch '2.0' into gitee2

Jiang qinghua 4 tahun lalu
induk
melakukan
adbf0141be
46 mengubah file dengan 448 tambahan dan 234 penghapusan
  1. 2 1
      composer.json
  2. 7 2
      resources/assets/dcat/extra/Upload/AddFile.js
  3. 180 167
      resources/assets/dcat/extra/Upload/AddUploadedFile.js
  4. 6 0
      resources/assets/dcat/extra/upload.js
  5. 2 1
      resources/assets/dcat/extra/upload.scss
  6. 2 1
      resources/assets/dcat/plugins/webuploader/webuploader.css
  7. 0 0
      resources/dist/adminlte/adminlte-blue-light.css
  8. 0 0
      resources/dist/adminlte/adminlte-blue.css
  9. 0 0
      resources/dist/adminlte/adminlte-green.css
  10. 0 0
      resources/dist/adminlte/adminlte.css
  11. 0 0
      resources/dist/adminlte/adminlte.js
  12. 0 0
      resources/dist/adminlte/adminlte.js.map
  13. 0 0
      resources/dist/dcat/extra/action.js.map
  14. 0 0
      resources/dist/dcat/extra/grid-extend.js
  15. 0 0
      resources/dist/dcat/extra/grid-extend.js.map
  16. 0 0
      resources/dist/dcat/extra/select-table.js.map
  17. 0 0
      resources/dist/dcat/extra/upload.css
  18. 0 0
      resources/dist/dcat/extra/upload.js
  19. 0 0
      resources/dist/dcat/extra/upload.js.map
  20. 0 0
      resources/dist/dcat/js/dcat-app.js
  21. 0 0
      resources/dist/dcat/js/dcat-app.js.map
  22. 2 1
      resources/dist/dcat/plugins/webuploader/webuploader.css
  23. 73 4
      resources/views/form/map.blade.php
  24. 7 3
      resources/views/grid/batch-actions.blade.php
  25. 2 2
      resources/views/widgets/radio.blade.php
  26. 1 1
      src/Actions/Action.php
  27. 1 1
      src/Admin.php
  28. 3 2
      src/AdminServiceProvider.php
  29. 8 8
      src/Extend/ServiceProvider.php
  30. 1 1
      src/Extend/Setting.php
  31. 3 1
      src/Form/Field/Checkbox.php
  32. 11 0
      src/Form/Field/Map.php
  33. 3 1
      src/Form/Field/Radio.php
  34. 4 1
      src/Form/Field/Select.php
  35. 1 1
      src/Form/Field/SelectTable.php
  36. 46 0
      src/Form/Field/Sizeable.php
  37. 2 0
      src/Form/Field/Text.php
  38. 14 0
      src/Form/Field/WebUploader.php
  39. 1 1
      src/Grid.php
  40. 3 0
      src/Grid/Filter/Scope.php
  41. 41 0
      src/Grid/Model.php
  42. 13 0
      src/Grid/Tools/ActionDivider.php
  43. 5 0
      src/Grid/Tools/BatchActions.php
  44. 1 1
      src/Http/Controllers/PermissionController.php
  45. 3 13
      src/Repositories/EloquentRepository.php
  46. 0 20
      src/Widgets/Radio.php

+ 2 - 1
composer.json

@@ -14,7 +14,8 @@
     "require": {
     "require": {
         "php": ">=7.1.0",
         "php": ">=7.1.0",
         "laravel/framework": "~5.5|~6.0|~7.0|~8.0",
         "laravel/framework": "~5.5|~6.0|~7.0|~8.0",
-        "spatie/eloquent-sortable": "3.*|4.*"
+        "spatie/eloquent-sortable": "3.*|4.*",
+        "doctrine/dbal": "^2.6|^3.0"
     },
     },
     "require-dev": {
     "require-dev": {
         "laravel/dusk": "~5.9|~6",
         "laravel/dusk": "~5.9|~6",

+ 7 - 2
resources/assets/dcat/extra/Upload/AddFile.js

@@ -42,8 +42,9 @@ export default class AddFile {
                 `);
                 `);
 
 
             $btns = $(`
             $btns = $(`
-<span style="right: 45px;" class="file-action d-none" data-file-act='order' data-order="1"><i class='feather icon-arrow-up'></i></span>
-<span style="right: 25px;" class="file-action d-none" data-file-act='order' data-order="0"><i class='feather icon-arrow-down'></i></span>
+<span style="right: 65px;" class="file-action d-none" data-file-act='order' data-order="1"><i class='feather icon-arrow-up'></i></span>
+<span style="right: 45px;" class="file-action d-none" data-file-act='order' data-order="0"><i class='feather icon-arrow-down'></i></span>
+<span style="right: 25px;" class="file-action d-none" data-file-act='download' data-id=''><i class='feather icon-download-cloud'></i></span>
 <span data-file-act="cancel" class="file-action" style="font-size:13px">
 <span data-file-act="cancel" class="file-action" style="font-size:13px">
     <i class="feather icon-x red-dark"></i>
     <i class="feather icon-x red-dark"></i>
 </span>
 </span>
@@ -236,6 +237,10 @@ export default class AddFile {
 
 
                     helper.orderFiles($(this));
                     helper.orderFiles($(this));
 
 
+                    break;
+                case 'download':
+                    window.open($(this).attr('data-id'));
+
                     break;
                     break;
             }
             }
 
 

+ 180 - 167
resources/assets/dcat/extra/Upload/AddUploadedFile.js

@@ -1,167 +1,180 @@
-
-export default class AddUploadedFile {
-    constructor(Uploder) {
-        this.uploader = Uploder;
-
-        // 已上传的文件
-        this.uploadedFiles = [];
-
-        this.init = false;
-    }
-
-    // 渲染已上传文件
-    render(file) {
-        let _this = this,
-            parent =  _this.uploader,
-            options = parent.options,
-            showImg = parent.isImage(),
-            html = "";
-
-        html += "<li title='" + file.serverPath + "'>";
-
-        if (! showImg && options.sortable) {
-            // 文件排序
-            html += `
-<p style="right: 45px" class="file-action" data-file-act='order' data-order="1" data-id='${file.serverId}'><i class='feather icon-arrow-up'></i></p>
-<p style="right: 25px" class="file-action" data-file-act='order' data-order="0" data-id='${file.serverId}'><i class='feather icon-arrow-down'></i></p>
-`;
-        }
-
-        if (showImg) {
-            html += `<p class='imgWrap'><img src='${file.serverUrl}'></p>`
-        } else if (!options.disabled) {
-            html += `<p class="file-action" data-file-act="delete" data-id="${file.serverId}"><i class="feather icon-trash red-dark"></i></p>`;
-        }
-
-        html += "<p class='title' style=''><i class='feather icon-check text-white icon-success text-white'></i>";
-        html += file.serverPath;
-        html += "</p>";
-
-        if (showImg) {
-            html += "<p class='title' style='margin-bottom:20px;'>&nbsp;</p>";
-            html += "<div class='file-panel' >";
-
-            if (!options.disabled) {
-                html += `<a class='btn btn-sm btn-white' data-file-act='deleteurl' data-id='${file.serverId}'><i class='feather icon-trash red-dark' style='font-size:13px'></i></a>`;
-            }
-            html += `<a class='btn btn-sm btn-white' data-file-act='preview' data-url='${file.serverUrl}' ><i class='feather icon-zoom-in'></i></a>`;
-
-            if (options.sortable) {
-                // 文件排序
-                html += `
-<a class='btn btn-sm btn-white' data-file-act='order' data-order="1" data-id='${file.serverId}'><i class='feather icon-arrow-up'></i></a>
-<a class='btn btn-sm btn-white' data-file-act='order' data-order="0" data-id='${file.serverId}'><i class='feather icon-arrow-down'></i></a>
-`;
-            }
-
-            html += "</div>";
-        } else {
-
-        }
-
-        html += "</li>";
-        html = $(html);
-
-        if (!showImg) {
-            html.find('.file-type').show();
-            html.find('.title').show();
-            parent.$wrapper.css('background', 'transparent');
-        }
-
-        // 删除操作
-        let deleteFile = function () {
-            var fileId = $(this).data('id');
-
-            // 本地删除
-            if (options.removable) {
-                html.remove();
-
-                return _this.removeFormFile(fileId);
-            }
-
-            // 发起删除请求
-            parent.request.delete({serverId: fileId}, function () {
-                // 移除
-                html.remove();
-
-                _this.removeFormFile(fileId);
-            });
-        };
-
-        // 删除按钮点击事件
-        html.find('[data-file-act="deleteurl"]').click(deleteFile);
-        html.find('[data-file-act="delete"]').click(deleteFile);
-
-        // 文件排序
-        if (options.sortable) {
-            html.find('[data-file-act="order"').click(function () {
-                parent.helper.orderFiles($(this));
-            });
-        }
-
-        // 图片预览
-        html.find('[data-file-act="preview"]').click(function () {
-            var url = $(this).data('url');
-
-            Dcat.helpers.previewImage(url);
-        });
-
-        parent.formFiles[file.serverId] = file;
-
-        parent.input.add(file.serverId);
-
-        parent.$files.append(html);
-
-        if (showImg) {
-            setTimeout(function () {
-                html.css('margin', '5px');
-            }, _this.init ? 0 : 400);
-
-            _this.init = 1;
-        }
-    }
-
-    // 重新渲染已上传的文件
-    reRender() {
-        for (let i in this.uploadedFiles) {
-            if (this.uploadedFiles[i]) {
-                this.render(this.uploadedFiles[i])
-            }
-        }
-    }
-
-    // 移除已上传文件
-    removeFormFile(fileId) {
-        if (!fileId) {
-            return;
-        }
-
-        let _this = this,
-            parent = _this.uploader,
-            uploader = _this.uploader,
-            file = parent.formFiles[fileId];
-
-        parent.input.delete(fileId);
-
-        delete parent.formFiles[fileId];
-
-        if (uploader && !file.fake) {
-            uploader.removeFile(file);
-        }
-
-        parent.status.switch('decrOriginalFileNum');
-        parent.status.switch('incrFileNumLimit');
-
-        if (! Dcat.helpers.len(parent.formFiles) && ! Dcat.helpers.len(parent.percentages)) {
-            parent.status.switch('pending');
-        }
-    }
-
-    add(file) {
-        if (!file.serverId || this.uploader.helper.searchUploadedFile(file.serverId) !== -1) {
-            return;
-        }
-
-        this.uploadedFiles.push(file)
-    }
-}
+
+export default class AddUploadedFile {
+    constructor(Uploder) {
+        this.uploader = Uploder;
+
+        // 已上传的文件
+        this.uploadedFiles = [];
+
+        this.init = false;
+    }
+
+    // 渲染已上传文件
+    render(file) {
+        let _this = this,
+            parent =  _this.uploader,
+            options = parent.options,
+            showImg = parent.isImage(),
+            html = "";
+
+        html += "<li title='" + file.serverPath + "'>";
+
+        if (! showImg && options.sortable) {
+            // 文件排序
+            html += `
+<p style="right: 65px" class="file-action" data-file-act='order' data-order="1" data-id='${file.serverId}'><i class='feather icon-arrow-up'></i></p>
+<p style="right: 45px" class="file-action" data-file-act='order' data-order="0" data-id='${file.serverId}'><i class='feather icon-arrow-down'></i></p>
+`;
+        }
+
+        // 下载
+        if (! showImg && options.downloadable) {
+            html += `
+<p style="right: 25px" class="file-action" data-file-act='download' data-id='${file.serverUrl}'><i class='feather icon-download-cloud'></i></p>
+`;
+        }
+
+        if (showImg) {
+            html += `<p class='imgWrap'><img src='${file.serverUrl}'></p>`
+        } else if (!options.disabled) {
+            html += `<p class="file-action" data-file-act="delete" data-id="${file.serverId}"><i class="feather icon-trash red-dark"></i></p>`;
+        }
+
+        html += "<p class='title' style=''><i class='feather icon-check text-white icon-success text-white'></i>";
+        html += file.serverPath;
+        html += "</p>";
+
+        if (showImg) {
+            html += "<p class='title' style='margin-bottom:20px;'>&nbsp;</p>";
+            html += "<div class='file-panel' >";
+
+            if (!options.disabled) {
+                html += `<a class='btn btn-sm btn-white' data-file-act='deleteurl' data-id='${file.serverId}'><i class='feather icon-trash red-dark' style='font-size:13px'></i></a>`;
+            }
+            html += `<a class='btn btn-sm btn-white' data-file-act='preview' data-url='${file.serverUrl}' ><i class='feather icon-zoom-in'></i></a>`;
+
+            if (options.sortable) {
+                // 文件排序
+                html += `
+<a class='btn btn-sm btn-white' data-file-act='order' data-order="1" data-id='${file.serverId}'><i class='feather icon-arrow-up'></i></a>
+<a class='btn btn-sm btn-white' data-file-act='order' data-order="0" data-id='${file.serverId}'><i class='feather icon-arrow-down'></i></a>
+`;
+            }
+
+            html += "</div>";
+        } else {
+
+        }
+
+        html += "</li>";
+        html = $(html);
+
+        if (!showImg) {
+            html.find('.file-type').show();
+            html.find('.title').show();
+            parent.$wrapper.css('background', 'transparent');
+        }
+
+        // 删除操作
+        let deleteFile = function () {
+            var fileId = $(this).data('id');
+
+            // 本地删除
+            if (options.removable) {
+                html.remove();
+
+                return _this.removeFormFile(fileId);
+            }
+
+            // 发起删除请求
+            parent.request.delete({serverId: fileId}, function () {
+                // 移除
+                html.remove();
+
+                _this.removeFormFile(fileId);
+            });
+        };
+
+        // 删除按钮点击事件
+        html.find('[data-file-act="deleteurl"]').click(deleteFile);
+        html.find('[data-file-act="delete"]').click(deleteFile);
+
+        // 文件排序
+        if (options.sortable) {
+            html.find('[data-file-act="order"]').click(function () {
+                parent.helper.orderFiles($(this));
+            });
+        }
+
+        if (options.downloadable) {
+            html.find('[data-file-act="download"]').click(function () {
+                window.open($(this).attr('data-id'));
+            });
+        }
+
+        // 图片预览
+        html.find('[data-file-act="preview"]').click(function () {
+            var url = $(this).data('url');
+
+            Dcat.helpers.previewImage(url);
+        });
+
+        parent.formFiles[file.serverId] = file;
+
+        parent.input.add(file.serverId);
+
+        parent.$files.append(html);
+
+        if (showImg) {
+            setTimeout(function () {
+                html.css('margin', '5px');
+            }, _this.init ? 0 : 400);
+
+            _this.init = 1;
+        }
+    }
+
+    // 重新渲染已上传的文件
+    reRender() {
+        for (let i in this.uploadedFiles) {
+            if (this.uploadedFiles[i]) {
+                this.render(this.uploadedFiles[i])
+            }
+        }
+    }
+
+    // 移除已上传文件
+    removeFormFile(fileId) {
+        if (!fileId) {
+            return;
+        }
+
+        let _this = this,
+            parent = _this.uploader,
+            uploader = _this.uploader,
+            file = parent.formFiles[fileId];
+
+        parent.input.delete(fileId);
+
+        delete parent.formFiles[fileId];
+
+        if (uploader && !file.fake) {
+            uploader.removeFile(file);
+        }
+
+        parent.status.switch('decrOriginalFileNum');
+        parent.status.switch('incrFileNumLimit');
+
+        if (! Dcat.helpers.len(parent.formFiles) && ! Dcat.helpers.len(parent.percentages)) {
+            parent.status.switch('pending');
+        }
+    }
+
+    add(file) {
+        if (!file.serverId || this.uploader.helper.searchUploadedFile(file.serverId) !== -1) {
+            return;
+        }
+
+        this.uploadedFiles.push(file)
+    }
+}

+ 6 - 0
resources/assets/dcat/extra/upload.js

@@ -33,6 +33,7 @@ import AddUploadedFile from './Upload/AddUploadedFile'
                 disabled: false, // 禁止任何上传编辑
                 disabled: false, // 禁止任何上传编辑
                 autoUpdateColumn: false,
                 autoUpdateColumn: false,
                 removable: false, // 是否允许直接删除服务器图片
                 removable: false, // 是否允许直接删除服务器图片
+                downloadable: false, // 是否允许下载文件
                 dimensions: {
                 dimensions: {
                     // width: 100, // 图片宽限制
                     // width: 100, // 图片宽限制
                     // height: 100, // 图片高限制
                     // height: 100, // 图片高限制
@@ -351,6 +352,11 @@ import AddUploadedFile from './Upload/AddUploadedFile'
             if (options.sortable) {
             if (options.sortable) {
                 $li.find('[data-file-act="order"]').removeClass('d-none').show();
                 $li.find('[data-file-act="order"]').removeClass('d-none').show();
             }
             }
+            if (options.downloadable) {
+                let $download = $li.find('[data-file-act="downloadable"]');
+                $download.removeClass('d-none').show();
+                $download.attr('data-id', obj.file.serverUrl);
+            }
         }
         }
 
 
         // 预览
         // 预览

+ 2 - 1
resources/assets/dcat/extra/upload.scss

@@ -301,7 +301,8 @@
 
 
 .web-uploader .filelist li img {
 .web-uploader .filelist li img {
   max-width: 95%;
   max-width: 95%;
-  height: 120px
+  height: 120px;
+  object-fit: cover;
 }
 }
 
 
 .web-uploader .filelist li p.error {
 .web-uploader .filelist li p.error {

+ 2 - 1
resources/assets/dcat/plugins/webuploader/webuploader.css

@@ -303,7 +303,8 @@
 
 
 .web-uploader .filelist li img {
 .web-uploader .filelist li img {
 	width: auto;
 	width: auto;
-	height: 120px
+	height: 120px;
+	object-fit: cover;
 }
 }
 
 
 .web-uploader .filelist li p.error {
 .web-uploader .filelist li p.error {

File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte-blue-light.css


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte-blue.css


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte-green.css


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte.css


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte.js


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/adminlte/adminlte.js.map


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/action.js.map


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js.map


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/select-table.js.map


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/upload.css


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/upload.js


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/extra/upload.js.map


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/js/dcat-app.js


File diff ditekan karena terlalu besar
+ 0 - 0
resources/dist/dcat/js/dcat-app.js.map


+ 2 - 1
resources/dist/dcat/plugins/webuploader/webuploader.css

@@ -303,7 +303,8 @@
 
 
 .web-uploader .filelist li img {
 .web-uploader .filelist li img {
 	width: auto;
 	width: auto;
-	height: 120px
+	height: 120px;
+	object-fit: cover;
 }
 }
 
 
 .web-uploader .filelist li p.error {
 .web-uploader .filelist li p.error {

+ 73 - 4
resources/views/form/map.blade.php

@@ -1,3 +1,10 @@
+<style>
+    .amap-icon img,
+    .amap-marker-content img{
+        width: 25px;
+        height: 34px;
+    }
+</style>
 <div class="{{$viewClass['form-group']}}">
 <div class="{{$viewClass['form-group']}}">
 
 
     <label class="{{$viewClass['label']}} control-label">{!! $label !!}</label>
     <label class="{{$viewClass['label']}} control-label">{!! $label !!}</label>
@@ -6,14 +13,16 @@
 
 
         @include('admin::form.error')
         @include('admin::form.error')
 
 
-        @if($type === 'baidu')
+        @if($type === 'baidu' || $type === 'amap')
             <div class="row mb-1">
             <div class="row mb-1">
                 <div class="col-md-5 col-md-offset-3">
                 <div class="col-md-5 col-md-offset-3">
                     <div class="input-group">
                     <div class="input-group">
                         <input type="text" placeholder="{{ trans('admin.search') }}" class="form-control" id="{{ $searchId }}">
                         <input type="text" placeholder="{{ trans('admin.search') }}" class="form-control" id="{{ $searchId }}">
-                        <span class="input-group-btn">
-                        <button type="button" class="btn btn-primary btn-flat"><i class="fa fa-search"></i></button>
-                    </span>
+                        @if($type === 'baidu')
+                            <span class="input-group-btn">
+                                <button type="button" class="btn btn-primary btn-flat"><i class="fa fa-search"></i></button>
+                            </span>
+                        @endif
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
@@ -199,4 +208,64 @@
 
 
     initBaiduMap();
     initBaiduMap();
     @endif
     @endif
+    @if($type === 'amap')
+    function initAmap(){
+        var map = new AMap.Map(container[0], {
+            resizeEnable: true
+        });
+        var marker = new AMap.Marker({
+            position: new AMap.LngLat(lng.val(), lat.val()),
+            draggable: true,
+            map:map,
+            icon:'//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png'
+        });
+        if (!lng.val() || !lat.val()){
+            var geolocation = new AMap.Geolocation({
+                enableHighAccuracy: true,
+                zoomToAccuracy: true,
+                buttonPosition: 'RB'
+            })
+            geolocation.getCurrentPosition(function (status,result){
+                if (status === 'complete'){
+                    var point = new AMap.LngLat(result.position.lng, result.position.lat);
+                    map.setCenter(point);
+                    map.setZoom(15);
+                    marker.setPosition(point)
+                    lat.val(result.position.lat);
+                    lng.val(result.position.lng);
+                }
+            })
+        }
+        //输入提示
+        var auto = new AMap.Autocomplete({
+            input: "{{$searchId}}"
+        });
+        var placeSearch = new AMap.PlaceSearch({
+            map: map
+        });
+        AMap.event.addListener(auto, "select", function (e){
+            placeSearch.setCity(e.poi.adcode);
+            placeSearch.search(e.poi.name);
+        });
+        AMap.event.addListener(placeSearch, "markerClick", function (e){
+            let point = new AMap.LngLat(e.data.location.lng, e.data.location.lat);
+            marker.setPosition(point)
+            lat.val(e.data.location.lat);
+            lng.val(e.data.location.lng);
+        });
+        marker.on('dragend',function (e){
+            lat.val(e.lnglat.lat);
+            lng.val(e.lnglat.lng);
+        });
+        map.on('click',function (e){
+            if (e.type === 'click'){
+                let point = new AMap.LngLat(e.lnglat.lng, e.lnglat.lat);
+                marker.setPosition(point)
+                lat.val(e.lnglat.lat);
+                lng.val(e.lnglat.lng);
+            }
+        })
+    }
+    initAmap();
+    @endif
 </script>
 </script>

+ 7 - 3
resources/views/grid/batch-actions.blade.php

@@ -7,9 +7,13 @@
     </button>
     </button>
     <ul class="dropdown-menu" role="menu">
     <ul class="dropdown-menu" role="menu">
         @foreach($actions as $action)
         @foreach($actions as $action)
-            <li class="dropdown-item">
-                {!! $action->render() !!}
-            </li>
+            @if ($action instanceof Dcat\Admin\Grid\Tools\ActionDivider)
+                <li class="dropdown-divider"></li>
+            @else
+                <li class="dropdown-item">
+                    {!! $action->render() !!}
+                </li>
+            @endif
         @endforeach
         @endforeach
     </ul>
     </ul>
 </div>
 </div>

+ 2 - 2
resources/views/widgets/radio.blade.php

@@ -3,7 +3,7 @@
 @endif
 @endif
 
 
 @foreach($options as $k => $label)
 @foreach($options as $k => $label)
-    <div class="vs-radio-con vs-radio-success{{ $style }}" style="margin-right: {{ $right }}">
+    <div class="vs-radio-con vs-radio-{{ $style }}" style="margin-right: {{ $right }}">
         <input {!! in_array($k, $disabled) ? 'disabled' : '' !!} value="{{$k}}" {!! $attributes !!} {!! \Dcat\Admin\Support\Helper::equal($checked, $k) ? 'checked' : '' !!}>
         <input {!! in_array($k, $disabled) ? 'disabled' : '' !!} value="{{$k}}" {!! $attributes !!} {!! \Dcat\Admin\Support\Helper::equal($checked, $k) ? 'checked' : '' !!}>
         <span class="vs-radio vs-radio-{{ $size }}">
         <span class="vs-radio vs-radio-{{ $size }}">
           <span class="vs-radio--border"></span>
           <span class="vs-radio--border"></span>
@@ -17,4 +17,4 @@
 
 
 @if($inline)
 @if($inline)
 </div>
 </div>
-@endif
+@endif

+ 1 - 1
src/Actions/Action.php

@@ -247,7 +247,7 @@ HTML;
             $attributes['href'] = $href;
             $attributes['href'] = $href;
         }
         }
 
 
-        $this->defaultHtmlAttribute('style', 'cursor: pointer');
+        $this->defaultHtmlAttribute('style', 'cursor: pointer;');
         $this->setHtmlAttribute($attributes);
         $this->setHtmlAttribute($attributes);
     }
     }
 
 

+ 1 - 1
src/Admin.php

@@ -31,7 +31,7 @@ class Admin
     use HasAssets;
     use HasAssets;
     use HasHtml;
     use HasHtml;
 
 
-    const VERSION = '2.1.0-beta';
+    const VERSION = '2.1.1-beta';
 
 
     const SECTION = [
     const SECTION = [
         // 往 <head> 标签内输入内容
         // 往 <head> 标签内输入内容

+ 3 - 2
src/AdminServiceProvider.php

@@ -13,6 +13,7 @@ use Dcat\Admin\Layout\Menu;
 use Dcat\Admin\Layout\Navbar;
 use Dcat\Admin\Layout\Navbar;
 use Dcat\Admin\Layout\SectionManager;
 use Dcat\Admin\Layout\SectionManager;
 use Dcat\Admin\Support\Context;
 use Dcat\Admin\Support\Context;
+use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Support\Setting;
 use Dcat\Admin\Support\Setting;
 use Dcat\Admin\Support\Translator;
 use Dcat\Admin\Support\Translator;
 use Dcat\Admin\Support\WebUploader;
 use Dcat\Admin\Support\WebUploader;
@@ -274,8 +275,8 @@ PHP;
 
 
         // register middleware group.
         // register middleware group.
         foreach ($this->middlewareGroups as $key => $middleware) {
         foreach ($this->middlewareGroups as $key => $middleware) {
-            if ($disablePermission && $middleware == 'admin.permission') {
-                continue;
+            if ($disablePermission) {
+                Helper::deleteByValue($middleware, 'admin.permission', true);
             }
             }
             $router->middlewareGroup($key, $middleware);
             $router->middlewareGroup($key, $middleware);
         }
         }

+ 8 - 8
src/Extend/ServiceProvider.php

@@ -138,7 +138,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return string|void
      * @return string|void
      */
      */
-    final public function getName()
+    public function getName()
     {
     {
         return $this->name ?: ($this->name = str_replace('/', '.', $this->getPackageName()));
         return $this->name ?: ($this->name = str_replace('/', '.', $this->getPackageName()));
     }
     }
@@ -162,7 +162,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return string|void
      * @return string|void
      */
      */
-    final public function getPackageName()
+    public function getPackageName()
     {
     {
         if (! $this->packageName) {
         if (! $this->packageName) {
             if (! $this->composerProperty) {
             if (! $this->composerProperty) {
@@ -190,7 +190,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return string
      * @return string
      */
      */
-    final public function getVersion()
+    public function getVersion()
     {
     {
         return Admin::extension()->versionManager()->getCurrentVersion($this);
         return Admin::extension()->versionManager()->getCurrentVersion($this);
     }
     }
@@ -200,7 +200,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return string
      * @return string
      */
      */
-    final public function getLatestVersion()
+    public function getLatestVersion()
     {
     {
         return Admin::extension()->versionManager()->getFileVersions($this);
         return Admin::extension()->versionManager()->getFileVersions($this);
     }
     }
@@ -210,7 +210,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return string
      * @return string
      */
      */
-    final public function getLocalLatestVersion()
+    public function getLocalLatestVersion()
     {
     {
         return last(
         return last(
             array_keys(Admin::extension()->versionManager()->getFileVersions($this))
             array_keys(Admin::extension()->versionManager()->getFileVersions($this))
@@ -277,7 +277,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return bool
      * @return bool
      */
      */
-    final public function enabled()
+    public function enabled()
     {
     {
         return Admin::extension()->enabled($this->getName());
         return Admin::extension()->enabled($this->getName());
     }
     }
@@ -287,7 +287,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return bool
      * @return bool
      */
      */
-    final public function disabled()
+    public function disabled()
     {
     {
         return ! $this->enabled();
         return ! $this->enabled();
     }
     }
@@ -300,7 +300,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
      *
      *
      * @return mixed
      * @return mixed
      */
      */
-    final public function config($key = null, $default = null)
+    public function config($key = null, $default = null)
     {
     {
         if ($this->config === null) {
         if ($this->config === null) {
             $this->initConfig();
             $this->initConfig();

+ 1 - 1
src/Extend/Setting.php

@@ -43,7 +43,7 @@ abstract class Setting extends Form implements LazyRenderable
     {
     {
         $this->extension()->config($this->formatInput($input));
         $this->extension()->config($this->formatInput($input));
 
 
-        return $this->response()->success(trans('admin.save_succeeded'));
+        return $this->response()->success(trans('admin.save_succeeded'))->refresh();
     }
     }
 
 
     /**
     /**

+ 3 - 1
src/Form/Field/Checkbox.php

@@ -9,6 +9,7 @@ class Checkbox extends MultipleSelect
 {
 {
     use CanCascadeFields;
     use CanCascadeFields;
     use CanLoadFields;
     use CanLoadFields;
+    use Sizeable;
 
 
     protected $style = 'primary';
     protected $style = 'primary';
 
 
@@ -95,7 +96,8 @@ class Checkbox extends MultipleSelect
         $checkbox
         $checkbox
             ->inline($this->inline)
             ->inline($this->inline)
             ->check($this->value())
             ->check($this->value())
-            ->class($this->getElementClassString());
+            ->class($this->getElementClassString())
+            ->size($this->size);
 
 
         $this->addVariables([
         $this->addVariables([
             'checkbox' => $checkbox,
             'checkbox' => $checkbox,

+ 11 - 0
src/Form/Field/Map.php

@@ -39,6 +39,9 @@ class Map extends Field
             case 'yandex':
             case 'yandex':
                 $js = '//api-maps.yandex.ru/2.1/?lang=ru_RU';
                 $js = '//api-maps.yandex.ru/2.1/?lang=ru_RU';
                 break;
                 break;
+            case 'amap':
+                $js = '//webapi.amap.com/maps?v=1.4.15&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geolocation&key='.($keys['amap'] ?? env('AMAP_API_KEY'));
+                break;
             case 'baidu':
             case 'baidu':
             default:
             default:
                 $js = '//api.map.baidu.com/api?v=2.0&ak='.($keys['baidu'] ?? env('BAIDU_MAP_API_KEY'));
                 $js = '//api.map.baidu.com/api?v=2.0&ak='.($keys['baidu'] ?? env('BAIDU_MAP_API_KEY'));
@@ -70,6 +73,9 @@ class Map extends Field
             case 'yandex':
             case 'yandex':
                 $this->yandex();
                 $this->yandex();
                 break;
                 break;
+            case 'amap':
+                $this->amap();
+                break;
             case 'baidu':
             case 'baidu':
             default:
             default:
                 $this->baidu();
                 $this->baidu();
@@ -108,6 +114,11 @@ class Map extends Field
         return $this->addVariables(['type' => 'baidu', 'searchId' => 'bdmap'.Str::random()]);
         return $this->addVariables(['type' => 'baidu', 'searchId' => 'bdmap'.Str::random()]);
     }
     }
 
 
+    public function amap()
+    {
+        return $this->addVariables(['type' => 'amap', 'searchId' => 'amap'.Str::random()]);
+    }
+
     protected function getDefaultElementClass()
     protected function getDefaultElementClass()
     {
     {
         $class = $this->normalizeElementClass($this->column['lat']).$this->normalizeElementClass($this->column['lng']);
         $class = $this->normalizeElementClass($this->column['lat']).$this->normalizeElementClass($this->column['lng']);

+ 3 - 1
src/Form/Field/Radio.php

@@ -10,6 +10,7 @@ class Radio extends Field
 {
 {
     use CanCascadeFields;
     use CanCascadeFields;
     use CanLoadFields;
     use CanLoadFields;
+    use Sizeable;
 
 
     protected $style = 'primary';
     protected $style = 'primary';
 
 
@@ -78,7 +79,8 @@ class Radio extends Field
         $radio
         $radio
             ->inline($this->inline)
             ->inline($this->inline)
             ->check($this->value())
             ->check($this->value())
-            ->class($this->getElementClassString());
+            ->class($this->getElementClassString())
+            ->size($this->size);
 
 
         $this->addVariables([
         $this->addVariables([
             'radio' => $radio,
             'radio' => $radio,

+ 4 - 1
src/Form/Field/Select.php

@@ -12,6 +12,7 @@ class Select extends Field
 {
 {
     use CanCascadeFields;
     use CanCascadeFields;
     use CanLoadFields;
     use CanLoadFields;
+    use Sizeable;
 
 
     protected $cascadeEvent = 'change';
     protected $cascadeEvent = 'change';
 
 
@@ -118,7 +119,7 @@ class Select extends Field
                 $resources[] = $value;
                 $resources[] = $value;
             }
             }
 
 
-            return $model::find($resources)->pluck($textField, $idField)->toArray();
+            return $model::whereIn($idField, $resources)->pluck($textField, $idField)->toArray();
         };
         };
 
 
         return $this;
         return $this;
@@ -236,6 +237,8 @@ class Select extends Field
             'cascadeScript' => $this->getCascadeScript(),
             'cascadeScript' => $this->getCascadeScript(),
         ]);
         ]);
 
 
+        $this->initSize();
+
         $this->attribute('data-value', implode(',', Helper::array($this->value())));
         $this->attribute('data-value', implode(',', Helper::array($this->value())));
 
 
         return parent::render();
         return parent::render();

+ 1 - 1
src/Form/Field/SelectTable.php

@@ -120,7 +120,7 @@ class SelectTable extends Field
                 return [];
                 return [];
             }
             }
 
 
-            return $model::find($v)->pluck($text, $id);
+            return $model::whereIn($id, Helper::array($v))->pluck($text, $id);
         });
         });
     }
     }
 
 

+ 46 - 0
src/Form/Field/Sizeable.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Dcat\Admin\Form\Field;
+
+trait Sizeable
+{
+    /**
+     * @var string
+     */
+    protected $size = '';
+
+    /**
+     * 设置为小尺寸.
+     *
+     * @return $this
+     */
+    public function small()
+    {
+        return $this->size('sm');
+    }
+
+    /**
+     * 设置为大尺寸.
+     *
+     * @return $this
+     */
+    public function large()
+    {
+        return $this->size('lg');
+    }
+
+    public function size(?string $size)
+    {
+        $this->size = $size;
+
+        return $this;
+    }
+
+    protected function initSize()
+    {
+        if ($this->size) {
+            $this->addElementClass('form-control-'.$this->size);
+            $this->setLabelClass('control-label-'.$this->size);
+        }
+    }
+}

+ 2 - 0
src/Form/Field/Text.php

@@ -9,6 +9,7 @@ use Illuminate\Support\Str;
 class Text extends Field
 class Text extends Field
 {
 {
     use PlainInput;
     use PlainInput;
+    use Sizeable;
 
 
     public function __construct($column, $arguments = [])
     public function __construct($column, $arguments = [])
     {
     {
@@ -27,6 +28,7 @@ class Text extends Field
     public function render()
     public function render()
     {
     {
         $this->initPlainInput();
         $this->initPlainInput();
+        $this->initSize();
 
 
         $this->defaultAttribute('type', 'text')
         $this->defaultAttribute('type', 'text')
             ->defaultAttribute('name', $this->getElementName())
             ->defaultAttribute('name', $this->getElementName())

+ 14 - 0
src/Form/Field/WebUploader.php

@@ -196,6 +196,20 @@ trait WebUploader
         return $this;
         return $this;
     }
     }
 
 
+    /**
+     * 是否允许下载文件.
+     *
+     * @param bool $value
+     *
+     * @return $this
+     */
+    public function downloadable(bool $value = true)
+    {
+        $this->options['downloadable'] = $value;
+
+        return $this;
+    }
+
     /**
     /**
      * 默认上传配置.
      * 默认上传配置.
      *
      *

+ 1 - 1
src/Grid.php

@@ -722,7 +722,7 @@ HTML;
 
 
     protected function renderHeaderOrFooter($callbacks)
     protected function renderHeaderOrFooter($callbacks)
     {
     {
-        $target = [$this->processFilter()];
+        $target = [$this->processFilter(), $this];
         $content = [];
         $content = [];
 
 
         foreach ($callbacks as $callback) {
         foreach ($callbacks as $callback) {

+ 3 - 0
src/Grid/Filter/Scope.php

@@ -6,12 +6,15 @@ use Dcat\Admin\Grid\Filter;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Collection;
+use Illuminate\Support\Traits\Macroable;
 
 
 /**
 /**
  * @mixin Builder
  * @mixin Builder
  */
  */
 class Scope implements Renderable
 class Scope implements Renderable
 {
 {
+    use Macroable;
+
     /**
     /**
      * @var Filter
      * @var Filter
      */
      */

+ 41 - 0
src/Grid/Model.php

@@ -649,6 +649,47 @@ class Model
         return $this;
         return $this;
     }
     }
 
 
+    public function getSortQueries()
+    {
+        return $this->findQueryByMethod('orderBy')
+            ->merge($this->findQueryByMethod('orderByDesc'))
+            ->merge($this->findQueryByMethod('latest'))
+            ->merge($this->findQueryByMethod('oldest'));
+    }
+
+    public function getSortDescMethods()
+    {
+        return ['orderByDesc', 'latest'];
+    }
+
+    /**
+     * @param \Illuminate\Database\Query\Builder $query
+     * @param bool $fetch
+     * @param string[] $columns
+     *
+     * @return mixed
+     */
+    public function apply($query, bool $fetch = true, $columns = null)
+    {
+        $this->getQueries()->unique()->each(function ($value) use (&$query, $fetch, $columns) {
+            if (! $fetch && in_array($value['method'], ['paginate', 'simplePaginate', 'get'], true)) {
+                return;
+            }
+
+            if ($columns) {
+                if (in_array($value['method'], ['paginate', 'simplePaginate'], true)) {
+                    $value['arguments'][1] = $columns;
+                } elseif ($value['method'] === 'get') {
+                    $value['arguments'] = [$columns];
+                }
+            }
+
+            $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+        });
+
+        return $query;
+    }
+
     /**
     /**
      * Set the relationships that should be eager loaded.
      * Set the relationships that should be eager loaded.
      *
      *

+ 13 - 0
src/Grid/Tools/ActionDivider.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace Dcat\Admin\Grid\Tools;
+
+use Dcat\Admin\Grid\BatchAction;
+
+class ActionDivider extends BatchAction
+{
+    public function render()
+    {
+        return '';
+    }
+}

+ 5 - 0
src/Grid/Tools/BatchActions.php

@@ -69,6 +69,11 @@ class BatchActions extends AbstractTool
         return $this;
         return $this;
     }
     }
 
 
+    public function divider()
+    {
+        return $this->add(new ActionDivider());
+    }
+
     /**
     /**
      * Disable delete And Hide SelectAll Checkbox.
      * Disable delete And Hide SelectAll Checkbox.
      *
      *

+ 1 - 1
src/Http/Controllers/PermissionController.php

@@ -146,7 +146,7 @@ class PermissionController extends AdminController
 
 
     public function getRoutes()
     public function getRoutes()
     {
     {
-        $prefix = config('admin.route.prefix');
+        $prefix = (string) config('admin.route.prefix');
 
 
         $container = collect();
         $container = collect();
 
 

+ 3 - 13
src/Repositories/EloquentRepository.php

@@ -167,17 +167,7 @@ class EloquentRepository extends Repository implements TreeRepository
             $query->with($this->relations);
             $query->with($this->relations);
         }
         }
 
 
-        $model->getQueries()->unique()->each(function ($value) use (&$query) {
-            if ($value['method'] === 'paginate' || $value['method'] === 'simplePaginate') {
-                $value['arguments'][1] = $this->getGridColumns();
-            } elseif ($value['method'] === 'get') {
-                $value['arguments'] = [$this->getGridColumns()];
-            }
-
-            $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
-        });
-
-        return $query;
+        return $model->apply($query, true, $this->getGridColumns());
     }
     }
 
 
     /**
     /**
@@ -192,13 +182,13 @@ class EloquentRepository extends Repository implements TreeRepository
         [$column, $type, $cast] = $model->getSort();
         [$column, $type, $cast] = $model->getSort();
 
 
         if (empty($column) || empty($type)) {
         if (empty($column) || empty($type)) {
-            $orders = $model->findQueryByMethod('orderBy')->merge($model->findQueryByMethod('orderByDesc'));
+            $orders = $model->getSortQueries();
 
 
             $model->resetOrderBy();
             $model->resetOrderBy();
 
 
             $orders->each(function ($orderBy) use ($model) {
             $orders->each(function ($orderBy) use ($model) {
                 $column = $orderBy['arguments'][0];
                 $column = $orderBy['arguments'][0];
-                $type = $orderBy['method'] === 'orderByDesc' ? 'desc' : ($orderBy['arguments'][1] ?? 'asc');
+                $type = in_array($orderBy['method'], $model->getSortDescMethods(), true) ? 'desc' : ($orderBy['arguments'][1] ?? 'asc');
                 $cast = null;
                 $cast = null;
 
 
                 $this->addOrderBy($model, $column, $type, $cast);
                 $this->addOrderBy($model, $column, $type, $cast);

+ 0 - 20
src/Widgets/Radio.php

@@ -37,26 +37,6 @@ class Radio extends Widget
         return $this->setHtmlAttribute('name', $name);
         return $this->setHtmlAttribute('name', $name);
     }
     }
 
 
-    /**
-     * 设置为小尺寸.
-     *
-     * @return $this
-     */
-    public function small()
-    {
-        return $this->size('sm');
-    }
-
-    /**
-     * 设置为大尺寸.
-     *
-     * @return $this
-     */
-    public function large()
-    {
-        return $this->size('lg');
-    }
-
     /**
     /**
      * 尺寸设置.
      * 尺寸设置.
      *
      *

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini