新增业务打印绑定功能,整合打印模板与业务数据的映射配置,优化打印数据生成逻辑。新增免密接口,支持桌面端打印模板的查询与列表展示,提升用户体验和系统的实时数据同步能力。同时,重构相关控制器以增强系统的可维护性和扩展性。
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:ctrls="clr-namespace:YY.Admin.Controls"
|
||||
xmlns:core="clr-namespace:YY.Admin.Core.Entity;assembly=YY.Admin.Core"
|
||||
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
mc:Ignorable="d">
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
<Grid Style="{StaticResource BaseViewStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -73,7 +75,30 @@
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="MainSplitRoot">
|
||||
<!-- 打印机:PrintDot 桥接器,与「打印模板」页一致 -->
|
||||
<Border Grid.Row="1" Margin="24,0,24,8" Padding="0,4,0,4" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,0,1">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="打印机:" VerticalAlignment="Center" FontSize="13" Foreground="#333333" Margin="0,0,8,0"/>
|
||||
<ComboBox ItemsSource="{Binding Printers}"
|
||||
SelectedItem="{Binding SelectedPrinter}"
|
||||
DisplayMemberPath="Name"
|
||||
MinWidth="220" Height="30"
|
||||
VerticalContentAlignment="Center"
|
||||
hc:InfoElement.Placeholder="请选择打印机"/>
|
||||
<Button Command="{Binding RefreshPrintersCommand}"
|
||||
Height="30" Padding="10,0" Margin="10,0,0,0"
|
||||
FontSize="12"
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
Content="刷新打印机"/>
|
||||
<TextBlock Text="{Binding PrinterStatus}"
|
||||
Margin="12,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="2" x:Name="MainSplitRoot">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="320"/>
|
||||
<ColumnDefinition x:Name="SplitterCol" Width="4"/>
|
||||
@@ -893,7 +918,13 @@
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="1,0,0,0"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" MinHeight="120"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel Grid.Row="0" LastChildFill="True">
|
||||
|
||||
<!-- ===== 标题 + 日期筛选 ===== -->
|
||||
<Border DockPanel.Dock="Top" BorderBrush="{DynamicResource BorderBrush}"
|
||||
@@ -998,12 +1029,100 @@
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</DockPanel>
|
||||
</DockPanel>
|
||||
|
||||
<!-- ===== 下方:入场标签实时打印预览(可折叠,仅画布无 JSON) ===== -->
|
||||
<StackPanel Grid.Row="1" Margin="0,4,0,0" VerticalAlignment="Bottom">
|
||||
<Border BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="6,6,0,0"
|
||||
Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Padding="10,8">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="入场标签打印预览"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="12"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding PrintPreviewStatus}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
FontSize="10"
|
||||
Opacity="0.72"
|
||||
Margin="8,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||
<ToggleButton Grid.Column="2"
|
||||
IsChecked="{Binding IsPrintPreviewExpanded, Mode=TwoWay}"
|
||||
MinWidth="56"
|
||||
Height="24"
|
||||
Background="Transparent"
|
||||
BorderThickness="1"
|
||||
Padding="8,0"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Cursor="Hand"
|
||||
VerticalAlignment="Center">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="2"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<TextBlock FontSize="12"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Text" Value="展开"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=ToggleButton}}" Value="True">
|
||||
<Setter Property="Text" Value="折叠"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</ToggleButton>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="1,0,1,1"
|
||||
CornerRadius="0,0,2,2"
|
||||
Padding="0"
|
||||
MinHeight="200"
|
||||
MaxHeight="420"
|
||||
Background="#525659"
|
||||
Visibility="{Binding IsPrintPreviewExpanded, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<wv2:WebView2 x:Name="PrintPreviewWebView"
|
||||
DefaultBackgroundColor="#FF525659"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,12,0,20">
|
||||
<Button Content="保存" Command="{Binding SaveCommand}" Style="{StaticResource ButtonPrimary}" Width="100" Margin="0,0,15,0"/>
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,12,0,20">
|
||||
<Button Content="保存并打印入场记录"
|
||||
Command="{Binding SaveAndPrintCommand}"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
IsEnabled="{Binding IsNotActionBusy}"
|
||||
Width="168" Margin="0,0,15,0"
|
||||
ToolTip="保存成功后直接发送到已选打印机(不弹预览窗口)"/>
|
||||
<Button Content="保存"
|
||||
Command="{Binding SaveCommand}"
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
IsEnabled="{Binding IsNotActionBusy}"
|
||||
Width="100" Margin="0,0,15,0"/>
|
||||
<Button Content="生成原材料卡片"
|
||||
Command="{Binding GenerateRawMaterialCardsCommand}"
|
||||
Style="{StaticResource ButtonDefault}"
|
||||
@@ -1011,5 +1130,29 @@
|
||||
IsEnabled="{Binding CanGenerateCards}"
|
||||
ToolTip="根据拆码明细生成原材料卡片(需先保存入场记录)"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 底部动作按钮忙碌遮罩:保存/保存并打印/生成时显示,禁止重复点击 -->
|
||||
<Border Grid.RowSpan="4"
|
||||
Panel.ZIndex="999"
|
||||
Background="#66000000"
|
||||
Visibility="{Binding IsActionBusy, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<Border Width="220"
|
||||
Height="120"
|
||||
CornerRadius="8"
|
||||
Background="#F2FFFFFF"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Padding="16">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<hc:LoadingCircle Width="42" Height="42"/>
|
||||
<TextBlock Text="{Binding ActionBusyText}"
|
||||
Margin="0,14,0,0"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -26,6 +26,8 @@ public partial class RawMaterialEntryOperationView : UserControl
|
||||
{
|
||||
_vm = vm;
|
||||
vm.PropertyChanged += OnVmPropertyChanged;
|
||||
vm.PrintPreviewHtmlReady += OnPrintPreviewHtmlReady;
|
||||
vm.StartPrintPreviewTimer();
|
||||
}
|
||||
|
||||
ApplySplitLayout();
|
||||
@@ -36,6 +38,8 @@ public partial class RawMaterialEntryOperationView : UserControl
|
||||
if (_vm != null)
|
||||
{
|
||||
_vm.PropertyChanged -= OnVmPropertyChanged;
|
||||
_vm.PrintPreviewHtmlReady -= OnPrintPreviewHtmlReady;
|
||||
_vm.StopPrintPreviewTimer();
|
||||
_vm = null;
|
||||
}
|
||||
}
|
||||
@@ -78,6 +82,21 @@ public partial class RawMaterialEntryOperationView : UserControl
|
||||
{
|
||||
_vm = vm;
|
||||
vm.PropertyChanged += OnVmPropertyChanged;
|
||||
vm.PrintPreviewHtmlReady += OnPrintPreviewHtmlReady;
|
||||
vm.StartPrintPreviewTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnPrintPreviewHtmlReady(object? sender, string html)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PrintPreviewWebView.EnsureCoreWebView2Async();
|
||||
PrintPreviewWebView.NavigateToString(html ?? string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
/* WebView2 未就绪或宿主已释放时忽略 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user