123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Admin\Actions\Grid;
- use Dcat\Admin\Actions\Response;
- use Dcat\Admin\Admin;
- use Dcat\Admin\Grid\BatchAction;
- use Illuminate\Http\Request;
- use App\Admin\Forms\InquiryAssignment as InquiryAssignmentForm;
- use Dcat\Admin\Widgets\Modal;
- class InquiryAssignment extends BatchAction
- {
- /**
- * 初始化操作
- */
- public function render()
- {
- $assignment = admin_trans_label('assignment');
- $button = '<button type="button" class="btn btn-success">'.$assignment.'</button>';
- // 实例化表单类
- return Modal::make()
- ->lg()
- ->title(admin_trans_label('inquiry_assignment'))
- ->body(InquiryAssignmentForm::make())
- //->on('click',$this->getModalScript2())
- ->onShow($this->getModalScript())
- // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
- ->button($button);
- }
- /**
- * 设置动作发起请求前的回调函数,返回false可以中断请求.
- *
- * @return string
- */
- public function getModalScript(){
- $warning = admin_trans_label('no_selected_data');
- return <<<JS
- try {
- var key = {$this->getSelectedKeysScript()}
- $('#inquiryIds').val(key);
- } catch (e) {
- Dcat.error('{$warning}');
- return false;
- }
- JS;
- }
- public function getSelectedKeysScript()
- {
- return "Dcat.grid.selected('{$this->parent->getName()}')";
- }
- }
|