From f824236252fe895ed4204019174d68866e62a96d Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Mon, 18 Nov 2024 08:58:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=8D=AF=E5=93=81=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E3=80=81=E5=8E=82=E5=AE=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.config | 4 +- DM_Weight/Models/DrugBase.cs | 4 +- DM_Weight/Models/DrugInfo.cs | 6 +- .../BindingChannelDialogViewModel.cs | 10 +- .../BindingChannelNewDialogViewModel.cs | 8 +- .../ViewModels/DrugListWindowViewModel.cs | 14 +- DM_Weight/ViewModels/HomeWindowViewModel.cs | 287 ++++++++++++------ .../Views/Dialog/BindingChannelDialog.xaml | 2 +- .../Views/Dialog/BindingChannelNewDialog.xaml | 2 +- DM_Weight/Views/HomeWindow.xaml | 11 +- 10 files changed, 236 insertions(+), 112 deletions(-) diff --git a/DM_Weight/App.config b/DM_Weight/App.config index b1d7c47..9bfa6cd 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -3,7 +3,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/DM_Weight/Models/DrugBase.cs b/DM_Weight/Models/DrugBase.cs index 694c073..3298824 100644 --- a/DM_Weight/Models/DrugBase.cs +++ b/DM_Weight/Models/DrugBase.cs @@ -17,9 +17,9 @@ namespace DM_Weight.Models private int _baseId = 0; [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } } - private long _drugId = 0; + private string _drugId; [SugarColumn(ColumnName = "drugid")] - public long DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } } + public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } } private string _machineId = ""; [SugarColumn(ColumnName = "machine_id")] public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } } diff --git a/DM_Weight/Models/DrugInfo.cs b/DM_Weight/Models/DrugInfo.cs index ed5ee52..b134d33 100644 --- a/DM_Weight/Models/DrugInfo.cs +++ b/DM_Weight/Models/DrugInfo.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Policy; using Prism.Mvvm; using SqlSugar; namespace DM_Weight.Models @@ -20,7 +21,7 @@ namespace DM_Weight.Models /// ҩƷID /// [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)] - public long DrugId { get; set; } + public string DrugId { get; set; } /// /// ƴ /// @@ -90,7 +91,8 @@ namespace DM_Weight.Models set { SetProperty(ref _base, value); } } - + [SugarColumn(IsIgnore = true)] + public string drug_name_spec { get; set; } } } diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs index 6f06729..ac982f5 100644 --- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs @@ -165,8 +165,10 @@ namespace DM_Weight.ViewModels private void GetAllDrugInfos() { - var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); - DrugInfos = list; + //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(); } private void GetChannelsByDrawerNo() @@ -280,7 +282,7 @@ namespace DM_Weight.ViewModels item.DrugId = DrugInfo.DrugId.ToString(); item.ManuNo = DrugManuNo.ManuNo; item.DrugInfo = DrugInfo; - item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate); + item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate).Substring(0, 10); SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand(); if (item.BoardType == 5) @@ -391,7 +393,7 @@ namespace DM_Weight.ViewModels 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"; + 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(); diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs index 98ede1d..4ef2073 100644 --- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs @@ -208,9 +208,11 @@ namespace DM_Weight.ViewModels private void GetAllDrugInfos() { - var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); - DrugInfos = list; + //var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); + //DrugInfos = list; //DrugInfos_PY = 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(); } private void GetChannelsByDrawerNo() @@ -468,7 +470,7 @@ namespace DM_Weight.ViewModels 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"; + 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(); diff --git a/DM_Weight/ViewModels/DrugListWindowViewModel.cs b/DM_Weight/ViewModels/DrugListWindowViewModel.cs index 3bd2e25..af67eca 100644 --- a/DM_Weight/ViewModels/DrugListWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrugListWindowViewModel.cs @@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels //查询最大药品id并+1赋值给新增药品 - long maxDrugId = SqlSugarHelper.Db.Queryable().Max(it => it.DrugId); + string maxDrugId = SqlSugarHelper.Db.Queryable().Max(it => it.DrugId); SelectedDrug.DrugId = maxDrugId + 1; var f = SqlSugarHelper.Db.UseTran(() => { @@ -207,7 +207,7 @@ namespace DM_Weight.ViewModels SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, + DrugId = SelectedDrug.DrugId.ToString(), MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); @@ -246,7 +246,7 @@ namespace DM_Weight.ViewModels _eventAggregator.GetEvent().Publish(alertMsg); return; } - }, () => SelectedDrug.DrugId <= 0).ObservesProperty(() => SelectedDrug); + }, () => SelectedDrug.DrugId ==null).ObservesProperty(() => SelectedDrug); } public DelegateCommand EditDrugCommand @@ -262,7 +262,7 @@ namespace DM_Weight.ViewModels { SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, + DrugId = SelectedDrug.DrugId.ToString(), MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); @@ -276,7 +276,7 @@ namespace DM_Weight.ViewModels { SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, + DrugId = SelectedDrug.DrugId.ToString(), MachineId = ConfigurationManager.AppSettings["machineId"]??"DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); @@ -306,7 +306,7 @@ namespace DM_Weight.ViewModels _eventAggregator.GetEvent().Publish(alertMsg); } RequestData(); - }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug); + }, () => SelectedDrug.DrugId==null).ObservesProperty(() => SelectedDrug); } public DelegateCommand AddManuCommand @@ -322,7 +322,7 @@ namespace DM_Weight.ViewModels GetManuNos(); } - }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug); + }, () => SelectedDrug.DrugId == null).ObservesProperty(() => SelectedDrug); } public DelegateCommand EditManuCommand diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index cf9b75c..57a6fc0 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -78,76 +78,76 @@ namespace DM_Weight.ViewModels get { return _selectedChildMenu; } set { - if (!_portUtil.Operate) - { - if (value != null) - { - if (value.PremissionPath.Equals("TakeRecordWindow")) - { - //定义传参变量 - NavigationParameters keys = new NavigationParameters(); + //if (!_portUtil.Operate) + //{ + // if (value != null) + // { + // if (value.PremissionPath.Equals("TakeRecordWindow")) + // { + // //定义传参变量 + // NavigationParameters keys = new NavigationParameters(); - //添加参数,键值对格式 - keys.Add("Type", 2); - _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); - } - else if (value.PremissionPath.Equals("AddRecordWindow")) - { - //定义传参变量 - NavigationParameters keys = new NavigationParameters(); + // //添加参数,键值对格式 + // keys.Add("Type", 2); + // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + // } + // else if (value.PremissionPath.Equals("AddRecordWindow")) + // { + // //定义传参变量 + // NavigationParameters keys = new NavigationParameters(); - //添加参数,键值对格式 - keys.Add("Type", 1); - _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); - } - else if (value.PremissionPath.Equals("ReturnRecordWindow")) - { - //定义传参变量 - NavigationParameters keys = new NavigationParameters(); + // //添加参数,键值对格式 + // keys.Add("Type", 1); + // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + // } + // else if (value.PremissionPath.Equals("ReturnRecordWindow")) + // { + // //定义传参变量 + // NavigationParameters keys = new NavigationParameters(); - //添加参数,键值对格式 - keys.Add("Type", 3); - _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); - } - else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow")) - { - //定义传参变量 - NavigationParameters keys = new NavigationParameters(); + // //添加参数,键值对格式 + // keys.Add("Type", 3); + // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + // } + // else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow")) + // { + // //定义传参变量 + // NavigationParameters keys = new NavigationParameters(); - //添加参数,键值对格式 - keys.Add("Type", 3); - _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys); - } - else if (value.PremissionPath.Equals("CheckRecordWindow")) - { - //定义传参变量 - NavigationParameters keys = new NavigationParameters(); + // //添加参数,键值对格式 + // keys.Add("Type", 3); + // _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys); + // } + // else if (value.PremissionPath.Equals("CheckRecordWindow")) + // { + // //定义传参变量 + // NavigationParameters keys = new NavigationParameters(); - //添加参数,键值对格式 - keys.Add("Type", 4); - _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); - } - else - { - if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2")) - { - if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1")) - { - _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2"); - } - else - { - _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); - } - } - else - { - _regionManager.RequestNavigate("ContentRegion", value.PremissionPath); - } - } - } + // //添加参数,键值对格式 + // keys.Add("Type", 4); + // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + // } + // else + // { + // if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2")) + // { + // if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1")) + // { + // _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2"); + // } + // else + // { + // _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); + // } + // } + // else + // { + // _regionManager.RequestNavigate("ContentRegion", value.PremissionPath); + // } + // } + // } SetProperty(ref _selectedChildMenu, value); - } + //} } } @@ -183,39 +183,150 @@ namespace DM_Weight.ViewModels } } - private DelegateCommand _selectionCommon; - public DelegateCommand SelectionCommon + private DelegateCommand _selectionCommon; + public DelegateCommand SelectionCommon { - get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod)); + //get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod)); + get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod)); } - private void SelectionMethod(ListBox viewName) + private void SelectionMethod() { - SelectedMenu = viewName.SelectedItem as PremissionDm; - if (SelectedMenu.PremissionName == "退出") + //SelectedMenu = viewName.SelectedItem as PremissionDm; + //if (SelectedMenu.PremissionName == "退出") + //{ + // if (!_portUtil.Operate) + // { + // _chkFunction.HIKStopDVRRecord(); + // logger.Info($"用户【{Operator?.Nickname}】退出登录"); + // Operator = null; + // Reviewer = null; + // _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + // } + // else + // { + // logger.Info($"未关闭抽屉操作退出"); + // SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); + // SnackbarMessageQueue.Enqueue("请关闭抽屉后再退出"); + // return; + // } + //} + //else + //{ + // //SelectedMenu.Children = SelectedMenu.Children; + // SelectedChildMenu = SelectedMenu.Children[0]; + //} + logger.Info("开始进入父菜单"); + if (SelectedMenu != null && SelectedMenu.PremissionName == "退出") { - if (!_portUtil.Operate) - { - _chkFunction.HIKStopDVRRecord(); - logger.Info($"用户【{Operator?.Nickname}】退出登录"); - Operator = null; - Reviewer = null; - _regionManager.RequestNavigate("MainRegion", "LoginWindow"); - } - else - { - logger.Info($"未关闭抽屉操作退出"); - SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); - SnackbarMessageQueue.Enqueue("请关闭抽屉后再退出"); - return; - } + logger.Info($"用户【{Operator?.Nickname}】退出登录"); + Operator = null; + Reviewer = null; + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); } else { - //SelectedMenu.Children = SelectedMenu.Children; - SelectedChildMenu = SelectedMenu.Children[0]; + if (!_portUtil.Operate) + { + _regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath); + } + } + logger.Info("结束父菜单"); + } + #region + private DelegateCommand _selectionChildCommon; + public DelegateCommand SelectionChildCommon + { + get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod)); + } + private void SelectionChildMethod() + { + SelectChildNavigate(SelectedChildMenu); + } + private void SelectChildNavigate(PremissionDm SelectedChildMenu) + { + if (!_portUtil.Operate) + { + if (SelectedChildMenu != null) + { + if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 2); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 1); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 3); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 3); + _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 4); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else + { + if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2")) + { + if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1")) + { + _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2"); + } + else + { + _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); + } + } + else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow")) + { + //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"])>0) + //{ + // _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow"); + //} + //else + { + _regionManager.RequestNavigate("ContentRegion", "SettingWindow"); + } + } + else + { + _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath); + } + } + } } } + #endregion public List PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } } public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } } @@ -350,6 +461,8 @@ namespace DM_Weight.ViewModels PremissionDmList = premissions; SelectedMenu = premissions[0]; SelectedChildMenu = premissions[0].Children[0]; + _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath); + FindDrawerCount(); int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0"); diff --git a/DM_Weight/Views/Dialog/BindingChannelDialog.xaml b/DM_Weight/Views/Dialog/BindingChannelDialog.xaml index a383533..53857ac 100644 --- a/DM_Weight/Views/Dialog/BindingChannelDialog.xaml +++ b/DM_Weight/Views/Dialog/BindingChannelDialog.xaml @@ -52,7 +52,7 @@ IsEditable="True" ItemsSource="{Binding DrugInfos}" SelectedItem="{Binding DrugInfo}" - DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp" + DisplayMemberPath="drug_name_spec" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp" />