交接柜加药页面添加选中药箱号行则选中反选复选框

This commit is contained in:
maqiao 2024-10-31 15:33:28 +08:00
parent dda2c23a45
commit c23428f5b8
4 changed files with 83 additions and 3 deletions

View File

@ -13,10 +13,12 @@ using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
@ -39,6 +41,8 @@ namespace DM_Weight.ViewModels
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
}
@ -54,6 +58,8 @@ namespace DM_Weight.ViewModels
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
RequestData();
}
private PortUtil _portUtil;
@ -453,6 +459,30 @@ namespace DM_Weight.ViewModels
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
//设置选中药箱的复选框状态
private void SetIsSelected(ChannelStock channelStock)
{
if (channelStock != null)
{
channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
if (channelStock != null && ChannelStocks != null)
{
ChannelStocks = ChannelStocks.Select(x =>
{
for (int i = 0; i < ChannelStocks.Count; i++)
{
if (ChannelStocks[i].DrawerNo == channelStock.DrawerNo)
{
ChannelStocks[i].ChannelLst = channelStock.ChannelLst;
}
}
return x;
}).ToList();
}
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
}
}
}
}

View File

@ -143,7 +143,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True"
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
<Expander.Header >
<StackPanel Orientation="Horizontal">
<CheckBox Margin="0 0 3 0" IsChecked="{Binding Path=Name.IsSelected}" FontSize="24" />

View File

@ -1,4 +1,7 @@
using System;
using DM_Weight.Models;
using DM_Weight.msg;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -20,9 +23,42 @@ namespace DM_Weight.Views
/// </summary>
public partial class AddToJiaoJieWindow : UserControl
{
public AddToJiaoJieWindow()
IEventAggregator _eventAggregator;
public AddToJiaoJieWindow(IEventAggregator eventAggregator)
{
InitializeComponent();
_eventAggregator = eventAggregator;
}
//展开
private void Expander_Expanded(object sender, RoutedEventArgs e)
{
//Expander expander = sender as Expander;
//if (expander != null)
//{
// // 假设你的数据在DataContext中
// List<ChannelStock> data = expander.DataContext as List<ChannelStock>;
// if (data != null&&data.Count>0)
// {
// // 使用data做你需要的操作
// }
//}
}
//收起
private void Expander_Collapsed(object sender, RoutedEventArgs e)
{
Expander expander = sender as Expander;
if (expander != null)
{
// 假设你的数据在DataContext中
CollectionViewGroup group = expander.DataContext as CollectionViewGroup;
if (group != null)
{
ChannelStock internalGroup = group.Items[0] as ChannelStock;
_eventAggregator.GetEvent<IsSelectedEvent>().Publish(internalGroup);
}
}
}
}
}

View File

@ -0,0 +1,14 @@
using DM_Weight.Models;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.msg
{
internal class IsSelectedEvent:PubSubEvent<ChannelStock>
{
}
}