jqh 5 years ago
parent
commit
90fe702a5b
2 changed files with 21 additions and 21 deletions
  1. 6 10
      src/Grid/Column/Filter.php
  2. 15 11
      src/Grid/Tools/QuickSearch.php

+ 6 - 10
src/Grid/Column/Filter.php

@@ -6,7 +6,6 @@ use Dcat\Admin\Grid\Column;
 use Dcat\Admin\Grid\Model;
 use Dcat\Admin\Support\Helper;
 use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Facades\URL;
 
 abstract class Filter implements Renderable
 {
@@ -143,15 +142,12 @@ abstract class Filter implements Renderable
      */
     public function formAction()
     {
-        return Helper::urlWithoutQuery(
-            URL::full(),
-            [
-                $this->getQueryName(),
-                $this->getColumnName(),
-                $this->parent->grid()->model()->getPageName(),
-                '_pjax',
-            ]
-        );
+        return Helper::fullUrlWithoutQuery([
+            $this->getQueryName(),
+            $this->getColumnName(),
+            $this->parent->grid()->model()->getPageName(),
+            '_pjax',
+        ]);
     }
 
     /**

+ 15 - 11
src/Grid/Tools/QuickSearch.php

@@ -4,6 +4,7 @@ namespace Dcat\Admin\Grid\Tools;
 
 use Dcat\Admin\Admin;
 use Dcat\Admin\Grid;
+use Dcat\Admin\Support\Helper;
 use Illuminate\Support\Arr;
 
 class QuickSearch extends AbstractTool
@@ -90,30 +91,33 @@ class QuickSearch extends AbstractTool
     }
 
     /**
-     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     * @return string
      */
-    public function render()
+    public function formAction()
     {
-        $request = request();
-        $query = $request->query();
-
-        $this->setupScript();
-
-        Arr::forget($query, [
+        return Helper::fullUrlWithoutQuery([
             $this->queryName,
             $this->parent->model()->getPageName(),
             '_pjax',
         ]);
+    }
+
+    /**
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function render()
+    {
+        $this->setupScript();
 
-        $vars = [
-            'action'      => $request->url().'?'.http_build_query($query),
+        $data = [
+            'action'      => $this->formAction(),
             'key'         => $this->queryName,
             'value'       => $this->value(),
             'placeholder' => $this->placeholder ?: trans('admin.search'),
             'width'       => $this->width,
         ];
 
-        return view($this->view, $vars);
+        return view($this->view, $data);
     }
 
     protected function setupScript()