From 3fdbb790ba375888e2549895077a83c38087c2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B7=A7?= <625215135@qq.com> Date: Fri, 4 Jul 2025 16:48:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=BD=95=E5=85=A5=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E4=BF=A1=E6=81=AF=E6=97=B6=E4=BF=AE=E6=94=B9=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E5=BC=B9=E7=AA=97=E6=B7=BB=E5=8A=A0=E8=8D=AF=E5=93=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReportDrugNameDialogViewModel.cs | 70 +++++++++-- .../Views/Dialog/ReportDrugNameDialog.xaml | 117 ++++++++++-------- .../Views/Dialog/ReportDrugNameDialog.xaml.cs | 17 ++- 3 files changed, 141 insertions(+), 63 deletions(-) diff --git a/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs b/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs index c598bb5..178cfc2 100644 --- a/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs @@ -45,12 +45,17 @@ namespace DM_Weight.ViewModels get => _rightDrugName; set => SetProperty(ref _rightDrugName, value); } - + public static ReportDrugNameDialogViewModel vm; public static ObservableCollection defaultAll = new ObservableCollection(); private ObservableCollection _allPremissions = defaultAll; public event Action RequestClose; + public ReportDrugNameDialogViewModel() + { + vm = this; + } + public ObservableCollection AllPremissions { get => _allPremissions; @@ -66,14 +71,14 @@ namespace DM_Weight.ViewModels void RequestData() { AllPremissions = new ObservableCollection(); - string str = "SELECT d.drug_id,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; - if (ConfigurationManager.AppSettings["DrugNames"] != null) - { - str += " where d.drug_id not in (" + CommonClass.ReadAppSetting("DrugNames") + ")"; - } - List DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugId).ToList(); + //string str = "SELECT d.drug_id,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; + //if (ConfigurationManager.AppSettings["DrugNames"] != null) + //{ + // str += " where d.drug_id not in (" + CommonClass.ReadAppSetting("DrugNames") + ")"; + //} + //List DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugId).ToList(); - AllPremissions.AddRange(DrugInfos); + //AllPremissions.AddRange(DrugInfos); string strRight = "SELECT d.drug_id,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; @@ -98,6 +103,7 @@ namespace DM_Weight.ViewModels { //查询报表中的药品名称 RequestData(); + GetAllDrugInfos(); } public DelegateCommand RightSelectedItemChangedCommand @@ -165,5 +171,53 @@ namespace DM_Weight.ViewModels RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); }); } + private ObservableCollection? _drugInfos= defaultAll; + public ObservableCollection ? DrugInfos + { + get => _drugInfos; + set => SetProperty(ref _drugInfos, value); + } + private DrugInfo? _drugInfo; + + public DrugInfo? DrugInfo + { + get => _drugInfo; + set + { + SetProperty(ref _drugInfo, value); + if (_drugInfo != null) + { + AllPremissions.Add(_drugInfo);// = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList(); + } + } + } + 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"; + var DrugInfoslist = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + DrugInfos.AddRange(DrugInfoslist); + //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)) + { + var DrugInfosLst = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + DrugInfos.AddRange(DrugInfosLst); + return; + } + if (DrugInfos != null) + { + DrugInfos.Clear(); + } + var DrugInfosList = SqlSugarHelper.Db.SqlQueryable(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + DrugInfos.AddRange(DrugInfosList); + } } } diff --git a/DM_Weight/Views/Dialog/ReportDrugNameDialog.xaml b/DM_Weight/Views/Dialog/ReportDrugNameDialog.xaml index 234e765..2858830 100644 --- a/DM_Weight/Views/Dialog/ReportDrugNameDialog.xaml +++ b/DM_Weight/Views/Dialog/ReportDrugNameDialog.xaml @@ -30,41 +30,50 @@ - + + + + + + + + + + - - + + - - - - - - - - - - -