RpcAlbumImport.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Admin\Actions\Grid;
  3. use App\Admin\Forms\ImportAlbum;
  4. use App\Distributor\Forms\ImportProduct;
  5. use Dcat\Admin\Grid\BatchAction;
  6. use Dcat\Admin\Widgets\Modal;
  7. class RpcAlbumImport extends BatchAction
  8. {
  9. protected $title = 'import';
  10. public function render()
  11. {
  12. // 实例化表单类
  13. $form = ImportAlbum::make();
  14. return Modal::make()
  15. ->lg()
  16. ->title(admin_trans_label($this->title))
  17. ->body($form)
  18. // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
  19. // 如果是非异步方式加载表单,则需要改成 onShow 方法
  20. ->onShow($this->getModalScript())
  21. ->button($this->getButtonHTML());
  22. }
  23. protected function getModalScript()
  24. {
  25. // 弹窗显示后往隐藏的id表单中写入批量选中的行ID
  26. return <<<JS
  27. // 获取选中的ID数组
  28. var key = {$this->getSelectedKeysScript()}
  29. $('#album_ids').val(key);
  30. JS;
  31. }
  32. /**
  33. * 获取按钮的 HTML
  34. * @return string
  35. */
  36. public function title()
  37. {
  38. return '<i class="feather icon-shopping-cart"></i> &nbsp;'.admin_trans('admin.import');
  39. }
  40. protected function getButtonHTML()
  41. {
  42. $title='<i class="feather icon-shopping-cart"></i> &nbsp;'.admin_trans('admin.import');
  43. return <<<HTML
  44. <button class="btn btn-success">
  45. <i class="feather"></i> {$title}
  46. </button>
  47. HTML;
  48. }
  49. }