InquiryAssignment.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Admin\Actions\Grid;
  3. use Dcat\Admin\Actions\Response;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Grid\BatchAction;
  6. use Illuminate\Http\Request;
  7. use App\Admin\Forms\InquiryAssignment as InquiryAssignmentForm;
  8. use Dcat\Admin\Widgets\Modal;
  9. class InquiryAssignment extends BatchAction
  10. {
  11. /**
  12. * @return string
  13. */
  14. protected $title = 'Inquiry Assignment';
  15. /**
  16. * 初始化操作
  17. */
  18. public function render()
  19. {
  20. // 实例化表单类
  21. return Modal::make()
  22. ->lg()
  23. ->title($this->title)
  24. ->body(InquiryAssignmentForm::make())
  25. //->on('click',$this->getModalScript2())
  26. ->onShow($this->getModalScript())
  27. // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
  28. ->button('<button type="button" class="btn btn-success"">Assignment</button>');
  29. }
  30. /**
  31. * 设置动作发起请求前的回调函数,返回false可以中断请求.
  32. *
  33. * @return string
  34. */
  35. public function getModalScript(){
  36. $warning = __('No data selected!');
  37. return <<<JS
  38. var key = {$this->getSelectedKeysScript()}
  39. $('#inquiryIds').val(key);
  40. JS;
  41. }
  42. public function getSelectedKeysScript()
  43. {
  44. return "Dcat.grid.selected('{$this->parent->getName()}')";
  45. }
  46. }