作者 何书鹏
1 个管道 的构建 通过 耗费 9 秒

用户列表按所学科目进行分类

... ... @@ -35,6 +35,8 @@ class User extends Backend
$this->model = model('User');
$moblieExamList = Db::name('mobile_exam')->where('pid','>',0)->column('id,name');
$this->assignconfig('mobileExamList', $moblieExamList);
$studyList = Db::name('study')->column('id,examname');
$this->assignconfig('studyList', $studyList);
}
/**
... ... @@ -50,6 +52,21 @@ class User extends Backend
return $this->selectpage();
}
// 修改where条件,sql字段替换
$filter = json_decode($this->request->get("filter"),true);
$op = json_decode($this->request->get("op"),true);
if(isset($filter['studys'])){
$user_ids = Db::name('third_study')
->alias('a')
->join('study b','b.id = a.study_id')
->where('a.study_id',$filter['studys'])
->column('a.third_id');
$filter['id'] = !empty($user_ids) ? implode(',',$user_ids) : 0;
$op['id'] = $op['studys'];
unset($filter['studys'],$op['studys']);
$this->request->get(["filter"=>json_encode($filter),'op'=>json_encode($op)]);
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams('user.id,user.username,user.nickname,user.password,user.card,user.work_address,user.studynum');
$total = $this->model
->with('group')
... ... @@ -64,6 +81,11 @@ class User extends Backend
->select();
foreach ($list as $k => &$v) {
$v['user.mobile_exam_ids'] = Db::name('mobile_exam')->whereIn('id',$v['mobile_exam_ids'])->column('name');
$v['studys'] = Db::name('third_study')
->alias('a')
->join('study b','b.id = a.study_id')
->where('a.third_id',$v['id'])
->column('b.examname');
}
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -64,7 +64,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
// {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
// {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
{field: 'id', title: __('按钮组'), table: table, events: Table.api.events.operate, buttons:
{field: 'studys', title: __('报考科目'), operate: 'IN', searchList: Config.studyList,formatter: Table.api.formatter.flag},
{field: 'id', title: __('查看报考科目'), table: table, events: Table.api.events.operate, buttons:
[
{
text: '报考科目',
... ...