将 SOP 导出按钮移至配方名后

This commit is contained in:
wanglei 2026-11-28 20:14:12 +08:00
parent e8a0e0f769
commit b9c0702fb0
2 changed files with 12 additions and 7 deletions

View File

@ -96,11 +96,14 @@
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Classes="Title" />
<TextBlock Text="配方名" Margin="16,0,8,0" Classes="Field" />
<TextBox Width="220" IsEnabled="{Binding Recipe.CanEditFileName}" Text="{Binding Recipe.Name, Mode=TwoWay}" ToolTip.Tip="文件名和目录名自动使用配方名;已有配方名称固定" />
<TextBlock Text="{Binding Title}" Classes="Title" />
<TextBlock Text="配方名" Margin="16,0,8,0" Classes="Field" />
<TextBox x:Name="RecipeNameInput" Width="220" IsEnabled="{Binding Recipe.CanEditFileName}" Text="{Binding Recipe.Name, Mode=TwoWay}" ToolTip.Tip="文件名和目录名自动使用配方名;已有配方名称固定" />
<!-- SOP 导出作用于整个配方,放在配方名后以便各页签共用。 -->
<Button Content="导出SOP文件" Margin="8,0,0,0" VerticalAlignment="Center" IsEnabled="{Binding CanTransferSteps}" Click="ExportSopFile" ToolTip.Tip="将步骤和关键帧导出为 Excel 文件" />
</StackPanel>
<TextBlock Text="{Binding NameValidationMessage}" Foreground="#F0533C" TextWrapping="Wrap" Margin="0,6,0,0" />
<TextBlock Text="{Binding StepTransferStatus}" IsVisible="{Binding StepTransferStatus, Converter={x:Static conv:StringConverters.IsNotNullOrEmpty}}" TextWrapping="Wrap" Foreground="{StaticResource FgDim}" FontSize="12" />
</StackPanel>
<TabControl Grid.Row="1">
<TabItem Header="步骤">
@ -116,10 +119,7 @@
<WrapPanel Orientation="Horizontal" IsEnabled="{Binding CanTransferSteps}">
<Button Content="导入步骤" Click="ImportStepsFile" ToolTip.Tip="从步骤文件或完整配方导入,可选择追加或替换" />
<Button Content="导出步骤" Click="ExportStepsFile" ToolTip.Tip="导出全部步骤及关联区域,保留触发、AI判定与复检设置" />
<!-- 供现场查阅的 Excel 文件包含步骤文字和已保存的关键帧。 -->
<Button Content="导出SOP文件" Click="ExportSopFile" ToolTip.Tip="将步骤和关键帧导出为 Excel 文件" />
</WrapPanel>
<TextBlock Text="{Binding StepTransferStatus}" TextWrapping="Wrap" Foreground="{StaticResource FgDim}" FontSize="12" />
</StackPanel>
<!-- 增加按钮两侧留白,便于点击。 -->
<Button DockPanel.Dock="Bottom" Content="加步骤" Margin="0,8,0,0" Padding="12,6" Command="{Binding Recipe.AddStepCommand}" />

View File

@ -60,12 +60,17 @@ internal static class StepTransferChecks
Check(model.Recipe.Steps.Count == 2 && model.Recipe.SelectedStep is not null && model.StepTransferStatus.Contains("保存"), "导入更新编辑列表和选中项,明确需保存");
var rendered = new RecipeEditor { DataContext = model };
var window = new Window { Content = rendered, Width = 1040, Height = 900 }; window.Show(); window.UpdateLayout();
// 在切换到步骤页签之前核对顶部入口,并确认它紧跟配方名输入框。
var nameInput = rendered.FindControl<TextBox>("RecipeNameInput")!;
var header = (StackPanel)nameInput.Parent!;
var exportButton = rendered.GetVisualDescendants().OfType<Button>().Single(button => button.Content?.ToString() == "导出SOP文件");
Check(ReferenceEquals(header.Children[header.Children.IndexOf(nameInput) + 1], exportButton), "SOP 导出入口紧跟顶部配方名");
var tabs = rendered.GetVisualDescendants().OfType<TabControl>().Single();
tabs.SelectedItem = tabs.Items.OfType<TabItem>().Single(t => t.Header?.ToString() == "步骤"); window.UpdateLayout();
var toolbar = rendered.GetVisualDescendants().OfType<WrapPanel>().Single(panel =>
panel.Children.OfType<Button>().Any(button => button.Content?.ToString() == "导出步骤"));
Check(toolbar.Children.OfType<Button>().Select(button => button.Content?.ToString())
.SequenceEqual(new[] { "导入步骤", "导出步骤", "导出SOP文件" }), "SOP 导出入口紧跟步骤导出");
.SequenceEqual(new[] { "导入步骤", "导出步骤" }), "步骤工具栏保留步骤导入和导出");
CheckSopExcel(root);
var edited = model.Recipe.ToConfig();
var exported = SopStepTransfer.Read(model.ExportStepsText());