查看: 365|回复: 0

[fastadmin] fastadmin从列表页带参数跳转到其他列表页怎么接收参数

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2025-11-15 20:00:57 | 显示全部楼层 |阅读模式
比如我们从A列表页的列表项传参category_id进入B列表页,在A列表页实现如下代码:

  1. {
  2.                             field: 'operate',
  3.                             title: __('Operate'),
  4.                             table: table,
  5.                             events: Table.api.events.operate,
  6.                             align: 'right',
  7.                             buttons: [
  8.                                 {
  9.                                     name: 'item',
  10.                                     text: __('项目'),
  11.                                     title: __('查看项目'),
  12.                                     classname: 'btn btn-xs btn-info btn-dialog',
  13.                                     // icon: 'fa fa-list',
  14.                                     url: 'tongji/items/index/category_id/{ids}',
  15.                                     extend: 'data-area=["90%","80%"]',
  16.                                     callback: function (data) {
  17.                                         Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  18.                                     }
  19.                                 }
  20.                             ],
  21.                             formatter: Table.api.formatter.operate
  22.                         }
复制代码


在B列表页的后端php代码的index方法中接收参数代码:
  1. public function index()
  2.     {
  3.         //设置过滤方法
  4.         $this->request->filter(['strip_tags', 'trim']);
  5.         if (false === $this->request->isAjax()) {
  6.             $category_id = $this->request->param('category_id');
  7.             $this->view->assign('category_id', $category_id);
  8.             return $this->view->fetch();
  9.         }
  10.         //如果发送的来源是 Selectpage,则转发到 Selectpage
  11.         if ($this->request->request('keyField')) {
  12.             return $this->selectpage();
  13.         }
  14.         [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  15.         $list = $this->model
  16.             ->with('category')
  17.             ->where($where)
  18.             ->order($sort, $order)
  19.             ->paginate($limit);
  20.         $result = ['total' => $list->total(), 'rows' => $list->items()];
  21.         return json($result);
  22.     }
复制代码


在B列表页的index.html中实现添加B列表项带A页面过来的参数代码:
  1. <a href="{:url('tongji/items/add',['category_id'=>$category_id])}" class="btn btn-success btn-dialog {:$auth->check('tongji/items/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
复制代码


道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部