059895d1c3
- Чтение СПРАВКИ из Excel (ClosedXML), поддержка нескольких файлов - Группировка по ТН ВЭД: схлопывание строк с суммированием кол-ва/веса/суммы - Автоназначение кодов деклараций по справочнику ТН ВЭД (87 пар) - Цветовая маркировка: зелёный/жёлтый/красный по уровню уверенности - Самообучение: ручной выбор кода сохраняется в tnved_codes.json - Формирование Лист3 с разворачиванием строк по рег. номерам (ключевая функция) - Экспорт Лист2 + Лист3 в Excel
237 lines
13 KiB
XML
237 lines
13 KiB
XML
<Window x:Class="DeclarationAutomatization.Views.MainWindow"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:local="clr-namespace:DeclarationAutomatization.Views"
|
|
xmlns:models="clr-namespace:DeclarationAutomatization.Models"
|
|
Title="Автоматизация деклараций" Height="780" Width="1200"
|
|
WindowStartupLocation="CenterScreen">
|
|
|
|
<Window.Resources>
|
|
<local:ConfidenceToColorConverter x:Key="ConfToColor"/>
|
|
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
|
|
|
|
<Style x:Key="HeaderStyle" TargetType="TextBlock">
|
|
<Setter Property="FontSize" Value="13"/>
|
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
|
<Setter Property="Margin" Value="0,0,0,6"/>
|
|
</Style>
|
|
|
|
<Style x:Key="SectionBorder" TargetType="Border">
|
|
<Setter Property="BorderBrush" Value="#DDDDDD"/>
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
<Setter Property="CornerRadius" Value="4"/>
|
|
<Setter Property="Padding" Value="12"/>
|
|
<Setter Property="Margin" Value="0,0,0,10"/>
|
|
<Setter Property="Background" Value="#FAFAFA"/>
|
|
</Style>
|
|
|
|
<Style x:Key="PrimaryButton" TargetType="Button">
|
|
<Setter Property="Padding" Value="16,8"/>
|
|
<Setter Property="Margin" Value="4,0"/>
|
|
<Setter Property="Background" Value="#0078D4"/>
|
|
<Setter Property="Foreground" Value="White"/>
|
|
<Setter Property="BorderThickness" Value="0"/>
|
|
<Setter Property="Cursor" Value="Hand"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="Button">
|
|
<Border Background="{TemplateBinding Background}"
|
|
CornerRadius="4" Padding="{TemplateBinding Padding}">
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
</Border>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter Property="Background" Value="#006CBE"/>
|
|
</Trigger>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter Property="Background" Value="#AAAAAA"/>
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style x:Key="SecondaryButton" TargetType="Button" BasedOn="{StaticResource PrimaryButton}">
|
|
<Setter Property="Background" Value="#6B7280"/>
|
|
</Style>
|
|
</Window.Resources>
|
|
|
|
<Grid Margin="16">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- Заголовок -->
|
|
<TextBlock Grid.Row="0" Text="Автоматизация оформления деклараций"
|
|
FontSize="18" FontWeight="Bold" Margin="0,0,0,16"
|
|
Foreground="#1F2937"/>
|
|
|
|
<!-- Шаг 1: Загрузка файлов -->
|
|
<Border Grid.Row="1" Style="{StaticResource SectionBorder}">
|
|
<StackPanel>
|
|
<TextBlock Style="{StaticResource HeaderStyle}" Text="1. Файлы СПРАВКИ"/>
|
|
|
|
<DataGrid ItemsSource="{Binding SpravkaFiles}"
|
|
AutoGenerateColumns="False" CanUserAddRows="False"
|
|
Height="120" Margin="0,0,0,8"
|
|
GridLinesVisibility="Horizontal"
|
|
HeadersVisibility="Column">
|
|
<DataGrid.Columns>
|
|
<DataGridTextColumn Header="Файл" Binding="{Binding FileName}"
|
|
IsReadOnly="True" Width="*"/>
|
|
<DataGridTextColumn Header="Начальный п/п"
|
|
Binding="{Binding StartingNumber, UpdateSourceTrigger=PropertyChanged}"
|
|
Width="130"/>
|
|
<DataGridTemplateColumn Header="" Width="60">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Button Content="✕" Width="28" Height="24"
|
|
Command="{Binding DataContext.RemoveSpravkaFileCommand,
|
|
RelativeSource={RelativeSource AncestorType=Window}}"
|
|
CommandParameter="{Binding}"
|
|
Background="#EF4444" Foreground="White"
|
|
BorderThickness="0" Cursor="Hand"/>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
</DataGrid.Columns>
|
|
</DataGrid>
|
|
|
|
<Button Content="+ Добавить файл СПРАВКИ"
|
|
Command="{Binding AddSpravkaFileCommand}"
|
|
Style="{StaticResource SecondaryButton}"
|
|
HorizontalAlignment="Left"/>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- Шаг 2: Кнопки действий -->
|
|
<Border Grid.Row="2" Style="{StaticResource SectionBorder}">
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Style="{StaticResource HeaderStyle}" Text="2. Действия:"
|
|
VerticalAlignment="Center" Margin="0,0,16,0"/>
|
|
<Button Content="▶ Обработать"
|
|
Command="{Binding ProcessCommand}"
|
|
Style="{StaticResource PrimaryButton}"/>
|
|
<Button Content="✅ Принять все авто"
|
|
Command="{Binding ApproveAllAutoCommand}"
|
|
Style="{StaticResource SecondaryButton}"
|
|
IsEnabled="{Binding HasResults}"/>
|
|
<Button Content="💾 Экспорт"
|
|
Command="{Binding ExportCommand}"
|
|
Style="{StaticResource PrimaryButton}"
|
|
IsEnabled="{Binding HasResults}"/>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- Таблица позиций -->
|
|
<Border Grid.Row="3" Style="{StaticResource SectionBorder}">
|
|
<DockPanel>
|
|
<!-- Статистика -->
|
|
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,8">
|
|
<TextBlock Style="{StaticResource HeaderStyle}" Text="3. Позиции декларации"/>
|
|
<Border Background="#C6EFCE" CornerRadius="3" Padding="8,2" Margin="12,0,4,0">
|
|
<TextBlock>
|
|
<Run Text="✅ Авто: "/>
|
|
<Run Text="{Binding AutoCount, Mode=OneWay}" FontWeight="Bold"/>
|
|
</TextBlock>
|
|
</Border>
|
|
<Border Background="#FFEB9C" CornerRadius="3" Padding="8,2" Margin="4,0">
|
|
<TextBlock>
|
|
<Run Text="⚠️ Проверить: "/>
|
|
<Run Text="{Binding ReviewCount, Mode=OneWay}" FontWeight="Bold"/>
|
|
</TextBlock>
|
|
</Border>
|
|
<Border Background="#FFC7CE" CornerRadius="3" Padding="8,2" Margin="4,0">
|
|
<TextBlock>
|
|
<Run Text="🔴 Не найдено: "/>
|
|
<Run Text="{Binding MissingCount, Mode=OneWay}" FontWeight="Bold"/>
|
|
</TextBlock>
|
|
</Border>
|
|
</StackPanel>
|
|
|
|
<DataGrid x:Name="ItemsGrid"
|
|
ItemsSource="{Binding DeclarationItems}"
|
|
AutoGenerateColumns="False"
|
|
CanUserAddRows="False"
|
|
SelectionMode="Single"
|
|
GridLinesVisibility="Horizontal"
|
|
RowBackground="White"
|
|
AlternatingRowBackground="#F9FAFB">
|
|
|
|
<DataGrid.RowStyle>
|
|
<Style TargetType="DataGridRow">
|
|
<Setter Property="Background"
|
|
Value="{Binding Confidence, Converter={StaticResource ConfToColor}}"/>
|
|
</Style>
|
|
</DataGrid.RowStyle>
|
|
|
|
<DataGrid.Columns>
|
|
<DataGridTextColumn Header="п/п"
|
|
Binding="{Binding SequentialNumber}"
|
|
IsReadOnly="True" Width="55"/>
|
|
<DataGridTextColumn Header="ТН ВЭД"
|
|
Binding="{Binding TnVed}"
|
|
IsReadOnly="True" Width="120"/>
|
|
<DataGridTextColumn Header="Наименование"
|
|
Binding="{Binding Description}"
|
|
IsReadOnly="True" Width="*"/>
|
|
<DataGridTextColumn Header="Страна"
|
|
Binding="{Binding CountryId}"
|
|
IsReadOnly="True" Width="60"/>
|
|
<DataGridTextColumn Header="Кол-во"
|
|
Binding="{Binding Quantity}"
|
|
IsReadOnly="True" Width="80"/>
|
|
<DataGridTextColumn Header="Сумма"
|
|
Binding="{Binding AmountWithVat, StringFormat=N2}"
|
|
IsReadOnly="True" Width="100"/>
|
|
<DataGridTextColumn Header="Брутто, кг"
|
|
Binding="{Binding GrossWeight, StringFormat=N3}"
|
|
IsReadOnly="True" Width="90"/>
|
|
<DataGridTextColumn Header="Нетто, кг"
|
|
Binding="{Binding NetWeight, StringFormat=N3}"
|
|
IsReadOnly="True" Width="90"/>
|
|
|
|
<!-- Редактируемая колонка кода — ComboBox при наличии кандидатов -->
|
|
<DataGridTemplateColumn Header="Код декларации" Width="130">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding DeclarationCode}"
|
|
Padding="4,2" VerticalAlignment="Center"/>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
<DataGridTemplateColumn.CellEditingTemplate>
|
|
<DataTemplate>
|
|
<ComboBox IsEditable="True"
|
|
Text="{Binding DeclarationCode, UpdateSourceTrigger=PropertyChanged}"
|
|
ItemsSource="{Binding CandidateCodes}"
|
|
VerticalAlignment="Center"/>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellEditingTemplate>
|
|
</DataGridTemplateColumn>
|
|
|
|
<DataGridTextColumn Header="Рег. номер"
|
|
Binding="{Binding RegNumber}"
|
|
IsReadOnly="True" Width="180"/>
|
|
</DataGrid.Columns>
|
|
</DataGrid>
|
|
</DockPanel>
|
|
</Border>
|
|
|
|
<!-- Строка статуса -->
|
|
<Border Grid.Row="4" Background="#F3F4F6" CornerRadius="4" Padding="12,6" Margin="0,4,0,0">
|
|
<Grid>
|
|
<TextBlock Text="{Binding StatusMessage}" VerticalAlignment="Center"
|
|
FontSize="12" Foreground="#374151"/>
|
|
<ProgressBar IsIndeterminate="True" Height="4"
|
|
VerticalAlignment="Bottom"
|
|
Visibility="{Binding IsProcessing, Converter={StaticResource BoolToVis}}"/>
|
|
</Grid>
|
|
</Border>
|
|
</Grid>
|
|
</Window>
|