交接柜补药
This commit is contained in:
		
							parent
							
								
									ac3a1f53c4
								
							
						
					
					
						commit
						44fc240bd4
					
				| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
  <connectionStrings>
 | 
					  <connectionStrings>
 | 
				
			||||||
	<!-- 数据库连接字符串 -->
 | 
						<!-- 数据库连接字符串 -->
 | 
				
			||||||
	<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
 | 
						<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
 | 
				
			||||||
	<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangxiang;userid=root;password=root" />
 | 
						<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangxiang_xianchang;userid=root;password=root" />
 | 
				
			||||||
  </connectionStrings>
 | 
					  </connectionStrings>
 | 
				
			||||||
	<!--<runtime>
 | 
						<!--<runtime>
 | 
				
			||||||
		--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
							--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,6 +134,9 @@ namespace DM_Weight
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
				
			||||||
            //交接柜补药
 | 
					            //交接柜补药
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
 | 
				
			||||||
 | 
					            //交接柜补药页面弹窗
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<AddToJiaoJieDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<AddToJiaoJieDialog, AddToJiaoJieDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 处方取药模态框
 | 
					            // 处方取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
					            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +73,14 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(ColumnName = "quantity")]
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
        public int Quantity { get; set; }
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 交接柜中库存基数
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "check_quantity")]
 | 
				
			||||||
 | 
					        public int BaseQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 1
 | 
					        /// 默认值: 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// ҩƷID 
 | 
					        /// ҩƷID 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
					        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
				
			||||||
        public long DrugId { get; set; }
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// ƴ 
 | 
					        /// ƴ 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,439 @@
 | 
				
			||||||
 | 
					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.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class AddToJiaoJieDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
				
			||||||
 | 
					        public string Title => "交接柜补药";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Status == 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            ChannelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private List<ChannelStock> _channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<ChannelStock> ChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _channelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _channelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime
 | 
				
			||||||
 | 
					   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public AddToJiaoJieDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					                int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					                List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                switch (msg.EventType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 抽屉打开
 | 
				
			||||||
 | 
					                    case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 1)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 2);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
 | 
				
			||||||
 | 
					                        CheckIsFridgeOpen();
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 抽屉关闭
 | 
				
			||||||
 | 
					                    case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 2)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 3);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
				
			||||||
 | 
					                            int DrawerNoBefore = groupingBefore.Key;
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
				
			||||||
 | 
					                                int DrawerNoAfter = groupingAfter.Key;
 | 
				
			||||||
 | 
					                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                OpenOneByOne();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // 已经全部取出
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Status = 3;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
 | 
				
			||||||
 | 
					                        CheckIsFridgeClose();
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 数量变化
 | 
				
			||||||
 | 
					                    case EventType.UPDATEQUANTITY:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 打开失败
 | 
				
			||||||
 | 
					                    case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = msg.Message,
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status; set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
				
			||||||
 | 
					            List<string> msg = new List<string>();
 | 
				
			||||||
 | 
					            for (int i = 0; i < ChannelStocks.Count; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                    .Where(cs => cs.Quantity > 0)
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrugId == ChannelStocks[i].DrugId)
 | 
				
			||||||
 | 
					                    .OrderBy(cs => cs.EffDate)
 | 
				
			||||||
 | 
					                    .OrderBy(cs => cs.DrawerNo)
 | 
				
			||||||
 | 
					                    .ToList();
 | 
				
			||||||
 | 
					                int total = HasQChannels.Sum(it => it.Quantity);
 | 
				
			||||||
 | 
					                int TakeQ = ChannelStocks[i].Quantity;
 | 
				
			||||||
 | 
					                // 说明数量足够
 | 
				
			||||||
 | 
					                if (total >= TakeQ)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    for (int j = 0; TakeQ > 0; j++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ChannelStock stock = HasQChannels[j];
 | 
				
			||||||
 | 
					                        if (TakeQ > stock.Quantity)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            stock.TakeQuantity = stock.Quantity;
 | 
				
			||||||
 | 
					                            channelStocks.Add(stock);
 | 
				
			||||||
 | 
					                            TakeQ -= stock.Quantity;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            stock.TakeQuantity = TakeQ;
 | 
				
			||||||
 | 
					                            channelStocks.Add(stock);
 | 
				
			||||||
 | 
					                            TakeQ = 0;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    msg.Add($"药品【{ChannelStocks[i].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (msg.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					                    //MessageBox.Show(string.Join("\n", msg));
 | 
				
			||||||
 | 
					                    DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                    dialogParameters.Add("msgInfo", msg);
 | 
				
			||||||
 | 
					                    DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    channelStocks.Sort((a, b) =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            return a.ColNo - b.ColNo;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return a.DrawerNo - b.DrawerNo;
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    ChannelStocks = channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand OpenDrawer
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(async () =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Status == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
				
			||||||
 | 
					                    enumerator = enumerable.GetEnumerator();
 | 
				
			||||||
 | 
					                    enumerator.MoveNext();
 | 
				
			||||||
 | 
					                    Status = 1;
 | 
				
			||||||
 | 
					                    OpenOneByOne();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void OpenOneByOne()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 发送取药数量
 | 
				
			||||||
 | 
					            singleChannels.ForEach(it =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"打开抽屉异常{ex.Message}",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
				
			||||||
 | 
					            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
				
			||||||
 | 
					            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
				
			||||||
 | 
					            _portUtil.DrawerNo = DrawerNo;
 | 
				
			||||||
 | 
					            _portUtil.Start();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isFinishClick = false;
 | 
				
			||||||
 | 
					        // 完成按钮
 | 
				
			||||||
 | 
					        public DelegateCommand TakeFinish
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!_isFinishClick)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _isFinishClick = true;
 | 
				
			||||||
 | 
					                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
				
			||||||
 | 
					                    if (record.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis();
 | 
				
			||||||
 | 
					                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            for (int i = 0; i < record.Count; i++)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                ChannelStock it = record[i];
 | 
				
			||||||
 | 
					                                // 更新数据 库存信息
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
				
			||||||
 | 
					                                    ManuNo = it.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = it.EffDate,
 | 
				
			||||||
 | 
					                                    Id = it.Id,
 | 
				
			||||||
 | 
					                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                // 更新数据 交接柜 库存信息
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
				
			||||||
 | 
					                                    ManuNo = it.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = it.EffDate,
 | 
				
			||||||
 | 
					                                    Id = it.Id,
 | 
				
			||||||
 | 
					                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
 | 
					                                // 保存数据 出库记录
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    MachineId = it.MachineId,
 | 
				
			||||||
 | 
					                                    DrawerNo = it.DrawerNo,
 | 
				
			||||||
 | 
					                                    ColNo = it.ColNo,
 | 
				
			||||||
 | 
					                                    DrugId = it.DrugId,
 | 
				
			||||||
 | 
					                                    ManuNo = it.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                    Quantity = it.TakeQuantity,
 | 
				
			||||||
 | 
					                                    Type = 2,
 | 
				
			||||||
 | 
					                                    InvoiceId = InvoiceId
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            return true;
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        if (f.Data)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            // 更新屏显库存
 | 
				
			||||||
 | 
					                            List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 5);
 | 
				
			||||||
 | 
					                            if (singleChannels.Count > 0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                singleChannels.ForEach(it =>
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "抽屉取药完成,库存已更新",
 | 
				
			||||||
 | 
					                                Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (!f.IsSuccess)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "抽屉取药完成,库存更新失败!",
 | 
				
			||||||
 | 
					                                Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        _isFinishClick = false;
 | 
				
			||||||
 | 
					                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        _isFinishClick = false;
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "没有填写取药数量",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public long CurrentTimeMillis()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 取消按钮
 | 
				
			||||||
 | 
					        public DelegateCommand CancleTake
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.ResetData();
 | 
				
			||||||
 | 
					                Status = 0;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //检查是否是冰箱抽屉(冰箱抽屉打开时需要发送冰箱延迟报警的指令)
 | 
				
			||||||
 | 
					        public async Task CheckIsFridgeOpen()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //if (ChannelStocks != null && ChannelStocks.Count > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    if (_portUtil.BoardType == (Int32)BoardTypeEnum.fridge)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        _portUtil.FridgeOperate = true;
 | 
				
			||||||
 | 
					            //        //发送冰箱延迟报警的指令
 | 
				
			||||||
 | 
					            //        await _portUtil.FridgeDelayWarm();
 | 
				
			||||||
 | 
					            //        _portUtil.FridgeOperate = false;
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //检查是否是冰箱抽屉(冰箱抽屉关闭时需要查询冰箱温度如温度不在范围则发送冰箱延迟报警的指令)
 | 
				
			||||||
 | 
					        public async Task CheckIsFridgeClose()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //if (ChannelStocks != null && ChannelStocks.Count > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    if (_portUtil.BoardType == (Int32)BoardTypeEnum.fridge)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        string[] iTempertureRange = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
 | 
				
			||||||
 | 
					            //        //发送查询冰箱温度的指令
 | 
				
			||||||
 | 
					            //        float temperature = await _portUtil.GetFridgeTemperature();
 | 
				
			||||||
 | 
					            //        if (temperature > Convert.ToSingle(iTempertureRange[0]) && temperature < Convert.ToSingle(iTempertureRange[1]))
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            _portUtil.FridgeOperate = true;
 | 
				
			||||||
 | 
					            //            //发送冰箱延迟报警的指令
 | 
				
			||||||
 | 
					            //            await _portUtil.FridgeDelayWarm();
 | 
				
			||||||
 | 
					            //            _portUtil.FridgeOperate = false;
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Status != 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _portUtil.ResetData();
 | 
				
			||||||
 | 
					                    Status = 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //DialogParameters parameters = new DialogParameters();
 | 
				
			||||||
 | 
					                //parameters.Add("",);
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,242 @@
 | 
				
			||||||
using System;
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class AddToJiaoJieWindowViewModel
 | 
					    public class AddToJiaoJieWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(AddToJiaoJieWindowViewModel));
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> channelStocks;
 | 
				
			||||||
 | 
					        public List<ChannelStock> ChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => channelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref channelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public AddToJiaoJieWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                .Includes<ChannelList>(cs => cs.ChannelLst)
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isEnable = true;
 | 
				
			||||||
 | 
					        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<int> iDrawerNoLst
 | 
				
			||||||
 | 
					        { get; set; }
 | 
				
			||||||
 | 
					        private int CurrentNum { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //刷新
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => RequestData());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //一键补药
 | 
				
			||||||
 | 
					        public DelegateCommand OpenDragCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Status = 1;
 | 
				
			||||||
 | 
					                    IsEnable = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                   var varDrawerNO = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                  .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ??"DM3"))
 | 
				
			||||||
 | 
					                                  .GroupBy(cs=>cs.DrawerNo).Select(DrawerNo=>DrawerNo).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    iDrawerNoLst= varDrawerNO.Select(item => item.DrawerNo).ToList();
 | 
				
			||||||
 | 
					                    CurrentNum = 0;
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开 {iDrawerNoLst[CurrentNum]} 号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.WindowName = "AddToJiaoJieWindow";
 | 
				
			||||||
 | 
					                    _portUtil.Operate = true;
 | 
				
			||||||
 | 
					                    //_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
				
			||||||
 | 
					                    //_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
				
			||||||
 | 
					                    _portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
 | 
				
			||||||
 | 
					                    _portUtil.Start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"补药异常{ex.Message}",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    logger.Info($"AddToJiaoJieWindowViewModel异常:{ex.Message}");
 | 
				
			||||||
 | 
					                    _portUtil.Operate = false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg.WindowName == "AddToJiaoJieWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                switch (msg.EventType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 抽屉打开
 | 
				
			||||||
 | 
					                    case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Status = 2;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        CurrentNum+=1;
 | 
				
			||||||
 | 
					                        if (CurrentNum< iDrawerNoLst.Count)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _portUtil.WindowName = "AddToJiaoJieWindow";
 | 
				
			||||||
 | 
					                            _portUtil.Operate = true;
 | 
				
			||||||
 | 
					                            _portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
 | 
				
			||||||
 | 
					                            _portUtil.Start();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 抽屉关闭
 | 
				
			||||||
 | 
					                    case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                        if (Status == 2)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Status = 3;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        _portUtil.Operate = false;
 | 
				
			||||||
 | 
					                        IsEnable=false;
 | 
				
			||||||
 | 
					                        CurrentNum = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 数量变化
 | 
				
			||||||
 | 
					                    case EventType.UPDATEQUANTITY:
 | 
				
			||||||
 | 
					                        if (Status == 2)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 打开失败
 | 
				
			||||||
 | 
					                    case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = msg.Message,
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        _portUtil.Operate = false;
 | 
				
			||||||
 | 
					                        IsEnable = false;
 | 
				
			||||||
 | 
					                        CurrentNum = 0;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //完成按钮
 | 
				
			||||||
 | 
					        //public DelegateCommand AddFinish
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => new DelegateCommand(() => 
 | 
				
			||||||
 | 
					        //    { 
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					        //    });
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //取消
 | 
				
			||||||
 | 
					        public DelegateCommand CancleAdd
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.ResetData();
 | 
				
			||||||
 | 
					                 Status = 0;
 | 
				
			||||||
 | 
					                IsEnable = true;
 | 
				
			||||||
 | 
					                CurrentNum = 0;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> csList = new List<ChannelStock>();
 | 
				
			||||||
 | 
					        //取药 弹出出药列表
 | 
				
			||||||
 | 
					        public DelegateCommand TakeDrugCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(async () =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                csList = ChannelStocks.FindAll(cs => cs.IsSelected == true).GroupBy(cs => cs.DrugId).Select(g => new {
 | 
				
			||||||
 | 
					                    DrugId = g.Key, Quantity = g.Sum(s => s.Quantity)
 | 
				
			||||||
 | 
					                }).Select(cs=>new ChannelStock() { DrugId=cs.DrugId,Quantity=cs.Quantity}).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (csList != null && csList.Count>0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 此处延时1毫秒,等待页面渲染
 | 
				
			||||||
 | 
					                    await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
				
			||||||
 | 
					                    DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                    dialogParameters.Add("ChannelStocks", csList);
 | 
				
			||||||
 | 
					                    DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            //if(dialogResult.Result == ButtonResult.OK)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //查询最大药品id并+1赋值给新增药品
 | 
					                    //查询最大药品id并+1赋值给新增药品
 | 
				
			||||||
                    long maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
 | 
					                    string maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
 | 
				
			||||||
                    SelectedDrug.DrugId = maxDrugId + 1;
 | 
					                    SelectedDrug.DrugId = maxDrugId + 1;
 | 
				
			||||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
| 
						 | 
					@ -246,7 +246,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }, () => SelectedDrug.DrugId <= 0).ObservesProperty(() => SelectedDrug);
 | 
					            }, () => SelectedDrug.DrugId ==null).ObservesProperty(() => SelectedDrug);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand EditDrugCommand
 | 
					        public DelegateCommand EditDrugCommand
 | 
				
			||||||
| 
						 | 
					@ -306,7 +306,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                RequestData();
 | 
					                RequestData();
 | 
				
			||||||
            }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
 | 
					            }, () => SelectedDrug.DrugId!=null).ObservesProperty(() => SelectedDrug);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand AddManuCommand
 | 
					        public DelegateCommand AddManuCommand
 | 
				
			||||||
