fastadmin 跳转后限定搜索条件
记录:从一个页面跳转进入此列表页并传入参数进行限定搜索条件。
·
记录:从一个页面跳转进入此列表页并传入参数进行限定搜索条件。
php代码示例:
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\user\LoanBill;
$this->view->assign("statusList", $this->model->getStatusList());
// 接收传来的参数
$user_loan_id = input('ids/d',0);
$this->assignconfig('user_loan_id',$user_loan_id);
$this->view->assign("user_loan_id", $user_loan_id);
}
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
// 接收传来的参数进行限定条件
$params = [];
if(input('user_loan_id')){
$params = ['user_loan_id'=>input('user_loan_id')];
}
$list = $this->model
->with(['user','loan'])
->where($where)
->where($params)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','repayment_date','money','interest','violate','status','repayment_time','createtime','updatetime']);
$row->visible(['user']);
$row->getRelation('user')->visible(['nickname','mobile','invite_code','avatar']);
$row->visible(['loan']);
$row->getRelation('loan')->visible(['money','service','status']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
js部分代码:
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var user_loan_id = Config.user_loan_id;
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user/loan_bill/index/user_loan_id/'+user_loan_id + location.search,
add_url: 'user/loan_bill/add/ids/'+ user_loan_id,
edit_url: 'user/loan_bill/edit/ids/'+ user_loan_id,
del_url: 'user/loan_bill/del',
multi_url: 'user/loan_bill/multi',
import_url: 'user/loan_bill/import',
table: 'user_loan_bill',
}
});
......
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
跳转前页面 js部分代码
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text:function(row){
return "课程列表("+row.course_num+")"
},
title:function(row){
return __('课表【'+row.name+'】课程管理')
},
classname: 'btn btn-xs btn-primary btn-dialog chakan',
icon: 'fa fa-book fa-fw',
url: 'schedule/schedule_course?ids={ids}',
},
],
formatter: Table.api.formatter.operate}
更多推荐
所有评论(0)