diff --git a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs index b54c49c..f931139 100644 --- a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs +++ b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs @@ -10,10 +10,13 @@ using Prism.Regions; using Prism.Services.Dialogs; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Linq; using System.Text; +using System.Threading.Channels; using System.Threading.Tasks; +using System.Windows.Data; namespace DM_Weight.ViewModels { @@ -36,6 +39,7 @@ namespace DM_Weight.ViewModels { // 取消消息订阅 _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent); + _eventAggregator.GetEvent().Unsubscribe(SetIsSelected); } @@ -51,6 +55,7 @@ namespace DM_Weight.ViewModels public void OnNavigatedTo(NavigationContext navigationContext) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); + _eventAggregator.GetEvent().Subscribe(SetIsSelected); RequestData(); } private PortUtil _portUtil; @@ -65,13 +70,16 @@ namespace DM_Weight.ViewModels private void RequestData() { ChannelStocks = SqlSugarHelper.Db.Queryable() - .Includes(cs => cs.ChannelLst) - .Includes(cs => cs.DrugInfo) - .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity) - .OrderBy(cs => cs.Chnguid) - .OrderBy(cs => cs.DrawerNo) - .ToList(); + .Includes(cs => cs.ChannelLst) + .Includes(cs => cs.DrugInfo) + .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity) + .OrderBy(cs => cs.Chnguid) + .OrderBy(cs => cs.DrawerNo) + .ToList(); ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity); + + ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks); + vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst")); } private int _status = 0; @@ -392,7 +400,8 @@ namespace DM_Weight.ViewModels public DelegateCommand RejectReport_Download { - get => new DelegateCommand(() => { + get => new DelegateCommand(() => + { //GridReportUtil.RejectionReport(""); }); } @@ -404,6 +413,7 @@ namespace DM_Weight.ViewModels }); } + private List csList = new List(); //取药 弹出出药列表 public DelegateCommand TakeDrugCommand @@ -450,5 +460,29 @@ 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")); + } + } } } diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml b/DM_Weight/Views/AddToJiaoJieWindow.xaml index 3b6ccc2..5de7e1f 100644 --- a/DM_Weight/Views/AddToJiaoJieWindow.xaml +++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml @@ -12,11 +12,11 @@ d:DesignHeight="450" d:DesignWidth="800"> - + @@ -94,7 +94,7 @@ + materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed"> diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs b/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs index 8f1b46f..ecfdf6d 100644 --- a/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs +++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs @@ -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 /// 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 data = expander.DataContext as List; + // 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().Publish(internalGroup); + } + } } } } diff --git a/DM_Weight/msg/IsSelectedEvent.cs b/DM_Weight/msg/IsSelectedEvent.cs new file mode 100644 index 0000000..1c159d8 --- /dev/null +++ b/DM_Weight/msg/IsSelectedEvent.cs @@ -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 + { + } +}