当前位置:网站首页>dcat 批量操作弹窗及参数传递
dcat 批量操作弹窗及参数传递
2022-07-29 05:19:00 【廖圣平】

创建表单
<?php
namespace App\Admin\Form;
use App\Models\Good;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class EditGoodsMatchForm extends Form
{
use LazyWidget;
public function form()
{
$this->select('goods_id', '修改商品')->options(Good::pluck('goods_name', 'id'));
$this->hidden('ids')->attribute('id', 'batchsp-id'); //批量选择的行的id通过隐藏元素 提交时一并传递过去
}
public function handle($input)
{
//获取表单传递过来的值
return $this->response()->success('成功');
}
}
行批量操作
<?php
namespace App\Admin\BatchAction;
use App\Admin\Form\EditGoodsMatchForm;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;
class EditGoodsMatch extends BatchAction
{
public $title = '修改匹配数据';
public function render()
{
$form = EditGoodsMatchForm::make();
$modal = Modal::make()
->lg()
->title($this->title)
->body($form)
->button($this->title);
$modal->onShow($this->getModalScript());
return $modal;
}
protected function getModalScript()
{
// 弹窗显示后往隐藏的id表单中写入批量选中的行ID
return <<<JS
// 获取选中的ID数组
var key = {
$this->getSelectedKeysScript()}
//batchsp-id 与 之前弹窗隐藏的绑定的id一致
$('#batchsp-id').val(key);
JS;
}
}
控制器操作
$grid->batchActions([
new EditGoodsMatch(),
]);
参考:https://blog.csdn.net/samee5/article/details/120920980
边栏推荐
- Wechat applet change attribute value -setdata- bidirectional binding -model
- Niuke network programming problem - [wy22 Fibonacci series] and [replace spaces] detailed explanation
- Wechat applet - screen height
- About local variables
- [C language series] - realize the exchange of two numbers without creating the third variable
- Similarities and differences between REM and PX and EM
- [C language series] - storage of deep anatomical data in memory (II) - floating point type
- 实现table某个单元格背景色设置
- Talking about Servlet
- 第三课threejs全景预览房间案例
猜你喜欢
随机推荐
[C language series] - three methods to simulate the implementation of strlen library functions
nmap是什么以及使用教程
uniapp页面标题显示效果
paddle. Fluid constant calculation error 'nonetype' object has no attribute 'get_ fetch_ list‘
Wechat applet - component parameter transmission, state management
Clickhouse learning (VIII) materialized view
Day 5
About local variables
QT layout management -- Part stretch principle and sizepolicy
What is nmap and how to use it
Set the background color of a cell in the table
What is wapiti and how to use it
Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
ClickHouse学习(一)ClickHouse?
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
uniapp组件之tab选项卡滑动切换
[C language series] - detailed explanation of file operation (Part 1)
Wapiti是什么以及使用教程
Win10 搭建MSYS2环境
相对定位和绝对定位