| 
						 | 
					@ -376,7 +376,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
 | 
					            }, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand EditManuCommand
 | 
					        public DelegateCommand EditManuCommand
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,147 @@
 | 
				
			||||||
<UserControl x:Class="DM_Weight.Views.AddToJiaoJieWindow"
 | 
					<UserControl x:Class="DM_Weight.Views.AddToJiaoJieWindow"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
				
			||||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
				
			||||||
             mc:Ignorable="d" 
 | 
					             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             mc:Ignorable="d">
 | 
				
			||||||
    <Grid>
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.Resources>
 | 
				
			||||||
 | 
					            <CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
 | 
				
			||||||
 | 
					                <CollectionViewSource.GroupDescriptions>
 | 
				
			||||||
 | 
					                    <PropertyGroupDescription PropertyName="ChannelLst" />
 | 
				
			||||||
 | 
					                </CollectionViewSource.GroupDescriptions>
 | 
				
			||||||
 | 
					            </CollectionViewSource>
 | 
				
			||||||
 | 
					            <convert:GroupSumConverter x:Key="GroupSumConverter" />
 | 
				
			||||||
 | 
					            <convert:TotalCountConverter x:Key="TotalCountConverter" />
 | 
				
			||||||
 | 
					            <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
 | 
					        </Grid.Resources>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					            <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="1*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="7*"/>
 | 
				
			||||||
 | 
					            </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                    ToolTip="一键补药"
 | 
				
			||||||
 | 
					                    Content="一键补药"
 | 
				
			||||||
 | 
					                    Command="{Binding OpenDragCommand}"
 | 
				
			||||||
 | 
					                    IsEnabled="{Binding IsEnable}"
 | 
				
			||||||
 | 
					                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                    materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding TakeDrugCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="取药" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding CancleAdd}"
 | 
				
			||||||
 | 
					                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="取消" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="6 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    ToolTip="刷新" Command="{Binding QueryCommand}">
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon
 | 
				
			||||||
 | 
					                    Kind="Refresh" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </StackPanel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        </Grid>
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <DataGrid
 | 
				
			||||||
 | 
					                Grid.Row="1"
 | 
				
			||||||
 | 
					                materialDesign:DataGridAssist.ColumnHeaderPadding="15"
 | 
				
			||||||
 | 
					                ItemsSource="{Binding Source={StaticResource GroupedDataList}}"
 | 
				
			||||||
 | 
					                materialDesign:DataGridAssist.EnableEditBoxAssist="False"
 | 
				
			||||||
 | 
					                IsSynchronizedWithCurrentItem="True"
 | 
				
			||||||
 | 
					                materialDesign:DataGridAssist.CellPadding="13"
 | 
				
			||||||
 | 
					                CanUserAddRows="False"
 | 
				
			||||||
 | 
					                AutoGenerateColumns="False">
 | 
				
			||||||
 | 
					            <DataGrid.Resources>
 | 
				
			||||||
 | 
					                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
				
			||||||
 | 
					                    <Setter Property="Background" Value="#31ccec" />
 | 
				
			||||||
 | 
					                    <Setter Property="Foreground" Value="white" />
 | 
				
			||||||
 | 
					                    <Setter Property="Height" Value="56" />
 | 
				
			||||||
 | 
					                    <Setter Property="BorderBrush" Value="white"/>
 | 
				
			||||||
 | 
					                    <Setter Property="BorderThickness" Value="0.6"/>
 | 
				
			||||||
 | 
					                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					                <!--<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
				
			||||||
 | 
					                    <Style.Triggers>
 | 
				
			||||||
 | 
					                        <Trigger Property="IsReadOnly" Value="True">
 | 
				
			||||||
 | 
					                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
				
			||||||
 | 
					                            <Setter Property="HorizontalAlignment" Value="Center"/>
 | 
				
			||||||
 | 
					                        </Trigger>
 | 
				
			||||||
 | 
					                    </Style.Triggers>
 | 
				
			||||||
 | 
					                    <Setter Property="HorizontalAlignment" Value="Center"/>
 | 
				
			||||||
 | 
					                </Style>-->
 | 
				
			||||||
 | 
					                <Style TargetType="DataGridCell">
 | 
				
			||||||
 | 
					                    <Setter Property="Template">
 | 
				
			||||||
 | 
					                        <Setter.Value>
 | 
				
			||||||
 | 
					                            <ControlTemplate TargetType="DataGridCell">
 | 
				
			||||||
 | 
					                                <TextBlock TextAlignment="Center" VerticalAlignment="Center"  >
 | 
				
			||||||
 | 
					                                <ContentPresenter Margin="13" />
 | 
				
			||||||
 | 
					                                </TextBlock>
 | 
				
			||||||
 | 
					                            </ControlTemplate>
 | 
				
			||||||
 | 
					                        </Setter.Value>
 | 
				
			||||||
 | 
					                    </Setter>
 | 
				
			||||||
 | 
					                    <Style.Triggers>
 | 
				
			||||||
 | 
					                        <Trigger Property="IsSelected" Value="True">
 | 
				
			||||||
 | 
					                            <Setter Property="Foreground" Value="Black"/>
 | 
				
			||||||
 | 
					                            <Setter Property="BorderBrush" Value="Transparent" />
 | 
				
			||||||
 | 
					                        </Trigger>
 | 
				
			||||||
 | 
					                    </Style.Triggers>
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					            </DataGrid.Resources>
 | 
				
			||||||
 | 
					            <DataGrid.GroupStyle>
 | 
				
			||||||
 | 
					                <GroupStyle>
 | 
				
			||||||
 | 
					                    <GroupStyle.ContainerStyle>
 | 
				
			||||||
 | 
					                        <Style TargetType="{x:Type GroupItem}">
 | 
				
			||||||
 | 
					                            <Setter Property="Template">
 | 
				
			||||||
 | 
					                                <Setter.Value>
 | 
				
			||||||
 | 
					                                    <ControlTemplate TargetType="{x:Type GroupItem}">
 | 
				
			||||||
 | 
					                                        <Expander IsExpanded="True"
 | 
				
			||||||
 | 
					                                                  materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
 | 
				
			||||||
 | 
					                                            <Expander.Header >
 | 
				
			||||||
 | 
					                                                <StackPanel Orientation="Horizontal">
 | 
				
			||||||
 | 
					                                                    <CheckBox Margin="0 0 3 0"  IsChecked="{Binding Path=Name.IsSelected}" FontSize="24" />
 | 
				
			||||||
 | 
					                                                    <TextBlock Text="{Binding Path=Name.DrawerNo,StringFormat={}{0}号药箱}" FontWeight="Bold" />
 | 
				
			||||||
 | 
					                                                </StackPanel>
 | 
				
			||||||
 | 
					                                            </Expander.Header>
 | 
				
			||||||
 | 
					                                            <ItemsPresenter/>
 | 
				
			||||||
 | 
					                                        </Expander>
 | 
				
			||||||
 | 
					                                    </ControlTemplate>
 | 
				
			||||||
 | 
					                                </Setter.Value>
 | 
				
			||||||
 | 
					                            </Setter>
 | 
				
			||||||
 | 
					                        </Style>
 | 
				
			||||||
 | 
					                    </GroupStyle.ContainerStyle>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                </GroupStyle>
 | 
				
			||||||
 | 
					            </DataGrid.GroupStyle>
 | 
				
			||||||
 | 
					            <DataGrid.Columns>
 | 
				
			||||||
 | 
					                <DataGridTextColumn IsReadOnly="True" Header="药品名称" Binding="{Binding DrugInfo.DrugName}"/>
 | 
				
			||||||
 | 
					                <DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddQuantity}"/>
 | 
				
			||||||
 | 
					            </DataGrid.Columns>
 | 
				
			||||||
 | 
					        </DataGrid>
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
</UserControl>
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,152 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.Dialog.AddToJiaoJieDialog"
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             prism:ViewModelLocator.AutoWireViewModel="True"
 | 
				
			||||||
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
				
			||||||
 | 
					             MinWidth="880"
 | 
				
			||||||
 | 
					             Width="Auto"
 | 
				
			||||||
 | 
					             Height="Auto"
 | 
				
			||||||
 | 
					             mc:Ignorable="d" >
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <materialDesign:Card Padding="0">
 | 
				
			||||||
 | 
					        <Grid>
 | 
				
			||||||
 | 
					            <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <Grid Background="#03a9f4" Grid.Row="0">
 | 
				
			||||||
 | 
					                <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="交接柜补药" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Command="{Binding BtnCloseCommand}"
 | 
				
			||||||
 | 
					                        IsEnabled="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CloseBtn}"
 | 
				
			||||||
 | 
					                        ToolTip="关闭"
 | 
				
			||||||
 | 
					                    >
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					            <DataGrid Grid.Row="1" ItemsSource="{Binding ChannelStocks}" AutoGenerateColumns="False" CanUserAddRows="False">
 | 
				
			||||||
 | 
					                <DataGrid.Resources>
 | 
				
			||||||
 | 
					                    <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
 | 
				
			||||||
 | 
					                        <Setter Property="HorizontalContentAlignment" Value="Center" />
 | 
				
			||||||
 | 
					                        <Setter Property="Background" Value="#31ccec" />
 | 
				
			||||||
 | 
					                        <Setter Property="Foreground" Value="white" />
 | 
				
			||||||
 | 
					                        <Setter Property="Height" Value="48" />
 | 
				
			||||||
 | 
					                        <Setter Property="BorderBrush" Value="white"/>
 | 
				
			||||||
 | 
					                        <Setter Property="BorderThickness" Value="0.6"/>
 | 
				
			||||||
 | 
					                    </Style>
 | 
				
			||||||
 | 
					                    <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
 | 
				
			||||||
 | 
					                        <Setter Property="HorizontalAlignment" Value="left" />
 | 
				
			||||||
 | 
					                        <Setter Property="Padding" Value="13" />
 | 
				
			||||||
 | 
					                    </Style>
 | 
				
			||||||
 | 
					                </DataGrid.Resources>
 | 
				
			||||||
 | 
					                <DataGrid.Columns>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <DataGridTextColumn Width="100"
 | 
				
			||||||
 | 
					                            Header="库位"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding Location}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="180"
 | 
				
			||||||
 | 
					                            Header="药品名称"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding DrugInfo.DrugName}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="180"
 | 
				
			||||||
 | 
					                            Header="规格"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding DrugInfo.DrugSpec}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                         />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="100"
 | 
				
			||||||
 | 
					                            Header="数量" 
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding Quantity}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="130"
 | 
				
			||||||
 | 
					                            Header="批次"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding ManuNo}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="130"
 | 
				
			||||||
 | 
					                            Header="效期"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding EffDate}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                    <DataGridTextColumn  Width="100"
 | 
				
			||||||
 | 
					                            Header="取出数量"
 | 
				
			||||||
 | 
					                            IsReadOnly="True"
 | 
				
			||||||
 | 
					                            Binding="{Binding TakeQuantity}"
 | 
				
			||||||
 | 
					                            ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
 | 
				
			||||||
 | 
					                            EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
 | 
					                </DataGrid.Columns>
 | 
				
			||||||
 | 
					            </DataGrid>
 | 
				
			||||||
 | 
					            <Grid Grid.Row="2">
 | 
				
			||||||
 | 
					                <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    <ColumnDefinition />
 | 
				
			||||||
 | 
					                    <ColumnDefinition />
 | 
				
			||||||
 | 
					                    <ColumnDefinition />
 | 
				
			||||||
 | 
					                </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Center">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <!--<Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
				
			||||||
 | 
					                            materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                            materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                            Content="取药"
 | 
				
			||||||
 | 
					                            Command="{Binding OpenDrawer}">
 | 
				
			||||||
 | 
					                    </Button>-->
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
				
			||||||
 | 
					                            materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                            materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                            Content="取药"
 | 
				
			||||||
 | 
					                            Command="{Binding OpenDrawer}">
 | 
				
			||||||
 | 
					                    </Button>
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
 | 
				
			||||||
 | 
					                            Content="完成"
 | 
				
			||||||
 | 
					                            Command="{Binding TakeFinish}"/>
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedButton}"
 | 
				
			||||||
 | 
					                            Background="Orange"
 | 
				
			||||||
 | 
					                            BorderBrush="Orange"
 | 
				
			||||||
 | 
					                            Content="取消"
 | 
				
			||||||
 | 
					                            Command="{Binding CancleTake}" />
 | 
				
			||||||
 | 
					                </StackPanel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					    </materialDesign:Card>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					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.Dialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// AddToJiaoJieDialog.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class AddToJiaoJieDialog : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public AddToJiaoJieDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue