Files
29WxOrder/29WxOrderWpf/Ctrls/Statistics/ShopRevenueStatisticsView.xaml
T

554 lines
16 KiB
XML

<UserControl
x:Class="_29WxOrderWpf.Ctrls.Statistics.ShopRevenueStatisticsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:charts="clr-namespace:_29WxOrderWpf.Ctrls.Statistics.Charts"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:_29WxOrderWpf.Ctrls.Statistics.ViewModels"
xmlns:stat="clr-namespace:_29WxOrderWpf.Ctrls.Statistics"
xmlns:wpf="clr-namespace:_29WxOrderWpf.Common"
d:Background="#F5F7FB"
d:DataContext="{d:DesignInstance Type=vm:ShopRevenueStatisticsViewModel,IsDesignTimeCreatable=True}"
d:DesignHeight="900"
d:DesignWidth="1600"
wpf:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
wpf:DialogWindowProperty.ShowMinButton="False"
mc:Ignorable="d">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
<!-- 卡片样式(白底、圆角、阴影) -->
<Style x:Key="CardBorderStyle" TargetType="Border">
<Setter Property="Background" Value="White" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="Padding" Value="18" />
<Setter Property="Margin" Value="4" />
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect
BlurRadius="10"
Opacity="0.08"
ShadowDepth="2"
Color="#000000" />
</Setter.Value>
</Setter>
</Style>
<!-- 表格单元格文字居中 -->
<Style x:Key="CenterCellTextStyle" TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<!-- 面板标题 -->
<Style x:Key="PanelTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="#333333" />
</Style>
<!-- TabControl 样式(页签 + 内容区) -->
<Style x:Key="StatisticsTabControlStyle" TargetType="TabControl">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabControl">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
Grid.Row="0"
Margin="6,0,0,0"
HorizontalAlignment="Left"
Background="Transparent">
<TabPanel
x:Name="HeaderPanel"
IsItemsHost="True"
Background="Transparent" />
</Border>
<Border
Grid.Row="1"
Background="Transparent"
CornerRadius="0,8,8,8">
<ContentPresenter
x:Name="PART_SelectedContentHost"
ContentSource="SelectedContent" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- TabItem 样式 -->
<Style x:Key="StatisticsTabItemStyle" TargetType="TabItem">
<Setter Property="Foreground" Value="#666666" />
<Setter Property="FontSize" Value="15" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border
x:Name="Bd"
Margin="0,0,4,0"
Padding="20,9"
Background="Transparent"
BorderBrush="#E0E4EA"
BorderThickness="1,1,1,0"
CornerRadius="8,8,0,0">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="#F0F4FB" />
<Setter Property="Foreground" Value="#98638F" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="White" />
<Setter TargetName="Bd" Property="BorderBrush" Value="#E0E4EA" />
<Setter Property="Foreground" Value="#98638F" />
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Background="#F5F7FB">
<TabControl Style="{StaticResource StatisticsTabControlStyle}">
<TabItem
Header="综合统计"
Style="{StaticResource StatisticsTabItemStyle}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="12">
<!-- ============ 查询条件工具栏 ============ -->
<Border
Margin="6,6,6,0"
Padding="14,10"
Style="{StaticResource CardBorderStyle}">
<WrapPanel>
<TextBlock
Margin="6,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="#666666"
Text="时间" />
<ComboBox
Width="110"
Height="32"
VerticalContentAlignment="Center"
DisplayMemberPath="Text"
ItemsSource="{Binding TimeRangeOptions}"
SelectedItem="{Binding SelectedTimeRange, Mode=TwoWay}"
Style="{StaticResource BaseComboBoxStyle}" />
<TextBlock
Margin="14,0,6,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="#666666"
Text="日期" />
<DatePicker
Height="32"
VerticalContentAlignment="Center"
SelectedDate="{Binding StartDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Margin="6,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="#666666"
Text="~" />
<DatePicker
Height="32"
VerticalContentAlignment="Center"
SelectedDate="{Binding EndDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Margin="14,0,6,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="#666666"
Text="店铺" />
<ComboBox
Width="130"
Height="32"
VerticalContentAlignment="Center"
DisplayMemberPath="ShopName"
ItemsSource="{Binding ShopOptions}"
SelectedItem="{Binding SelectedShop, Mode=TwoWay}"
Style="{StaticResource BaseComboBoxStyle}" />
<Button
Height="32"
Margin="18,0,0,0"
Padding="16,0"
Command="{Binding QueryCommand}"
Content=" 查询 "
Style="{StaticResource BasePageButtonStyle}" />
<Button
Height="32"
Margin="8,0,0,0"
Padding="16,0"
Command="{Binding ResetCommand}"
Content=" 重置 "
Style="{StaticResource BasePageButtonLightStyle}" />
</WrapPanel>
</Border>
<!-- ============ 汇总卡片(2 行 x 4 列) ============ -->
<Grid Margin="3,8,3,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 销售额 -->
<Border
Grid.Row="0"
Grid.Column="0"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="销售额" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.SalesAmount, StringFormat={}¥{0:N2}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="最终有效销售额" />
</StackPanel>
</Border>
<!-- 有效订单 -->
<Border
Grid.Row="0"
Grid.Column="1"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="有效订单" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.ValidOrderCount, StringFormat={}{0:N0}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="已扣除退款订单" />
</StackPanel>
</Border>
<!-- 利润 -->
<Border
Grid.Row="0"
Grid.Column="2"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="利润" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.Profit, StringFormat={}¥{0:N2}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="实际利润" />
</StackPanel>
</Border>
<!-- 退款金额 -->
<Border
Grid.Row="0"
Grid.Column="3"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="退款金额" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.RefundAmount, StringFormat={}¥{0:N2}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="统计期间退款" />
</StackPanel>
</Border>
<!-- 商品销量 -->
<Border
Grid.Row="1"
Grid.Column="0"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="商品销量" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.ProductSalesVolume, StringFormat={}{0:N0}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="有效销量" />
</StackPanel>
</Border>
<!-- 客户数 -->
<Border
Grid.Row="1"
Grid.Column="1"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="客户数" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.CustomerCount, StringFormat={}{0:N0}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="成交客户" />
</StackPanel>
</Border>
<!-- 客单价 -->
<Border
Grid.Row="1"
Grid.Column="2"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="客单价" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.AvgOrderAmount, StringFormat={}¥{0:N2}}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="平均每单金额" />
</StackPanel>
</Border>
<!-- 退款率 -->
<Border
Grid.Row="1"
Grid.Column="3"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#888888"
Text="退款率" />
<TextBlock
Margin="0,12,0,0"
FontSize="30"
FontWeight="Bold"
Foreground="#333333"
Text="{Binding Summary.RefundRate, StringFormat={}{0:0.00}%}" />
<TextBlock
Margin="0,10,0,0"
FontSize="12"
Foreground="#999999"
Text="退款订单占比" />
</StackPanel>
</Border>
</Grid>
<!-- ============ 图表区域 ============ -->
<Grid Margin="3,8,3,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<!-- 销售趋势 -->
<Border
Grid.Column="0"
Margin="6,6,3,6"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock Style="{StaticResource PanelTitleStyle}" Text="销售趋势" />
<charts:RevenueLineChart
Height="330"
Margin="0,10,0,0"
Points="{Binding TrendData}" />
</StackPanel>
</Border>
<!-- 店铺销售占比 -->
<Border
Grid.Column="1"
Margin="3,6,6,6"
Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock Style="{StaticResource PanelTitleStyle}" Text="店铺销售占比 TOP 5" />
<charts:RevenuePieChart
Height="330"
Margin="0,10,0,0" MaxItems="5"
ItemsSource="{Binding ShopProportionData}" />
</StackPanel>
</Border>
</Grid>
<!-- ============ 店铺统计表格 ============ -->
<Border Margin="6,8,6,12" Style="{StaticResource CardBorderStyle}">
<StackPanel>
<TextBlock
Margin="0,0,0,10"
Style="{StaticResource PanelTitleStyle}"
Text="店铺统计" />
<DataGrid
AlternatingRowBackground="#FAFAFA"
AutoGenerateColumns="False"
Background="Transparent"
BorderThickness="0"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
ColumnHeaderStyle="{StaticResource BaseDataGridColumnHeaderStyle}"
FontSize="13"
Foreground="#333333"
GridLinesVisibility="Horizontal"
HeadersVisibility="Column"
HorizontalGridLinesBrush="#EEEEEE"
IsReadOnly="True"
ItemsSource="{Binding ShopStatistics}"
RowHeight="46"
ScrollViewer.CanContentScroll="True"
SelectionMode="Single"
SelectionUnit="FullRow"
VerticalScrollBarVisibility="Disabled">
<DataGrid.Columns>
<DataGridTextColumn
Width="*"
Binding="{Binding ShopName}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="店铺" />
<DataGridTextColumn
Width="*"
Binding="{Binding OrderCount, StringFormat={}{0:N0}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="订单数" />
<DataGridTextColumn
Width="*"
Binding="{Binding SalesAmount, StringFormat={}¥{0:N2}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="销售额" />
<DataGridTextColumn
Width="*"
Binding="{Binding Profit, StringFormat={}¥{0:N2}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="利润" />
<DataGridTextColumn
Width="*"
Binding="{Binding RefundAmount, StringFormat={}¥{0:N2}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="退款金额" />
<DataGridTextColumn
Width="*"
Binding="{Binding CustomerCount, StringFormat={}{0:N0}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="客户数" />
<DataGridTextColumn
Width="*"
Binding="{Binding AvgOrderAmount, StringFormat={}¥{0:N2}}"
ElementStyle="{StaticResource CenterCellTextStyle}"
Header="客单价" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem
Header="天统计"
Style="{StaticResource StatisticsTabItemStyle}">
<stat:PeriodRevenueStatisticsView PeriodType="Day" />
</TabItem>
<TabItem
Header="周统计"
Style="{StaticResource StatisticsTabItemStyle}">
<stat:PeriodRevenueStatisticsView PeriodType="Week" />
</TabItem>
<TabItem
Header="月统计"
Style="{StaticResource StatisticsTabItemStyle}">
<stat:PeriodRevenueStatisticsView PeriodType="Month" />
</TabItem>
</TabControl>
<!-- ============ 加载遮罩 ============ -->
<Border Background="#66FFFFFF" Visibility="{Binding IsLoading, Converter={StaticResource boolToVisibilityConverter}}" d:Visibility="Collapsed" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<ProgressBar
Width="240"
Height="8"
IsIndeterminate="True" />
<TextBlock
Margin="0,12,0,0"
HorizontalAlignment="Center"
FontSize="13"
Foreground="#888888"
Text="数据加载中..." />
</StackPanel>
</Border>
</Grid>
</UserControl>