<pi:UserControlBase x:Class="智慧物流软件系统.UserView"
             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:local="clr-namespace:智慧物流软件系统"
             mc:Ignorable="d"
             xmlns:hc="https://handyorg.github.io/handycontrol"
             xmlns:pi="https://github.com/ping9719/wpfex"
             d:DesignHeight="450" d:DesignWidth="800" LoadedVisibleFirst="loadFirst">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <!--条件区-->
        <Grid Margin="5,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <UniformGrid Grid.Column="0" Columns="1">
                <hc:TextBox Text="{Binding Info1}" Margin="5" Style="{StaticResource TextBoxExtend}" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="用户名称" hc:InfoElement.Placeholder="模糊匹配" VerticalAlignment="Center"/>
            </UniformGrid>
            <hc:UniformSpacingPanel Grid.Column="1" Spacing="5">
                <Button Content="新增" Command="{Binding AddCommand}" Style="{StaticResource ButtonSuccess}" Width="70" Visibility="{Binding Auth,Source={x:Static local:UserInfoView.viewModel},ConverterParameter={x:Static local:AuthEnum.权限},Converter={StaticResource AuthVisConverter}}"></Button>
                <Button Content="查询" Command="{Binding UpdateListCommand}" Style="{StaticResource ButtonPrimary}" Width="70"></Button>
            </hc:UniformSpacingPanel>
        </Grid>
        <!--内容区-->
        <Border Grid.Row="1" Grid.Column="0" Style="{StaticResource BorderRegion}" BorderThickness="1" Background="#EEEEEE" Margin="3,0,3,3" Padding="0" >
            <DataGrid RowHeaderWidth="50" HeadersVisibility="All" AutoGenerateColumns="False" ItemsSource="{Binding DataList}" hc:DataGridAttach.CanUnselectAllWithBlankArea="False" hc:DataGridAttach.ShowSelectAllButton="False" hc:DataGridAttach.ShowRowNumber="True">
                <DataGrid.Columns>
                    <DataGridTextColumn IsReadOnly="True" Width="5*" Binding="{Binding LoginName}" Header="用户名称" CanUserSort="False"/>
                    <DataGridTextColumn IsReadOnly="True" Width="5*" Binding="{Binding RoleNames,Converter={StaticResource List2StrConverter}}" Header="角色" CanUserSort="False"/>
                    <DataGridTextColumn IsReadOnly="True" Width="200" Binding="{Binding Time,StringFormat=yyyy-MM-dd HH:mm}" Header="创建时间" CanUserSort="False"/>
                    <DataGridTemplateColumn CanUserResize="False" Width="auto">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" IsEnabled="{Binding IsAdmin,Converter={StaticResource Boolean2BooleanReConverter}}">
                                    <Button Style="{StaticResource ButtonInfo}" Margin="0,0,5,0" IsEnabled="True" Content="查看" Width="60" Command="{Binding DataContext.SeeCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }"/>
                                    <Button Style="{StaticResource ButtonWarning}" Margin="0,0,5,0" IsEnabled="True" Content="修改" Width="60" Command="{Binding DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }" Visibility="{Binding Auth,Source={x:Static local:UserInfoView.viewModel},ConverterParameter={x:Static local:AuthEnum.权限},Converter={StaticResource AuthVisConverter}}"/>
                                    <Button Style="{StaticResource ButtonDanger}" Margin="0,0,0,0" IsEnabled="True" Content="删除" Width="60" Command="{Binding DataContext.DelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }" Visibility="{Binding Auth,Source={x:Static local:UserInfoView.viewModel},ConverterParameter={x:Static local:AuthEnum.权限},Converter={StaticResource AuthVisConverter}}"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Border>
    </Grid>
</pi:UserControlBase>
