Просмотр исходного кода

修复Cleanup模块后台计划内容列表显示问题

- 修复CleanupPlanContentRepository缺少关联关系预加载的问题
- 修复所属计划列显示为空的问题
- 修复启用状态和备份启用列显示为空的问题
- 将switch字段改为using+label显示方式,确保正确显示状态
notfff 6 месяцев назад
Родитель
Сommit
425a7e3025

+ 8 - 2
app/Module/Cleanup/AdminControllers/CleanupPlanContentController.php

@@ -93,8 +93,14 @@ class CleanupPlanContentController extends AdminController
             })->sortable();
 
             // 状态
-            $grid->column('is_enabled', '启用状态')->switch()->sortable();
-            $grid->column('backup_enabled', '备份启用')->switch()->sortable();
+            $grid->column('is_enabled', '启用状态')->using([1 => '启用', 0 => '禁用'])->label([
+                1 => 'success',
+                0 => 'danger',
+            ])->sortable();
+            $grid->column('backup_enabled', '备份启用')->using([1 => '启用', 0 => '禁用'])->label([
+                1 => 'success',
+                0 => 'danger',
+            ])->sortable();
 
             // 条件描述
             $grid->column('conditions_description', '清理条件')->display(function () {

+ 10 - 1
app/Module/Cleanup/Repositories/CleanupPlanContentRepository.php

@@ -7,7 +7,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
  * 计划内容数据仓库
- * 
+ *
  * 用于 Dcat Admin 后台管理的数据访问
  */
 class CleanupPlanContentRepository extends EloquentRepository
@@ -16,4 +16,13 @@ class CleanupPlanContentRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = CleanupPlanContent::class;
+
+    /**
+     * 构造函数 - 设置关联关系
+     */
+    public function __construct()
+    {
+        // 设置需要预加载的关联关系
+        parent::__construct(['plan']);
+    }
 }