6
0
Fork 0
jiqu-library-server/app/Admin/Extensions/Grid/Tools/Product/BatchSkuVerify.php

50 lines
1.2 KiB
PHP

<?php
namespace App\Admin\Extensions\Grid\Tools\Product;
use App\Admin\Forms\SkuVerifyBatch;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;
class BatchSkuVerify extends BatchAction
{
protected $title = '批量审核';
/**
* 是否有权限判断.
*
* @param Model|Authenticatable|HasPermissions|null $user
* @return bool
*/
protected function authorize($user): bool
{
return $user->can('dcat.admin.product_sku_verifies.batch_verify');
}
public function render()
{
// 实例化表单类
$form = SkuVerifyBatch::make();
return Modal::make()
->lg()
->title($this->title)
->body($form)
// 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
// 如果是非异步方式加载表单,则需要改成 onShow 方法
->onLoad($this->getModalScript())
->button($this->title);
}
protected function getModalScript()
{
// 弹窗显示后往隐藏的id表单中写入批量选中的行ID
return <<<JS
// 获取选中的ID数组
var key = {$this->getSelectedKeysScript()}
$('#verify-sku-id').val(key);
JS;
}
}