mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-01 15:31:03 +00:00
附件分类显示修改
This commit is contained in:
parent
89a1bda0e4
commit
cd68d42a31
@ -38,8 +38,10 @@ class SystemAttachmentCategory extends AuthController
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['name', '']
|
||||
['name', ''],
|
||||
['pid', 0]
|
||||
]);
|
||||
if ($where['name'] != '') $where['pid'] = '';
|
||||
return app('json')->success($this->service->getAll($where));
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class SystemAttachmentCategory extends BaseModel
|
||||
*/
|
||||
public function searchNameAttr($query, $value)
|
||||
{
|
||||
if ($value) $query->where('name', 'like', '%' . $value . '%');
|
||||
if ($value != '') $query->where('name', 'like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +54,7 @@ class SystemAttachmentCategory extends BaseModel
|
||||
*/
|
||||
public function searchPidAttr($query, $value)
|
||||
{
|
||||
$query->where('pid', $value);
|
||||
if ($value !== '') $query->where('pid', $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\services\system\attachment;
|
||||
|
||||
@ -45,20 +45,12 @@ class SystemAttachmentCategoryServices extends BaseServices
|
||||
*/
|
||||
public function getAll(array $where)
|
||||
{
|
||||
$categoryList = $this->dao->getList($where);
|
||||
if ($where['name'] != '') {
|
||||
$pids = Arr::getUniqueKey($categoryList, 'pid');
|
||||
$parentList = $this->dao->getList(['id' => $pids]);
|
||||
$categoryList = array_merge($categoryList, $parentList);
|
||||
foreach ($categoryList as $key => $item) {
|
||||
$arr = $categoryList[$key];
|
||||
unset($categoryList[$key]);
|
||||
if (!in_array($arr, $categoryList)) {
|
||||
$categoryList[] = $arr;
|
||||
}
|
||||
}
|
||||
$list = $this->dao->getList($where);
|
||||
foreach ($list as &$item) {
|
||||
$item['title'] = $item['name'];
|
||||
$item['children'] = [];
|
||||
if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) $item['loading'] = false;
|
||||
}
|
||||
$list = $this->tidyMenuTier($categoryList);
|
||||
return compact('list');
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user