diff --git a/DM_Weight/App.config b/DM_Weight/App.config index e4ba36b..27b072d 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -37,7 +37,7 @@ - + diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 0d26a25..3606165 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -167,6 +167,8 @@ namespace DM_Weight //开药箱 containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); + //交接柜补药 + containerRegistry.RegisterForNavigation(); //核对处方 containerRegistry.RegisterForNavigation(); //管理员根据药箱进行核对处方 diff --git a/DM_Weight/ViewModels/AdditionWindowViewModel.cs b/DM_Weight/ViewModels/AdditionWindowViewModel.cs new file mode 100644 index 0000000..d3ce0fa --- /dev/null +++ b/DM_Weight/ViewModels/AdditionWindowViewModel.cs @@ -0,0 +1,159 @@ +using DM_Weight.Models; +using DM_Weight.msg; +using DM_Weight.Port; +using DM_Weight.util; +using log4net; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +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; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace DM_Weight.ViewModels +{ + public class AdditionWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + public bool KeepAlive => false; + + private readonly ILog logger = LogManager.GetLogger(typeof(AdditionWindowViewModel)); + + private List channelStocks; + public List ChannelStocks + { + get => channelStocks; + set => SetProperty(ref channelStocks, value); + } + List selectedStock=new List(); + private object _finishStatus = Visibility.Collapsed; + public object FinishStatus + { + get => _finishStatus; + set => SetProperty(ref _finishStatus, value); + } + + IDialogService _dialogService; + IEventAggregator _eventAggregator; + + public AdditionWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator) + { + _dialogService = dialogService; + _eventAggregator = eventAggregator; + } + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + _eventAggregator.GetEvent().Unsubscribe(SetIsSelected); + } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + _eventAggregator.GetEvent().Subscribe(SetIsSelected); + RequestData(); + } + private void RequestData() + { + ChannelStocks = SqlSugarHelper.Db.Queryable() + .Includes(cs => cs.ChannelLst) + .Includes(cs => cs.DrugInfo) + .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity) + .OrderBy(cs => cs.Chnguid) + .OrderBy(cs => cs.DrawerNo) + .ToList(); + ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity); + } + //开药箱放入药品 + public DelegateCommand OpenBoxCommand + { + get => new DelegateCommand(() => + { + selectedStock = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList(); + if (selectedStock != null && selectedStock.Count > 0) + { + for (int i = 0; i < selectedStock.Count; i++) + { + ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1); + Thread.Sleep(100); + } + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"未选择药箱,请先选择药箱", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } + FinishStatus = Visibility.Visible; + }); + } + //完成按钮 + public DelegateCommand AddFinish + { + get => new DelegateCommand(() => + { + //更新 交接柜 库存信息 + if (selectedStock != null && selectedStock.Count > 0) + { + for (int j = 0; j < selectedStock.Count; j++) + { + // 更新数据 交接柜 库存信息 + ChannelStock jiaojie_it = selectedStock[j]; + SqlSugarHelper.Db.Updateable(new ChannelStock() + { + Quantity = jiaojie_it.BaseQuantity, + //ManuNo = it.ManuNo, + //EffDate = it.EffDate, + Id = jiaojie_it.Id, + }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand(); + } + } + }); + } + + //刷新 + public DelegateCommand QueryCommand + { + get => new DelegateCommand(() => RequestData()); + } + //设置选中药箱的复选框状态 + 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/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index dabcf36..2afd8c2 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -203,6 +203,14 @@ namespace DM_Weight.ViewModels //PremissionPath = "CheckOrderWindow", PremissionPath = "CheckOrderNewWindow", }; + //核对处方 + PremissionDm addition = new PremissionDm + { + Id = 12, + PremissionName = "药箱补药", + //PremissionPath = "CheckOrderWindow", + PremissionPath = "AdditionWindow", + }; //PremissionDm quyao1 = new PremissionDm //{ @@ -253,6 +261,7 @@ namespace DM_Weight.ViewModels //quyaoChild.Add(quyao5); quyaoChild.Add(openBox); quyaoChild.Add(checkOrder); + quyaoChild.Add(addition); quyao.Children = quyaoChild; defaultAll.Add(quyao); #endregion diff --git a/DM_Weight/Views/AdditionWindow.xaml b/DM_Weight/Views/AdditionWindow.xaml new file mode 100644 index 0000000..8ebe5cf --- /dev/null +++ b/DM_Weight/Views/AdditionWindow.xaml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DM_Weight/Views/AdditionWindow.xaml.cs b/DM_Weight/Views/AdditionWindow.xaml.cs new file mode 100644 index 0000000..9d51aa2 --- /dev/null +++ b/DM_Weight/Views/AdditionWindow.xaml.cs @@ -0,0 +1,53 @@ +using DM_Weight.Models; +using DM_Weight.msg; +using Prism.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DM_Weight.Views +{ + /// + /// AdditionWindow.xaml 的交互逻辑 + /// + public partial class AdditionWindow : UserControl + { + IEventAggregator _eventAggregator; + public AdditionWindow(IEventAggregator eventAggregator) + { + InitializeComponent(); + _eventAggregator = eventAggregator; + } + //private void Expander_Expanded(object sender, RoutedEventArgs e) + //{ + + //} + //收起 + 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 + { + } +}