change - 界面修改、日志信息导出

master
wenjy 1 month ago
parent faa58cbcf3
commit 04c8000b42

@ -1,5 +1,6 @@
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using MiniExcelLibs.Attributes;
using SqlSugar; using SqlSugar;
namespace SlnMesnac.Model.domain namespace SlnMesnac.Model.domain
@ -48,22 +49,28 @@ namespace SlnMesnac.Model.domain
this.CreateTime = DateTime.Now; this.CreateTime = DateTime.Now;
} }
[ExcelColumnName("标识"), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; } public int Id { get; set; }
[ExcelColumnName("记录时间"), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "createtime")] [SugarColumn(ColumnName = "createtime")]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
[ExcelColumnName("日志类型"), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "log_type")] [SugarColumn(ColumnName = "log_type")]
public string LogType { get; set; } public string LogType { get; set; }
[ExcelColumnName("日志级别"), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "log_level")] [SugarColumn(ColumnName = "log_level")]
public string LogLevel { get; set; } public string LogLevel { get; set; }
[ExcelColumnName("日志内容"), ExcelColumnWidth(60)]
[SugarColumn(ColumnName = "content")] [SugarColumn(ColumnName = "content")]
public string Content { get; set; } public string Content { get; set; }
[ExcelColumnName("异常信息"), ExcelColumnWidth(50)]
[SugarColumn(ColumnName = "err_msg")] [SugarColumn(ColumnName = "err_msg")]
public string ErrMsg { get; set; } public string ErrMsg { get; set; }

@ -38,12 +38,12 @@
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent" <DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="18" ColumnHeaderHeight="35" FontSize="18" ColumnHeaderHeight="35"
RowHeight="40" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="40" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" > Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" >
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>

@ -46,9 +46,8 @@
<RowDefinition Height="3*"/> <RowDefinition Height="3*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码总数" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/> <TextBlock Grid.Row="0" Text="条码总数" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,20,0,0">
<TextBlock Text="{Binding TagAmount}" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="{Binding TagAmount}" FontSize="24" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="个" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>
@ -63,7 +62,7 @@
<RowDefinition Height="3*"/> <RowDefinition Height="3*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码信息" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/> <TextBlock Grid.Row="0" Text="条码信息" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="200" Height="70" Margin="10" VerticalContentAlignment="Center" HorizontalAlignment="Center"> <!--<TextBox Text="{Binding TagCode}" FontSize="24" Foreground="Black" Grid.Row="1" Width="200" Height="70" Margin="10" VerticalContentAlignment="Top" HorizontalAlignment="Center" IsReadOnly="True">
<TextBox.Template> <TextBox.Template>
<ControlTemplate TargetType="TextBox"> <ControlTemplate TargetType="TextBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="10"> <Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="10">
@ -71,7 +70,10 @@
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</TextBox.Template> </TextBox.Template>
</TextBox> </TextBox>-->
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,20,0,0">
<TextBlock Text="{Binding TagCode}" FontSize="24" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</Grid> </Grid>
</Border> </Border>

