重构联查功能

尝试把列表构建改成由前端渲染
This commit is contained in:
2021-03-12 07:56:51 +08:00
parent 8ad68e938e
commit d795809fb3
19 changed files with 515 additions and 196 deletions
@@ -43,6 +43,16 @@ class ArticleController extends DefaultController
'display' => $this->access['edit'],
]];
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['cols'] = $cols;
$header['tabs'] = Article::$tabs;
$header['bys'] = Article::$bys;
$header['js'] = Grid::js($header);
$search = $header['search_form'];
$query = $search['query'];
@@ -64,13 +74,14 @@ class ArticleController extends DefaultController
$model->permission('receive_id', null, false, true, false, 'created_id');
}
// 查询是否已经阅读
// 是否已经阅读
$reader = function ($q) {
$q->selectRaw('1')
->from('article_reader')
->whereRaw('article_reader.article_id = article.id')
->where('article_reader.created_id', auth()->id());
};
if ($query['tab'] == 'done') {
$model->whereExists($reader);
}
@@ -81,27 +92,11 @@ class ArticleController extends DefaultController
$model->select($header['select']);
$rows = $model->paginate($query['limit'])->appends($query);
$header['cols'] = $cols;
$header['tabs'] = Article::$tabs;
$header['bys'] = Article::$bys;
$header['js'] = Grid::js($header);
$items = Grid::dataFilters($rows, $header, function($item) {
return Grid::dataFilters($rows, $header, function($item) {
return $item;
});
return $items;
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['cols'] = $cols;
$header['tabs'] = Article::$tabs;
$header['bys'] = Article::$bys;
$header['js'] = Grid::js($header);
return $this->display([
'header' => $header,
]);