新增打印模板管理功能,包含免密接口和实时通知机制,支持桌面端打印模板的查询和列表展示。更新相关控制器、服务和视图,优化用户体验并增强系统的实时数据同步能力。
This commit is contained in:
125
yy-admin-master/YY.Admin/Views/Print/PrintPreviewWindow.xaml
Normal file
125
yy-admin-master/YY.Admin/Views/Print/PrintPreviewWindow.xaml
Normal file
@@ -0,0 +1,125 @@
|
||||
<hc:Window x:Class="YY.Admin.Views.Print.PrintPreviewWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
Width="1200" Height="760"
|
||||
MinWidth="900" MinHeight="560"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="CanResize"
|
||||
Background="White"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="1"
|
||||
Title="打印预览">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 顶部工具栏 -->
|
||||
<Border Grid.Row="0"
|
||||
Background="#fafafa"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="0,0,0,1">
|
||||
<Grid Margin="16,0">
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock x:Name="TbTemplateName"
|
||||
FontSize="14" FontWeight="SemiBold"
|
||||
Foreground="#333333"/>
|
||||
<TextBlock x:Name="TbTemplateCode"
|
||||
FontSize="11" Foreground="#888888" Margin="0,1,0,0"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock x:Name="TbStatus"
|
||||
FontSize="12" Foreground="#888888"
|
||||
VerticalAlignment="Center" Margin="0,0,16,0"/>
|
||||
<Button Content="关闭" Click="CloseButton_Click"
|
||||
Width="72" Height="30" FontSize="13"
|
||||
Style="{StaticResource ButtonDefault}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="360"/>
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 左侧参数 JSON 区 -->
|
||||
<Border Grid.Column="0"
|
||||
BorderBrush="#f0f0f0"
|
||||
BorderThickness="0,0,1,0"
|
||||
Background="#fafafa"
|
||||
Padding="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="参数JSON"
|
||||
FontSize="13"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="#333333"/>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Orientation="Horizontal"
|
||||
Margin="0,8,0,8">
|
||||
<Button Content="根据画布生成"
|
||||
Click="GenerateMockJson_Click"
|
||||
Height="28"
|
||||
Padding="10,0"
|
||||
FontSize="12"
|
||||
Style="{StaticResource ButtonDefault}"/>
|
||||
<Button Content="重新渲染"
|
||||
Click="RenderByParamJson_Click"
|
||||
Margin="8,0,0,0"
|
||||
Height="28"
|
||||
Padding="10,0"
|
||||
FontSize="12"
|
||||
Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBox x:Name="TbParamJson"
|
||||
Grid.Row="2"
|
||||
AcceptsReturn="True"
|
||||
AcceptsTab="True"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
FontFamily="Consolas"
|
||||
FontSize="12"
|
||||
TextWrapping="NoWrap"
|
||||
BorderBrush="#d9d9d9"
|
||||
BorderThickness="1"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<GridSplitter Grid.Column="1"
|
||||
Width="8"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ResizeBehavior="PreviousAndNext"
|
||||
ShowsPreview="True"
|
||||
Background="#f0f0f0"
|
||||
Cursor="SizeWE"/>
|
||||
|
||||
<!-- 右侧 WebView2 预览区 -->
|
||||
<wv2:WebView2 Grid.Column="2" x:Name="WebView" DefaultBackgroundColor="Transparent"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
240
yy-admin-master/YY.Admin/Views/Print/PrintPreviewWindow.xaml.cs
Normal file
240
yy-admin-master/YY.Admin/Views/Print/PrintPreviewWindow.xaml.cs
Normal file
@@ -0,0 +1,240 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using YY.Admin.Core.Entity;
|
||||
using YY.Admin.Services.Service.Print;
|
||||
|
||||
namespace YY.Admin.Views.Print;
|
||||
|
||||
public partial class PrintPreviewWindow : HandyControl.Controls.Window
|
||||
{
|
||||
private readonly string _templateJson;
|
||||
|
||||
public PrintPreviewWindow(PrintTemplate template, string? templateJson)
|
||||
{
|
||||
InitializeComponent();
|
||||
_templateJson = templateJson ?? string.Empty;
|
||||
|
||||
TbTemplateName.Text = template.TemplateName ?? "(未命名)";
|
||||
TbTemplateCode.Text = $"编码:{template.TemplateCode} " +
|
||||
$"尺寸:{template.PaperWidthMm ?? 210}×{template.PaperHeightMm ?? 297} mm " +
|
||||
$"方向:{template.PaperOrientation ?? "纵向"}";
|
||||
|
||||
TbParamJson.Text = BuildMockParamJson(_templateJson);
|
||||
|
||||
Loaded += async (_, _) => await LoadPreviewAsync();
|
||||
}
|
||||
|
||||
private async Task LoadPreviewAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
TbStatus.Text = "加载中…";
|
||||
await WebView.EnsureCoreWebView2Async();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_templateJson) || _templateJson == "{}")
|
||||
{
|
||||
WebView.NavigateToString(BuildEmptyHtml());
|
||||
TbStatus.Text = "尚未设计模板内容";
|
||||
return;
|
||||
}
|
||||
|
||||
await RenderCurrentParamJsonAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TbStatus.Text = $"预览失败:{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildEmptyHtml() => """
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"/>
|
||||
<style>
|
||||
body { margin:0; background:#525659; display:flex;
|
||||
align-items:center; justify-content:center; height:100vh;
|
||||
font-family:"Microsoft YaHei",Arial,sans-serif; }
|
||||
.card { background:#fff; border-radius:8px; padding:48px 64px;
|
||||
text-align:center; box-shadow:0 6px 24px rgba(0,0,0,.4); }
|
||||
.icon { font-size:48px; color:#ccc; margin-bottom:16px; }
|
||||
.tip { font-size:15px; color:#888; }
|
||||
</style></head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<div class="icon">📄</div>
|
||||
<div class="tip">该模板尚未设计内容</div>
|
||||
</div>
|
||||
</body></html>
|
||||
""";
|
||||
|
||||
/// <summary>
|
||||
/// 左侧参数 JSON 重新渲染预览(与后端预览一致:用参数 JSON 驱动模板绑定字段)。
|
||||
/// </summary>
|
||||
private async Task RenderCurrentParamJsonAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
TbStatus.Text = "渲染中…";
|
||||
|
||||
JsonObject dataObj;
|
||||
var text = TbParamJson.Text?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
dataObj = new JsonObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
var node = JsonNode.Parse(text);
|
||||
if (node is not JsonObject obj)
|
||||
{
|
||||
WebView.NavigateToString(BuildErrorHtml("参数JSON必须是对象(JSON Object)"));
|
||||
TbStatus.Text = "参数JSON格式错误";
|
||||
return;
|
||||
}
|
||||
dataObj = obj;
|
||||
}
|
||||
|
||||
var html = NativePrintRenderService.RenderToHtml(_templateJson, dataObj);
|
||||
WebView.NavigateToString(html);
|
||||
TbStatus.Text = string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WebView.NavigateToString(BuildErrorHtml(ex.Message));
|
||||
TbStatus.Text = $"渲染失败:{ex.Message}";
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模板绑定字段生成参数 JSON(便于用户直接编辑并预览)。
|
||||
/// </summary>
|
||||
private static string BuildMockParamJson(string templateJson)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(templateJson) || templateJson == "{}")
|
||||
return "{}";
|
||||
|
||||
try
|
||||
{
|
||||
var root = JsonNode.Parse(templateJson);
|
||||
var obj = new JsonObject();
|
||||
var elements = root?["elements"]?.AsArray() ?? new JsonArray();
|
||||
var fields = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var el in elements.OfType<JsonObject>())
|
||||
{
|
||||
var type = (el["type"]?.ToString() ?? string.Empty).Trim();
|
||||
if (type is "table" or "detailTable")
|
||||
{
|
||||
var source = (el["source"]?.ToString() ?? "mainTable").Trim();
|
||||
if (!obj.ContainsKey(source))
|
||||
{
|
||||
var rows = new JsonArray();
|
||||
var columns = el["columns"]?.AsArray() ?? new JsonArray();
|
||||
for (var i = 1; i <= 8; i++)
|
||||
{
|
||||
var row = new JsonObject();
|
||||
foreach (var col in columns.OfType<JsonObject>())
|
||||
{
|
||||
var field = (col["bindField"]?.ToString() ?? col["field"]?.ToString() ?? string.Empty).Trim();
|
||||
if (string.IsNullOrWhiteSpace(field)) continue;
|
||||
var contentType = (col["contentType"]?.ToString() ?? "text").Trim().ToLowerInvariant();
|
||||
row[field] = contentType switch
|
||||
{
|
||||
"number" => i * 123.45,
|
||||
"amount" => i * 24567.89,
|
||||
"qrcode" => $"QR_{field}_{i}",
|
||||
"barcode" => $"BAR_{field}_{i}",
|
||||
"image" => $"https://picsum.photos/seed/{Uri.EscapeDataString(field + "_" + i)}/260/120",
|
||||
_ => $"{field}_示例值_{i}"
|
||||
};
|
||||
fields.Add(field);
|
||||
}
|
||||
rows.Add(row);
|
||||
}
|
||||
obj[source] = rows;
|
||||
}
|
||||
}
|
||||
|
||||
var bind = (el["bindField"]?.ToString() ?? string.Empty).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(bind))
|
||||
fields.Add(bind);
|
||||
|
||||
// 提取 text 中的 {{field}} 占位符(支持内嵌)
|
||||
var text = el["text"]?.ToString() ?? string.Empty;
|
||||
foreach (Match m in Regex.Matches(text, @"\{\{\s*([\w\.]+)\s*\}\}"))
|
||||
{
|
||||
var key = m.Groups[1].Value.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(key))
|
||||
fields.Add(key);
|
||||
}
|
||||
|
||||
CollectBindFields(el["cells"], fields);
|
||||
}
|
||||
|
||||
foreach (var f in fields.OrderBy(x => x, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
if (f.Equals("pageNo", StringComparison.OrdinalIgnoreCase) || f.Equals("totalPages", StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
if (!obj.ContainsKey(f))
|
||||
obj[f] = $"{f}_示例值";
|
||||
}
|
||||
|
||||
return obj.ToJsonString(new JsonSerializerOptions { WriteIndented = true });
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
|
||||
private static void CollectBindFields(JsonNode? node, ISet<string> fields)
|
||||
{
|
||||
if (node == null) return;
|
||||
if (node is JsonObject o)
|
||||
{
|
||||
if (o.TryGetPropertyValue("bindField", out var bindNode))
|
||||
{
|
||||
var bind = bindNode?.ToString()?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(bind))
|
||||
fields.Add(bind);
|
||||
}
|
||||
foreach (var kv in o)
|
||||
CollectBindFields(kv.Value, fields);
|
||||
return;
|
||||
}
|
||||
if (node is JsonArray arr)
|
||||
{
|
||||
foreach (var it in arr)
|
||||
CollectBindFields(it, fields);
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildErrorHtml(string message)
|
||||
{
|
||||
var esc = message.Replace("&", "&").Replace("<", "<").Replace(">", ">");
|
||||
return "<html><head><meta charset=\"utf-8\"/><style>"
|
||||
+ "body{margin:0;background:#525659;display:flex;align-items:center;"
|
||||
+ "justify-content:center;height:100vh;font-family:'Microsoft YaHei',Arial,sans-serif;}"
|
||||
+ ".card{background:#fff;border-radius:8px;padding:32px 48px;text-align:center;"
|
||||
+ "box-shadow:0 6px 24px rgba(0,0,0,.4);max-width:560px;}"
|
||||
+ "</style></head><body><div class=\"card\">"
|
||||
+ "<div style=\"font-size:40px;margin-bottom:12px\">⚠️</div>"
|
||||
+ "<div style=\"font-size:13px;color:#e74c3c;word-break:break-all;\">渲染失败:" + esc + "</div>"
|
||||
+ "</div></body></html>";
|
||||
}
|
||||
|
||||
private async void RenderByParamJson_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await RenderCurrentParamJsonAsync();
|
||||
}
|
||||
|
||||
private async void GenerateMockJson_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TbParamJson.Text = BuildMockParamJson(_templateJson);
|
||||
await RenderCurrentParamJsonAsync();
|
||||
}
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
96
yy-admin-master/YY.Admin/Views/Print/PrintSettingsView.xaml
Normal file
96
yy-admin-master/YY.Admin/Views/Print/PrintSettingsView.xaml
Normal file
@@ -0,0 +1,96 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Print.PrintSettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Margin="24" MaxWidth="680">
|
||||
|
||||
<!-- 标题 -->
|
||||
<TextBlock Text="打印设置" FontSize="18" FontWeight="Bold" Margin="0,0,0,20"/>
|
||||
|
||||
<!-- PrintDot 连接配置 -->
|
||||
<Border BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" CornerRadius="4" Padding="16" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="PrintDot 桥接器连接" FontSize="14" FontWeight="SemiBold" Margin="0,0,0,12"/>
|
||||
|
||||
<Grid Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="WebSocket 地址" VerticalAlignment="Center" FontSize="13"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding WsUrl, UpdateSourceTrigger=PropertyChanged}"
|
||||
hc:InfoElement.Placeholder="ws://192.168.x.x:1122/ws"
|
||||
FontSize="13" Padding="6,4"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="格式:ws://<IP>:1122/ws,支持局域网任意 IP" FontSize="11"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}" Margin="120,0,0,12"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
||||
<Button Content="测试连接并获取打印机" Command="{Binding TestConnectionCommand}"
|
||||
Style="{StaticResource ButtonPrimary}" Padding="12,6" FontSize="13" Margin="0,0,8,0"/>
|
||||
<Button Content="保存设置" Command="{Binding SaveCommand}"
|
||||
Style="{StaticResource ButtonDefault}" Padding="12,6" FontSize="13"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 状态提示 -->
|
||||
<TextBlock Text="{Binding StatusMessage}" FontSize="12" Foreground="{DynamicResource InfoBrush}"
|
||||
Visibility="{Binding StatusMessage, Converter={StaticResource String2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 打印机列表 -->
|
||||
<Border BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" CornerRadius="4" Padding="16" Margin="0,0,0,16">
|
||||
<StackPanel>
|
||||
<TextBlock Text="可用打印机" FontSize="14" FontWeight="SemiBold" Margin="0,0,0,12"/>
|
||||
|
||||
<ListBox ItemsSource="{Binding Printers}" SelectedItem="{Binding SelectedPrinter}"
|
||||
MaxHeight="180" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="4,2">
|
||||
<TextBlock Text="{Binding Name}" FontSize="13"/>
|
||||
<TextBlock Text=" (默认)" FontSize="11" Foreground="{DynamicResource InfoBrush}"
|
||||
Visibility="{Binding IsDefault, Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<TextBlock Margin="0,8,0,0" FontSize="12" Foreground="{DynamicResource SecondaryTextBrush}">
|
||||
已选打印机:<Run Text="{Binding SelectedPrinter.Name, FallbackValue='(未选择)'}"/>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 打印模板列表 -->
|
||||
<Border BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" CornerRadius="4" Padding="16">
|
||||
<StackPanel>
|
||||
<DockPanel Margin="0,0,0,12">
|
||||
<Button DockPanel.Dock="Right" Content="刷新模板" Command="{Binding RefreshTemplatesCommand}"
|
||||
Style="{StaticResource ButtonDefault}" Padding="10,4" FontSize="12"/>
|
||||
<TextBlock Text="打印模板" FontSize="14" FontWeight="SemiBold" VerticalAlignment="Center"/>
|
||||
</DockPanel>
|
||||
|
||||
<DataGrid ItemsSource="{Binding Templates}" AutoGenerateColumns="False"
|
||||
IsReadOnly="True" MaxHeight="240" GridLinesVisibility="Horizontal"
|
||||
HeadersVisibility="Column" FontSize="12">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="模板编码" Binding="{Binding TemplateCode}" Width="160"/>
|
||||
<DataGridTextColumn Header="模板名称" Binding="{Binding TemplateName}" Width="*"/>
|
||||
<DataGridTextColumn Header="分类" Binding="{Binding Category}" Width="80"/>
|
||||
<DataGridTextColumn Header="纸宽(mm)" Binding="{Binding PaperWidthMm}" Width="70"/>
|
||||
<DataGridTextColumn Header="纸高(mm)" Binding="{Binding PaperHeightMm}" Width="70"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 忙碌指示 -->
|
||||
<hc:LoadingCircle Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityConverter}}"
|
||||
HorizontalAlignment="Center" Margin="0,16,0,0"/>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views.Print;
|
||||
|
||||
public partial class PrintSettingsView : UserControl
|
||||
{
|
||||
public PrintSettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
125
yy-admin-master/YY.Admin/Views/Print/PrintTemplateListView.xaml
Normal file
125
yy-admin-master/YY.Admin/Views/Print/PrintTemplateListView.xaml
Normal file
@@ -0,0 +1,125 @@
|
||||
<UserControl x:Class="YY.Admin.Views.Print.PrintTemplateListView"
|
||||
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:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
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 FilterCode, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0 0 10 10"
|
||||
hc:InfoElement.Title="模板编码"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.Placeholder="请输入模板编码"
|
||||
hc:InfoElement.ShowClearButton="True"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox Text="{Binding FilterName, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0 0 10 10"
|
||||
hc:InfoElement.Title="模板名称"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.Placeholder="请输入模板名称"
|
||||
hc:InfoElement.ShowClearButton="True"/>
|
||||
</hc:Col>
|
||||
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||
<hc:TextBox Text="{Binding FilterCategory, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0 0 10 10"
|
||||
hc:InfoElement.Title="分类"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
hc:InfoElement.TitleWidth="65"
|
||||
hc:InfoElement.Placeholder="请输入分类"
|
||||
hc:InfoElement.ShowClearButton="True"/>
|
||||
</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}" Command="{Binding ResetCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<md:PackIcon Kind="Refresh"/>
|
||||
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<DataGrid Grid.Row="2"
|
||||
ItemsSource="{Binding Templates}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow"
|
||||
RowHeaderWidth="55"
|
||||
GridLinesVisibility="Horizontal"
|
||||
HorizontalGridLinesBrush="#FFEDEDED"
|
||||
VerticalGridLinesBrush="Transparent"
|
||||
HeadersVisibility="All"
|
||||
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||
Style="{StaticResource CusDataGridStyle}"
|
||||
hc:DataGridAttach.ShowSelectAllButton="True"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto">
|
||||
<DataGrid.RowHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowHeaderTemplate>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="模板编码" Binding="{Binding TemplateCode}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="160"/>
|
||||
<DataGridTextColumn Header="模板名称" Binding="{Binding TemplateName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="*"/>
|
||||
<DataGridTextColumn Header="分类" Binding="{Binding Category}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="100"/>
|
||||
<DataGridTextColumn Header="纸宽(mm)" Binding="{Binding PaperWidthMm}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="90"/>
|
||||
<DataGridTextColumn Header="纸高(mm)" Binding="{Binding PaperHeightMm}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="90"/>
|
||||
<DataGridTextColumn Header="方向" Binding="{Binding PaperOrientation}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="80"/>
|
||||
<DataGridTextColumn Header="备注" Binding="{Binding Remark}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="180"/>
|
||||
<DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="130"/>
|
||||
<DataGridTemplateColumn Header="操作" Width="72" CanUserSort="False" CanUserResize="False">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Content="预览"
|
||||
Command="{Binding DataContext.PreviewCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Padding="0" Height="26" FontSize="12"
|
||||
Margin="4,0"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<!-- 底部状态栏 -->
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
|
||||
<TextBlock Text="{Binding StatusMessage}"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace YY.Admin.Views.Print;
|
||||
|
||||
public partial class PrintTemplateListView : UserControl
|
||||
{
|
||||
public PrintTemplateListView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user