diff --git a/application/admin/controller/statistics/Item.php b/application/admin/controller/statistics/Item.php index 08f9736..d5ba0e4 100644 --- a/application/admin/controller/statistics/Item.php +++ b/application/admin/controller/statistics/Item.php @@ -25,7 +25,7 @@ use function Symfony\Component\Clock\now; */ class Item extends Backend { - + protected $itemsformattedTree = null; protected $noNeedRight = ['list','chartData']; @@ -54,8 +54,21 @@ class Item extends Backend ]; } } - $this->view->assign("sources", $res); + $items = Db::name('item') + ->where('status', 1) + ->field(['id', 'title', 'key_word', 'pid']) + ->order('pid', 'asc') + ->order('sort', 'desc') + ->select(); + $tree = $this->buildTree($items); + $formattedTree = $this->formatTree($tree); + + $this->items = $items; + $this->itemsformattedTree = $formattedTree; + + $this->view->assign("sources", $res); + $this->view->assign("items", $formattedTree); } @@ -188,6 +201,14 @@ class Item extends Backend $build->where('area_id','LIKE',request()->post('source').'%'); } + if(!empty(request()->post('item_id',null))){ + $item_id =request()->post('item_id'); + $item_ids = $this->getItemsById($item_id); + $item_ids [] = $item_id; + $build->whereIn('item_id', $item_ids); + } + + $res = $build->field([ 'item_title name', // 类型 'sum(total) total', // 营业额 diff --git a/application/admin/view/statistics/item/index.html b/application/admin/view/statistics/item/index.html index 4881a88..da9d918 100644 --- a/application/admin/view/statistics/item/index.html +++ b/application/admin/view/statistics/item/index.html @@ -46,6 +46,14 @@ +