diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 5f7b376..d5eed5b 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -51,8 +51,6 @@
-->
-
-
@@ -62,5 +60,8 @@
+
+
+
\ No newline at end of file
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index e080d97..fb5455e 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -154,6 +154,9 @@ namespace DM_Weight
#region 取药
+ // 多处方取药页面
+ containerRegistry.RegisterForNavigation();
+ containerRegistry.RegisterForNavigation();
// 处方取药页面
containerRegistry.RegisterForNavigation();
// 处方取药模态框
diff --git a/DM_Weight/Models/OrderDepartment.cs b/DM_Weight/Models/OrderDepartment.cs
new file mode 100644
index 0000000..ce3cbd7
--- /dev/null
+++ b/DM_Weight/Models/OrderDepartment.cs
@@ -0,0 +1,16 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ public class OrderDepartment : BindableBase
+ {
+ //科室
+ public string _deptName="全部";
+ public string DeptName { get=>_deptName; set { SetProperty(ref _deptName, value); } }
+ }
+}
diff --git a/DM_Weight/Models/OrderInfo.cs b/DM_Weight/Models/OrderInfo.cs
index eabac86..5abbed2 100644
--- a/DM_Weight/Models/OrderInfo.cs
+++ b/DM_Weight/Models/OrderInfo.cs
@@ -10,6 +10,12 @@ namespace DM_Weight.Models
[SugarTable("order_info")]
public class OrderInfo
{
+ ///
+ /// 是否选中
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public bool ItemIsChecked { get; set; }
+
///
///
/////
diff --git a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
new file mode 100644
index 0000000..ccd3e7e
--- /dev/null
+++ b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
@@ -0,0 +1,488 @@
+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 SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace DM_Weight.ViewModels
+{
+ public class MultiOrderTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
+ {
+ private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
+ public string Title => "多处方取药";
+
+
+ public event Action RequestClose;
+
+ private static readonly DateTime Jan1st1970 = new DateTime
+ (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+ IDialogService _dialogService;
+ public MultiOrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
+ {
+ _dialogService = DialogService;
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+
+ void DoMyPrismEvent(DeviceMsg msg)
+ {
+
+ if (msg.WindowName == "OrderTakeDrugWindow")
+ {
+ IGrouping grouping = enumerator.Current;
+ int DrawerNo = grouping.Key;
+ List 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 groupingBefore = enumerator.Current;
+ int DrawerNoBefore = groupingBefore.Key;
+ if (enumerator.MoveNext())
+ {
+ IGrouping 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().Publish(alertMsg);
+ Status = 0;
+ break;
+ }
+ }
+
+ }
+
+ private int _status = 0;
+
+ public int Status
+ {
+ get => _status; set => SetProperty(ref _status, value);
+ }
+
+ //多处方的处方号
+ private string _multiOrderNo = "处方号:";
+ public string MultiOrderNo
+ {
+ get => _multiOrderNo;
+ set => SetProperty(ref _multiOrderNo, value);
+ }
+ private ObservableCollection? _orderInfo;
+
+
+ public ObservableCollection? OrderInfo
+ {
+ get => _orderInfo;
+ set => SetProperty(ref _orderInfo, value);
+ }
+
+ private List orderDetails { get; set; }
+
+ private List _channelStocks;
+
+ public List ChannelStocks
+ {
+ get => _channelStocks;
+ set => SetProperty(ref _channelStocks, value);
+ }
+
+ private IEnumerable> enumerable;
+ private IEnumerator> enumerator;
+
+
+ public bool CanCloseDialog()
+ {
+ return Status == 0;
+ }
+
+ public void OnDialogClosed()
+ {
+ // 取消消息订阅
+ _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ }
+
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ OrderInfo = parameters.GetValue>("orderInfo");
+ MultiOrderNo += string.Join(", ", OrderInfo.Select(o => o.OrderNo));
+ RequestData();
+ }
+
+ public async void RequestData()
+ {
+ orderDetails = SqlSugarHelper.Db.Queryable()
+ //.Includes(od => od.DrugInfo)
+ .InnerJoin(SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
+ .Where(od => OrderInfo.Select(o => o.OrderNo).Contains(od.OrderNo)).GroupBy(od=>od.DrugId)
+
+ .Select(od=>new OrderDetail { DrugId=od.DrugId,SetEffDate=od.SetEffDate,SetManuNo=od.SetManuNo, Quantity=SqlFunc.AggregateSum(od.Quantity) })
+
+ //.Where(od => od.OrderNo. OrderInfo.OrderNo)
+ .ToList();
+
+
+ List channelStocks = new List();
+ List msg = new List();
+ for (int i = 0; i < orderDetails.Count; i++)
+ {
+ OrderDetail orderDetail = orderDetails[i];
+
+ List HasQChannels = SqlSugarHelper.Db.Queryable()
+ .Includes(cs => cs.DrugInfo)
+ .Where(cs => cs.Quantity > 0)
+ .Where(cs => cs.DrawerType == 1)
+ .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ .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;
+ int multiTakeQ = orderDetail.Quantity;
+ List multiTake = new List();
+ //multiTakeQ = orderDetails.Where(c => c.DrugId == orderDetail.DrugId).Sum(c => c.Quantity);
+ // 说明数量足够
+ if (total >= multiTakeQ)
+ {
+ for (int j = 0; TakeQ > 0; j++)
+ {
+ ChannelStock stock = HasQChannels[j];
+
+ if (TakeQ > stock.Quantity)
+ {
+
+ //#region 存在该库存且库存数量大于待取数量则把取药数量加上
+ //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
+ //if (varChannelStock != null && varChannelStock.Count > 0)
+ //{
+ // channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
+ // break;
+ //}
+ //#endregion
+ stock.TakeQuantity = stock.Quantity;
+ channelStocks.Add(stock);
+ TakeQ -= stock.Quantity;
+ }
+ else
+ {
+
+ //#region 存在该库存且库存数量大于待取数量则把取药数量加上
+ //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
+ //if (varChannelStock != null && varChannelStock.Count > 0)
+ //{
+ // channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
+ // break;
+ //}
+ //#endregion
+ stock.TakeQuantity = TakeQ;
+ channelStocks.Add(stock);
+ TakeQ = 0;
+ }
+ }
+ }
+ else
+ {
+ //msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
+ msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
+ }
+ }
+ if (msg.Count > 0)
+ {
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ //MessageBox.Show(string.Join("\n", msg));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("msgInfo", msg);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
+
+ }
+ else
+ {
+ channelStocks.Sort((a, b) =>
+ {
+ if ((a.DrawerNo - b.DrawerNo) == 0)
+ {
+ return a.ColNo - b.ColNo;
+ }
+ return a.DrawerNo - b.DrawerNo;
+ });
+ ChannelStocks = channelStocks;
+
+
+ }
+ }
+ public DelegateCommand OpenDrawer
+ {
+ get => new DelegateCommand(async () =>
+ {
+ if (Status == 0)
+ {
+ enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
+ enumerator = enumerable.GetEnumerator();
+ enumerator.MoveNext();
+ Status = 1;
+ OpenOneByOne();
+ }
+
+ });
+ }
+
+ private void OpenOneByOne()
+ {
+ IGrouping grouping = enumerator.Current;
+ int DrawerNo = grouping.Key;
+ List channelStocks = grouping.ToList();
+ channelStocks.ForEach(it => it.process = 1);
+ _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
+
+
+ List 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().Publish(alertMsg);
+ }
+ });
+
+ _portUtil.WindowName = "OrderTakeDrugWindow";
+ _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
+ _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
+ _portUtil.DrawerNo = DrawerNo;
+ _portUtil.Start();
+ }
+
+ private bool _isFinishClick = false;
+ // 完成按钮
+ public DelegateCommand TakeFinish
+ {
+ get => new DelegateCommand(() =>
+ {
+ if (!_isFinishClick)
+ {
+ _isFinishClick = true;
+ List record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
+
+ //根据处方单数量分别更新处方状态、写记录信息
+ if (OrderInfo.Count > 0)
+ {
+
+ for (int j = 0; j < OrderInfo.Count; j++)
+ {
+ string InvoiceId = OrderInfo[j].OrderNo;
+ var f = SqlSugarHelper.Db.UseTran(() =>
+ {
+ //SqlSugarHelper.Db.Updateable(new OrderInfo()
+ //{
+ // DmStatus = 1,
+ // OrderNo = OrderInfo[j].OrderNo
+ //}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
+
+ SqlSugarHelper.Db.Insertable(new OrderFinish()
+ {
+ OrderNo = OrderInfo[j].OrderNo,
+ PatientId = OrderInfo[j].PatientId,
+ Pharmacy = OrderInfo[j].Pharmacy,
+ State = 1,
+ Operator = HomeWindowViewModel.Operator?.Nickname,
+ });
+ for (int i = 0; i < record.Count; i++)
+ {
+
+ List orderDet = SqlSugarHelper.Db.Queryable().Where(od => od.OrderNo == OrderInfo[j].OrderNo && od.DrugId == record[i].DrugId).ToList();
+ //该对方没有这个药,跳出循环
+ if (orderDet == null || orderDet.Count <= 0)
+ continue;
+ int orderTakeQuantity = orderDet[0].Quantity;
+ ChannelStock it = record[i];
+ // 更新数据 库存信息
+ SqlSugarHelper.Db.Updateable(new ChannelStock()
+ {
+ Quantity = it.Quantity - it.TakeQuantity,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
+ Id = it.Id,
+ }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
+ // 获取更新完库存后的药品库存
+ List nowChannels = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId.Equals(it.MachineId))
+ .Where(cs => cs.DrugId.Equals(it.DrugId))
+ .Where(cs => cs.DrawerType == 1)
+ .ToList();
+
+ // 保存数据 出库记录
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = it.MachineId,
+ DrawerNo = it.DrawerNo,
+ ColNo = it.ColNo,
+ DrugId = it.DrugId,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ OperationTime = DateTime.Now,
+ Quantity = orderTakeQuantity,
+ Type = 2,
+ InvoiceId = InvoiceId
+ //,StockQuantity = nowChannels.Sum(it => it.Quantity)
+ }).ExecuteCommand();
+ }
+ //更新处方状态
+ SqlSugarHelper.Db.Updateable(new OrderInfo()
+ {
+ DmStatus = 1,
+ OrderNo = OrderInfo[j].OrderNo
+ }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
+ return true;
+ });
+ if (f.Data)
+ {
+
+
+ //});
+ // 更新屏显库存
+ List singleChannels = record.FindAll(it => it.BoardType != 1);
+ 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().Publish(alertMsg);
+ }
+ if (!f.IsSuccess)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "抽屉取药完成,库存更新失败!",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ Status = 0;
+ _isFinishClick = false;
+ //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ }
+ }
+
+ });
+ }
+
+ 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;
+ }
+}
diff --git a/DM_Weight/ViewModels/MultiOrderTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/MultiOrderTakeDrugWindowViewModel.cs
new file mode 100644
index 0000000..811d242
--- /dev/null
+++ b/DM_Weight/ViewModels/MultiOrderTakeDrugWindowViewModel.cs
@@ -0,0 +1,380 @@
+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.Collections.ObjectModel;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.ViewModels
+{
+ public class MultiOrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
+ {
+ public static MultiOrderTakeDrugWindowViewModel vm;
+ 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;
+
+
+ public MultiOrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
+ {
+ _dialogService = DialogService;
+ _eventAggregator = eventAggregator;
+ vm = this;
+ }
+
+ //public static ObservableCollection StaticOrderTakeSelects = new()
+ //{
+ // new OrderTakeSelect
+ // {
+ // Code = "OrderNo",
+ // Name = "处方号"
+ // },
+ // new OrderTakeSelect
+ // {
+ // Code = "PatientId",
+ // Name = "患者编号"
+ // }
+ //};
+
+ //private ObservableCollection _orderTakeSelects = StaticOrderTakeSelects;
+
+ //public ObservableCollection OrderTakeSelects
+ //{
+ // get { return _orderTakeSelects; }
+ // set
+ // {
+ // SetProperty(ref _orderTakeSelects, value);
+ // }
+ //}
+
+
+
+ //private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
+ /////
+ ///// 查询条件 查询字段
+ /////
+ //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");
+ ///
+ /// 查询条件 处方日期
+ ///
+ 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;
+
+ /////
+ ///// 查询条件 查询字段值
+ /////
+ //public string? SearchValue
+ //{
+ // get { return _searchValue; }
+ // set
+ // {
+ // SetProperty(ref _searchValue, value);
+ // RequestData();
+ // }
+ //}
+
+ ///
+ ///全选
+ ///
+ private bool _allChecked = false;
+ public bool IsAllChecked
+ {
+ get { return _allChecked; }
+ set
+ {
+ SetProperty(ref _allChecked, value);
+ if (!IsItemCheck)
+ {
+ RequestData();
+ //根据全选或反选设置其后的选中状态
+ OrderInfos.ToList().ForEach(oi => oi.ItemIsChecked = _allChecked);
+ }
+ else
+ {
+ IsItemCheck = false;
+ }
+ }
+
+ }
+
+ public bool _isItemCheck = false;
+ public bool IsItemCheck
+ {
+ get => _isItemCheck;
+ set
+ {
+ SetProperty(ref _isItemCheck, value);
+ if (OrderInfos.ToList().Where(od => od.ItemIsChecked == false).Count() <= 0)
+ {
+ IsAllChecked = true;
+ }
+ }
+ }
+ //private bool _itemIsChecked = false;
+ //public bool ItemIsChecked
+ //{
+ // get => _itemIsChecked;
+ // set
+ // {
+ // SetProperty(ref _itemIsChecked, value);
+ // }
+ //}
+ //多处方取药
+ public DelegateCommand BtnTakeOrder { get => new DelegateCommand(TakeByMultiOrder); }
+ private void TakeByMultiOrder()
+ {
+ OrderInfos = new ObservableCollection(OrderInfos.Where(o => o.ItemIsChecked == true).ToList());
+ if (OrderInfos != null && OrderInfos.Count() > 0)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ //await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("orderInfo", OrderInfos);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "MultiOrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
+ }
+ else
+ {
+ //请勾选要取药的处方信息
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "请勾选要取药的处方信息",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ IsAllChecked = false;
+ }
+
+ private ObservableCollection _orderInfos = new();
+
+ public ObservableCollection OrderInfos
+ {
+ get { return _orderInfos; }
+ set
+ {
+ SetProperty(ref _orderInfos, value);
+ }
+ }
+
+ //部门
+ private ObservableCollection _orderDepartments = new ObservableCollection();
+ public ObservableCollection OrderDepartments
+ {
+ get => _orderDepartments;
+ set
+ {
+ SetProperty(ref _orderDepartments, value);
+ }
+ }
+
+ private OrderDepartment _orderDepartment = new OrderDepartment();
+ public OrderDepartment OrderDepartment
+ {
+ get => _orderDepartment;
+ set
+ {
+ SetProperty(ref _orderDepartment, value);
+ RequestData();
+ }
+ }
+
+
+ public bool KeepAlive => false;
+
+ 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 continuationCallback)
+ {
+ continuationCallback(true);
+ }
+
+ public DelegateCommand QueryCommand
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestData();
+ });
+ }
+
+ public void RequestData()
+ {
+ OrderInfos.Clear();
+ int totalCount = 0;
+ //string SearchValue = null;
+ //if (SearchValue != null)
+ //{
+ // strSearchValue = SearchValue.Trim().Replace("\r", "");
+ //}
+ List queryData = SqlSugarHelper.Db.Queryable()
+ .InnerJoin((oi, od) => oi.OrderNo == od.OrderNo)
+ .InnerJoin(SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
+ .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
+ .WhereIF(!(OrderDepartment.DeptName.Equals("全部")), oi => oi.DeptName == OrderDepartment.DeptName)
+ //.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)
+ .GroupBy(oi => oi.OrderNo)
+ .Select(oi => oi)
+ .ToPageList(PageNum, PageSize, ref totalCount);
+ //.ToList();
+ OrderInfos = new ObservableCollection(queryData);
+
+ if (OrderDepartments.Where(d => d.DeptName == "全部").ToList().Count <= 0)
+ {
+ OrderDepartment deptDefault = new OrderDepartment();
+ deptDefault.DeptName = "全部";
+ OrderDepartments.Add(deptDefault);
+
+ }
+ var orderDeparts = queryData.GroupBy(o=>o.DeptName).ToList();
+ for (int i = 0; i < orderDeparts.Count; i++)
+ {
+ OrderDepartment dept = new OrderDepartment();
+ if (orderDeparts[i].Key != null && orderDeparts[i].Key != string.Empty&& OrderDepartments.Where(d => d.DeptName == orderDeparts[i].Key).ToList().Count<=0)
+ {
+ dept.DeptName = orderDeparts[i].Key;
+ OrderDepartments.Add(dept);
+ }
+ }
+ TotalCount = totalCount;
+ PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
+
+ }
+
+ //接收导航传过来的参数 现在是在此处初始化了表格数据
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ //_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ RequestData();
+ }
+
+ //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ //这个方法用于拦截请求
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+
+ // 取消消息订阅
+ //_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ }
+
+ void DoMyPrismEvent(DeviceMsg msg)
+ {
+ //if (msg.EventType == EventType.CODESCAN)
+ //{
+ // SearchValue = msg.Code;
+ //}
+
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
index eb8be5d..f03534e 100644
--- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
+++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
@@ -200,6 +200,16 @@ namespace DM_Weight.ViewModels
PremissionPath = "TakeRecordWindow",
};
+ if (ConfigurationManager.AppSettings["MultiOrder"].ToString().Equals("1"))
+ {
+ PremissionDm mulityOrder = new PremissionDm
+ {
+ Id = 16,
+ PremissionName = "多处方取药",
+ PremissionPath = "MultiOrderTakeDrugWindow",
+ };
+ quyaoChild.Add(mulityOrder);
+ }
quyaoChild.Add(quyao1);
quyaoChild.Add(quyao2);
quyaoChild.Add(quyao3);
diff --git a/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml b/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml
new file mode 100644
index 0000000..1f9dcbe
--- /dev/null
+++ b/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml.cs b/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml.cs
new file mode 100644
index 0000000..7c7b7a4
--- /dev/null
+++ b/DM_Weight/Views/Dialog/MultiOrderTakeDialog.xaml.cs
@@ -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
+{
+ ///
+ /// MultiOrderTakeDialog.xaml 的交互逻辑
+ ///
+ public partial class MultiOrderTakeDialog : UserControl
+ {
+ public MultiOrderTakeDialog()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml b/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml
new file mode 100644
index 0000000..360f414
--- /dev/null
+++ b/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml.cs b/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml.cs
new file mode 100644
index 0000000..acf48c1
--- /dev/null
+++ b/DM_Weight/Views/MultiOrderTakeDrugWindow.xaml.cs
@@ -0,0 +1,55 @@
+using DM_Weight.ViewModels;
+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
+{
+ ///
+ /// OrderTakeDrugWindow.xaml 的交互逻辑
+ ///
+ public partial class MultiOrderTakeDrugWindow : UserControl
+ {
+ MultiOrderTakeDrugWindowViewModel vms;
+ public MultiOrderTakeDrugWindow()
+ {
+ InitializeComponent();
+ }
+
+ private void CheckBox_Checked_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+ //某项被选中
+ private void Item_Checked(object sender, RoutedEventArgs e)
+ {
+ CheckBox cbx= (CheckBox)sender;
+ if(!(bool)cbx.IsChecked)
+ {
+ vms.IsItemCheck = true;
+ vms.IsAllChecked = false;
+ }
+ else
+ {
+ vms.IsItemCheck = true;
+ }
+ }
+
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ vms = MultiOrderTakeDrugWindowViewModel.vm;
+
+ }
+ }
+}