From a60c914fc5f211592a17a56c46db8908be27cd0b Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Wed, 4 Dec 2024 09:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E5=AF=B9=E5=8E=BB=E6=8E=A5=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E6=95=88=E6=9C=9F=EF=BC=88=E6=89=8B=E9=BA=BB=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=9C=9F=E5=AD=97=E6=AE=B5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.xaml.cs | 5 +- DM_Weight/Models/BoxMenu.cs | 27 ++++ .../ViewModels/AddNewMenuDialogViewModel.cs | 82 ++++++++++++ .../ViewModels/SetMenuWindowViewModel.cs | 69 +++++++++++ DM_Weight/Views/CheckOrderNewWindow.xaml | 8 +- DM_Weight/Views/CheckSelfOrderWindow.xaml | 8 +- DM_Weight/Views/Dialog/AddNewMenuDialog.xaml | 117 ++++++++++++++++++ .../Views/Dialog/AddNewMenuDialog.xaml.cs | 47 +++++++ DM_Weight/Views/SetMenuWindow.xaml | 108 ++++++++++++++++ DM_Weight/Views/SetMenuWindow.xaml.cs | 28 +++++ 10 files changed, 490 insertions(+), 9 deletions(-) create mode 100644 DM_Weight/Models/BoxMenu.cs create mode 100644 DM_Weight/ViewModels/AddNewMenuDialogViewModel.cs create mode 100644 DM_Weight/ViewModels/SetMenuWindowViewModel.cs create mode 100644 DM_Weight/Views/Dialog/AddNewMenuDialog.xaml create mode 100644 DM_Weight/Views/Dialog/AddNewMenuDialog.xaml.cs create mode 100644 DM_Weight/Views/SetMenuWindow.xaml create mode 100644 DM_Weight/Views/SetMenuWindow.xaml.cs diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 5c692ce..c381a97 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -277,7 +277,7 @@ namespace DM_Weight //containerRegistry.RegisterForNavigation(); ////只有一个冰箱抽屉设置页面 //containerRegistry.RegisterForNavigation(); - //绑定药箱套餐 + //药箱绑定 containerRegistry.RegisterForNavigation(); //药箱设置 containerRegistry.RegisterForNavigation(); @@ -287,6 +287,9 @@ namespace DM_Weight //温湿度记录 containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); #endregion // 设备记录页面 diff --git a/DM_Weight/Models/BoxMenu.cs b/DM_Weight/Models/BoxMenu.cs new file mode 100644 index 0000000..79d732e --- /dev/null +++ b/DM_Weight/Models/BoxMenu.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Models +{ + /// + /// 药品套餐表 + /// + [SugarTable("box_menu")] + public class BoxMenu + { + [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + public int Id { get; set; } + [SugarColumn(ColumnName ="name")] + public string Name { get; set; } + [SugarColumn(ColumnName ="drug_id")] + public string DrugId { get;set; } + [SugarColumn(ColumnName ="base_quantity")] + public int BaseQuantity { get; set; } + [Navigate(NavigateType.ManyToOne, nameof(DrugId))] + public DrugInfo DrugInfo { get; set; } + } +} diff --git a/DM_Weight/ViewModels/AddNewMenuDialogViewModel.cs b/DM_Weight/ViewModels/AddNewMenuDialogViewModel.cs new file mode 100644 index 0000000..36850ed --- /dev/null +++ b/DM_Weight/ViewModels/AddNewMenuDialogViewModel.cs @@ -0,0 +1,82 @@ +using DM_Weight.Models; +using DM_Weight.util; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.ViewModels +{ + public class AddNewMenuDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime + { + public bool KeepAlive => false; + + public string Title => "添加套餐"; + private List? _drugInfos; + + public List? DrugInfos + { + get => _drugInfos; + set => SetProperty(ref _drugInfos, value); + } + public static AddNewMenuDialogViewModel vm; + + IEventAggregator _eventAggregator; + public AddNewMenuDialogViewModel(IEventAggregator eventAggregator) + { + _eventAggregator = eventAggregator; + vm = this; + } + + public event Action RequestClose; + + public bool CanCloseDialog() + { + throw new NotImplementedException(); + } + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnDialogClosed() + { + throw new NotImplementedException(); + } + + public void OnDialogOpened(IDialogParameters parameters) + { + throw new NotImplementedException(); + } + private void GetAllDrugInfos() + { + //var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); + //DrugInfos = list; + 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,' / ',manufactory) as drug_name_spec FROM `drug_info` d"; + DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + //DrugInfos_PY = list; + } + + 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,' / ',manufactory) as drug_name_spec FROM `drug_info` d"; + if (string.IsNullOrEmpty(text)) + { + DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + return; + } + if (DrugInfos != null) + { + DrugInfos.Clear(); + } + DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + } + } +} diff --git a/DM_Weight/ViewModels/SetMenuWindowViewModel.cs b/DM_Weight/ViewModels/SetMenuWindowViewModel.cs new file mode 100644 index 0000000..98a5fcd --- /dev/null +++ b/DM_Weight/ViewModels/SetMenuWindowViewModel.cs @@ -0,0 +1,69 @@ +using DM_Weight.Models; +using DM_Weight.util; +using Prism.Commands; +using Prism.Ioc; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Channels; +using System.Threading.Tasks; + +namespace DM_Weight.ViewModels +{ + public class SetMenuWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + public bool KeepAlive => false; + + private List _menuList; + public List MenuList { get=>_menuList; set=>SetProperty(ref _menuList,value); } + IDialogService _dialogService; + public SetMenuWindowViewModel(IDialogService dialogService) + { + _dialogService = dialogService; + } + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + RequestData(); + } + public void RequestData() + { + MenuList?.Clear(); + var list = SqlSugarHelper.Db.Queryable() + //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase) + .Includes(cs => cs.DrugInfo).ToList(); + if (list != null && list.Count > 0) + { + MenuList = list; + } + else + { + MenuList = null; + } + } + public DelegateCommand BindingAddMenu + { + get => new DelegateCommand(() => + { + DialogParameters dialogParameters=new DialogParameters(); + DialogServiceExtensions.ShowDialogHost(_dialogService, "AddNewMenuDialog", dialogParameters, DoDialogResult, "RootDialog"); + }); + } + private void DoDialogResult(IDialogResult dialogResult) + { + RequestData(); + } + } +} diff --git a/DM_Weight/Views/CheckOrderNewWindow.xaml b/DM_Weight/Views/CheckOrderNewWindow.xaml index ec0e976..538eb19 100644 --- a/DM_Weight/Views/CheckOrderNewWindow.xaml +++ b/DM_Weight/Views/CheckOrderNewWindow.xaml @@ -191,7 +191,7 @@ DisplayMemberBinding="{Binding _OrderDetail.Quantity}" Header="数量"/>--> - + @@ -205,13 +205,13 @@ - + @@ -236,7 +236,7 @@ - --> - + @@ -215,13 +215,13 @@ - + @@ -246,7 +246,7 @@ - + + + + + + + + + + + + + + + + + +