Files
qhmes/yy-admin-master/YY.Admin/Views/SysManage/UserManagementView.xaml

267 lines
15 KiB
XML

<UserControl x:Class="YY.Admin.Views.SysManage.UserManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:YY.Admin.Views.SysManage"
xmlns:core="clr-namespace:YY.Admin.Core;assembly=YY.Admin.Core"
xmlns:components="clr-namespace:YY.Admin.Views.Control"
mc:Ignorable="d">
<Grid Style="{StaticResource BaseViewStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 搜索条件区域 -->
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
<hc:Row>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:TextBox
Text="{Binding UserInput.Account, UpdateSourceTrigger=PropertyChanged}"
hc:InfoElement.Placeholder="请输入账号"
hc:InfoElement.Title="账号"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:TextBox
Text="{Binding UserInput.RealName, UpdateSourceTrigger=PropertyChanged}"
hc:InfoElement.Placeholder="请输入姓名"
hc:InfoElement.Title="姓名"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:TextBox
Text="{Binding UserInput.NickName, UpdateSourceTrigger=PropertyChanged}"
hc:InfoElement.Placeholder="请输入昵称"
hc:InfoElement.Title="昵称"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:ComboBox
SelectedValue="{Binding UserInput.Sex}"
ItemsSource="{Binding GenderList}"
hc:InfoElement.Placeholder="请选择性别"
hc:InfoElement.Title="性别"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10">
<hc:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</hc:ComboBox.ItemTemplate>
</hc:ComboBox>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:TextBox
Text="{Binding UserInput.Phone, UpdateSourceTrigger=PropertyChanged}"
hc:InfoElement.Placeholder="请输入手机号码"
hc:InfoElement.Title="手机号码"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:ComboBox
SelectedValue="{Binding UserInput.Status, Converter={StaticResource EnumToIntConverter}, ConverterParameter={x:Type core:StatusEnum}}"
ItemsSource="{Binding StatusList}"
DisplayMemberPath="Key"
SelectedValuePath="Value"
hc:InfoElement.Placeholder="请选择状态"
hc:InfoElement.Title="状态"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:DateTimePicker
x:Name="BeginTimePicker"
Style="{StaticResource DateTimePickerPlus}"
SelectedDateTime="{Binding UserInput.BeginTime}"
DateTimeFormat="yyyy-MM-dd HH:mm:ss"
hc:InfoElement.Title="创建时间"
hc:InfoElement.Placeholder="开始时间"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
<hc:DateTimePicker
x:Name="EndTimePicker"
Style="{StaticResource DateTimePickerPlus}"
SelectedDateTime="{Binding UserInput.EndTime}"
DateTimeFormat="yyyy-MM-dd HH:mm:ss"
hc:InfoElement.Title="至"
hc:InfoElement.Placeholder="结束时间"
hc:InfoElement.TitleWidth="65"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.ShowClearButton="True"
Margin="0 0 10 10"/>
</hc:Col>
</hc:Row>
</Border>
<!-- 批量操作工具栏 -->
<Border Grid.Row="1" Margin="0,10">
<hc:UniformSpacingPanel Spacing="10">
<!-- 搜索按钮 -->
<Button
Style="{StaticResource ButtonPrimary}"
Command="{Binding SearchCommand}">
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="Search"/>
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
</StackPanel>
</Button>
<!-- 重置按钮 -->
<Button
Style="{StaticResource ButtonDefault}"
Click="ResetButton_Click">
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="Refresh"/>
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
</StackPanel>
</Button>
<Button
Command="{Binding AddCommand}"
Style="{StaticResource ButtonSuccess}">
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="Plus"/>
<TextBlock Text="新增" Style="{StaticResource IconButtonStyle}"/>
</StackPanel>
</Button>
<Button
Style="{StaticResource ButtonPrimary}"
Command="{Binding ManualUploadCommand}">
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="Upload"/>
<TextBlock Text="手动上传" Style="{StaticResource IconButtonStyle}"/>
</StackPanel>
</Button>
<Button
Style="{StaticResource ButtonDanger}"
IsEnabled="{Binding HasSelectedItems}"
Command="{Binding BatchDeleteCommand}">
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="TrashCanOutline"/>
<TextBlock Text="删除" Style="{StaticResource IconButtonStyle}"/>
</StackPanel>
</Button>
</hc:UniformSpacingPanel>
</Border>
<DataGrid
Grid.Row="2"
RowHeaderWidth="55"
AutoGenerateColumns="False"
HeadersVisibility="All"
SelectionMode="Extended"
SelectionUnit="FullRow"
ItemsSource="{Binding PaginationDataGridViewModel.Data}"
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
Style="{StaticResource CusDataGridStyle}"
hc:DataGridAttach.ShowSelectAllButton="True"
SelectionChanged="DataGrid_SelectionChanged">
<!-- 同步行选择和数据选择 -->
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>
</DataGrid.ItemContainerStyle>
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Account}" Header="账号" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding RealName}" Header="姓名" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding NickName}" Header="昵称" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Phone}" Header="手机号码" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Birthday, StringFormat='yyyy-MM-dd'}" Header="出生日期" CellStyle="{StaticResource CusDataGridCellStyle}" Width="120"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding Sex, Converter={StaticResource EnumDescriptionConverter}}" Header="性别" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding AccountType, Converter={StaticResource EnumDescriptionConverter}}" Header="用户类型" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
<DataGridTemplateColumn Header="状态" Width="80" CellStyle="{StaticResource CusDataGridCellStyle}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ToggleButton
Command="{Binding DataContext.StatusToggleCommand,
RelativeSource={RelativeSource AncestorType=DataGrid}}"
CommandParameter="{Binding}"
IsChecked="{Binding Status, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter=Enable}"
Cursor="Hand"
Style="{StaticResource ToggleButtonSwitch}"
hc:VisualElement.HighlightBrush="{DynamicResource PrimaryBrush}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn IsReadOnly="True" Binding="{Binding CreateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" Header="创建时间" CellStyle="{StaticResource CusDataGridCellStyle}" Width="180"/>
<!-- 操作列 -->
<DataGridTemplateColumn Header="操作" Width="150" CellStyle="{StaticResource CusOperDataGridCellStyle}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<hc:UniformSpacingPanel Spacing="5">
<!-- 修改 -->
<Border Style="{DynamicResource DataGridOpeButtonStyle}">
<Border.InputBindings>
<MouseBinding
Command="{Binding DataContext.EditCommand,
RelativeSource={RelativeSource AncestorType=DataGrid}}"
CommandParameter="{Binding}"
MouseAction="LeftClick"/>
</Border.InputBindings>
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="SquareEditOutline" VerticalAlignment="Center"/>
<TextBlock Text="修改" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<!-- 删除 -->
<Border Style="{DynamicResource DataGridOpeButtonStyle}">
<Border.InputBindings>
<MouseBinding
Command="{Binding DataContext.DeleteCommand,
RelativeSource={RelativeSource AncestorType=DataGrid}}"
CommandParameter="{Binding Id}"
MouseAction="LeftClick"/>
</Border.InputBindings>
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="TrashCanOutline" VerticalAlignment="Center"/>
<TextBlock Text="删除" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</hc:UniformSpacingPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<components:PaginationDataGridControl Grid.Row="3" DataContext="{Binding PaginationDataGridViewModel}"/>
</Grid>
</UserControl>