配置文件添加1)多处方取药2)多批次抽屉加药。页面根据配置文件字段值显示是否需要多处方取药及多批次加药及绑定信息。

This commit is contained in:
maqiao 2023-11-14 14:49:22 +08:00
parent 2f0956fe84
commit de22a9a6c9
19 changed files with 2067 additions and 43 deletions

View File

@ -55,6 +55,12 @@
<add key="machineNumber" value="1"/> <add key="machineNumber" value="1"/>
<!-- 指纹机ip --> <!-- 指纹机ip -->
<add key="fingerIp" value="192.168.1.201"/> <add key="fingerIp" value="192.168.1.201"/>
<!-- 多处方取药 0:不启用 1启用-->
<add key="MultiOrder" value="1"/>
<!-- 多批次抽屉加药 0:不启用 1启用
启用channel_list记录库位信息 -->
<add key="MultiBatch" value="0"/>
</appSettings> </appSettings>
</configuration> </configuration>

View File

@ -157,6 +157,8 @@ namespace DM_Weight
// 自选加药模态框 // 自选加药模态框
containerRegistry.RegisterDialog<SelfAddDialog>(); containerRegistry.RegisterDialog<SelfAddDialog>();
containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>(); containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
//多批次抽屉加药
containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
#endregion #endregion
#region #region
@ -184,6 +186,8 @@ namespace DM_Weight
// 库位绑定模态框 // 库位绑定模态框
containerRegistry.RegisterDialog<BindingChannelDialog>(); containerRegistry.RegisterDialog<BindingChannelDialog>();
containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>(); containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
//同一药品多批次库位绑定
containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
// 库存盘点页面 // 库存盘点页面
containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>(); containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
// 药品列表页面 // 药品列表页面

View File

@ -0,0 +1,200 @@
using Prism.Commands;
using Prism.Mvvm;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
[SugarTable("channel_list")]
public class ChannelList : BindableBase
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "chnguid", IsPrimaryKey = true)]
//[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "machine_id")]
public string MachineId { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "row_no")]
public int DrawerNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "col_no")]
public int ColNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "pos_no")]
public int PosNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "drug_id")]
public string DrugId { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "manu_no")]
//public string ManuNo { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "eff_date")]
//public string EffDate { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "quantity")]
//public int Quantity { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "drawer_type")]
public int DrawerType { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "board_type")]
public int BoardType { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "state")]
public int? State { get; set; }
[SugarColumn(IsIgnore = true)]
public bool IsSelected { get; set; }
[SugarColumn(IsIgnore = true)]
public InOutInvoice Invoice { get; set; }
[SugarColumn(IsIgnore = true)]
public string Location
{
get => DrawerNo + "-" + ColNo;
}
//private int _addQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int AddQuantity
//{
// get => _addQuantity;
// set
// {
// SetProperty(ref _addQuantity, value);
// }
//}
//private int _takeQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int TakeQuantity
//{
// get => _takeQuantity;
// set
// {
// if (value > Quantity)
// {
// throw new ArgumentException("取药数量不能大于库存");
// }
// SetProperty(ref _takeQuantity, value);
// }
//}
//private int _returnQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int ReturnQuantity
//{
// get => _returnQuantity;
// set
// {
// SetProperty(ref _returnQuantity, value);
// }
//}
//private int _checkQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int CheckQuantity
//{
// get => _checkQuantity;
// set
// {
// if (value < 0)
// {
// throw new ArgumentException("盘点数量不能是负数");
// }
// SetProperty(ref _checkQuantity, value);
// }
//}
//[SugarColumn(IsIgnore = true)]
//public int? CanReturnQuantity { get; set; }
private DrugInfo? _DrugInfo;
[Navigate(NavigateType.ManyToOne, nameof(DrugId))]
public DrugInfo Drug { get => _DrugInfo; set => SetProperty(ref _DrugInfo, value); }
//[SugarColumn(IsIgnore = true)]
//public int process { get; set; } = 0;
private DrugManuNo? _drugManuNo;
[SugarColumn(IsIgnore = true)]
public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
private List<ChannelStock>? _channelStocks;
[Navigate(NavigateType.OneToMany, nameof(ChannelStock.Chnguid))]
public List<ChannelStock> channelStocks { get => _channelStocks; set => SetProperty(ref _channelStocks, value); }
//private DelegateCommand<ChannelList> _addManunoCommand;
//[SugarColumn(IsIgnore = true)]
//public DelegateCommand<ChannelList> AddManunoCommand
//{
// get
// {
// if (_addManunoCommand == null)
// _addManunoCommand = new DelegateCommand<ChannelList>(o => DoDelete(o));
// return _addManunoCommand;
// }
//}
//private void DoDelete(ChannelList parameter)
//{
//}
//药品规格
private string _drugSpec;
[SugarColumn(ColumnName = "drug_manu_no")]
public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
}
}

View File

@ -18,6 +18,9 @@ namespace DM_Weight.Models
//[SugarColumn(ColumnName = "id", IsPrimaryKey = true)] //[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; } public string Id { get; set; }
[SugarColumn(ColumnName = "chnguid")]
public string Chnguid { get; set; }
/// <summary> /// <summary>
/// ///
/// 默认值: NULL /// 默认值: NULL
@ -178,5 +181,9 @@ namespace DM_Weight.Models
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public DrugManuNo? drugManuNo { get; set; } public DrugManuNo? drugManuNo { get; set; }
private ChannelList? _channelList;
[Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
} }
} }

View File

