初始化
This commit is contained in:
@@ -116,7 +116,7 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Border Style="{StaticResource CardBorderStyle}">
|
<Border Style="{StaticResource CardBorderStyle}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Style="{StaticResource SectionTitleStyle}" Text="条款检索与采集策略" />
|
<TextBlock Style="{StaticResource SectionTitleStyle}" Text="项目检索与采集策略" />
|
||||||
<TextBlock Style="{StaticResource CaptionStyle}" Text="根据 YY 0948-2025 将项目区分为“实时监控”“实时显示+手动录入”和“手动录入”三类。" TextWrapping="Wrap" />
|
<TextBlock Style="{StaticResource CaptionStyle}" Text="根据 YY 0948-2025 将项目区分为“实时监控”“实时显示+手动录入”和“手动录入”三类。" TextWrapping="Wrap" />
|
||||||
<Grid Margin="0,10,0,0">
|
<Grid Margin="0,10,0,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ public partial class MainViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string itemSearchText = "";
|
private string itemSearchText = "";
|
||||||
|
|
||||||
|
private string activeFilter = "全部";
|
||||||
|
|
||||||
public MainViewModel(IStandardRepository repository, IModbusTelemetryService telemetryService)
|
public MainViewModel(IStandardRepository repository, IModbusTelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
_telemetryService = telemetryService;
|
_telemetryService = telemetryService;
|
||||||
@@ -109,7 +111,8 @@ public partial class MainViewModel : ObservableObject
|
|||||||
public ObservableCollection<TraceEvent> TraceEvents { get; }
|
public ObservableCollection<TraceEvent> TraceEvents { get; }
|
||||||
public ObservableCollection<AlarmMessage> AlarmMessages { get; }
|
public ObservableCollection<AlarmMessage> AlarmMessages { get; }
|
||||||
public ObservableCollection<string> ResultStatusOptions { get; }
|
public ObservableCollection<string> ResultStatusOptions { get; }
|
||||||
public IEnumerable<InspectionItem> FilteredItems => InspectionItems.Where(MatchesItemSearch);
|
public ObservableCollection<string> ItemFilterOptions { get; } = new(["全部", "待填写", "已完成", "实时监控", "手动填写"]);
|
||||||
|
public IEnumerable<InspectionItem> FilteredItems => InspectionItems.Where(MatchesActiveFilter).Where(MatchesItemSearch);
|
||||||
public bool HasFilteredItems => FilteredItems.Any();
|
public bool HasFilteredItems => FilteredItems.Any();
|
||||||
public IEnumerable<DeviceChannel> FlowSensorChannels => Channels.Where(IsFlowSensorChannel);
|
public IEnumerable<DeviceChannel> FlowSensorChannels => Channels.Where(IsFlowSensorChannel);
|
||||||
public IEnumerable<DeviceChannel> OtherChannels => Channels.Where(channel => !IsFlowSensorChannel(channel));
|
public IEnumerable<DeviceChannel> OtherChannels => Channels.Where(channel => !IsFlowSensorChannel(channel));
|
||||||
@@ -158,20 +161,18 @@ public partial class MainViewModel : ObservableObject
|
|||||||
partial void OnDetectionCompletedChanged(bool value) => OnPropertyChanged(nameof(ExportStateText));
|
partial void OnDetectionCompletedChanged(bool value) => OnPropertyChanged(nameof(ExportStateText));
|
||||||
partial void OnItemSearchTextChanged(string value)
|
partial void OnItemSearchTextChanged(string value)
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(FilteredItems));
|
RefreshFilteredItemsView();
|
||||||
OnPropertyChanged(nameof(FilteredItemSummary));
|
|
||||||
OnPropertyChanged(nameof(HasFilteredItems));
|
|
||||||
OnPropertyChanged(nameof(HasItemSearchText));
|
|
||||||
|
|
||||||
var filtered = FilteredItems.ToList();
|
|
||||||
if (filtered.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedItem is null || !filtered.Contains(SelectedItem))
|
public string ActiveFilter
|
||||||
{
|
{
|
||||||
SelectedItem = filtered[0];
|
get => activeFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (SetProperty(ref activeFilter, value))
|
||||||
|
{
|
||||||
|
RefreshFilteredItemsView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +306,7 @@ public partial class MainViewModel : ObservableObject
|
|||||||
});
|
});
|
||||||
|
|
||||||
RefreshComputedState();
|
RefreshComputedState();
|
||||||
|
RefreshFilteredItemsView();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -388,6 +390,7 @@ public partial class MainViewModel : ObservableObject
|
|||||||
|
|
||||||
RefreshTelemetryPanel();
|
RefreshTelemetryPanel();
|
||||||
RefreshComputedState();
|
RefreshComputedState();
|
||||||
|
RefreshFilteredItemsView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshTelemetryPanel()
|
private void RefreshTelemetryPanel()
|
||||||
@@ -430,6 +433,25 @@ public partial class MainViewModel : ObservableObject
|
|||||||
ComplianceRate = InspectionItems.Count == 0 ? 0 : QualifiedCount * 100d / InspectionItems.Count;
|
ComplianceRate = InspectionItems.Count == 0 ? 0 : QualifiedCount * 100d / InspectionItems.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshFilteredItemsView()
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(FilteredItems));
|
||||||
|
OnPropertyChanged(nameof(FilteredItemSummary));
|
||||||
|
OnPropertyChanged(nameof(HasFilteredItems));
|
||||||
|
OnPropertyChanged(nameof(HasItemSearchText));
|
||||||
|
|
||||||
|
var filtered = FilteredItems.ToList();
|
||||||
|
if (filtered.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SelectedItem is null || !filtered.Contains(SelectedItem))
|
||||||
|
{
|
||||||
|
SelectedItem = filtered[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadSelectedItemDraft(InspectionItem item)
|
private void LoadSelectedItemDraft(InspectionItem item)
|
||||||
{
|
{
|
||||||
ResultValue = SelectedItemUsesRealtimeValue
|
ResultValue = SelectedItemUsesRealtimeValue
|
||||||
@@ -629,6 +651,15 @@ ul {{ padding-left: 20px; }}
|
|||||||
|| MatchesKeyword(item.TestMethod, keyword);
|
|| MatchesKeyword(item.TestMethod, keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool MatchesActiveFilter(InspectionItem item) => ActiveFilter switch
|
||||||
|
{
|
||||||
|
"待填写" => item.Status == InspectionItemStatus.Pending,
|
||||||
|
"已完成" => item.Status != InspectionItemStatus.Pending,
|
||||||
|
"实时监控" => item.CaptureMode == InspectionItemCaptureMode.RealtimeMonitor,
|
||||||
|
"手动填写" => item.CaptureMode != InspectionItemCaptureMode.RealtimeMonitor,
|
||||||
|
_ => true
|
||||||
|
};
|
||||||
|
|
||||||
private static bool MatchesKeyword(string source, string keyword)
|
private static bool MatchesKeyword(string source, string keyword)
|
||||||
{
|
{
|
||||||
if (source.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
if (source.Contains(keyword, StringComparison.OrdinalIgnoreCase))
|
||||||
|
|||||||
Reference in New Issue
Block a user