统计页面 修改店铺选择,增加店铺搜索Combobox

This commit is contained in:
chfei committed 2026-08-07 11:25:19 +08:00
1 parent b6b72e6bc3
commit f12a7f14ea
16 files changed
+1801 -41

No files matched your search

@@ -25,7 +25,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
private ObservableCollection<RevenueTrendPoint> _trendData;
private ObservableCollection<ShopSalesProportionItem> _shopProportionData;
private ObservableCollection<ShopStatisticsItem> _shopStatistics;
private ShopOption _selectedShop;
private ObservableCollection<ShopOption> _selectedShops;
private string _selectedPlatform;
public ShopRevenueStatisticsViewModel()
@@ -92,17 +92,17 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
set { this.SetValue(x => x.EndDate, value); }
}
/// <summary>店铺选项(含“全部店铺”)</summary>
/// <summary>店铺选项(“全部店铺”由多选控件“全部商铺”表示)</summary>
public ObservableCollection<ShopOption> ShopOptions { get; }
/// <summary>选中的店铺</summary>
public ShopOption SelectedShop
public ObservableCollection<ShopOption> SelectedShops
{
get { return _selectedShop; }
get { return _selectedShops; }
set
{
_selectedShop = value;
OnPropertyChanged(nameof(SelectedShop));
_selectedShops = value;
OnPropertyChanged(nameof(SelectedShops));
}
}
@@ -179,12 +179,11 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
{
try
{
// 店铺选项
ShopOptions.Add(new ShopOption { AppKey = string.Empty, ShopName = "全部店铺" });
// 店铺选项(全部店铺由多选控件“全部商铺”表示,不再额外加入“全部店铺”项)
var shops = await _service.GetShopOptionsAsync();
foreach (var shop in shops)
ShopOptions.Add(shop);
SelectedShop = ShopOptions.FirstOrDefault();
SelectedShops = new ObservableCollection<ShopOption>(ShopOptions);
// 默认时间范围:本月
SelectedTimeRange = TimeRangeOptions.FirstOrDefault(t => t.Value == "month");
@@ -233,6 +232,23 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
}
}
/// <summary>根据选中店铺生成查询店铺 key 列表:未选/全选/选中“全部店铺”时返回空列表(表示全部店铺)</summary>
private List<string> BuildSelectedShopKeys()
{
var selected = SelectedShops;
if (selected == null || selected.Count == 0)
return new List<string>();
var keys = selected.Select(s => s == null ? string.Empty : s.AppKey).ToList();
if (keys.Any(string.IsNullOrEmpty))
return new List<string>();
if (selected.Count >= ShopOptions.Count)
return new List<string>();
return keys;
}
/// <summary>执行查询,刷新页面所有统计数据</summary>
private async Task LoadAsync()
{
@@ -250,7 +266,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
{
StartDate = StartDate,
EndDate = EndDate,
ShopKey = SelectedShop == null ? string.Empty : SelectedShop.AppKey,
ShopKeys = BuildSelectedShopKeys(),
};
Summary = await _service.GetSummaryAsync(query);
@@ -277,7 +293,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
/// <summary>重置查询条件并重新加载</summary>
private async void Reset()
{
SelectedShop = ShopOptions.FirstOrDefault();
SelectedShops = new ObservableCollection<ShopOption>(ShopOptions);
SelectedTimeRange = TimeRangeOptions.FirstOrDefault(t => t.Value == "month");
ApplyTimeRange();
await LoadAsync();