104 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			104 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using DM_Weight.Models;
							 | 
						|||
| 
								 | 
							
								using DM_Weight.util;
							 | 
						|||
| 
								 | 
							
								using Prism.Commands;
							 | 
						|||
| 
								 | 
							
								using Prism.Mvvm;
							 | 
						|||
| 
								 | 
							
								using Prism.Regions;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Collections.ObjectModel;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace DM_Weight.ViewModels
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public class OperationTakeWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 处方明细
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        private ObservableCollection<OrderDetail> _orderDetails = new ObservableCollection<OrderDetail>();
							 | 
						|||
| 
								 | 
							
								        public ObservableCollection<OrderDetail> OrderDetails
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get { return _orderDetails; }
							 | 
						|||
| 
								 | 
							
								            set { SetProperty(ref _orderDetails, value); }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 药品集合
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        private ObservableCollection<DrugInfo> _drugInfos=new ObservableCollection<DrugInfo>();
							 | 
						|||
| 
								 | 
							
								        public ObservableCollection<DrugInfo> DrugInfos
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get { return _drugInfos; }
							 | 
						|||
| 
								 | 
							
								            set { SetProperty(ref _drugInfos, value); }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 加药按钮操作
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public DelegateCommand AddBtnCommand => new DelegateCommand(AddBtnAction);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public bool KeepAlive => false;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private void AddBtnAction()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            OrderDetail orderDetail = new OrderDetail();
							 | 
						|||
| 
								 | 
							
								            orderDetail.PatientId = "123";
							 | 
						|||
| 
								 | 
							
								            orderDetail.OrderNo = "123";
							 | 
						|||
| 
								 | 
							
								            List<DrugInfo> dgs= DrugInfos.ToList();
							 | 
						|||
| 
								 | 
							
								            orderDetail.DrugInfos = dgs;
							 | 
						|||
| 
								 | 
							
								            orderDetail.DrugInfo = dgs?[0];
							 | 
						|||
| 
								 | 
							
								            OrderDetails.Add(orderDetail);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public void RequestData()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            //List<OrderDetail> queryData = SqlSugarHelper.Db.Queryable<OrderDetail>()
							 | 
						|||
| 
								 | 
							
								            //    .Includes(cl => cl.DrugInfo, di => di.DrugManuNos)
							 | 
						|||
| 
								 | 
							
								            //    .Where(cl => cl.DrawerNo == DrawerNo)
							 | 
						|||
| 
								 | 
							
								            //    .Where(cl => cl.DrawerType == 1)
							 | 
						|||
| 
								 | 
							
								            //    .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
							 | 
						|||
| 
								 | 
							
								            //    .Where(cl => cl.DrugId != null)
							 | 
						|||
| 
								 | 
							
								            //    .OrderBy(cl => cl.ColNo)
							 | 
						|||
| 
								 | 
							
								            //    .ToList();
							 | 
						|||
| 
								 | 
							
								            //ChannelLsts = queryData.Select(cl =>
							 | 
						|||
| 
								 | 
							
								            //{
							 | 
						|||
| 
								 | 
							
								            //    cl.channelStocks = cl.channelStocks.Select(cs =>
							 | 
						|||
| 
								 | 
							
								            //    {
							 | 
						|||
| 
								 | 
							
								            //        cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
							 | 
						|||
| 
								 | 
							
								            //        return cs;
							 | 
						|||
| 
								 | 
							
								            //    }).ToList();
							 | 
						|||
| 
								 | 
							
								            //    return cl;
							 | 
						|||
| 
								 | 
							
								            //}).ToList();
							 | 
						|||
| 
								 | 
							
								            ////ChannelLsts = new ObservableCollection<ChannelList>(queryData);
							 | 
						|||
| 
								 | 
							
								            //ChannelLsts.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            DrugInfos=new ObservableCollection<DrugInfo>(SqlSugarHelper.Db.Queryable<DrugInfo>()
							 | 
						|||
| 
								 | 
							
								                .Includes(di=>di.DrugManuNos)
							 | 
						|||
| 
								 | 
							
								                .OrderBy(cl=>cl.DrugId).ToList());
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            
							 | 
						|||
| 
								 | 
							
								            
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            continuationCallback(true);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public void OnNavigatedTo(NavigationContext navigationContext)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            RequestData();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public bool IsNavigationTarget(NavigationContext navigationContext)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return true;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public void OnNavigatedFrom(NavigationContext navigationContext)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |