diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php index ca7e31f4..b16c4d47 100644 --- a/application/admin/controller/Category.php +++ b/application/admin/controller/Category.php @@ -46,22 +46,33 @@ class Category extends Backend if ($this->request->isAjax()) { $search = $this->request->request("search"); + $type = $this->request->request("type"); + //构造父类select列表选项数据 $list = []; - if ($search) - { + foreach ($this->categorylist as $k => $v) { - if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) - { - $list[] = $v; + if ($search) { + if ($v['type'] == $type && stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) + { + if($type == "all" || $type == null) { + $list = $this->categorylist; + } else { + $list[] = $v; + } + } + } else { + if($type == "all" || $type == null) { + $list = $this->categorylist; + } else if ($v['type'] == $type){ + $list[] = $v; + } + } + } - } - else - { - $list = $this->categorylist; - } + $total = count($list); $result = array("total" => $total, "rows" => $list); diff --git a/application/admin/view/category/index.html b/application/admin/view/category/index.html index 3c07c85b..da8cf509 100644 --- a/application/admin/view/category/index.html +++ b/application/admin/view/category/index.html @@ -1,6 +1,14 @@