@ -0,0 +1,533 @@
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.Drawing.Printing;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace DM_Weight.ViewModels
{
public class AddDrugControlViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
private List<int> _drawerNoList = new List<int>();
public static AddDrugControlViewModel vm;
//凭证号
//private string _pzh;
//public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
private List<ChannelList>? _channelLsts;
public List<ChannelList>? ChannelLsts
{
get => _channelLsts;
set => SetProperty(ref _channelLsts, value);
}
private List<ChannelStock> __channelStocks = new List<ChannelStock>();
public List<ChannelStock> ChannelStocks
{
get => __channelStocks;
set => SetProperty(ref __channelStocks, value);
}
private ChannelStock? _channelStock;
public ChannelStock? CStock
{
get => _channelStock;
set => SetProperty(ref _channelStock, value);
}
//private ChannelList? _channelList;
//public ChannelList? ChannelLst
//{
// get => _channelList;
// set => SetProperty(ref _channelList, value);
//}
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
public AddDrugControlViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
{
_dialogService = DialogService;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
vm = this;
}
public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
private async void selectionAction()
{
if (CStock != null)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("addManuno", CStock);
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
}
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if(dialogResult.Result == ButtonResult.OK)
//{
CStock = null;
RequestData();
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "DrawerAddDrugWindow")
{
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)
{
//ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
break;
}
}
if (msg.WindowName == "AddDrugControl")
{
}
}
private int _status;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private int _drawerNo = 1;
public int DrawerNo
{
get => _drawerNo;
set => SetProperty(ref _drawerNo, value);
}
private bool _is8Drawer = true;
public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
private bool _is16Drawer = false;
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
private bool _is17Drawer = false;
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
public DelegateCommand<string> UpdateDrawerNo
{
get => new DelegateCommand<string>((DrawerNo) =>
{
this.DrawerNo = Convert.ToInt32(DrawerNo);
RequestData();
}, (DrawerNo) => Status == 0
);
}
public DelegateCommand OpenDrawer
{
get => new DelegateCommand(() =>
{
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
try
{
//List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
List<ChannelList> singleChannels = ChannelLsts.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = "DrawerAddDrugWindow";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
//_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
catch (Exception ex)
{
logger.Info($"OpenDrawer异常{ex.Message}");
}
}, () => Status == 0).ObservesProperty(() => Status);
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
_isFinishClick = true;
foreach (ChannelList lst in ChannelLsts)
{
ChannelStocks.AddRange(lst.channelStocks);
}
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
if (record.Count > 0)
{
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
//string InvoiceId = PZH;
//List<string> repeatList = new List<string>();
List<ChannelStock> stockRepeats = new List<ChannelStock>();
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
it.ManuNo = it.drugManuNo.ManuNo;
it.EffDate = it.drugManuNo.EffDate;
if (it.Id != null)
{
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
}
else
{
//如果批号重复则不让添加
List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
if (csCount.Count > 0)
{
//repeatList.Add(it.ManuNo);
stockRepeats.Add(it);
continue;
}
// 更新数据 库存信息
SqlSugarHelper.Db.Insertable(new ChannelStock()
{
Quantity = it.AddQuantity,
Chnguid = it.Chnguid,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
DrawerType = it.DrawerType,
BoardType = it.BoardType,
Id = Guid.NewGuid().ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
}).ExecuteCommand();
}
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.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,
OperationTime = DateTime.Now,
Quantity = it.AddQuantity,
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
}
return true;
});
ChannelStocks.Clear();
//if (record.Count == repeatList.Count)
if (stockRepeats.Count == record.Count)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"该抽屉已存在此药品批次{string.Join(',', stockRepeats.Select(r=>r.ManuNo).ToArray())},请选择其他批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
//if (repeatList.Count > 0)
//{
// AlertMsg alertMsg = new AlertMsg
// {
// Message = $"该抽屉已存在此药品批次{string.Join(',', repeatList)},请选择其他批次",
// Type = MsgType.ERROR
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
//}
if (f.Data)
{
string msg = string.Empty;
MsgType type = MsgType.SUCCESS;
//if (repeatList.Count > 0)
if (stockRepeats.Count > 0)
{
msg = $"该抽屉下批次{string.Join(',', stockRepeats.Select(r => r.ManuNo).ToArray())}已存在,不可重复添加,其他批次加药完成,库存已更新";
foreach(var stockRpt in stockRepeats)
{
//移除重复的信息,以免更新屏显库存时更新了重复数据
record.Remove(stockRpt);
}
type = MsgType.WARING;
}
else
{
msg = "抽屉加药完成,库存已更新";
}
// 更新屏显库存
List<ChannelStock> 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.AddQuantity);
});
}
RequestData();
AlertMsg alertMsg = new AlertMsg
{
Message = msg,
Type = type,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "更新库存失败",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
Status = 0;
_isFinishClick = false;
//PZH = string.Empty;
}
else
{
_isFinishClick = false;
AlertMsg alertMsg = new AlertMsg
{
Message = "没有填写加药数量",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
});
}
// 取消按钮
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
_portUtil.ResetData();
Status = 0;
});
}
//添加批次
public void AddAction(ChannelList channelLS)
{
if (channelLS != null)
{
ChannelStock cls = new ChannelStock();
DrugManuNo drugManu = new DrugManuNo();
cls.DrugInfo = channelLS.Drug;
if (channelLS.channelStocks.Count > 0)
{
//drugManu = channelLS.channelStocks[0].DrugInfo.DrugManuNos[0];
cls.drugManuNo = channelLS.channelStocks[0].drugManuNo;
}
else
{
//drugManu= cls.DrugInfo.DrugManuNos[0];
if (cls.DrugInfo.DrugManuNos.Count > 0)
{
cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "该药品下没有批次,请先添加批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
//cls.Id = "";
cls.Chnguid = channelLS.Id;
cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
cls.DrawerNo = channelLS.DrawerNo;
cls.BoardType = channelLS.BoardType;
cls.DrawerType = channelLS.DrawerType;
cls.ColNo = channelLS.ColNo;
cls.DrugId = channelLS.DrugId;
cls.AddQuantity = 0;
//string sqlStr = @"select drug_id,manu_no,manu_date,eff_date from drug_manu_no where drug_id=@drugId
// and manu_no not in(select manu_no from channel_stock where drug_id=@drugId) ";
//cls.DrugInfo.DrugManuNos=SqlSugarHelper.Db.SqlQueryable<dynamic>(sqlStr).AddParameters(new
//{
// drugId = channelLS.DrugId
//})
//.Select(it => new DrugManuNo()).ToList();
List<ChannelStock> stockList = new List<ChannelStock>();
stockList.AddRange(channelLS.channelStocks);
stockList.Add(cls);
channelLS.channelStocks = stockList;
}
}
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public void FindDrawerCount()
{
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is8Drawer = count < 9;
Is16Drawer = count >= 16;
Is17Drawer = count > 16;
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
List<ChannelList> queryData = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes(cl => cl.Drug, di => di.DrugManuNos)
.Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.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));
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
FindDrawerCount();
RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
}
}
}

