parent
							
								
									5f990b7fa4
								
							
						
					
					
						commit
						0bc3542281
					
				| 
						 | 
					@ -127,6 +127,13 @@ namespace DM_Weight
 | 
				
			||||||
            #region 取药
 | 
					            #region 取药
 | 
				
			||||||
            // 处方取药页面
 | 
					            // 处方取药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeDrugNewWindow, OrderTakeDrugNewWindowViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeAllDrugDialog, OrderTakeAllDrugDialogViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 处方取药模态框
 | 
					            // 处方取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
					            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -191,5 +191,8 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public int? MachineRecordId { get; set; }
 | 
					        public int? MachineRecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string OrderNos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -127,5 +127,17 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "use_dosage")]
 | 
					        [SugarColumn(ColumnName = "use_dosage")]
 | 
				
			||||||
        public string UseDosage { get; set; }
 | 
					        public string UseDosage { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[Navigate(NavigateType.ManyToOne, nameof(OrderNo))]
 | 
				
			||||||
 | 
					        //public OrderInfo _OrderInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string DrawerNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string ColNo { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					using DM_Weight.Models;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
using DM_Weight.util;
 | 
					using DM_Weight.util;
 | 
				
			||||||
using Prism.Commands;
 | 
					using Prism.Commands;
 | 
				
			||||||
using Prism.Events;
 | 
					using Prism.Events;
 | 
				
			||||||
| 
						 | 
					@ -15,6 +16,7 @@ using System.Reflection.PortableExecutable;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Channels;
 | 
					using System.Threading.Channels;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Threading;
 | 
				
			||||||
using static Unity.Storage.RegistrationSet;
 | 
					using static Unity.Storage.RegistrationSet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
| 
						 | 
					@ -23,7 +25,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Title => "空瓶销毁";
 | 
					        public string Title => "空瓶取出";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private List<MachineRecord> _machineRecords = new();
 | 
					        private List<MachineRecord> _machineRecords = new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,12 +56,66 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => _channelStock;
 | 
					            get => _channelStock;
 | 
				
			||||||
            set => SetProperty(ref _channelStock, value);
 | 
					            set => SetProperty(ref _channelStock, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					
 | 
				
			||||||
        public DestoryEmptyDialogViewModel(IEventAggregator eventAggregator)
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status; set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public DestoryEmptyDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg.WindowName == "DrawerTakeDrugWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                switch (msg.EventType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 抽屉打开
 | 
				
			||||||
 | 
					                    case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Status = 2;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 抽屉关闭
 | 
				
			||||||
 | 
					                    case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                        if (Status == 2)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Status = 3;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 数量变化
 | 
				
			||||||
 | 
					                    case EventType.UPDATEQUANTITY:
 | 
				
			||||||
 | 
					                        if (Status == 2)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _ChannelStock.TakeQuantity = msg.Quantitys[_ChannelStock.ColNo - 1];
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 打开失败
 | 
				
			||||||
 | 
					                    case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = msg.Message,
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
| 
						 | 
					@ -69,11 +125,13 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnDialogClosed()
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
            ChannelStock _record = parameters.GetValue<ChannelStock>("channel");
 | 
					            ChannelStock _record = parameters.GetValue<ChannelStock>("channel");
 | 
				
			||||||
            _ChannelStock = _record;
 | 
					            _ChannelStock = _record;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,6 +195,39 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public DelegateCommand DestoryEmptyCommand
 | 
					        public DelegateCommand DestoryEmptyCommand
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Status == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Status = 1;
 | 
				
			||||||
 | 
					                    //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //IEnumerable<string> strDrugName = _MachineRecords.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					                    //string strNames = string.Empty;
 | 
				
			||||||
 | 
					                    //foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                    //    {
 | 
				
			||||||
 | 
					                    //        strNames += name + ";";
 | 
				
			||||||
 | 
					                    //    }
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    int sumQuantity = _MachineRecords.FindAll(it => it.IsSelected).Sum(cs => cs.Quantity);
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开 {_ChannelStock.DrawerNo} 号抽屉,请取出空瓶 {_ChannelStock.DrugInfo.DrugName} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.WindowName = "DrawerTakeDrugWindow";
 | 
				
			||||||
 | 
					                    _portUtil.BoardType = _ChannelStock.BoardType;
 | 
				
			||||||
 | 
					                    _portUtil.ColNos=new int[] { _ChannelStock.ColNo };
 | 
				
			||||||
 | 
					                    _portUtil.DrawerNo = _ChannelStock.DrawerNo;
 | 
				
			||||||
 | 
					                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
 | 
				
			||||||
 | 
					                    ;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand TakeFinish {
 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                List<MachineRecord> records = _MachineRecords.FindAll(it => it.IsSelected).ToList();
 | 
					                List<MachineRecord> records = _MachineRecords.FindAll(it => it.IsSelected).ToList();
 | 
				
			||||||
| 
						 | 
					@ -146,12 +237,14 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        for (int i = 0; i < records.Count; i++)
 | 
					                        for (int i = 0; i < records.Count; i++)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            MachineRecord record= records[i];
 | 
					                            MachineRecord record = records[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            //修改库存数量
 | 
					                            //修改库存数量
 | 
				
			||||||
                            _ChannelStock.Quantity = _ChannelStock.Quantity - record.Quantity;
 | 
					                            _ChannelStock.Quantity = _ChannelStock.Quantity - record.Quantity;
 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(_ChannelStock).ExecuteCommand();
 | 
					                            SqlSugarHelper.Db.Updateable(_ChannelStock).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            //修改记录表中状态
 | 
					                            //修改记录表中状态
 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(record).ReSetValue(mr =>
 | 
					                            SqlSugarHelper.Db.Updateable(record).ReSetValue(mr =>
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
| 
						 | 
					@ -179,7 +272,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        RequestData();
 | 
					                        RequestData();
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Message = "销毁完成",
 | 
					                            Message = "取出完成",
 | 
				
			||||||
                            Type = MsgType.SUCCESS,
 | 
					                            Type = MsgType.SUCCESS,
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
| 
						 | 
					@ -189,7 +282,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Message = "销毁失败!",
 | 
					                            Message = "取出失败!",
 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
| 
						 | 
					@ -199,7 +292,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Message = "请选择要销毁的数据",
 | 
					                        Message = "请选择要取空瓶的数据",
 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,636 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					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.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OrderTakeAllDrugDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
				
			||||||
 | 
					        public string Title => "处方取药";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime
 | 
				
			||||||
 | 
					   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public OrderTakeAllDrugDialogViewModel(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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        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;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderInfo? _orderInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public OrderInfo? OrderInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _orderInfo;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _orderInfo, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderDetail> orderDetails { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderInfo> orderInfos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> _channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<ChannelStock> ChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _channelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _channelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Status == 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        string orderDate;
 | 
				
			||||||
 | 
					        OrderTakeSelect selectedItem;
 | 
				
			||||||
 | 
					        string? searchValue;
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            orderDate = parameters.GetValue<string>("OrderDate");
 | 
				
			||||||
 | 
					            selectedItem = parameters.GetValue<OrderTakeSelect>("SelectedItem");
 | 
				
			||||||
 | 
					            searchValue = parameters.GetValue<string>("SearchValue");
 | 
				
			||||||
 | 
					            //OrderInfo = o;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
				
			||||||
 | 
					                      .InnerJoin<OrderInfo>((od, oi) => oi.DmStatus == 0 && oi.HisDispFlag == 0 && oi.CancelFlag == 0 && od.OrderNo == oi.OrderNo)
 | 
				
			||||||
 | 
					                      .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, oi, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
 | 
					                      .WhereIF(orderDate != null, (od, oi) => oi.OrderDate.ToString("yyyy-MM-dd") == orderDate)
 | 
				
			||||||
 | 
					                      .WhereIF(!String.IsNullOrEmpty(searchValue) && selectedItem.Code.Equals("OrderNo"), (od, oi) => oi.OrderNo == searchValue)
 | 
				
			||||||
 | 
					                      .WhereIF(!String.IsNullOrEmpty(searchValue) && selectedItem.Code.Equals("PatientId"), (od, oi) => oi.PatientId == searchValue)
 | 
				
			||||||
 | 
					                      .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), (od, oi) => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
				
			||||||
 | 
					                      .Includes<DrugInfo>(od => od.DrugInfo)
 | 
				
			||||||
 | 
					                      .ToList();
 | 
				
			||||||
 | 
					                if (orderDetails == null || orderDetails.Count <= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "没有处方数据",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                IEnumerable<IGrouping<string, OrderDetail>> groupOrderDetails = orderDetails.GroupBy(it => it.DrugId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
				
			||||||
 | 
					                List<string> msg = new List<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                foreach (var orderGroup in groupOrderDetails)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    int quantity = orderGroup.Sum(it => it.Quantity);
 | 
				
			||||||
 | 
					                    foreach (var orderDetail in orderGroup)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        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"] ?? "DM3"))
 | 
				
			||||||
 | 
					                         .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
				
			||||||
 | 
					                         .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
				
			||||||
 | 
					                         .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
				
			||||||
 | 
					                         .OrderBy(cs => cs.EffDate)
 | 
				
			||||||
 | 
					                         .OrderBy(cs => cs.DrawerNo)
 | 
				
			||||||
 | 
					                         .ToList();
 | 
				
			||||||
 | 
					                        int total = HasQChannels.Sum(it => it.Quantity);
 | 
				
			||||||
 | 
					                        int TakeQ = 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;
 | 
				
			||||||
 | 
					                                    orderDetail.DrawerNo += stock.DrawerNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.ColNo += stock.ColNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.SetManuNo += stock.ManuNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.SetEffDate += stock.EffDate + ",";
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    stock.TakeQuantity = TakeQ;
 | 
				
			||||||
 | 
					                                    channelStocks.Add(stock);
 | 
				
			||||||
 | 
					                                    TakeQ = 0;
 | 
				
			||||||
 | 
					                                    orderDetail.DrawerNo += stock.DrawerNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.ColNo += stock.ColNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.SetManuNo += stock.ManuNo + ",";
 | 
				
			||||||
 | 
					                                    orderDetail.SetEffDate += stock.EffDate + ",";
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            msg.Add($"药品【{orderDetail.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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"处方取药异常:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name + ";";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (orderDetails == null || orderDetails.Count <= 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "没有处方数据",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    IEnumerable<IGrouping<string, OrderDetail>> enumerableOrderDetails = orderDetails.GroupBy(it => it.OrderNo);
 | 
				
			||||||
 | 
					                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        for (int i = 0; i < ChannelStocks.Count; i++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            ChannelStock it = ChannelStocks[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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        foreach (var orderGroup in enumerableOrderDetails)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            int iQuantity = 0;
 | 
				
			||||||
 | 
					                            foreach (var orderDetail in orderGroup)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                OrderInfo orderInfo = SqlSugarHelper.Db.Queryable<OrderInfo>().Where(oi => oi.OrderNo == orderDetail.OrderNo).First();
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    DmStatus = 1,
 | 
				
			||||||
 | 
					                                    OrderNo = orderDetail.OrderNo
 | 
				
			||||||
 | 
					                                }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    OrderNo = orderDetail.OrderNo,
 | 
				
			||||||
 | 
					                                    PatientId = orderDetail.PatientId,
 | 
				
			||||||
 | 
					                                    Pharmacy = orderInfo.Pharmacy,
 | 
				
			||||||
 | 
					                                    State = 1,
 | 
				
			||||||
 | 
					                                    Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                                //查询药品对应库存表的库位及批次、效期信息
 | 
				
			||||||
 | 
					                                List<ChannelStock> stockList= ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId).OrderBy(cs=>cs.EffDate).ToList();
 | 
				
			||||||
 | 
					                                int iOrderDetailQuantity = -1;
 | 
				
			||||||
 | 
					                                string manuNo = string.Empty;
 | 
				
			||||||
 | 
					                                string effDate = string.Empty;
 | 
				
			||||||
 | 
					                                int drawerNo = 0;
 | 
				
			||||||
 | 
					                                int colNo = 0;
 | 
				
			||||||
 | 
					                                if (stockList.Count> 1)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    iOrderDetailQuantity = orderDetail.Quantity;
 | 
				
			||||||
 | 
					                                    for (int i = 0; i < stockList.Count; i++)
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        if (iOrderDetailQuantity>0&&stockList[i].Quantity- iOrderDetailQuantity > 0)
 | 
				
			||||||
 | 
					                                        {
 | 
				
			||||||
 | 
					                                            stockList[i].Quantity = stockList[i].Quantity - iOrderDetailQuantity;
 | 
				
			||||||
 | 
					                                            break;
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                        else
 | 
				
			||||||
 | 
					                                        {
 | 
				
			||||||
 | 
					                                            iOrderDetailQuantity = iOrderDetailQuantity - stockList[i].Quantity;
 | 
				
			||||||
 | 
					                                            stockList[i].Quantity = 0;
 | 
				
			||||||
 | 
					                                            if(iOrderDetailQuantity==0)
 | 
				
			||||||
 | 
					                                            {
 | 
				
			||||||
 | 
					                                                manuNo = stockList[i].ManuNo;
 | 
				
			||||||
 | 
					                                                effDate = stockList[i].EffDate;
 | 
				
			||||||
 | 
					                                                drawerNo = stockList[i].DrawerNo;
 | 
				
			||||||
 | 
					                                                colNo= stockList[i].ColNo;
 | 
				
			||||||
 | 
					                                                break;
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                ChannelStock cs = null;
 | 
				
			||||||
 | 
					                                if (iOrderDetailQuantity==0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    cs = ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId && cs.ManuNo == manuNo&&cs.EffDate==effDate&&cs.DrawerNo==drawerNo&&cs.ColNo==colNo).OrderBy(cs => cs.EffDate).FirstOrDefault();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    cs = ChannelStocks.Where(cs => cs.DrugId == orderDetail.DrugId && cs.Quantity > 0).OrderBy(cs => cs.EffDate).FirstOrDefault();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                               
 | 
				
			||||||
 | 
					                                if (cs != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                        DrawerNo = cs.DrawerNo,
 | 
				
			||||||
 | 
					                                        ColNo = cs.ColNo,
 | 
				
			||||||
 | 
					                                        DrugId = cs.DrugId,
 | 
				
			||||||
 | 
					                                        ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                        EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                        Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                        Quantity = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                        Type = 2,
 | 
				
			||||||
 | 
					                                        InvoiceId = orderDetail.OrderNo
 | 
				
			||||||
 | 
					                                        //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                //保存账册
 | 
				
			||||||
 | 
					                                int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
				
			||||||
 | 
					                                    Type = 2,
 | 
				
			||||||
 | 
					                                    Department = orderInfo.DeptName,
 | 
				
			||||||
 | 
					                                    OrderNo = orderDetail.OrderNo,
 | 
				
			||||||
 | 
					                                    ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                    OutQuantity = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                    MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                    CreateTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                    InvoiceNo = orderDetail.OrderNo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                                AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                                .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
				
			||||||
 | 
					                                .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                                .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId))
 | 
				
			||||||
 | 
					                                .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
				
			||||||
 | 
					                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                                if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - orderDetail.Quantity;
 | 
				
			||||||
 | 
					                                    SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                                    int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
				
			||||||
 | 
					                                        Type = 3,
 | 
				
			||||||
 | 
					                                        ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                        EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                        YQuantity = 0,
 | 
				
			||||||
 | 
					                                        ManuStock = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                        TotalStock = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                        InvoiceNo = "日结存"
 | 
				
			||||||
 | 
					                                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                    if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        logger.Info($"未写入日结存数据{orderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                                AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                                .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
				
			||||||
 | 
					                                .Where(ab => ab.Type == 4)
 | 
				
			||||||
 | 
					                                .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId))
 | 
				
			||||||
 | 
					                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                                if (accountBookG2Total != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - orderDetail.Quantity;
 | 
				
			||||||
 | 
					                                    SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
				
			||||||
 | 
					                                    int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        DrugId = Convert.ToInt32(orderDetail.DrugId),
 | 
				
			||||||
 | 
					                                        Type = 4,
 | 
				
			||||||
 | 
					                                        YQuantity = 0,
 | 
				
			||||||
 | 
					                                        ManuStock = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                        TotalStock = orderDetail.Quantity,
 | 
				
			||||||
 | 
					                                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                        InvoiceNo = "总结存"
 | 
				
			||||||
 | 
					                                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                    if (iTotalResult <= 0)
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        logger.Info($"未写入总结存数据{orderDetail.DrugId}-{orderDetail.Quantity}");
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return true;
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    if (f.Data)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 更新屏显库存
 | 
				
			||||||
 | 
					                        List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType == 5);
 | 
				
			||||||
 | 
					                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            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 DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Status != 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _portUtil.ResetData();
 | 
				
			||||||
 | 
					                    Status = 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //DialogParameters parameters = new DialogParameters();
 | 
				
			||||||
 | 
					                //parameters.Add("",);
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,295 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					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.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OrderTakeDrugNewWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private int _pageNum = 1;
 | 
				
			||||||
 | 
					        public int PageNum
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageNum;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageNum, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _pageCount = 1;
 | 
				
			||||||
 | 
					        public int PageCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageCount;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageCount, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _pageSize = 8;
 | 
				
			||||||
 | 
					        public int PageSize
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageSize;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageSize, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _totalCount = 0;
 | 
				
			||||||
 | 
					        public int TotalCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _totalCount;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _totalCount, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DelegateCommand _rowSelected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public OrderTakeDrugNewWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "OrderNo",
 | 
				
			||||||
 | 
					                Name = "处方号"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "PatientId",
 | 
				
			||||||
 | 
					                Name = "患者编号"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<OrderTakeSelect> OrderTakeSelects
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _orderTakeSelects; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _orderTakeSelects, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public OrderTakeSelect SelectedItem
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedItem; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedItem, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderInfo? _selectedOrder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public OrderInfo? SelectedOrder
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedOrder; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedOrder, value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //OpenOrderDialog();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件  处方日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string OrderDate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _orderDate; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!String.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderInfo> _orderInfos = new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public async void OpenOrderDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 此处延时1毫秒,等待页面渲染
 | 
				
			||||||
 | 
					                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeNewDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            //if(dialogResult.Result == ButtonResult.OK)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            SelectedOrder = null;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //取药按钮事件
 | 
				
			||||||
 | 
					        public DelegateCommand TakeDrug
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => {
 | 
				
			||||||
 | 
					                if(OrderInfos is null|| OrderInfos.Count<=0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "没有处方数据",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    return;                
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("OrderDate", OrderDate);
 | 
				
			||||||
 | 
					                dialogParameters.Add("SelectedItem", SelectedItem);
 | 
				
			||||||
 | 
					                dialogParameters.Add("SearchValue", SearchValue);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeAllDrugDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OrderInfos.Clear();
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            //string SearchValue = null;
 | 
				
			||||||
 | 
					            //if (SearchValue != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
				
			||||||
 | 
					                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
				
			||||||
 | 
					                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
 | 
					                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
				
			||||||
 | 
					                .Where(oi => oi.DmStatus == 0)
 | 
				
			||||||
 | 
					                .Where(oi => oi.HisDispFlag == 0)
 | 
				
			||||||
 | 
					                .Where(oi => oi.CancelFlag == 0)
 | 
				
			||||||
 | 
					                .Where(oi => oi.Pharmacy.Equals(ConfigurationManager.AppSettings["storage"] ?? ""))
 | 
				
			||||||
 | 
					                .GroupBy(oi => oi.OrderDate)
 | 
				
			||||||
 | 
					                .Select(oi => oi)
 | 
				
			||||||
 | 
					                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					            //.ToList();
 | 
				
			||||||
 | 
					            OrderInfos = queryData;
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg.EventType == EventType.CODESCAN)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SearchValue = msg.Code;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,185 @@
 | 
				
			||||||
 | 
					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 OrderTakeNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
				
			||||||
 | 
					        public string Title => "处方取药";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime
 | 
				
			||||||
 | 
					   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public OrderTakeNewDialogViewModel(IDialogService DialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status; set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderInfo? _orderInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public OrderInfo? OrderInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _orderInfo;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _orderInfo, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderDetail> orderDetails { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> _channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<ChannelStock> ChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _channelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _channelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Status == 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
				
			||||||
 | 
					            OrderInfo = o;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
				
			||||||
 | 
					                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
 | 
					                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
				
			||||||
 | 
					            List<string> msg = new List<string>();
 | 
				
			||||||
 | 
					            for (int i = 0; i < orderDetails.Count; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                OrderDetail orderDetail = orderDetails[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"] ?? "DM3"))
 | 
				
			||||||
 | 
					                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
				
			||||||
 | 
					                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
				
			||||||
 | 
					                    .OrderBy(cs => cs.EffDate)
 | 
				
			||||||
 | 
					                    .OrderBy(cs => cs.DrawerNo)
 | 
				
			||||||
 | 
					                    .ToList();
 | 
				
			||||||
 | 
					                int total = HasQChannels.Sum(it => it.Quantity);
 | 
				
			||||||
 | 
					                int TakeQ = orderDetail.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($"药品【{orderDetail.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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _isFinishClick = false;
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        public long CurrentTimeMillis()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Status != 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Status = 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //DialogParameters parameters = new DialogParameters();
 | 
				
			||||||
 | 
					                //parameters.Add("",);
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -165,11 +165,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionImage = "/Images/TbQyao.png",
 | 
					                PremissionImage = "/Images/TbQyao.png",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
 | 
					            ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					            //PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "处方取药",
 | 
				
			||||||
 | 
					            //    PremissionPath = "OrderTakeDrugWindow",
 | 
				
			||||||
 | 
					            //};  
 | 
				
			||||||
            PremissionDm quyao1 = new PremissionDm
 | 
					            PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 11,
 | 
					                Id = 11,
 | 
				
			||||||
                PremissionName = "处方取药",
 | 
					                PremissionName = "处方取药",
 | 
				
			||||||
                PremissionPath = "OrderTakeDrugWindow",
 | 
					                PremissionPath = "OrderTakeDrugNewWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            PremissionDm quyao2 = new PremissionDm
 | 
					            PremissionDm quyao2 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -306,18 +312,18 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionName = "归还药品",
 | 
					                PremissionName = "归还药品",
 | 
				
			||||||
                PremissionPath = "ReturnDrugWindow2",
 | 
					                PremissionPath = "ReturnDrugWindow2",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            PremissionDm huanyao2 = new PremissionDm
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Id = 32,
 | 
					 | 
				
			||||||
                PremissionName = "归还空瓶",
 | 
					 | 
				
			||||||
                PremissionPath = "ReturnEmptyWindow",
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
            //PremissionDm huanyao2 = new PremissionDm
 | 
					            //PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
            //{
 | 
					            //{
 | 
				
			||||||
            //    Id = 32,
 | 
					            //    Id = 32,
 | 
				
			||||||
            //    PremissionName = "空瓶销毁",
 | 
					            //    PremissionName = "归还空瓶",
 | 
				
			||||||
            //    PremissionPath = "ReturnEmptyDestoryWindow",
 | 
					            //    PremissionPath = "ReturnEmptyWindow",
 | 
				
			||||||
            //};
 | 
					            //};
 | 
				
			||||||
 | 
					            PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 32,
 | 
				
			||||||
 | 
					                PremissionName = "空瓶取出",
 | 
				
			||||||
 | 
					                PremissionPath = "ReturnEmptyDestoryWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
            PremissionDm huanyao3 = new PremissionDm
 | 
					            PremissionDm huanyao3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 33,
 | 
					                Id = 33,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,10 @@
 | 
				
			||||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
				
			||||||
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
					             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
             mc:Ignorable="d"
 | 
					             mc:Ignorable="d"
 | 
				
			||||||
             d:DesignHeight="450" d:DesignWidth="800">
 | 
					              MinWidth="880"
 | 
				
			||||||
 | 
					             MaxHeight="500"
 | 
				
			||||||
 | 
					             Width="Auto"
 | 
				
			||||||
 | 
					             Height="Auto">
 | 
				
			||||||
    <UserControl.Resources>
 | 
					    <UserControl.Resources>
 | 
				
			||||||
        <convert:StatusConverter x:Key="StatusConverter" />
 | 
					        <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
        <convert:InputQuantityConverter x:Key="InputQuantityConverter" />
 | 
					        <convert:InputQuantityConverter x:Key="InputQuantityConverter" />
 | 
				
			||||||
| 
						 | 
					@ -33,7 +36,7 @@
 | 
				
			||||||
            <Grid.RowDefinitions>
 | 
					            <Grid.RowDefinitions>
 | 
				
			||||||
                <RowDefinition Height="Auto" />
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
                <RowDefinition Height="50" />
 | 
					                <RowDefinition Height="50" />
 | 
				
			||||||
                <RowDefinition Height="Auto" />
 | 
					                <RowDefinition Height="5*" />
 | 
				
			||||||
                <RowDefinition Height="Auto" />
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
            </Grid.RowDefinitions>
 | 
					            </Grid.RowDefinitions>
 | 
				
			||||||
            <Grid Background="#03a9f4" Grid.Row="0">
 | 
					            <Grid Background="#03a9f4" Grid.Row="0">
 | 
				
			||||||
| 
						 | 
					@ -108,7 +111,7 @@
 | 
				
			||||||
                      VerticalAlignment="Center"
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
                      HorizontalAlignment="Right"
 | 
					                      HorizontalAlignment="Right"
 | 
				
			||||||
                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
                      Text="可销毁空瓶数:" />
 | 
					                      Text="可取空瓶数:" />
 | 
				
			||||||
                <TextBlock
 | 
					                <TextBlock
 | 
				
			||||||
                      Grid.Column="7"
 | 
					                      Grid.Column="7"
 | 
				
			||||||
                      Margin="16 0 16 8"
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
| 
						 | 
					@ -118,7 +121,7 @@
 | 
				
			||||||
                      Text="{Binding _ChannelStock.Quantity}" />
 | 
					                      Text="{Binding _ChannelStock.Quantity}" />
 | 
				
			||||||
            </Grid>
 | 
					            </Grid>
 | 
				
			||||||
            <ListView
 | 
					            <ListView
 | 
				
			||||||
                Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Auto"
 | 
					                Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Visible"
 | 
				
			||||||
                ItemsSource="{Binding _MachineRecords}"
 | 
					                ItemsSource="{Binding _MachineRecords}"
 | 
				
			||||||
                SelectedItem="{Binding _MachineRecord}"
 | 
					                SelectedItem="{Binding _MachineRecord}"
 | 
				
			||||||
                materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
					                materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
				
			||||||
| 
						 | 
					@ -177,17 +180,31 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <Button
 | 
					                    <Button
 | 
				
			||||||
                            Margin="2"
 | 
					                            Margin="2"
 | 
				
			||||||
                            Style="{StaticResource MaterialDesignRaisedAccentButton}"                           
 | 
					                            Style="{StaticResource MaterialDesignOutlinedLightButton}"           
 | 
				
			||||||
                            Content="销毁"
 | 
					                            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 DestoryEmptyCommand}">
 | 
					                            Command="{Binding DestoryEmptyCommand}">
 | 
				
			||||||
                    </Button>
 | 
					                    </Button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding TakeFinish}"
 | 
				
			||||||
 | 
					                    Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="完成" />
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
                    <Button
 | 
					                    <Button
 | 
				
			||||||
                            Margin="2"
 | 
					                            Margin="2"
 | 
				
			||||||
                            Style="{StaticResource MaterialDesignRaisedButton}"
 | 
					                            Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
                            Background="Orange"
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
				
			||||||
                            BorderBrush="Orange"
 | 
					 | 
				
			||||||
                            Content="取消"
 | 
					                            Content="取消"
 | 
				
			||||||
                            Command="{Binding CancleTake}" />
 | 
					                            Command="{Binding CancleTake}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                </StackPanel>
 | 
					                </StackPanel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            </Grid>
 | 
					            </Grid>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,150 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.Dialog.OrderTakeAllDrugDialog"
 | 
				
			||||||
 | 
					             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" MinHeight="500"
 | 
				
			||||||
 | 
					             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>
 | 
				
			||||||
 | 
					    /// OrderTakeAllDrugDialog.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class OrderTakeAllDrugDialog : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public OrderTakeAllDrugDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,178 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.Dialog.OrderTakeNewDialog"
 | 
				
			||||||
 | 
					               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="50" />
 | 
				
			||||||
 | 
					                <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>
 | 
				
			||||||
 | 
					            <Grid Grid.Row="1">
 | 
				
			||||||
 | 
					                <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="3*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="*" />
 | 
				
			||||||
 | 
					                </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="0"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="处方号:" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="1"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Left"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="{Binding OrderInfo.OrderNo}" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="2"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="患者姓名:" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="3"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Left"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="{Binding OrderInfo.PName}" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="4"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="性别:" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="5"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Left"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="{Binding OrderInfo.Sex}" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="6"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="年龄:" />
 | 
				
			||||||
 | 
					                <TextBlock
 | 
				
			||||||
 | 
					                      Grid.Column="7"
 | 
				
			||||||
 | 
					                      Margin="16 0 16 8"
 | 
				
			||||||
 | 
					                      VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                      HorizontalAlignment="Left"
 | 
				
			||||||
 | 
					                      Style="{StaticResource MaterialDesignBody2TextBlock}"
 | 
				
			||||||
 | 
					                      Text="{Binding OrderInfo.Age}" />
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					            <DataGrid Grid.Row="2" 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>
 | 
				
			||||||
 | 
					    </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>
 | 
				
			||||||
 | 
					    /// OrderTakeNewDialog.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class OrderTakeNewDialog : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public OrderTakeNewDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,152 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.OrderTakeDrugNewWindow"
 | 
				
			||||||
 | 
					            xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
 | 
					             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:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             mc:Ignorable="d">
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <convert:OrderStatusConverter x:Key="OrderStatusConverter" />
 | 
				
			||||||
 | 
					        <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
 | 
					        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
				
			||||||
 | 
					            <Style.Setters>
 | 
				
			||||||
 | 
					                <Setter Property="Height">
 | 
				
			||||||
 | 
					                    <Setter.Value>55</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Background">
 | 
				
			||||||
 | 
					                    <Setter.Value>#31ccec</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Foreground">
 | 
				
			||||||
 | 
					                    <Setter.Value>white</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					            </Style.Setters>
 | 
				
			||||||
 | 
					        </Style>
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					            <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="1.5*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="4.5*"/>
 | 
				
			||||||
 | 
					            </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					            <ComboBox
 | 
				
			||||||
 | 
					                Grid.Column="0"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
				
			||||||
 | 
					                SelectedItem="{Binding SelectedItem}"
 | 
				
			||||||
 | 
					                DisplayMemberPath="Name"
 | 
				
			||||||
 | 
					                ItemsSource="{Binding OrderTakeSelects}"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					            <TextBox
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                Text="{Binding SearchValue, UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.IsFloating="True"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					            <DatePicker
 | 
				
			||||||
 | 
					                Grid.Column="2"
 | 
				
			||||||
 | 
					                SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                SelectedDateFormat="Short"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="开方日期"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
				
			||||||
 | 
					            <!--<Grid
 | 
				
			||||||
 | 
					                Grid.Column="3">
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                    Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding QueryCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    ToolTip="刷新" Cursor="Hand" Click="Button_Click">
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon
 | 
				
			||||||
 | 
					                    Kind="Refresh" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </Grid>-->
 | 
				
			||||||
 | 
					            <StackPanel  Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding TakeDrug}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="取药" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                    Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding QueryCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    ToolTip="刷新" Cursor="Hand">
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon
 | 
				
			||||||
 | 
					                    Kind="Refresh" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </StackPanel>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <ListView
 | 
				
			||||||
 | 
					            Grid.Row="1"  Grid.ColumnSpan="3"
 | 
				
			||||||
 | 
					            ItemsSource="{Binding OrderInfos}"
 | 
				
			||||||
 | 
					            SelectedItem="{Binding SelectedOrder}"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec">
 | 
				
			||||||
 | 
					            <!--<ListView.Resources>
 | 
				
			||||||
 | 
					                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
				
			||||||
 | 
					                    <Setter Property="Foreground" Value="White" />
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					                </ListView.Resources>-->
 | 
				
			||||||
 | 
					            <i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                <i:EventTrigger EventName="SelectionChanged">
 | 
				
			||||||
 | 
					                    <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
				
			||||||
 | 
					                </i:EventTrigger>
 | 
				
			||||||
 | 
					            </i:Interaction.Triggers>
 | 
				
			||||||
 | 
					            <ListView.ItemContainerStyle>
 | 
				
			||||||
 | 
					                <Style TargetType="ListViewItem" BasedOn="{StaticResource MaterialDesignGridViewItem}">
 | 
				
			||||||
 | 
					                    <Setter Property="ListView.Height" Value="50"/>
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					            </ListView.ItemContainerStyle>
 | 
				
			||||||
 | 
					            <ListView.View>
 | 
				
			||||||
 | 
					                <GridView ColumnHeaderContainerStyle="{StaticResource st}" >
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        Header="患者ID"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding PatientId}"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        Header="姓名"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding PName}" />
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Sex}"
 | 
				
			||||||
 | 
					                        Header="性别"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Age}"
 | 
				
			||||||
 | 
					                        Header="年龄"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding IdNumber}"
 | 
				
			||||||
 | 
					                        Header="身份证"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OrderNo}"
 | 
				
			||||||
 | 
					                        Header="处方号"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DeptName}"
 | 
				
			||||||
 | 
					                        Header="科室"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DmStatus, Converter={StaticResource OrderStatusConverter}}"
 | 
				
			||||||
 | 
					                        Header="状态"/>
 | 
				
			||||||
 | 
					                </GridView>
 | 
				
			||||||
 | 
					            </ListView.View>
 | 
				
			||||||
 | 
					        </ListView>
 | 
				
			||||||
 | 
					        <pagination:Pagination Grid.Row="2" Grid.ColumnSpan="3"
 | 
				
			||||||
 | 
					                                   CurrentPage="{Binding PageNum}"
 | 
				
			||||||
 | 
					                                   PageSize="{Binding PageSize}"
 | 
				
			||||||
 | 
					                                   TotalPages="{Binding TotalCount}"
 | 
				
			||||||
 | 
					                                   InfoTextIsEnabel="True"
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// OrderTakeDrugNewWindow.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class OrderTakeDrugNewWindow : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public OrderTakeDrugNewWindow()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue