123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Admin\Actions\Tools;
- use App\Admin\Repositories\DistInquiry;
- use Dcat\Admin\Grid\Tools\AbstractTool;
- use Dcat\Admin\Widgets\Modal;
- use Illuminate\Http\Request;
- class InquiryHandle extends AbstractTool
- {
- protected $style = 'btn btn-success';
-
- public function title()
- {
- return admin_trans_label('process');
- }
-
- public function confirm()
- {
-
-
- return ['Are you sure you want to process this document?', ''];
- }
-
- public function handle(Request $request)
- {
- $keys = $request->input('_key');
- if (is_array($keys) && count($keys) > 0) {
- $result = DistInquiry::distSetStatusProcessed($keys);
- if ($result === false) {
- return $this->response()->error('Failed to process!')->refresh();
- }
- return $this->response()->success('Success')->refresh();
- } else {
- return $this->response()->error('No data selected!')->refresh();
- }
-
- }
- public function actionScript(){
- $warning = __('No data selected!');
- return <<<JS
- function (data, target, action) {
- var key = {$this->getSelectedKeysScript()}
- if (key.length === 0) {
- Dcat.warning('{$warning}');
- return false;
- }
- // 设置主键为复选框选中的行ID数组
- action.options.key = key;
- }
- JS;
- }
- public function getSelectedKeysScript()
- {
- return "Dcat.grid.selected('{$this->parent->getName()}')";
- }
- }
|