View File

@ -0,0 +1,484 @@
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.Tasks;
using System.Windows.Media;
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using System.Threading;
using System.Reflection.Metadata.Ecma335;
namespace DM_Weight.ViewModels
{
public class BindingChannelNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
{
public static BindingChannelNewDialogViewModel vm;
public string Title => "库位绑定";
public event Action<IDialogResult> RequestClose;
private int _drawerNo = 0;
private SolidColorBrush _colorBrush;
public SolidColorBrush SnackbarBackground
{
get => _colorBrush;
set => SetProperty(ref _colorBrush, value);
}
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
public ISnackbarMessageQueue SnackbarMessageQueue
{
get => _snackbarMessageQueue;
set => SetProperty(ref _snackbarMessageQueue, value);
}
IEventAggregator _eventAggregator;
PortUtil _portUtil;
//ScreenUtil _screenUtil;
public BindingChannelNewDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
)
{
_eventAggregator = eventAggregator;
_portUtil = portUtil;
//_screenUtil = screenUtil;
vm = this;
}
public int DrawerNo
{
get => _drawerNo;
set
{
SetProperty(ref _drawerNo, value);
GetChannelsByDrawerNo();
}
}
private DrugInfo? _drugInfo;
public DrugInfo? DrugInfo
{
get => _drugInfo;
set
{
SetProperty(ref _drugInfo, value);
//if (_drugInfo != null)
//{
// DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
//}
}
}
//拼音码对应药品实体
//private DrugInfo? _durgInfo_for_py;
//public DrugInfo? DrugInfo_Py
//{
// get => _durgInfo_for_py;
// set
// {
// SetProperty(ref _durgInfo_for_py, value);
// if (_durgInfo_for_py != null)
// {
// DrugInfos = GetDrugByDrugPY(_durgInfo_for_py.PyCode);
// }
// else
// {
// DrugInfos = GetDrugByDrugPY("");
// }
// }
//}
//#region 根据药品拼音码查询药品名称
//private List<DrugInfo> GetDrugByDrugPY(string pycode)
//{
// List<DrugInfo> DrugList = null;
// if (!string.IsNullOrEmpty(pycode))
// {
// DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
// }
// else
// {
// DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
// }
// return DrugList;
//}
//private List<DrugInfo>? _drugInfos_py;
//public List<DrugInfo>? DrugInfos_PY
//{
// get => _drugInfos_py;
// set => SetProperty(ref _drugInfos_py, value);
//}
//#endregion 根据药品拼音码查询药品名称
private List<DrugInfo>? _drugInfos;
public List<DrugInfo>? DrugInfos
{
get => _drugInfos;
set => SetProperty(ref _drugInfos, value);
}
//private DrugManuNo? _drugManuNo;
//public DrugManuNo? DrugManuNo
//{
// get => _drugManuNo;
// set => SetProperty(ref _drugManuNo, value);
//}
//private List<DrugManuNo>? _drugManuNos;
//public List<DrugManuNo>? DrugManuNos
//{
// get => _drugManuNos;
// set => SetProperty(ref _drugManuNos, value);
//}
private List<ChannelList>? _channels;
public List<ChannelList>? Channels
{
get => _channels;
set => SetProperty(ref _channels, value);
}
private int _totalCount = 0;
public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
GetChannelsByDrawerNo();
}
}
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);
}
}
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
private void GetAllDrugInfos()
{
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
//DrugInfos_PY = list;
}
private void GetChannelsByDrawerNo()
{
Channels?.Clear();
int totalCount = 0;
var list = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes<DrugInfo>(cl => cl.Drug)
//.Includes<ChannelStock>(cs => cs.channelStock)
.WhereIF(DrawerNo > 0, cl => cl.DrawerNo == DrawerNo)
.Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.OrderBy(cl => cl.DrawerNo)
.OrderBy(cl => cl.ColNo)
.ToPageList(PageNum, PageSize, ref totalCount);
Channels = list;
TotalCount = totalCount;
}
public void OnDialogOpened(IDialogParameters parameters)
{
if (parameters.ContainsKey("DrawerNo"))
{
DrawerNo = parameters.GetValue<int>("DrawerNo");
}
GetAllDrugInfos();
GetChannelsByDrawerNo();
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
}
public DelegateCommand Query
{
get => new DelegateCommand(() =>
{
GetChannelsByDrawerNo();
});
}
public DelegateCommand BindingDrug
{
get => new DelegateCommand(async () =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected);
if (SelectChannels.All(it => it.DrawerType != 1))
{
if (SelectChannels.Count == 1)
{
if (DrugInfo != null)
{
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
if (count == 0)
{
var item = SelectChannels[0];
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
item.DrugSpec= DrugInfo.DrugSpec.ToString();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
GetChannelsByDrawerNo();
if (item.BoardType == 5)
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
//_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
//_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
}
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
}
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
}
}
else
{
//if (DrugInfo != null && DrugManuNo != null)
//{
var c = SelectChannels.Count;
if (c > 0)
{
for (int i = 0; i < SelectChannels.Count; i++)
{
var item = SelectChannels[i];
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
if(channelStock.Count>0)
{
//有库存,不能解绑
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue($"库位{item.DrawerNo}-{item.ColNo}中还存在药品,不能绑定其他药品");
continue;
}
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
//item.ManuNo = DrugManuNo.ManuNo;
item.Drug = DrugInfo;
item.DrugSpec = DrugInfo.DrugSpec.ToString();
//item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
if (item.BoardType == 5)
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
Thread.Sleep(200);
//_portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
//Thread.Sleep(200);
//_portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
////await Task.Delay(200);
//Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
}
GetChannelsByDrawerNo();
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
}
//}
//else
//{
// SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
// SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
//}
}
});
}
public DelegateCommand RemoveBinding
{
get => new DelegateCommand(async () =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected && item.DrugId != null);
var c = SelectChannels.Count;
if (c > 0)
{
SelectChannels.ForEach(async item =>
{
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
if (channelStock.Count > 0)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品【库位还存在药品】");
//该药品下的批次还有库存则不能解绑
return;
}
item.DrugId = null;
//item.ManuNo = null;
//item.EffDate = null;
item.Drug = null;
item.DrugSpec = null;
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId,it.DrugSpec }).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
});
GetChannelsByDrawerNo();
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品");
}
});
}
public DelegateCommand BtnCloseCommand
{
get => new DelegateCommand(() =>
{
//DialogParameters parameters = new DialogParameters();
//parameters.Add("",);
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
public bool KeepAlive => false;
string message = string.Empty;
private void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "BindingChannelDialog")
{
switch (msg.EventType)
{
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
if (message != msg.Message)
{
message = msg.Message;
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
break;
}
}
}
public void UpdateComboBoxItems(string text)
{
string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
if (string.IsNullOrEmpty(text))
{
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
return;
}
if (DrugInfos != null)
{
DrugInfos.Clear();
}
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
}
}

View File

@ -263,8 +263,18 @@ namespace DM_Weight.ViewModels
public void FindDrawerCount() public void FindDrawerCount()
{ {
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3) int count = 0;
if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count(); .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
else
{
count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
Is8Drawer = count < 9; Is8Drawer = count < 9;
Is16Drawer = count >= 16; Is16Drawer = count >= 16;
Is17Drawer = count > 16; Is17Drawer = count > 16;

View File

@ -159,7 +159,7 @@ namespace DM_Weight.ViewModels
if (!_isFinishClick) if (!_isFinishClick)
{ {
_isFinishClick = true; _isFinishClick = true;
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0&&it.Quantity==0).ToList(); List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
if (record.Count > 0) if (record.Count > 0)
{ {
string InvoiceId = "DRAWER_" + CurrentTimeMillis(); string InvoiceId = "DRAWER_" + CurrentTimeMillis();
@ -263,8 +263,18 @@ namespace DM_Weight.ViewModels
public void FindDrawerCount() public void FindDrawerCount()
{ {
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3) int count = 0;
if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count(); .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
else
{
count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
Is8Drawer = count < 9; Is8Drawer = count < 9;
Is16Drawer = count >= 16; Is16Drawer = count >= 16;
Is17Drawer = count > 16; Is17Drawer = count > 16;

View File

@ -35,11 +35,11 @@ namespace DM_Weight.ViewModels
get => _channelStocks; get => _channelStocks;
set => SetProperty(ref _channelStocks, value); set => SetProperty(ref _channelStocks, value);
} }
private static readonly DateTime Jan1st1970 = new DateTime private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private PortUtil _portUtil; private PortUtil _portUtil;
IEventAggregator _eventAggregator; IEventAggregator _eventAggregator;
@ -53,7 +53,7 @@ namespace DM_Weight.ViewModels
void DoMyPrismEvent(DeviceMsg msg) void DoMyPrismEvent(DeviceMsg msg)
{ {
if(msg.WindowName == "DrawerTakeDrugWindow") if (msg.WindowName == "DrawerTakeDrugWindow")
{ {
switch (msg.EventType) switch (msg.EventType)
{ {
@ -91,7 +91,7 @@ namespace DM_Weight.ViewModels
break; break;
} }
} }
} }
private int _status; private int _status;
@ -127,7 +127,7 @@ namespace DM_Weight.ViewModels
}, (DrawerNo) => Status == 0 }, (DrawerNo) => Status == 0
); );
} }
public DelegateCommand OpenDrawer public DelegateCommand OpenDrawer
{ {
@ -198,7 +198,7 @@ namespace DM_Weight.ViewModels
ColNo = it.ColNo, ColNo = it.ColNo,
DrugId = it.DrugId, DrugId = it.DrugId,
ManuNo = it.ManuNo, ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ?DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture):null, EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id, Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id, Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now, OperationTime = DateTime.Now,
@ -246,7 +246,7 @@ namespace DM_Weight.ViewModels
} }
} }
}); });
} }
@ -269,8 +269,17 @@ namespace DM_Weight.ViewModels
public void FindDrawerCount() public void FindDrawerCount()
{ {
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3) int count = 0;
if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count(); .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
else
{
count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
Is8Drawer = count < 9; Is8Drawer = count < 9;
Is16Drawer = count >= 16; Is16Drawer = count >= 16;
Is17Drawer = count > 16; Is17Drawer = count > 16;

View File

@ -241,9 +241,17 @@ namespace DM_Weight.ViewModels
public void FindDrawerCount() public void FindDrawerCount()
{ {
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3) int count = 0;
if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count(); .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
else
{
count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
}
Is16Drawer = count == 16; Is16Drawer = count == 16;
} }
@ -256,8 +264,6 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 //接收导航传过来的参数
public void OnNavigatedTo(NavigationContext navigationContext) public void OnNavigatedTo(NavigationContext navigationContext)
{ {
//取出user //取出user
UserList = navigationContext.Parameters.GetValue<UserList>("operator"); UserList = navigationContext.Parameters.GetValue<UserList>("operator");
Operator = UserList; Operator = UserList;

View File

@ -181,7 +181,8 @@ namespace DM_Weight.ViewModels
//.Where(od => od.OrderNo. OrderInfo.OrderNo) //.Where(od => od.OrderNo. OrderInfo.OrderNo)
.ToList(); .ToList();
List<ChannelStock> channelStocks = new List<ChannelStock>(); List<ChannelStock> channelStocks = new List<ChannelStock>();
List<string> msg = new List<string>(); List<string> msg = new List<string>();
for (int i = 0; i < orderDetails.Count; i++) for (int i = 0; i < orderDetails.Count; i++)
@ -245,7 +246,8 @@ namespace DM_Weight.ViewModels
} }
else else
{ {
msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】"); //msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
} }
} }
if (msg.Count > 0) if (msg.Count > 0)

