This commit is contained in:
xman 2025-07-07 16:05:27 +08:00
parent e2c2ea0086
commit e08dc78904
3 changed files with 47 additions and 2 deletions

View File

@ -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', // 营业额

View File

@ -46,6 +46,14 @@
</div>
<div class="form-group" style="margin-left: 15px;">
<div class="col-xs-12">
<input id="select_item" class="form-control" type="text" autocomplete="off" />
<input id="select_item_id" type="hidden" name="item_id" />
</div>
</div>
<!-- 查询按钮 -->
<button class="btn btn-default" id="filter-btn" style="margin-left: 15px;">查询</button>
</div>
@ -79,3 +87,6 @@
</div>
</div>
</div>
<script>
var items = {:json_encode($items); };
</script>

View File

@ -96,6 +96,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
$("#select_area_id").val(code);
});
var _data = items;
$('#select_item').zdCascader({
data: _data,
onChange: function ($this, data, allPathData) {
// console.log(data,allPathData);
$('#select_item_id').val(data.value);
},
clear: true,
clickParent: true
});
},
add: function () {
@ -204,6 +216,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t
'daterange': daterange,
'source': source,
'area_id': city_id,
'item_id': item_id,
};
$.ajax({