- ProductDto 增加 extJson 解析,从服务端读取货品编号 - ProductExtJson 类用于序列化/反序列化扩展属性 - 同步时优先使用本地货品编号,其次使用服务端的 - 新增"上传到服务端"按钮,批量上传货品编号 - 调用 /user/apiExtShopGoods/save 接口更新 extJsonStr 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
207 lines
11 KiB
XML
207 lines
11 KiB
XML
<UserControl x:Class="PackagingMallShipper.Views.ProductListView"
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||
mc:Ignorable="d"
|
||
Background="White">
|
||
|
||
<Grid Margin="15">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="*"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- 统计信息 -->
|
||
<Border Grid.Row="0" Background="#F5F7FA" CornerRadius="4" Padding="15" Margin="0,0,0,15">
|
||
<Grid>
|
||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||
<StackPanel Margin="0,0,40,0">
|
||
<TextBlock Text="产品总数" FontSize="12" Foreground="#666"/>
|
||
<TextBlock Text="{Binding TotalCount}" FontSize="24" FontWeight="Bold" Foreground="#1890FF"/>
|
||
</StackPanel>
|
||
<StackPanel Margin="0,0,40,0">
|
||
<TextBlock Text="上架中" FontSize="12" Foreground="#666"/>
|
||
<TextBlock Text="{Binding OnSaleCount}" FontSize="24" FontWeight="Bold" Foreground="#52C41A"/>
|
||
</StackPanel>
|
||
</StackPanel>
|
||
|
||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||
<TextBlock Text="上次同步:" FontSize="12" Foreground="#999" VerticalAlignment="Center"/>
|
||
<TextBlock Text="{Binding LastSyncTime, StringFormat=yyyy-MM-dd HH:mm, TargetNullValue=未同步}"
|
||
FontSize="12" Foreground="#666" VerticalAlignment="Center"/>
|
||
</StackPanel>
|
||
</Grid>
|
||
</Border>
|
||
|
||
<!-- 工具栏 -->
|
||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,10">
|
||
<ComboBox Width="100" SelectedIndex="{Binding SelectedStatusIndex}" Height="30">
|
||
<ComboBoxItem Content="全部"/>
|
||
<ComboBoxItem Content="上架"/>
|
||
<ComboBoxItem Content="下架"/>
|
||
</ComboBox>
|
||
|
||
<TextBox Width="250" Margin="10,0"
|
||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
|
||
VerticalContentAlignment="Center" Height="30"
|
||
Padding="5,0">
|
||
<TextBox.Style>
|
||
<Style TargetType="TextBox">
|
||
<Style.Triggers>
|
||
<Trigger Property="Text" Value="">
|
||
<Setter Property="Background">
|
||
<Setter.Value>
|
||
<VisualBrush Stretch="None" AlignmentX="Left">
|
||
<VisualBrush.Visual>
|
||
<TextBlock Text="搜索产品名称/货品编号/条码" Foreground="Gray" Margin="5,0"/>
|
||
</VisualBrush.Visual>
|
||
</VisualBrush>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
</TextBox.Style>
|
||
</TextBox>
|
||
|
||
<Button Content="搜索" Command="{Binding SearchCommand}"
|
||
Width="70" Height="30" Margin="0,0,10,0"/>
|
||
|
||
<Separator Width="1" Background="#DDD" Margin="10,5"/>
|
||
|
||
<Button Content="同步产品" Command="{Binding SyncProductsCommand}"
|
||
Width="90" Height="30" Margin="0,0,5,0"
|
||
Background="#1890FF" Foreground="White" BorderThickness="0"
|
||
IsEnabled="{Binding IsBusy, Converter={StaticResource InverseBool}}"/>
|
||
|
||
<Separator Width="1" Background="#DDD" Margin="10,5"/>
|
||
|
||
<Button Content="编辑货品编号" Command="{Binding StartEditItemCodeCommand}"
|
||
Width="100" Height="30" Margin="0,0,5,0"/>
|
||
|
||
<Button Content="上传到服务端" Command="{Binding UploadItemCodesToServerCommand}"
|
||
Width="100" Height="30" Margin="0,0,5,0"
|
||
Background="#FA8C16" Foreground="White" BorderThickness="0"
|
||
ToolTip="将本地货品编号同步到服务端"
|
||
IsEnabled="{Binding IsBusy, Converter={StaticResource InverseBool}}"/>
|
||
</StackPanel>
|
||
|
||
<!-- 产品列表 -->
|
||
<DataGrid Grid.Row="2"
|
||
ItemsSource="{Binding Products}"
|
||
SelectedItem="{Binding SelectedProduct}"
|
||
AutoGenerateColumns="False"
|
||
IsReadOnly="True"
|
||
SelectionMode="Single"
|
||
CanUserAddRows="False"
|
||
CanUserDeleteRows="False"
|
||
GridLinesVisibility="Horizontal"
|
||
HorizontalGridLinesBrush="#EEE"
|
||
RowHeight="45"
|
||
HeadersVisibility="Column">
|
||
|
||
<DataGrid.Columns>
|
||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="60"/>
|
||
|
||
<DataGridTextColumn Header="商品名称" Binding="{Binding Name}" Width="200"/>
|
||
|
||
<DataGridTemplateColumn Header="货品编号" Width="280">
|
||
<DataGridTemplateColumn.CellTemplate>
|
||
<DataTemplate>
|
||
<TextBlock Padding="5,0">
|
||
<TextBlock.Style>
|
||
<Style TargetType="TextBlock">
|
||
<Setter Property="Text" Value="{Binding ItemCode}"/>
|
||
<Setter Property="Foreground" Value="#1890FF"/>
|
||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||
<Style.Triggers>
|
||
<DataTrigger Binding="{Binding HasItemCode}" Value="False">
|
||
<Setter Property="Text" Value="(未设置)"/>
|
||
<Setter Property="Foreground" Value="#CCC"/>
|
||
<Setter Property="FontStyle" Value="Italic"/>
|
||
<Setter Property="FontWeight" Value="Normal"/>
|
||
</DataTrigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
</TextBlock.Style>
|
||
</TextBlock>
|
||
</DataTemplate>
|
||
</DataGridTemplateColumn.CellTemplate>
|
||
</DataGridTemplateColumn>
|
||
|
||
<DataGridTextColumn Header="条码" Binding="{Binding BarCode}" Width="120"/>
|
||
|
||
<DataGridTextColumn Header="外部编号" Binding="{Binding YyId}" Width="100"/>
|
||
|
||
<DataGridTextColumn Header="现价" Binding="{Binding MinPrice, StringFormat=¥{0:F2}}" Width="80"/>
|
||
|
||
<DataGridTextColumn Header="库存" Binding="{Binding Stores}" Width="60"/>
|
||
|
||
<DataGridTextColumn Header="单位" Binding="{Binding Unit}" Width="50"/>
|
||
|
||
<DataGridTemplateColumn Header="状态" Width="60">
|
||
<DataGridTemplateColumn.CellTemplate>
|
||
<DataTemplate>
|
||
<TextBlock Text="{Binding StatusText}" Padding="5,0">
|
||
<TextBlock.Style>
|
||
<Style TargetType="TextBlock">
|
||
<Style.Triggers>
|
||
<DataTrigger Binding="{Binding Status}" Value="0">
|
||
<Setter Property="Foreground" Value="#52C41A"/>
|
||
</DataTrigger>
|
||
<DataTrigger Binding="{Binding Status}" Value="1">
|
||
<Setter Property="Foreground" Value="#999"/>
|
||
</DataTrigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
</TextBlock.Style>
|
||
</TextBlock>
|
||
</DataTemplate>
|
||
</DataGridTemplateColumn.CellTemplate>
|
||
</DataGridTemplateColumn>
|
||
|
||
<DataGridTextColumn Header="同步时间"
|
||
Binding="{Binding SyncedAt, StringFormat=MM-dd HH:mm}"
|
||
Width="100"/>
|
||
</DataGrid.Columns>
|
||
</DataGrid>
|
||
|
||
<!-- 编辑货品编号面板 -->
|
||
<Border Grid.Row="3" Background="#F0F5FF" CornerRadius="4" Padding="15" Margin="0,10,0,0"
|
||
Visibility="{Binding IsEditing, Converter={StaticResource BoolToVisibility}}">
|
||
<StackPanel>
|
||
<TextBlock Text="编辑货品编号" FontWeight="Bold" Margin="0,0,0,10"/>
|
||
<StackPanel Orientation="Horizontal">
|
||
<TextBlock Text="产品:" VerticalAlignment="Center" Width="50"/>
|
||
<TextBlock Text="{Binding SelectedProduct.Name}" VerticalAlignment="Center"
|
||
FontWeight="SemiBold" Foreground="#1890FF"/>
|
||
</StackPanel>
|
||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||
<TextBlock Text="货品编号:" VerticalAlignment="Center" Width="70"/>
|
||
<TextBox Text="{Binding EditingItemCode, UpdateSourceTrigger=PropertyChanged}"
|
||
Width="400" Height="30" Padding="5" VerticalContentAlignment="Center"/>
|
||
<Button Content="保存" Command="{Binding SaveItemCodeCommand}"
|
||
Width="70" Height="30" Margin="10,0,0,0"
|
||
Background="#52C41A" Foreground="White" BorderThickness="0"/>
|
||
<Button Content="取消" Command="{Binding CancelEditItemCodeCommand}"
|
||
Width="70" Height="30" Margin="5,0,0,0"/>
|
||
</StackPanel>
|
||
<TextBlock Text="格式示例:1222003x12+13222003x24+1322003x12+0000000x12"
|
||
FontSize="11" Foreground="#999" Margin="70,5,0,0"/>
|
||
</StackPanel>
|
||
</Border>
|
||
|
||
<!-- 加载遮罩 -->
|
||
<Border Grid.Row="2" Background="#80FFFFFF"
|
||
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}">
|
||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||
<TextBlock Text="..." FontSize="30" HorizontalAlignment="Center"/>
|
||
<TextBlock Text="{Binding StatusMessage}" FontSize="14" Margin="0,10,0,0"/>
|
||
</StackPanel>
|
||
</Border>
|
||
</Grid>
|
||
</UserControl>
|