View File

@ -34,7 +34,7 @@ namespace DM_Weight.ViewModels
//{ //{
// _allPremissions = Clone<PremissionDm>(defaultAll); // _allPremissions = Clone<PremissionDm>(defaultAll);
//} //}
public static ObservableCollection<T> Clone<T>(object List) public static ObservableCollection<T> Clone<T>(object List)
{ {
using (Stream objectStream = new MemoryStream()) using (Stream objectStream = new MemoryStream())
@ -89,7 +89,7 @@ namespace DM_Weight.ViewModels
// { // {
// AllPremissions.RemoveAt(index); // AllPremissions.RemoveAt(index);
// } // }
// }); // });
// RightPremissions = new ObservableCollection<PremissionDm>(Permissions); // RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
//} //}
@ -118,7 +118,7 @@ namespace DM_Weight.ViewModels
{ {
int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id); int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
//if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i) //if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i)
if (p.Children[i] != null) if (p.Children.Count > 0 && i >= 0 && p.Children[i] != null)
{ {
AllPremissions.ElementAt(index).Children.RemoveAt(i); AllPremissions.ElementAt(index).Children.RemoveAt(i);
} }
@ -158,7 +158,8 @@ namespace DM_Weight.ViewModels
static RoleManagerWindowViewModel() static RoleManagerWindowViewModel()
{ {
#region #region
PremissionDm quyao = new PremissionDm{ PremissionDm quyao = new PremissionDm
{
Id = 1, Id = 1,
PremissionName = "取药", PremissionName = "取药",
PremissionImage = "/Images/TbQyao.png", PremissionImage = "/Images/TbQyao.png",
@ -194,20 +195,22 @@ namespace DM_Weight.ViewModels
PremissionName = "取药记录", PremissionName = "取药记录",
PremissionPath = "TakeRecordWindow", PremissionPath = "TakeRecordWindow",
}; };
if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
PremissionDm mulityOrder = new PremissionDm
{ {
Id = 16, PremissionDm mulityOrder = new PremissionDm
PremissionName = "多处方取药", {
PremissionPath = "MultiOrderTakeDrugWindow", Id = 16,
}; PremissionName = "多处方取药",
PremissionPath = "MultiOrderTakeDrugWindow",
};
quyaoChild.Add(mulityOrder);
}
quyaoChild.Add(quyao1); quyaoChild.Add(quyao1);
quyaoChild.Add(quyao2); quyaoChild.Add(quyao2);
quyaoChild.Add(quyao3); quyaoChild.Add(quyao3);
quyaoChild.Add(quyao4); quyaoChild.Add(quyao4);
quyaoChild.Add(quyao5); quyaoChild.Add(quyao5);
quyaoChild.Add(mulityOrder);
quyao.Children = quyaoChild; quyao.Children = quyaoChild;
defaultAll.Add(quyao); defaultAll.Add(quyao);
#endregion #endregion
@ -243,6 +246,16 @@ namespace DM_Weight.ViewModels
PremissionName = "加药记录", PremissionName = "加药记录",
PremissionPath = "AddRecordWindow", PremissionPath = "AddRecordWindow",
}; };
if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
PremissionDm jiayao5 = new PremissionDm
{
Id = 25,
PremissionName = "多批次抽屉加药",
PremissionPath = "AddDrugControl",
};
jiayaoChild.Add(jiayao5);
}
jiayaoChild.Add(jiayao1); jiayaoChild.Add(jiayao1);
jiayaoChild.Add(jiayao2); jiayaoChild.Add(jiayao2);
jiayaoChild.Add(jiayao3); jiayaoChild.Add(jiayao3);
@ -282,7 +295,7 @@ namespace DM_Weight.ViewModels
PremissionName = "归还记录", PremissionName = "归还记录",
PremissionPath = "ReturnRecordWindow", PremissionPath = "ReturnRecordWindow",
}; };
huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1? huanyao11:huanyao1); huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
huanyaoChild.Add(huanyao2); huanyaoChild.Add(huanyao2);
huanyaoChild.Add(huanyao3); huanyaoChild.Add(huanyao3);
huanyao.Children = huanyaoChild; huanyao.Children = huanyaoChild;
@ -377,7 +390,7 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _allPremissions, value); set => SetProperty(ref _allPremissions, value);
} }
private PremissionDm? _leftPremission ; private PremissionDm? _leftPremission;
public PremissionDm? LeftPremission public PremissionDm? LeftPremission
{ {
get => _leftPremission; get => _leftPremission;
@ -441,9 +454,10 @@ namespace DM_Weight.ViewModels
if (v > item.Children.Count) if (v > item.Children.Count)
{ {
item.Children.Add(it); item.Children.Add(it);
} else }
else
{ {
item.Children.Insert(v-1, it); item.Children.Insert(v - 1, it);
} }
}); });
} }
@ -458,7 +472,7 @@ namespace DM_Weight.ViewModels
{ {
RightPremissions.Insert(v - 1, LeftPremission); RightPremissions.Insert(v - 1, LeftPremission);
} }
} }
AllPremissions.RemoveAt(AllPremissions.ToList().FindIndex(it => it.Id == LeftPremission.Id)); AllPremissions.RemoveAt(AllPremissions.ToList().FindIndex(it => it.Id == LeftPremission.Id));
@ -473,7 +487,7 @@ namespace DM_Weight.ViewModels
// 存在 // 存在
if (index > -1) if (index > -1)
{ {
ObservableCollection<PremissionDm> a= RightPremissions.ElementAt(index).Children; ObservableCollection<PremissionDm> a = RightPremissions.ElementAt(index).Children;
int v = LeftPremission.Id % 10; int v = LeftPremission.Id % 10;
if (v > a.Count) if (v > a.Count)
{ {
@ -506,7 +520,7 @@ namespace DM_Weight.ViewModels
{ {
RightPremissions.Insert(v - 1, item2); RightPremissions.Insert(v - 1, item2);
} }
item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == LeftPremission.Id)); item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == LeftPremission.Id));
} }
@ -527,7 +541,7 @@ namespace DM_Weight.ViewModels
RightPremission = _selected; RightPremission = _selected;
}); });
} }
public DelegateCommand ToLeft public DelegateCommand ToLeft
{ {
@ -663,7 +677,7 @@ namespace DM_Weight.ViewModels
Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"; Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
Role.Permissions = RightPremissions.ToList(); Role.Permissions = RightPremissions.ToList();
List<RoleDm> roleList = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList(); List<RoleDm> roleList = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList();
if(roleList.Count>0) if (roleList.Count > 0)
{ {
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("该角色已存在!"); SnackbarMessageQueue.Enqueue("该角色已存在!");
@ -704,7 +718,7 @@ namespace DM_Weight.ViewModels
{ {
RoleList = SqlSugarHelper.Db.Queryable<RoleDm>() RoleList = SqlSugarHelper.Db.Queryable<RoleDm>()
.Where(di => di.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) .Where(di => di.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue), (di) => di.RoleName.Contains(SearchValue??"")) .WhereIF(!String.IsNullOrEmpty(SearchValue), (di) => di.RoleName.Contains(SearchValue ?? ""))
.Select(r => r) .Select(r => r)
.ToList() .ToList()
; ;

View File

@ -112,7 +112,14 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() => get => new DelegateCommand(() =>
{ {
DialogParameters dialogParameters = new DialogParameters(); DialogParameters dialogParameters = new DialogParameters();
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog"); if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
{
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelNewDialog", dialogParameters, DoDialogResult, "RootDialog");
}
else
{
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
}
}); });
} }

View File

@ -0,0 +1,395 @@
<UserControl x:Class="DM_Weight.Views.AddDrugControl"
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"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<convert:QuantityCountConverter x:Key="QuantityCountConverter" />
<convert:BoardTypeConverter x:Key="BoardTypeConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
<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.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Margin="0" Grid.Column="0" Width="280" Height="570" Visibility="{Binding Is8Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.Background>
<ImageBrush ImageSource="/Images/box.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</Trigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DrawerSelectConverter}">
<Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
<Binding Path="DrawerNo" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Button Grid.Row="0" Width="210" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
</Grid>
</Grid>
<Grid Margin="0" Grid.Column="1" Width="300" Height="570" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</Trigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DrawerSelectConverter}">
<Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
<Binding Path="DrawerNo" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.Background>
<ImageBrush ImageSource="/Images/box-16.jpg" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="10 0 0 0" Visibility="{Binding Is17Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Row="0">
<Button Width="110" Content="17" HorizontalAlignment="Left" Command="{Binding UpdateDrawerNo}" CommandParameter="17" />
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Width="120" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Grid.Column="0" Width="120" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Grid.Column="0" Width="120" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Grid.Column="0" Width="120" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Grid.Column="0" Width="120" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Grid.Column="0" Width="120" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Grid.Column="0" Width="120" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Grid.Column="0" Width="120" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
<Button Grid.Row="0" Grid.Column="1" Width="120" Content="9" Command="{Binding UpdateDrawerNo}" CommandParameter="9" />
<Button Grid.Row="1" Grid.Column="1" Width="120" Content="10" Command="{Binding UpdateDrawerNo}" CommandParameter="10" />
<Button Grid.Row="2" Grid.Column="1" Width="120" Content="11" Command="{Binding UpdateDrawerNo}" CommandParameter="11" />
<Button Grid.Row="3" Grid.Column="1" Width="120" Content="12" Command="{Binding UpdateDrawerNo}" CommandParameter="12" />
<Button Grid.Row="4" Grid.Column="1" Width="120" Content="13" Command="{Binding UpdateDrawerNo}" CommandParameter="13" />
<Button Grid.Row="5" Grid.Column="1" Width="120" Content="14" Command="{Binding UpdateDrawerNo}" CommandParameter="14" />
<Button Grid.Row="6" Grid.Column="1" Width="120" Content="15" Command="{Binding UpdateDrawerNo}" CommandParameter="15" />
<Button Grid.Row="7" Grid.Column="1" Width="120" Content="16" Command="{Binding UpdateDrawerNo}" CommandParameter="16" />
</Grid>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding OpenDrawer}"
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}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="加药" />
<!--<TextBox Text="{Binding PZH, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="凭证号"
materialDesign:HintAssist.IsFloating="True" Width="100"
Margin="0 0 3 0"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
/>-->
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="完成" />
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消" />
</StackPanel>
<ScrollViewer Grid.Row="1" Margin="6">
<ItemsControl
ItemsSource="{Binding ChannelLsts}"
Grid.IsSharedSizeScope="True"
>
<!--<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
-->
<!--<UniformGrid Columns="4" />-->
<!--
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>-->
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--<materialDesign:Card
Background="{StaticResource MaterialDesignLightBackground}"
Margin="4"
Padding="0">-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="1">
<StackPanel Orientation="Horizontal" Background="#31ccec" Grid.Column="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 10 0 0 " Text="{Binding Drug.DrugName}"/>
<TextBlock TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 0 0 1 " Text="{Binding Drug.DrugSpec}"/>
<Button Grid.Row="2" Padding="0 0 0 1 " Style="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Click="Button_Click" CommandParameter="{Binding}">
<Button.Content>
<Border Width="32" Height="32" CornerRadius="16" Background="CornflowerBlue" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Data="M0 11L22 11M11 0L11 22" Stroke="WhiteSmoke" StrokeThickness="4" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
</Border>
</Button.Content>
</Button>
</Grid>
</StackPanel>
</Border>
<DataGrid
Margin="0"
Grid.Column="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding channelStocks}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
materialDesign:DataGridAssist.CellPadding="13"
SelectionUnit="Cell"
CanUserAddRows="False"
AutoGenerateColumns="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="80"
Binding="{Binding ColNo}"
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="180"
Binding="{Binding DrugInfo.DrugName}"
Header="药品名称"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding DrugInfo.DrugSpec}"
Header="规格"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="200" IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
Style="{StaticResource MaterialDesignDataGridComboBox}"
ItemsSource="{Binding DrugInfo.DrugManuNos}"
SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ManuNo"
IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="100"
Binding="{Binding drugManuNo.EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding Quantity}"
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="100"
Header="添加数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" IsReadOnly="{Binding BoardType, Converter={StaticResource InputQuantityConverter}}">
<TextBox.Text>
<Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<!--<ListView Padding="0 6 0 0" Grid.Column="1"
materialDesign:ListViewAssist.ListViewItemPadding="15"
ItemsSource="{Binding channelStocks}" SelectedItem="{Binding channelStock}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</ListView.Resources>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridView.Columns>
<GridViewColumn Width="80" Header="库位" DisplayMemberBinding="{Binding ColNo}" />
<GridViewColumn Width="130" Header="批次">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox Style="{StaticResource MaterialDesignComboBox}"
ItemsSource="{Binding DrugInfo.DrugManuNos}" SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ManuNo" IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
</ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="130" Header="效期" DisplayMemberBinding="{Binding drugManuNo.EffDate}" />
<GridViewColumn Width="80" Header="库存" DisplayMemberBinding="{Binding Quantity}" />
<GridViewColumn Width="80" Header="添加数量">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="80" Padding="10" Grid.Column="1"
Text="{Binding AddQuantity}"
materialDesign:HintAssist.Hint="添加数量"
Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>-->
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,41 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.ViewModels;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// AddDrugControl.xaml 的交互逻辑
/// </summary>
public partial class AddDrugControl : UserControl
{
IEventAggregator _eventAggregator;
public AddDrugControl(IEventAggregator eventAggregator)
{
InitializeComponent();
_eventAggregator= eventAggregator;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
ChannelList cls = (ChannelList)btn.CommandParameter;
//vms.AddAction(cls);
_eventAggregator.GetEvent<AddDrugEvent>().Publish(cls);
}
}
}

