海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. <?php
  2. namespace App\AdminAgent\Renderable;
  3. use App\Models\IndustryProductSpec;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Grid\LazyRenderable;
  7. /**
  8. * 选择行业产品规格
  9. * Class SelectProduct
  10. * @package App\AdminAgent\Renderable
  11. */
  12. class SelectIndustryProductSpec extends LazyRenderable
  13. {
  14. public function grid(): Grid
  15. {
  16. // 获取外部传递的参数
  17. // $id = $this->id;
  18. Admin::translation('product');
  19. return Grid::make(new IndustryProductSpec(), function (Grid $grid) {
  20. $grid->disableActions();
  21. $grid->disableBatchDelete();
  22. $grid->disableBatchActions();
  23. $grid->model()->where([
  24. ['stock', '>', 0],
  25. ['date', '>=', date('Y-m-d')],
  26. ['industry_product_id', '=', $this->industry_product_id],
  27. ])->selectRaw('*,concat(name, " | ", date) AS title');
  28. $grid->quickSearch(['name', 'date'])->placeholder('搜索规格名称、日期');
  29. $grid->column('id');
  30. $grid->column('name');
  31. $grid->column('date');
  32. $grid->column('stock');
  33. $grid->column('original_price');
  34. $grid->column('price');
  35. $grid->paginate(15);
  36. $grid->filter(function (Grid\Filter $filter) {
  37. $filter->panel();
  38. $filter->like('name')->width(3);
  39. $filter->like('date')->width(2);
  40. });
  41. });
  42. }
  43. }