|
|
@@ -53,8 +53,8 @@ class ItemChestConfigController extends AdminController
|
|
|
protected function grid(): Grid
|
|
|
{
|
|
|
return Grid::make(new ItemChestConfig(), function (Grid $grid) {
|
|
|
- // 首先设置关联查询,确保数据正确预加载
|
|
|
- $grid->model()->with(['item', 'consumeGroup', 'rewardGroup', 'conditionGroup']);
|
|
|
+ // 首先设置关联查询,确保数据正确预加载,包括子项目
|
|
|
+ $grid->model()->with(['item', 'consumeGroup.consumeItems', 'rewardGroup.rewardItems', 'conditionGroup.conditionItems']);
|
|
|
|
|
|
$helper = new GridHelper($grid, $this);
|
|
|
$helper->columnId();
|
|
|
@@ -65,18 +65,69 @@ class ItemChestConfigController extends AdminController
|
|
|
|
|
|
$grid->column('item_id', '宝箱ID')->sortable();
|
|
|
|
|
|
+ // 消耗组列 - 可点击跳转
|
|
|
$grid->column('consumeGroup.name', '消耗组')->display(function ($name) {
|
|
|
- return $name ?: '<span class="text-muted">无消耗</span>';
|
|
|
+ if (!$name || !$this->consume_group_id) {
|
|
|
+ return '<span class="text-muted">无消耗</span>';
|
|
|
+ }
|
|
|
+ return $name;
|
|
|
+ })->link(function () {
|
|
|
+ if (!$this->consume_group_id) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return admin_url('game-consume-groups/' . $this->consume_group_id);
|
|
|
});
|
|
|
|
|
|
+ // 奖励组列 - 可点击跳转
|
|
|
$grid->column('rewardGroup.name', '奖励组')->display(function ($name) {
|
|
|
- return $name ?: '<span class="text-danger">未配置</span>';
|
|
|
+ if (!$name || !$this->reward_group_id) {
|
|
|
+ return '<span class="text-danger">未配置</span>';
|
|
|
+ }
|
|
|
+ return $name;
|
|
|
+ })->link(function () {
|
|
|
+ if (!$this->reward_group_id) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return admin_url('game-reward-groups/' . $this->reward_group_id);
|
|
|
});
|
|
|
|
|
|
+ // 条件组列 - 可点击跳转
|
|
|
$grid->column('conditionGroup.name', '条件组')->display(function ($name) {
|
|
|
- return $name ?: '<span class="text-muted">无条件</span>';
|
|
|
+ if (!$name || !$this->condition_group_id) {
|
|
|
+ return '<span class="text-muted">无条件</span>';
|
|
|
+ }
|
|
|
+ return $name;
|
|
|
+ })->link(function () {
|
|
|
+ if (!$this->condition_group_id) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return admin_url('game-condition-groups/' . $this->condition_group_id);
|
|
|
});
|
|
|
|
|
|
+ // 消耗组详情列
|
|
|
+ $grid->column('consume_group_details', '消耗组详情')->display(function () {
|
|
|
+ if (!$this->consumeGroup) {
|
|
|
+ return '<span class="text-muted">无消耗组</span>';
|
|
|
+ }
|
|
|
+ return $this->consumeGroup->formatConsumeDetails();
|
|
|
+ })->width('200px');
|
|
|
+
|
|
|
+ // 奖励组详情列
|
|
|
+ $grid->column('reward_group_details', '奖励组详情')->display(function () {
|
|
|
+ if (!$this->rewardGroup) {
|
|
|
+ return '<span class="text-muted">无奖励组</span>';
|
|
|
+ }
|
|
|
+ return $this->rewardGroup->formatRewardDetails();
|
|
|
+ })->width('200px');
|
|
|
+
|
|
|
+ // 条件组详情列
|
|
|
+ $grid->column('condition_group_details', '条件组详情')->display(function () {
|
|
|
+ if (!$this->conditionGroup) {
|
|
|
+ return '<span class="text-muted">无条件组</span>';
|
|
|
+ }
|
|
|
+ return $this->conditionGroup->formatConditionDetails();
|
|
|
+ })->width('200px');
|
|
|
+
|
|
|
$grid->column('is_active', '状态')->switch();
|
|
|
|
|
|
$grid->column('status_text', '配置状态')->display(function () {
|