View File

@ -0,0 +1,230 @@
<UserControl xmlns:pagination="clr-namespace:DM_Weight.Components.pagination" x:Class="DM_Weight.Views.Dialog.BindingChannelNewDialog"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
MinWidth="880"
MinHeight="479"
Width="Auto"
Height="Auto"
mc:Ignorable="d" >
<UserControl.Resources>
<convert:BoardTypeConverter x:Key="BoardTypeConverter" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<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="{Binding Title}" />
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
HorizontalAlignment="Right"
Command="{Binding BtnCloseCommand}"
ToolTip="关闭" Cursor="Hand"
>
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<Grid Grid.Row="1" Margin="0 4 0 4">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--<ComboBox
Margin="6 0 6 0"
Grid.Column="0"
materialDesign:HintAssist.Hint="拼音码"
IsEditable="True"
ItemsSource="{Binding DrugInfos_PY}"
SelectedItem="{Binding DrugInfo_Py}"
DisplayMemberPath="PyCode"
/>
<ComboBox
Margin="6 0 6 0"
Grid.Column="1"
materialDesign:HintAssist.Hint="药品名称"
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName"
/>-->
<ComboBox
Margin="6 0 6 0"
Grid.Column="0"
materialDesign:HintAssist.Hint="药品名称/拼音码"
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
<StackPanel HorizontalAlignment="Right" Grid.Column="3" Orientation="Horizontal">
<Button
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="绑定库位"
Content="绑定"
Command="{Binding BindingDrug}"/>
<Button
Margin="6 0 6 0"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="解除绑定"
Content="解绑"
Command="{Binding RemoveBinding}" />
<Button
Margin="0 0 6 0"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新"
Command="{Binding Query}"
Content="{materialDesign:PackIcon Refresh}"/>
</StackPanel>
</Grid>
<ItemsControl
Grid.Row="2"
ItemsSource="{Binding Channels}"
Grid.IsSharedSizeScope="True"
Margin="12 0 12 0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<materialDesign:Card
Background="{StaticResource MaterialDesignLightBackground}"
Margin="4"
Padding="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="#31ccec" >
<CheckBox
materialDesign:CheckBoxAssist.CheckBoxSize="30"
VerticalAlignment="Center"
IsChecked="{Binding IsSelected}" />
<TextBlock
Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Padding="8"
Text="{Binding Location}" />
<TextBlock
Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Padding="8"
HorizontalAlignment="Right">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource BoardTypeConverter}">
<Binding Path="BoardType" />
<Binding Path="DrawerType" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" x:Name="Border">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignSubtitle1TextBlock}">
<Setter Property="Padding" Value="6" />
</Style>
</Grid.Resources>
<TextBlock
HorizontalAlignment="Left"
Grid.Row="0"
Grid.Column="0"
Text="药品:" />
<StackPanel
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Right"
Orientation="Horizontal">
<TextBlock Text="{Binding Drug.DrugName}" />
<!--<TextBlock
Visibility="{Binding Quantity, Converter={StaticResource NotZeroToVisibilityConverter}}"
Text="{Binding Quantity, StringFormat=({0})}" />-->
</StackPanel>
<TextBlock
HorizontalAlignment="Left"
Grid.Row="1"
Grid.Column="0"
Text="规格:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="1"
Grid.Column="1"
Text="{Binding DrugSpec}" />
<!--<TextBlock
HorizontalAlignment="Left"
Grid.Row="1"
Grid.Column="0"
Text="批次:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="1"
Grid.Column="1"
Text="{Binding ManuNo}" />
<TextBlock
HorizontalAlignment="Left"
Grid.Row="2"
Grid.Column="0"
Text="效期:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="2"
Grid.Column="1"
Text="{Binding EffDate}" />-->
</Grid>
</Grid>
</materialDesign:Card>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter TargetName="Border" Property="Background" Value="#90caf9" />
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95" />
</Setter.Value>
</Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<pagination:Pagination Grid.Row="3"
CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}"
InfoTextIsEnabel="True"
/>
<materialDesign:Snackbar
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>
</Grid>
</UserControl>