@ -12,9 +12,10 @@
<RowDefinition Height="14*"/> <RowDefinition Height="14*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10"> <Border Grid.Row="0" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock Text="日志类型" FontSize="18" Foreground="#31446E" Margin="10,3"/> <TextBlock Text="日志类型" FontSize="18" Foreground="#31446E" Margin="10,3,5,3"/>
<ComboBox SelectedItem="{Binding LogType}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5"> <ComboBox SelectedItem="{Binding LogType}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<ComboBoxItem>包裹数据</ComboBoxItem> <ComboBoxItem>包裹数据</ComboBoxItem>
<ComboBoxItem>设备监控</ComboBoxItem> <ComboBoxItem>设备监控</ComboBoxItem>
@ -22,7 +23,7 @@
<ComboBoxItem IsSelected="True">所有</ComboBoxItem> <ComboBoxItem IsSelected="True">所有</ComboBoxItem>
</ComboBox> </ComboBox>
<TextBlock Text="日志级别" FontSize="18" Foreground="#31446E" Margin="10,3"/> <TextBlock Text="日志级别" FontSize="18" Foreground="#31446E" Margin="5,3"/>
<ComboBox SelectedItem="{Binding LogLevel}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5"> <ComboBox SelectedItem="{Binding LogLevel}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<ComboBoxItem>Info</ComboBoxItem> <ComboBoxItem>Info</ComboBoxItem>
<ComboBoxItem>Warn</ComboBoxItem> <ComboBoxItem>Warn</ComboBoxItem>
@ -30,7 +31,7 @@
<ComboBoxItem IsSelected="True">所有</ComboBoxItem> <ComboBoxItem IsSelected="True">所有</ComboBoxItem>
</ComboBox> </ComboBox>
<TextBlock Text="日志时间" FontSize="18" Foreground="#31446E" Margin="20,3,10,0"/> <TextBlock Text="日志时间" FontSize="18" Foreground="#31446E" Margin="5,3,5,0"/>
<DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/> <DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
<TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/> <TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/> <DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
@ -44,29 +45,29 @@
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent" <DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="18" ColumnHeaderHeight="35" FontSize="18" ColumnHeaderHeight="35"
RowHeight="150" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="150" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center" ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" > Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" >
<!--resourceStyle 399行修改选中字体颜色--> <!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id}" Header="序号" Width="1*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Id}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding LogType}" Header="日志类型" Width="1*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding LogType}" Header="日志类型" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding LogLevel}" Header="日志级别" Width="1*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding LogLevel}" Header="日志级别" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Content}" Header="日志内容" Width="3*" IsReadOnly="True"> <DataGridTextColumn Binding="{Binding Content}" Header="日志内容" Width="4*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="TextWrapping" Value="Wrap"/>
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Binding="{Binding ErrMsg}" Header="异常日志" Width="3*" IsReadOnly="True"> <DataGridTextColumn Binding="{Binding ErrMsg}" Header="异常日志" Width="4*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="TextWrapping" Value="Wrap"/>
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Border> </Border>

@ -96,7 +96,7 @@ namespace SlnMesnac.WPF.ViewModel
SaveFileDialog saveFileDialog = new SaveFileDialog(); SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel文件 (*.xlsx)|*.xlsx|所有文件 (*.*)|*.*"; saveFileDialog.Filter = "Excel文件 (*.xlsx)|*.xlsx|所有文件 (*.*)|*.*";
saveFileDialog.Title = "保存文件"; saveFileDialog.Title = "保存文件";
saveFileDialog.FileName = $"扫描记录{DateTime.Now.Date:yyyy-MM-dd}.xlsx"; saveFileDialog.FileName = $"扫描记录{System.Guid.NewGuid().ToString()}.xlsx";
if (saveFileDialog.ShowDialog() == true) if (saveFileDialog.ShowDialog() == true)
{ {

@ -1,6 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Win32;
using MiniExcelLibs;
using SlnMesnac.Business; using SlnMesnac.Business;
using SlnMesnac.Model.domain; using SlnMesnac.Model.domain;
using System; using System;
@ -9,6 +11,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
@ -90,5 +93,32 @@ namespace SlnMesnac.WPF.ViewModel
ScanItems = new ObservableCollection<BaseLog>(info); ScanItems = new ObservableCollection<BaseLog>(info);
} }
[RelayCommand]
private void Export()
{
try
{
var info = _scanItems;
// 创建 SaveFileDialog 对象
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel文件 (*.xlsx)|*.xlsx|所有文件 (*.*)|*.*";
saveFileDialog.Title = "保存文件";
saveFileDialog.FileName = $"日志信息{System.Guid.NewGuid().ToString()}.xlsx";
if (saveFileDialog.ShowDialog() == true)
{
string filePath = saveFileDialog.FileName;
MiniExcel.SaveAs(filePath, info);
MessageBox.Show($"日志信息导出成功:{filePath}");
}
}
catch (Exception ex)
{
MessageBox.Show($"日志信息导出异常:{ex.Message}");
}
}
} }
} }

Loading…
Cancel
Save