# 前言
FastAdmin 中的 table 自定义搜索,有时候需要重构 where 条件
list ($where, $sort, $order, $offset, $limit) = $this->buildparams ();
经过 buildparams 处理后不好修改
可以在 buildparams 之前处理
下面记录 php 和 js 两种处理方式
# 方式一 php
| $filter = json_decode($this->request->get("filter", ''), true); |
| $op = json_decode($this->request->get("op", '','trim'), true); |
| |
| $where0 = []; |
| if (isset($filter['groupIds'])) { |
| |
| |
| |
| unset($filter['groupIds'],$op['groupIds']); |
| } |
| |
| $this->request->get(['filter'=>json_encode($filter,true)]); |
| $this->request->get(['op'=>json_encode($op,true)]); |
# 方式二 js
| table.bootstrapTable({ |
| |
| queryParams: function (params) { |
| let filter = JSON.parse(params.filter); |
| let op = JSON.parse(params.op); |
| |
| |
| filter['game.game_mode'] = 0; |
| filter['game.play_mode'] = 0; |
| |
| op['game.game_mode'] = '='; |
| op['game.play_mode'] = '='; |
| |
| params.filter = JSON.stringify(filter); |
| params.op = JSON.stringify(op); |
| console.log(params); |
| return params; |
| }, |
| }) |