View File

@ -0,0 +1,47 @@
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.Dialog
{
/// <summary>
/// BindingChannelNewDialog.xaml 的交互逻辑
/// </summary>
public partial class BindingChannelNewDialog : UserControl
{
BindingChannelNewDialogViewModel vms;
public BindingChannelNewDialog()
{
InitializeComponent();
vms = BindingChannelNewDialogViewModel.vm;
}
/// <summary>
/// 药品名称触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBox_KeyUp(object sender, KeyEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
vms.UpdateComboBoxItems(comboBox.Text);
if (this.vms.DrugInfos.Count > 0)
{
comboBox.IsDropDownOpen = true;
}
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
textBox.SelectionStart = textBox.Text.Length;
}
}
}

View File

@ -220,12 +220,17 @@
Header="规格" Header="规格"
IsReadOnly="True" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/> ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTextColumn Width="100" <DataGridTextColumn Width="100"
Binding="{Binding ManuNo}" Binding="{Binding ManuNo}"
Header="批次" Header="批次"
IsReadOnly="True" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>--> ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="200" IsReadOnly="True" <DataGridTextColumn Width="100"
Binding="{Binding EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTemplateColumn Width="200" IsReadOnly="True"
Header="批次"> Header="批次">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
@ -246,7 +251,7 @@
Header="效期" Header="效期"
IsReadOnly="True" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/> ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-->
<!--<materialDesign:DataGridComboBoxColumn <!--<materialDesign:DataGridComboBoxColumn
Header="批次/效期" Header="批次/效期"
Width="200" Width="200"

View File

@ -0,0 +1,14 @@
using DM_Weight.Models;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.msg
{
internal class AddDrugEvent:PubSubEvent<ChannelList>
{
}
}