当前位置:网站首页>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
边栏推荐
- 【JS题解】牛客网JS篇1-10题
- uniapp之常用提示弹框
- Li Kou 994: rotten orange (BFS)
- Sqlmap是什么以及使用方法
- JS deep copy - Notes
- Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)
- Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
- Day14: upload labs customs clearance tutorial
- Day 3
- Clickhouse learning (VIII) materialized view
猜你喜欢
随机推荐
Talking about Servlet
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
Display effect of uniapp page title
shell基本操作(上)
365 day challenge leetcode1000 question - day 036 binary tree pruning + subarray and sorted interval sum + delete the shortest subarray to order the remaining arrays
Three handshakes and four waves for the interview summary
[C language series] - a recursive topic
uniapp之常用提示弹框
[JS question solution] questions 1-10 in JS of niuke.com
[C language series] - constants and variables that confuse students
2022 mathematical modeling competition summer training lecture - optimization method: goal planning
Character type conversion
基础爬虫实战案例之获取游戏商品数据
使用Qss设置窗体样式
[untitled]
ClickHouse学习(七)表查询优化
Relationship between redrawing and reflow
Set the background color of a cell in the table
Wapiti是什么以及使用教程
Qtcreator+cmake compiler settings