添加药箱补药页面
This commit is contained in:
parent
74829d0382
commit
0d16348630
|
@ -37,7 +37,7 @@
|
|||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||
<add key="returnDrugMode" value="2" />
|
||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||
<add key="autoExit" value="5"/>
|
||||
<add key="autoExit" value="0"/>
|
||||
|
||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||
<add key="stopRecord" value="180"/>
|
||||
|
|
|
@ -167,6 +167,8 @@ namespace DM_Weight
|
|||
//开药箱
|
||||
containerRegistry.RegisterForNavigation<OpenBoxWindow, OpenBoxWindowViewModel>();
|
||||
containerRegistry.RegisterForNavigation<OpenBoxNewWindow, OpenBoxNewWindowViewModel>();
|
||||
//交接柜补药
|
||||
containerRegistry.RegisterForNavigation<AdditionWindow, AdditionWindowViewModel>();
|
||||
//核对处方
|
||||
containerRegistry.RegisterForNavigation<CheckOrderWindow, CheckOrderWindowViewModel>();
|
||||
//管理员根据药箱进行核对处方
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
using DM_Weight.Models;
|
||||
using DM_Weight.msg;
|
||||
using DM_Weight.Port;
|
||||
using DM_Weight.util;
|
||||
using log4net;
|
||||
using Prism.Commands;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Regions;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
public class AdditionWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
|
||||
{
|
||||
public bool KeepAlive => false;
|
||||
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(AdditionWindowViewModel));
|
||||
|
||||
private List<ChannelStock> channelStocks;
|
||||
public List<ChannelStock> ChannelStocks
|
||||
{
|
||||
get => channelStocks;
|
||||
set => SetProperty(ref channelStocks, value);
|
||||
}
|
||||
List<ChannelStock> selectedStock=new List<ChannelStock>();
|
||||
private object _finishStatus = Visibility.Collapsed;
|
||||
public object FinishStatus
|
||||
{
|
||||
get => _finishStatus;
|
||||
set => SetProperty(ref _finishStatus, value);
|
||||
}
|
||||
|
||||
IDialogService _dialogService;
|
||||
IEventAggregator _eventAggregator;
|
||||
|
||||
public AdditionWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
public bool IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
|
||||
}
|
||||
|
||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
_eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
|
||||
RequestData();
|
||||
}
|
||||
private void RequestData()
|
||||
{
|
||||
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Includes<ChannelList>(cs => cs.ChannelLst)
|
||||
.Includes<DrugInfo>(cs => cs.DrugInfo)
|
||||
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
|
||||
.OrderBy(cs => cs.Chnguid)
|
||||
.OrderBy(cs => cs.DrawerNo)
|
||||
.ToList();
|
||||
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
|
||||
}
|
||||
//开药箱放入药品
|
||||
public DelegateCommand OpenBoxCommand
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
selectedStock = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
|
||||
if (selectedStock != null && selectedStock.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < selectedStock.Count; i++)
|
||||
{
|
||||
ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = $"未选择药箱,请先选择药箱",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
return;
|
||||
}
|
||||
FinishStatus = Visibility.Visible;
|
||||
});
|
||||
}
|
||||
//完成按钮
|
||||
public DelegateCommand AddFinish
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
//更新 交接柜 库存信息
|
||||
if (selectedStock != null && selectedStock.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < selectedStock.Count; j++)
|
||||
{
|
||||
// 更新数据 交接柜 库存信息
|
||||
ChannelStock jiaojie_it = selectedStock[j];
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
Quantity = jiaojie_it.BaseQuantity,
|
||||
//ManuNo = it.ManuNo,
|
||||
//EffDate = it.EffDate,
|
||||
Id = jiaojie_it.Id,
|
||||
}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//刷新
|
||||
public DelegateCommand QueryCommand
|
||||
{
|
||||
get => new DelegateCommand(() => RequestData());
|
||||
}
|
||||
//设置选中药箱的复选框状态
|
||||
private void SetIsSelected(ChannelStock channelStock)
|
||||
{
|
||||
if (channelStock != null)
|
||||
{
|
||||
channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
|
||||
if (channelStock != null && ChannelStocks != null)
|
||||
{
|
||||
ChannelStocks = ChannelStocks.Select(x =>
|
||||
{
|
||||
for (int i = 0; i < ChannelStocks.Count; i++)
|
||||
{
|
||||
if (ChannelStocks[i].DrawerNo == channelStock.DrawerNo)
|
||||
{
|
||||
ChannelStocks[i].ChannelLst = channelStock.ChannelLst;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}).ToList();
|
||||
}
|
||||
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
|
||||
vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -203,6 +203,14 @@ namespace DM_Weight.ViewModels
|
|||
//PremissionPath = "CheckOrderWindow",
|
||||
PremissionPath = "CheckOrderNewWindow",
|
||||
};
|
||||
//核对处方
|
||||
PremissionDm addition = new PremissionDm
|
||||
{
|
||||
Id = 12,
|
||||
PremissionName = "药箱补药",
|
||||
//PremissionPath = "CheckOrderWindow",
|
||||
PremissionPath = "AdditionWindow",
|
||||
};
|
||||
|
||||
//PremissionDm quyao1 = new PremissionDm
|
||||
//{
|
||||
|
@ -253,6 +261,7 @@ namespace DM_Weight.ViewModels
|
|||
//quyaoChild.Add(quyao5);
|
||||
quyaoChild.Add(openBox);
|
||||
quyaoChild.Add(checkOrder);
|
||||
quyaoChild.Add(addition);
|
||||
quyao.Children = quyaoChild;
|
||||
defaultAll.Add(quyao);
|
||||
#endregion
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
<UserControl x:Class="DM_Weight.Views.AdditionWindow"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:convert="clr-namespace:DM_Weight.Converter"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="ChannelLst" />
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
</CollectionViewSource>
|
||||
<convert:GroupSumConverter x:Key="GroupSumConverter" />
|
||||
<convert:TotalCountConverter x:Key="TotalCountConverter" />
|
||||
<convert:StatusConverter x:Key="StatusConverter" />
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Margin="0 6 0 6" Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="7*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
|
||||
<!--<Button
|
||||
Margin="6 0 6 0"
|
||||
ToolTip="一键补药"
|
||||
Content="一键补药"
|
||||
Command="{Binding OpenDragCommand}"
|
||||
IsEnabled="{Binding IsEnable}"
|
||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}" />
|
||||
<Button
|
||||
Margin="0 0 6 0"
|
||||
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="完成"
|
||||
Command="{Binding AddFinish}"/>
|
||||
|
||||
<Button
|
||||
Margin="0 0 6 0"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding CancleAdd}"
|
||||
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="取消" />-->
|
||||
|
||||
<Button
|
||||
Margin="3 0 3 0"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding OpenBoxCommand}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="开药箱" />
|
||||
<Button
|
||||
Margin="0 0 6 0"
|
||||
Visibility="{Binding FinishStatus}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="完成"
|
||||
Command="{Binding AddFinish}"/>
|
||||
|
||||
<Button
|
||||
Margin="6 0 6 0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="刷新" Command="{Binding QueryCommand}">
|
||||
<materialDesign:PackIcon
|
||||
Kind="Refresh" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
|
||||
ItemsSource="{Binding Source={StaticResource GroupedDataList}}"
|
||||
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
materialDesign:DataGridAssist.CellPadding="13"
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False">
|
||||
<DataGrid.Resources>
|
||||
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
||||
<Setter Property="Background" Value="#31ccec" />
|
||||
<Setter Property="Foreground" Value="white" />
|
||||
<Setter Property="Height" Value="56" />
|
||||
<Setter Property="BorderBrush" Value="white"/>
|
||||
<Setter Property="BorderThickness" Value="0.6"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<!--<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsReadOnly" Value="True">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>-->
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridCell">
|
||||
<TextBlock TextAlignment="Center" VerticalAlignment="Center" >
|
||||
<ContentPresenter Margin="13" />
|
||||
</TextBlock>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="{x:Type GroupItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type GroupItem}">
|
||||
<Expander IsExpanded="True"
|
||||
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise" Collapsed="Expander_Collapsed">
|
||||
<Expander.Header >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Margin="0 0 3 0" IsChecked="{Binding Path=Name.IsSelected}" FontSize="24" />
|
||||
<TextBlock Text="{Binding Path=Name.DrawerNo,StringFormat={}{0}号药箱}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<ItemsPresenter/>
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
|
||||
</GroupStyle>
|
||||
</DataGrid.GroupStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="药品名称" Binding="{Binding DrugInfo.DrugName}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding DrugInfo.DrugSpec}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding ManuNo}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="效期" Binding="{Binding EffDate}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="厂家" Binding="{Binding DrugInfo.Manufactory}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="药品基数" Binding="{Binding BaseQuantity}"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddQuantity}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,53 @@
|
|||
using DM_Weight.Models;
|
||||
using DM_Weight.msg;
|
||||
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>
|
||||
/// AdditionWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AdditionWindow : UserControl
|
||||
{
|
||||
IEventAggregator _eventAggregator;
|
||||
public AdditionWindow(IEventAggregator eventAggregator)
|
||||
{
|
||||
InitializeComponent();
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
//private void Expander_Expanded(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
|
||||
//}
|
||||
//收起
|
||||
private void Expander_Collapsed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Expander expander = sender as Expander;
|
||||
if (expander != null)
|
||||
{
|
||||
// 假设你的数据在DataContext中
|
||||
CollectionViewGroup group = expander.DataContext as CollectionViewGroup;
|
||||
if (group != null)
|
||||
{
|
||||
ChannelStock internalGroup = group.Items[0] as ChannelStock;
|
||||
|
||||
_eventAggregator.GetEvent<IsSelectedEvent>().Publish(internalGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 IsSelectedEvent:PubSubEvent<ChannelStock>
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue