附件分类优化

This commit is contained in:
evoxwht 2023-06-28 10:21:52 +08:00
parent fc4bd5b578
commit 0239ec3e25
2 changed files with 9 additions and 6 deletions

View File

@ -48,9 +48,10 @@ class SystemAttachmentCategory extends AuthController
{
$where = $this->request->getMore([
['name', ''],
['pid', 0]
['pid', 0],
['all', 0]
]);
if ($where['name'] != '') $where['pid'] = '';
if ($where['name'] != '' || $where['all'] == 1) $where['pid'] = '';
return app('json')->success($this->service->getAll($where));
}

View File

@ -49,11 +49,13 @@ class SystemAttachmentCategoryServices extends BaseServices
public function getAll(array $where)
{
$list = $this->dao->getList($where);
foreach ($list as &$item) {
$item['title'] = $item['name'];
if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) {
$item['loading'] = false;
if ($where['all'] == 1) {
$list = $this->tidyMenuTier($list);
} else {
foreach ($list as &$item) {
$item['title'] = $item['name'];
$item['children'] = [];
if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) $item['loading'] = false;
}
}
return compact('list');