<?php /** * Created by PhpStorm. * User: OneDark * Date: 2018/9/29 * Time: 13:44 */ namespace App\Admin\Extensions\Tools; use Encore\Admin\Grid\Tools\BatchAction; class PageCache extends BatchAction { protected $action; public function __construct($action = 0) { $this->action = $action; } public function script() { return <<<EOT $('{$this->getElementClass()}').on('click', function() { $.ajax({ method: 'post', url: '{$this->resource}/release', data: { _token:LA.token, ids: selectedRows(), action: {$this->action} }, success: function () { $.pjax.reload('#pjax-container'); toastr.success('操作成功'); } }); }); EOT; } }