diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php index 4a18c275..1e8a7b60 100644 --- a/app/Admin/Controllers/DealerEarningController.php +++ b/app/Admin/Controllers/DealerEarningController.php @@ -3,6 +3,7 @@ namespace App\Admin\Controllers; use App\Admin\Actions\Show\DealerEarningPay; +use App\Admin\Renderable\Grid\Filter\DealerEarningStatusIn; use App\Admin\Repositories\DealerEarning; use App\Enums\DealerEarningStatus; use App\Models\DealerChannelSubsidyLog; @@ -68,8 +69,13 @@ class DealerEarningController extends AdminController -1=> '待结算', 0 => '待打款', 1 => '待收款', - 2 => '已完成', - ])->dot(); + 5 => '已完成', + ])->dot()->filter(DealerEarningStatusIn::make([ + -1=> '待结算', + 0 => '待打款', + 1 => '待收款', + 5 => '已完成', + ])); $grid->column('settle_at'); $grid->column('payer_id')->display(function () { return $this->payer_id ? $this->payer?->phone : '公司'; diff --git a/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php b/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php new file mode 100644 index 00000000..e007fe78 --- /dev/null +++ b/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php @@ -0,0 +1,78 @@ +options = $options; + + $this->class = [ + 'all' => uniqid('column-filter-all-'), + 'item' => uniqid('column-filter-item-'), + ]; + } + + /** + * Add a binding to the query. + * + * @param array $value + * @param Model $model + */ + public function addBinding($value, Model $model) + { + if (empty($value)) { + return; + } + $all = [-1, 0, 1, 5]; + + if (array_diff($all, $value)) {//无差别则直接跳过 + //判断查询的状态有哪些; + $model->where(function ($query) use ($value) { + foreach ($value as $status) { + switch ($status) { + case -1: + $query->orWhereNull('settle_at'); + break; + case 0: + $query->orWhere('status', 0); + break; + case 1: + $query->orWhere('status', 1); + break; + case 5: + $query->orWhere('status', 5); + break; + } + } + }); + } + } + + /** + * Render this filter. + * + * @return string + */ + public function render() + { + return $this->renderCheckbox(); + } +}