交接柜补药页面选中药箱行则勾选复选框

This commit is contained in:
maqiao 2024-10-30 09:06:09 +08:00
parent bf4342a57f
commit 4a3236fc5c
4 changed files with 97 additions and 13 deletions

View File

@ -10,10 +10,13 @@ using Prism.Regions;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; using System.Configuration;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels namespace DM_Weight.ViewModels
{ {
@ -36,6 +39,7 @@ namespace DM_Weight.ViewModels
{ {
// 取消消息订阅 // 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent); _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
} }
@ -51,6 +55,7 @@ namespace DM_Weight.ViewModels
public void OnNavigatedTo(NavigationContext navigationContext) public void OnNavigatedTo(NavigationContext navigationContext)
{ {
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent); _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
RequestData(); RequestData();
} }
private PortUtil _portUtil; private PortUtil _portUtil;
@ -65,13 +70,16 @@ namespace DM_Weight.ViewModels
private void RequestData() private void RequestData()
{ {
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>() ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<ChannelList>(cs => cs.ChannelLst) .Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo) .Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity) .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
.OrderBy(cs => cs.Chnguid) .OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo) .OrderBy(cs => cs.DrawerNo)
.ToList(); .ToList();
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity); ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
} }
private int _status = 0; private int _status = 0;
@ -392,7 +400,8 @@ namespace DM_Weight.ViewModels
public DelegateCommand RejectReport_Download public DelegateCommand RejectReport_Download
{ {
get => new DelegateCommand(() => { get => new DelegateCommand(() =>
{
//GridReportUtil.RejectionReport(""); //GridReportUtil.RejectionReport("");
}); });
} }
@ -404,6 +413,7 @@ namespace DM_Weight.ViewModels
}); });
} }
private List<ChannelStock> csList = new List<ChannelStock>(); private List<ChannelStock> csList = new List<ChannelStock>();
//取药 弹出出药列表 //取药 弹出出药列表
public DelegateCommand TakeDrugCommand public DelegateCommand TakeDrugCommand
@ -450,5 +460,29 @@ namespace DM_Weight.ViewModels
//} //}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString()); //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

@ -12,11 +12,11 @@
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>
<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}"> <!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
<CollectionViewSource.GroupDescriptions> <CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ChannelLst" /> <PropertyGroupDescription PropertyName="ChannelLst" />
</CollectionViewSource.GroupDescriptions> </CollectionViewSource.GroupDescriptions>
</CollectionViewSource> </CollectionViewSource>-->
<convert:GroupSumConverter x:Key="GroupSumConverter" /> <convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:TotalCountConverter x:Key="TotalCountConverter" /> <convert:TotalCountConverter x:Key="TotalCountConverter" />
<convert:StatusConverter x:Key="StatusConverter" /> <convert:StatusConverter x:Key="StatusConverter" />
@ -94,7 +94,7 @@
<DataGrid <DataGrid
Grid.Row="1" Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15" materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding Source={StaticResource GroupedDataList}}" ItemsSource="{Binding ChannelStocks,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False" materialDesign:DataGridAssist.EnableEditBoxAssist="False"
IsSynchronizedWithCurrentItem="True" IsSynchronizedWithCurrentItem="True"
materialDesign:DataGridAssist.CellPadding="13" materialDesign:DataGridAssist.CellPadding="13"
@ -144,7 +144,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}"> <ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True" <Expander IsExpanded="True"
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise"> materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
<Expander.Header > <Expander.Header >
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<CheckBox Margin="0 0 3 0" IsChecked="{Binding Path=Name.IsSelected}" FontSize="24" /> <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.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -20,9 +23,42 @@ namespace DM_Weight.Views
/// </summary> /// </summary>
public partial class AddToJiaoJieWindow : UserControl public partial class AddToJiaoJieWindow : UserControl
{ {
public AddToJiaoJieWindow() IEventAggregator _eventAggregator;
public AddToJiaoJieWindow(IEventAggregator eventAggregator)
{ {
InitializeComponent(); 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>
{
}
}