moshaorui 3 months ago
parent
commit
f9d49e4baf
1 changed files with 32 additions and 6 deletions
  1. 32 6
      app/Admin/Controllers/SiteAlbumController.php

+ 32 - 6
app/Admin/Controllers/SiteAlbumController.php

@@ -24,26 +24,42 @@ class SiteAlbumController extends AdminController
      */
     public function index(Content $content)
     {
-        return $content
+        $html =  $content
             ->header(admin_trans( 'admin.album'))
             ->body($this->indexForm());
+        $html = $html->render();
+
+
+        $html = preg_replace('/<form(.*?)method="post"(.*?)>/s', '<form$1method="get"$2>', $html, 1);
+
+        preg_match('/<form[^>]*id="([^"]*)"[^>]*>/', $html, $matches);
+        if (isset($matches[1])) {
+            $formId = $matches[1]; // 获取 id 的值
+           // echo "找到的 form id: " . $formId . "\n";
+            // 2. 根据 id 值,删除对应的 JavaScript 代码
+            $pattern = '/\$\(\'#' . preg_quote($formId, '/') . '\'\)\.form\(\{.*?\}\);/s';
+            $html = preg_replace($pattern, '', $html);
+        }
+
+        return $html;
     }
 
     protected function indexForm()
     {
         return Form::make(new NullRepository(), function (Form $form) {
-            $form->block(2, function (Form\BlockForm $form) {
+            $form->action('/site-album');
+            $folderModel = new SiteAlbumFolderModel();
+            $folderTree = $folderModel->allNodes();
+            $form->block(2, function (Form\BlockForm $form) use ($folderTree) {
                 $type = [
                     'default'  => [
                         'icon' => true,
                     ],
                 ];
                 $plugins = ['types'];
-
-                $menuModel = new SiteAlbumFolderModel();
                 $form->tree()
                     ->setTitleColumn('title')
-                    ->nodes($menuModel->allNodes())
+                    ->nodes($folderTree)
                     ->type($type)
                     ->plugins($plugins)
                     ->width(12,0);
@@ -67,7 +83,15 @@ class SiteAlbumController extends AdminController
             $grid->column('enabled')->switch();
             $grid->column('created_at')->sortable();
 
-            $grid->quickSearch(['title','model']);
+           // $grid->quickSearch(['title','model']);
+
+            // 筛选
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->panel();
+                $filter->expand();
+                $filter->like('title')->width(2);
+                $filter->equal('folder_id',admin_trans_label('folder'))->select(SiteAlbumFolderModel::selectOptions())->width(3);
+            });
 
             $grid->disableViewButton();
             //$grid->showQuickEditButton();
@@ -75,6 +99,8 @@ class SiteAlbumController extends AdminController
             $grid->disableRefreshButton();
 
             $grid->model()->orderBy('order', 'asc')->orderBy('id', 'desc');
+
+
             //弹窗大小
             $grid->setDialogFormDimensions('830px','670px');
         });