Sfoglia il codice sorgente

Merge branch 'master' of https://git.xxb.lttc.cn/wangbc/UniformMaterialManagementSystem

宝臣 王 3 mesi fa
parent
commit
24f0fa4fa6
19 ha cambiato i file con 2557 aggiunte e 1397 eliminazioni
  1. 5 1
      UniformMaterialManagementSystem/App.xaml.cs
  2. 98 0
      UniformMaterialManagementSystem/Utils/SampleRegistrationUtil.cs
  3. 29 9
      UniformMaterialManagementSystem/ViewModels/FactoryLicenseInputPageViewModel.cs
  4. 67 18
      UniformMaterialManagementSystem/ViewModels/InspectionReportInputPageViewModel.cs
  5. 76 67
      UniformMaterialManagementSystem/ViewModels/InspectionReportManagePageViewModel.cs
  6. 304 0
      UniformMaterialManagementSystem/ViewModels/SampleRegistrationInputPageViewModel.cs
  7. 357 0
      UniformMaterialManagementSystem/ViewModels/SampleRegistrationManagePageViewModel.cs
  8. 0 422
      UniformMaterialManagementSystem/ViewModels/SampleRegistrationPageViewModel.cs
  9. 26 16
      UniformMaterialManagementSystem/Views/FactoryLicense/FactoryLicenseInputPage.xaml
  10. 2 2
      UniformMaterialManagementSystem/Views/FactoryLicense/FactoryLicenseManagePage.xaml
  11. 1 1
      UniformMaterialManagementSystem/Views/InspectionRecordPage.xaml
  12. 7 10
      UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportInputPage.xaml
  13. 37 12
      UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportManagePage.xaml
  14. 675 0
      UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml
  15. 19 0
      UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml.cs
  16. 746 0
      UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml
  17. 87 0
      UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml.cs
  18. 9 717
      UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml
  19. 12 122
      UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml.cs

+ 5 - 1
UniformMaterialManagementSystem/App.xaml.cs

@@ -12,6 +12,7 @@ using UniformMaterialManagementSystem.Views;
 using UniformMaterialManagementSystem.Views.FactoryLicense;
 using UniformMaterialManagementSystem.Views.InspectionReport;
 using UniformMaterialManagementSystem.Views.LoginAndRegister;
+using UniformMaterialManagementSystem.Views.SampleRegistration;
 
 namespace UniformMaterialManagementSystem
 {
@@ -75,6 +76,8 @@ namespace UniformMaterialManagementSystem
             services.AddKeyedTransient<UserControl, InspectionReportManagePage>("InspectionReportManagePage");
             services.AddKeyedTransient<UserControl, InspectionReportPage>("InspectionReportPage");
             services.AddKeyedTransient<UserControl, SampleRegistrationPage>("SampleRegistrationPage");
+            services.AddKeyedTransient<UserControl, SampleRegistrationManagePage>("SampleRegistrationManagePage");
+            services.AddKeyedTransient<UserControl, SampleRegistrationInputPage>("SampleRegistrationInputPage");
             services.AddKeyedTransient<UserControl, SelectApplyContractDialog>("SelectApplyContractDialog");
             services.AddKeyedTransient<UserControl, InspectionOrganizationPage>("InspectionOrganizationPage");
             services.AddKeyedTransient<UserControl, FactoryLicensePage>("FactoryLicensePage");
@@ -106,7 +109,8 @@ namespace UniformMaterialManagementSystem
             services.AddTransient<DeliveryReceiptViewModel>();
             services.AddTransient<InspectionReportManagePageViewModel>();
             services.AddTransient<InspectionReportInputPageViewModel>();
-            services.AddTransient<SampleRegistrationPageViewModel>();
+            services.AddTransient<SampleRegistrationManagePageViewModel>();
+            services.AddTransient<SampleRegistrationInputPageViewModel>();
             services.AddTransient<InspectionOrganizationPageViewModel>();
             services.AddTransient<FactoryLicenseInputPageViewModel>();
             services.AddTransient<FactoryLicenseManagePageViewModel>();

+ 98 - 0
UniformMaterialManagementSystem/Utils/SampleRegistrationUtil.cs

@@ -0,0 +1,98 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using UniformMaterialManagementSystem.Models;
+
+namespace UniformMaterialManagementSystem.Utils
+{
+    public static class SampleRegistrationUtil
+    {
+        public static void ExportSampleRegistrationFile(SampleRegistrationModel sampleRegistration)
+        {
+            const string templateFilePath = "Template\\被装材料产品抽样信息登记表模板.docx";
+            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            {
+                Title = "请选择抽样信息登记表保存位置",
+                FileName = "抽样信息登记表-" + sampleRegistration.SampleNo + "-" + WordUtil.GenerateFileSerialNumber(),
+                Filter = "PDF文件格式 (*.pdf)|*.pdf",
+            };
+            if (saveFileDialog.ShowDialog() == false) return;
+            var destinationFile = saveFileDialog.FileName;
+
+            var dictionary = CreateDictionary(sampleRegistration);
+            var tempFile = $"Template\\temp_{WordUtil.GenerateFileSerialNumber()}.docx";
+
+            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
+            WordUtil.SaveWordToPdf(tempFile, destinationFile);
+
+            //删除临时文件
+            File.Delete(tempFile);
+
+            MessageBox.Show("文档已生成!");
+        }
+
+        private static Dictionary<string, string> CreateDictionary(SampleRegistrationModel sampleRegistration)
+        {
+            Dictionary<string, string> dictionary = new()
+            {
+                { "SampleNo", sampleRegistration.SampleNo },
+                { "Department", sampleRegistration.Department },
+                { "EditTime", sampleRegistration.EditTime.ToString("yyyy年MM月dd日") }
+            };
+            //检验类别
+            switch (sampleRegistration.InspectApply.InspCategory)
+            {
+                case "首批检验":
+                    dictionary.Add("FirstSelected", "\u25a0");//选中框
+                    break;
+                case "出厂检验":
+                    dictionary.Add("SecondSelected", "\u25a0");//选中框
+                    break;
+            }
+            dictionary.Add("ProductName", sampleRegistration.InspectApply.ProductName);
+            dictionary.Add("Company", sampleRegistration.InspectApply.Company);
+            dictionary.Add("ProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
+            dictionary.Add("BatchNo", sampleRegistration.BatchNo);
+            dictionary.Add("PacketNo", sampleRegistration.PacketNo);
+            dictionary.Add("Quantity", sampleRegistration.Quantity + sampleRegistration.InspectApply.Material.MeasureUnit + "\u00d7" + "3");
+            dictionary.Add("TestProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
+            dictionary.Add("TestBatchNo", sampleRegistration.BatchNo);
+            dictionary.Add("TestPacketNo", sampleRegistration.PacketNo);
+            dictionary.Add("TestQuantity", sampleRegistration.Quantity + sampleRegistration.InspectApply.Material.MeasureUnit);
+            switch (sampleRegistration.TestingItem)
+            {
+                case "全检":
+                    dictionary.Add("TestAll", "\u25a0");
+                    break;
+                case "强制性指标":
+                    dictionary.Add("MandatoryTest", "\u25a0");
+                    break;
+                case "色牢度":
+                    dictionary.Add("ColorFastness", "\u25a0");
+                    break;
+                case "光谱":
+                    dictionary.Add("Spectrum", "\u25a0");
+                    break;
+                case "参考性指标":
+                    dictionary.Add("Reference", "\u25a0");
+                    break;
+                case "单项指标":
+                    dictionary.Add("Single", "\u25a0");
+
+                    break;
+            }
+            dictionary.Add("SingleIndexItem", sampleRegistration.SingleIndexItem ?? "");
+            dictionary.Add("InspectionOrganization", sampleRegistration.InspectionOrganization);
+            dictionary.Add("ProductUsers", sampleRegistration.ProductUsers ?? "");
+            dictionary.Add("EditUser", sampleRegistration.EditUser);
+            dictionary.Add("Telephone", sampleRegistration.Telephone ?? "");
+
+            return dictionary;
+        }
+    }
+}

+ 29 - 9
UniformMaterialManagementSystem/ViewModels/FactoryLicenseInputPageViewModel.cs

@@ -1,16 +1,15 @@
-using System.Collections.ObjectModel;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
 using System.ComponentModel.DataAnnotations;
-using System.Printing;
 using System.Text;
 using System.Windows;
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.EntityFrameworkCore;
-using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
 using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
 using UniformMaterialManagementSystem.Utils;
+using ValidationResult = System.ComponentModel.DataAnnotations.ValidationResult;
 
 namespace UniformMaterialManagementSystem.ViewModels
 {
@@ -54,11 +53,15 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         [ObservableProperty]
         [Required(ErrorMessage = "审核人不能为空")]
+        [CustomValidation(typeof(FactoryLicenseInputPageViewModel), nameof(ValidateAuditUser))]
         private string _auditUser = string.Empty;
 
         [ObservableProperty]
         private InspectApply? _inspectApply;
 
+        [ObservableProperty]
+        private List<string> _userNames = [];
+
         [ObservableProperty]
         private ObservableCollection<InspectApply> _inspectApplies = [];
 
@@ -69,13 +72,20 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private FactoryLicense? _factoryLicense;
 
-        public FactoryLicenseInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionReport> inspectionReportService, IDataBaseService<SampleRegistration> sampleRegistrationService, IDataBaseService<FactoryLicense> factoryLicenseService)
+        public FactoryLicenseInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionReport> inspectionReportService, IDataBaseService<SampleRegistration> sampleRegistrationService, IDataBaseService<FactoryLicense> factoryLicenseService, IDataBaseService<User> userService)
         {
             _inspectApplyService = inspectApplyService;
             _inspectionReportService = inspectionReportService;
             _sampleRegistrationService = sampleRegistrationService;
             _factoryLicenseService = factoryLicenseService;
 
+            //初始化用户
+            var users = userService.QueryNoTracking(x => x.IsEnabled && x.SupervisionUnitGuid == App.CurrentUser!.SupervisionUnitGuid).ToList();
+            foreach (var user in users)
+            {
+                UserNames.Add(user.UserName);
+            }
+
             LoadData();
         }
 
@@ -103,7 +113,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             //校验是否选择检验申请单
             if (InspectApply == null)
             {
-                MessageBox.Show("请双击检验申请表行数据进行新增,再执行保存!","提示",MessageBoxButton.OK,MessageBoxImage.Warning);
+                MessageBox.Show("请双击检验申请表行数据进行新增,再执行保存!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
 
@@ -246,9 +256,19 @@ namespace UniformMaterialManagementSystem.ViewModels
                             inspectApply.ApplyNo.Substring(inspectApply.ApplyNo.Length - 4, 3);
 
             //发证单位
-            Department = "军需能源质量监督总站" + App.CurrentUser.SupervisionUnit.Name;
+            Department = "军需能源质量监督总站" + App.CurrentUser!.SupervisionUnit.Name;
             EditUser = App.CurrentUser.UserName;
 
         }
+
+        public static ValidationResult? ValidateAuditUser(string auditUser, ValidationContext context)
+        {
+            var instance = (FactoryLicenseInputPageViewModel)context.ObjectInstance;
+            if (!string.IsNullOrEmpty(instance.EditUser) && !string.IsNullOrEmpty(auditUser) && instance.EditUser == auditUser)
+            {
+                return new ValidationResult("审核人不能为承办人");
+            }
+            return ValidationResult.Success;
+        }
     }
 }

+ 67 - 18
UniformMaterialManagementSystem/ViewModels/InspectionReportInputPageViewModel.cs

@@ -5,7 +5,6 @@ using System.Collections.ObjectModel;
 using System.ComponentModel.DataAnnotations;
 using System.Text;
 using System.Windows;
-using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
 using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
@@ -79,7 +78,14 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private InspectionReport? _inspectionReport;
 
-        public InspectionReportInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<User> userService,IDataBaseService<InspectionReport> inspectionReportService)
+        public const string ReportDescOne = "共抽检()包,平均幅宽()厘米,与标样对比色差()级,抽检产品外观质量、实物质量及包装符合标准要求。\r\n备注:随机数(),随机抽取()米(生产日期(),批号(),包号())送()进行理化性能检测,另同包抽取2份备用。";
+        public const string ReportDescTwo = "共抽检()包,平均幅宽()厘米,与标样对比色差()级,抽检产品外观质量、实物质量及包装符合标准要求。\r\n备注:理化检测同(XXXX年XX月XX日)送检……";
+        public const string ConclusionDescOne = "不合格检验情况说明……\r\n综合检验情况,该批抽样产品出厂检验不合格。按要求下达处理意见告知书,要求整改。整改完成后申请二次检验。";
+        public const string ConclusionDescTwo = "经我单位对该批产品抽样检验,抽检产品外观实物质量符合规范要求,待理化检测合格具备出厂条件后,准予出厂。产品出厂后,材料企业依法承担产品生产质量责任。";
+        public const string ConclusionDescThree = "经我单位对该批出厂产品抽样检验,确认具备出厂条件,准予出厂。产品出厂后,材料企业依法承担产品生产质量责任。";
+        public const string ConclusionDescFour = "未抽样,不合格的检验结论描述……";
+
+        public InspectionReportInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<User> userService, IDataBaseService<InspectionReport> inspectionReportService)
         {
             _inspectApplyService = inspectApplyService;
             _inspectionReportService = inspectionReportService;
@@ -90,7 +96,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             //姓名
             var users = userService.QueryNoTracking(
-                x => x.IsEnabled && x.SupervisionUnitGuid == App.CurrentUser.SupervisionUnitGuid).ToList();
+                x => x.IsEnabled && x.SupervisionUnitGuid == App.CurrentUser!.SupervisionUnitGuid).ToList();
             foreach (var user in users)
             {
                 UserNames.Add(user.UserName);
@@ -99,6 +105,24 @@ namespace UniformMaterialManagementSystem.ViewModels
             LoadData();
         }
 
+        /// <summary>
+        /// 是否抽样发生改变时触发
+        /// </summary>
+        partial void OnIsSampleChanged(bool value)
+        {
+            SetReportDesc(value);
+            SetConclusionDesc(value, Conclusion);
+        }
+
+        /// <summary>
+        /// 检验结论发生改变时触发
+        /// </summary>
+        partial void OnConclusionChanged(string value)
+        {
+            SetReportDesc(IsSample);
+            SetConclusionDesc(IsSample, value);
+        }
+
         /// <summary>
         /// 刷新
         /// </summary>
@@ -108,7 +132,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             var inspectApplyList = _inspectApplyService.QueryNoTracking()
                 .Include(x => x.Material)
                 .Include(x => x.InspectApplyContractDetails)
-                .Where(x => x.Year == App.CurrentUser.WorkYear && !x.ReportStatus).ToList();
+                .Where(x => x.Year == App.CurrentUser!.WorkYear && !x.ReportStatus).ToList();
 
             InspectApplies.Clear();
             foreach (var inspectApply in inspectApplyList)
@@ -126,7 +150,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             //校验是否选择检验申请单
             if (SelectedInspectApply == null)
             {
-                MessageBox.Show("请双击检验申请表行数据进行新增,再执行保存!","提示",MessageBoxButton.OK,MessageBoxImage.Warning);
+                MessageBox.Show("请双击检验申请表行数据进行新增,再执行保存!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
 
@@ -141,7 +165,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             Dictionary<string, string> dictionary = CustomValidate();
             if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
             {
-                MessageBox.Show(dictionary["result"],"提示",MessageBoxButton.OK,MessageBoxImage.Warning);
+                MessageBox.Show(dictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
 
@@ -164,7 +188,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             //分离检验申请单跟踪
             if (inspect != null)
             {
-                _inspectApplyService.SetEntryState(inspect,EntityState.Detached);
+                _inspectApplyService.SetEntryState(inspect, EntityState.Detached);
             }
 
             //重新加载检验申请列表
@@ -179,7 +203,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private void GenerateDocument()
         {
-            if (_inspectionReport == null) return;
+            if (_inspectionReport == null || SelectedInspectApply == null) return;
 
             _inspectionReport.InspectApply = SelectedInspectApply;
 
@@ -208,6 +232,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private void AddInspectionReportAndDetail()
         {
+            if (SelectedInspectApply == null) return;
             _inspectionReport = new()
             {
                 InspectApplyGuid = SelectedInspectApply.Guid,
@@ -242,7 +267,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             //校验验收组
             var details = InspectionReportDetails;
-            if (details == null || details.Count == 0)
+            if (details.Count == 0)
             {
                 errorMessage.Append("验收组不允许为空!\n");
             }
@@ -288,7 +313,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             var isRepeat = InspectionReportDetails.GroupBy(x => x.Inspector).Any(g => g.Count() > 1);
-            if (isRepeat != null && (bool)isRepeat)
+            if (isRepeat)
             {
                 errorMessage.Append("验收组姓名有重复,请检查!\n");
             }
@@ -297,9 +322,9 @@ namespace UniformMaterialManagementSystem.ViewModels
             return result;
         }
 
-        /// <summary>
-        /// 选择检验申请单行改变事件
-        /// </summary>
+        ///// <summary>
+        ///// 选择检验申请单行改变事件
+        ///// </summary>
         //[RelayCommand]
         //private void InspectApplySelectionChanged(InspectApply inspectApply)
         //{
@@ -315,7 +340,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             SelectedInspectApply = inspectApply;
 
             ReportNo = inspectApply.ApplyNo.Replace("申请", "");
-            Department = App.CurrentUser.SupervisionUnit.Name;
+            Department = "军需能源质量监督总站" + App.CurrentUser!.SupervisionUnit.Name;
             ReportTime = DateTime.Now;
             InspectCategory = inspectApply.InspCategory;
             PurchaseCompanyNames = GetPurchaseCompanyNames(inspectApply);
@@ -323,8 +348,8 @@ namespace UniformMaterialManagementSystem.ViewModels
             ReportBasis = "依据" + inspectApply.Material.NormName;
             IsSample = true;
             Conclusion = "合格";
-            ReportDesc = "检验情况及主要问题";
-            ConclusionDesc = "请录入检验结论";
+            ReportDesc = ReportDescOne;
+            ConclusionDesc = ConclusionDescTwo;
             EditUser = App.CurrentUser.UserName;
         }
 
@@ -336,7 +361,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         {
             InspectionReportDetail detail = new InspectionReportDetail()
             {
-                SupervisionUnit = App.CurrentUser.SupervisionUnit.Name,
+                SupervisionUnit = App.CurrentUser!.SupervisionUnit.Name,
             };
 
             InspectionReportDetails.Add(detail);
@@ -350,7 +375,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         {
             if (_selectedInspectionReportDetail == null)
             {
-                MessageBox.Show("请选中一行,再执行删除操作!","提示",MessageBoxButton.OK,MessageBoxImage.Warning);
+                MessageBox.Show("请选中一行,再执行删除操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
 
@@ -383,5 +408,29 @@ namespace UniformMaterialManagementSystem.ViewModels
             return sb.ToString();
         }
 
+        private void SetReportDesc(bool isSample)
+        {
+            ReportDesc = isSample ? ReportDescOne : ReportDescTwo;
+        }
+
+        private void SetConclusionDesc(bool isSample, string conclusion)
+        {
+            if (isSample && (conclusion == "合格" || conclusion == "合格(初测不合格,复测合格)"))
+            {
+                ConclusionDesc = ConclusionDescTwo;
+            }
+            else if (isSample && conclusion == "不合格")
+            {
+                ConclusionDesc = ConclusionDescOne;
+            }
+            else if (!isSample && (conclusion == "合格" || conclusion == "合格(初测不合格,复测合格)"))
+            {
+                ConclusionDesc = ConclusionDescThree;
+            }
+            else if (!isSample && conclusion == "不合格")
+            {
+                ConclusionDesc = ConclusionDescFour;
+            }
+        }
     }
 }

+ 76 - 67
UniformMaterialManagementSystem/ViewModels/InspectionReportManagePageViewModel.cs

@@ -58,19 +58,19 @@ namespace UniformMaterialManagementSystem.ViewModels
             LoadData();
         }
 
-        partial void OnSelectedInspectionReportChanging(InspectionReportModel? oldValue, InspectionReportModel? newValue)
-        {
-            if (oldValue == null) return;
-            bool isChanged = IsCurrentReportChanged(oldValue);
-            if (isChanged)
-            {
-                if (!AskIsSave())
-                {
-                    //取消变更新行
-                    SelectedInspectionReport = oldValue;
-                }
-            }
-        }
+        //partial void OnSelectedInspectionReportChanging(InspectionReportModel? oldValue, InspectionReportModel? newValue)
+        //{
+        //    if (oldValue == null) return;
+        //    bool isChanged = IsCurrentReportChanged(oldValue);
+        //    if (isChanged)
+        //    {
+        //        if (!AskIsSave())
+        //        {
+        //            //取消变更新行
+        //            SelectedInspectionReport = oldValue;
+        //        }
+        //    }
+        //}
 
         /// <summary>
         /// 加载数据
@@ -79,7 +79,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void LoadData()
         {
             //询问是否保存
-            if(!AskIsSave()) return;
+            //if(!AskIsSave()) return;
 
             var inspectionReports = _inspectionReportService.Query()
                 .Include(x => x.InspectionReportDetails)
@@ -235,6 +235,12 @@ namespace UniformMaterialManagementSystem.ViewModels
                 return;
             }
 
+            if (SelectedInspectionReport.InspectApply.LicenseStatus)
+            {
+                MessageBox.Show($"检验报告编号:【{SelectedInspectionReport.ReportNo}】已生成许可证,不允许删除!(如需删除,请先删除对应的许可证,再删除检验报告!)", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+
             var result = MessageBox.Show($"确定删除编号为【{SelectedInspectionReport.ReportNo}】的检验报告吗?", "提示", MessageBoxButton.OKCancel,
                 MessageBoxImage.Question);
             if (result != MessageBoxResult.OK) return;
@@ -248,10 +254,13 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             //删除
             _inspectionReportService.Delete(x=>x.Guid == SelectedInspectionReport.Guid); //删除主表时会级联删除子表
-            _inspectionReportService.SaveChanges();
+            var success = _inspectionReportService.SaveChanges();
 
-            //重新加载数据
-            LoadData();
+            if (success)
+            {
+                MessageBox.Show("删除成功!");
+                InspectionReports.Remove(SelectedInspectionReport);
+            }
         }
 
         /// <summary>
@@ -262,7 +271,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         {
             if (SelectedInspectionReport == null) return;
 
-            if (!AskIsSave()) return;
+            //if (!AskIsSave()) return;
 
             InspectionReportUtil.ExportInspectionReportFile(SelectedInspectionReport);
         }
@@ -406,56 +415,56 @@ namespace UniformMaterialManagementSystem.ViewModels
             return false;
         }
 
-        /// <summary>
-        /// 询问是否保存更改
-        /// </summary>
-        private bool AskIsSave()
-        {
-            if (SelectedInspectionReport == null) return true;
-            var isChanged = IsCurrentReportChanged(SelectedInspectionReport);
-            if (!isChanged) return true;
-
-            var result = MessageBox.Show($"检验报告编号【{SelectedInspectionReport?.ReportNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            if (result == MessageBoxResult.Yes)
-            {
-                Dictionary<string, string> dictionary = CustomValidate();
-                if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
-                {
-                    MessageBox.Show(dictionary["result"], "错误", MessageBoxButton.OK, MessageBoxImage.Error);
-                    return false;
-                }
-                //保存修改
-                SaveInspectionReport();
-            }
-            else if (result == MessageBoxResult.No) //放弃更改
-            {
-                var inspectionReport = _inspectionReportService.Get(x => x.Guid == SelectedInspectionReport!.Guid);
-
-                if (inspectionReport == null) //新增行直接移除
-                {
-                    if (SelectedInspectionReport != null) InspectionReports.Remove(SelectedInspectionReport);
-                }
-                else
-                {
-                    _inspectionReportService.SetEntryState(inspectionReport, EntityState.Unchanged);
+        ///// <summary>
+        ///// 询问是否保存更改
+        ///// </summary>
+        //private bool AskIsSave()
+        //{
+        //    if (SelectedInspectionReport == null) return true;
+        //    var isChanged = IsCurrentReportChanged(SelectedInspectionReport);
+        //    if (!isChanged) return true;
 
-                    if (SelectedInspectionReport != null)
-                    {
-                        ModifyModelFromInspectReport(SelectedInspectionReport, inspectionReport);
-
-                        var details = _inspectionReportDetailService
-                            .GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
-                        SelectedInspectionReport.InspectionReportDetails.Clear();//detail被跟踪,clear之后变为Deleted状态
-                        foreach (var detail in details) //重新将数据库的数据赋值过来,并设置跟踪状态Unchanged
-                        {
-                            SelectedInspectionReport.InspectionReportDetails.Add(detail);
-                            _inspectionReportDetailService.SetEntryState(detail, EntityState.Unchanged);
-                        }
-                    }
-                }
-            }
-            return true;
-        }
+        //    var result = MessageBox.Show($"检验报告编号【{SelectedInspectionReport?.ReportNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
+        //    if (result == MessageBoxResult.Yes)
+        //    {
+        //        Dictionary<string, string> dictionary = CustomValidate();
+        //        if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
+        //        {
+        //            MessageBox.Show(dictionary["result"], "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+        //            return false;
+        //        }
+        //        //保存修改
+        //        SaveInspectionReport();
+        //    }
+        //    else if (result == MessageBoxResult.No) //放弃更改
+        //    {
+        //        var inspectionReport = _inspectionReportService.Get(x => x.Guid == SelectedInspectionReport!.Guid);
+
+        //        if (inspectionReport == null) //新增行直接移除
+        //        {
+        //            if (SelectedInspectionReport != null) InspectionReports.Remove(SelectedInspectionReport);
+        //        }
+        //        else
+        //        {
+        //            _inspectionReportService.SetEntryState(inspectionReport, EntityState.Unchanged);
+
+        //            if (SelectedInspectionReport != null)
+        //            {
+        //                ModifyModelFromInspectReport(SelectedInspectionReport, inspectionReport);
+
+        //                var details = _inspectionReportDetailService
+        //                    .GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
+        //                SelectedInspectionReport.InspectionReportDetails.Clear();//detail被跟踪,clear之后变为Deleted状态
+        //                foreach (var detail in details) //重新将数据库的数据赋值过来,并设置跟踪状态Unchanged
+        //                {
+        //                    SelectedInspectionReport.InspectionReportDetails.Add(detail);
+        //                    _inspectionReportDetailService.SetEntryState(detail, EntityState.Unchanged);
+        //                }
+        //            }
+        //        }
+        //    }
+        //    return true;
+        //}
 
         private void ModifyModelFromInspectReport(InspectionReportModel model, InspectionReport report)
         {

+ 304 - 0
UniformMaterialManagementSystem/ViewModels/SampleRegistrationInputPageViewModel.cs

@@ -0,0 +1,304 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+using System.Text;
+using System.Windows;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Utils;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class SampleRegistrationInputPageViewModel : ObservableValidator
+    {
+        [ObservableProperty]
+        private string _sampleNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "单位不能为空")]
+        private string _department = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "时间不能为空")]
+        private DateTime _editTime;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "样品生产日期不能为空")]
+        private DateTime _productDate;
+
+        [ObservableProperty]
+        private string _batchNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "包号不能为空")]
+        [CustomValidation(typeof(SampleRegistrationInputPageViewModel), nameof(ValidatePacketNo))]
+        private string _packetNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "数量不能为空")]
+        [CustomValidation(typeof(SampleRegistrationInputPageViewModel), nameof(ValidateQuantity))]
+        [Range(0.1, double.MaxValue, ErrorMessage = "数量必须大于0")]
+        private decimal _quantity;
+
+        [ObservableProperty]
+        private string _testingItem = string.Empty;
+
+        [ObservableProperty]
+        [CustomValidation(typeof(SampleRegistrationInputPageViewModel), nameof(ValidateSingleIndexItem))]
+        private string? _singleIndexItem;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "检测机构不能为空,请抽取检测机构")]
+        private string _inspectionOrganization = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "生产企业人员不能为空")]
+        private string _productUsers = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "承办人不能为空")]
+        private string _editUser = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "联系电话不能为空")]
+        private string _telephone = string.Empty;
+
+        [ObservableProperty]
+        private string? _randomTip;
+
+        [ObservableProperty]
+        private InspectApply? _inspectApply;
+
+        [ObservableProperty]
+        private List<string> _userNames = [];
+
+        [ObservableProperty]
+        private ObservableCollection<InspectApply> _inspectApplies = [];
+
+        private SampleRegistration? _sampleRegistration;
+
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+        private readonly IDataBaseService<InspectApplyDetail> _inspectApplyDetailService;
+        private readonly IDataBaseService<InspectionOrganization> _organizationService;
+        private readonly IDataBaseService<SampleRegistration> _sampleRegistrationService;
+
+        public SampleRegistrationInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService, IDataBaseService<InspectApplyDetail> inspectApplyDetailService, IDataBaseService<SampleRegistration> sampleRegistrationService,IDataBaseService<User> userService)
+        {
+            _inspectApplyService = inspectApplyService;
+            _inspectApplyDetailService = inspectApplyDetailService;
+            _organizationService = organizationService;
+            _sampleRegistrationService = sampleRegistrationService;
+
+            //初始化人员
+            var users = userService.QueryNoTracking(x =>
+                x.IsEnabled && x.SupervisionUnitGuid == App.CurrentUser!.SupervisionUnitGuid).ToList();
+            foreach (var user in users)
+            {
+                UserNames.Add(user.UserName);
+            }
+
+            //加载数据
+            LoadData();
+        }
+
+        /// <summary>
+        /// 加载数据
+        /// </summary>
+        [RelayCommand]
+        private void LoadData()
+        {
+            var inspectApplyList = _inspectApplyService.QueryNoTracking(x => x.Year == App.CurrentUser!.WorkYear && !x.SampleStatus)
+                .Include(x => x.Material)
+                .Include(x => x.InspectApplyContractDetails).ToList();
+
+            InspectApplies.Clear();
+            foreach (var inspectApply in inspectApplyList)
+            {
+                InspectApplies.Add(inspectApply);
+            }
+        }
+
+        /// <summary>
+        /// 保存
+        /// </summary>
+        [RelayCommand]
+        private void SaveSampleRegistration()
+        {
+            ValidateAllProperties();
+            if (HasErrors) return;
+
+            AddSampleRegistration();
+
+            if (_sampleRegistration == null) return;
+
+            //反写检验申请表的样品登记状态为true
+            var inspectApply = _inspectApplyService.Get(x => x.Guid == _sampleRegistration.InspectApplyGuid);
+            if (inspectApply != null)
+            {
+                inspectApply.SampleStatus = true;
+            }
+
+            var result = _sampleRegistrationService.SaveChanges();
+            if (result)
+            {
+                MessageBox.Show("保存成功!");
+            }
+
+            //脱离跟踪
+            if (inspectApply != null)
+            {
+                _inspectApplyService.SetEntryState(inspectApply, EntityState.Detached);
+            }
+
+            //生成文档
+            SampleRegistrationUtil.ExportSampleRegistrationFile(new SampleRegistrationModel(_sampleRegistration));
+
+            //重新加载数据
+            LoadData();
+
+            //清空界面
+            ClearInput();
+        }
+
+        /// <summary>
+        /// 鼠标双击事件,新增抽样登记表
+        /// </summary>
+        [RelayCommand]
+        private void MouseDoubleClick(InspectApply inspectApply)
+        {
+            InspectApply = inspectApply;
+            if (InspectApply == null) return;
+
+            SampleNo = inspectApply.ApplyNo.Replace("申请", "");
+            Department = App.CurrentUser!.SupervisionUnit.Name;
+            EditTime = inspectApply.InspDate; //默认报检时间
+            ProductDate = inspectApply.StartProductDate; //默认开始生产日期
+            BatchNo = inspectApply.BatchNo;
+            TestingItem = "全检";
+            ProductUsers = "我已知悉样品用途和后续处置方式,对以上样品的抽取封样程序、处理方式及样品的真实性和代表性均无异议。";
+            EditUser = App.CurrentUser.UserName;
+        }
+
+        /// <summary>
+        /// 抽取检测机构
+        /// </summary>
+        [RelayCommand]
+        private void RandomInspectionOrg()
+        {
+            //获取检测机构数量
+            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
+            if (organizations.Count == 0)
+            {
+                RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
+                return;
+            }
+
+            //生成随机数1-3000
+            int random = RandomHelper.CreateRandom(3000);
+            int count = random % 5 + 1;
+
+            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
+            if (organization == null)
+            {
+                RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
+                return;
+            }
+
+            RandomTip = $"随机数:{random}";
+
+            StringBuilder sb = new StringBuilder();
+            sb.AppendLine("随机数:" + random);
+            sb.AppendLine("1.名称:" + organization.Name);
+            sb.AppendLine("2.地址:" + organization.Address);
+            sb.AppendLine("3.联系人:" + organization.Contacts);
+            sb.AppendLine("4.联系电话:" + organization.Telephone);
+
+            InspectionOrganization = sb.ToString();
+        }
+
+        private void ClearInput()
+        {
+            InspectApply = null;
+            SampleNo = string.Empty;
+            Department = string.Empty;
+            EditTime = DateTime.Now;
+            ProductDate = DateTime.Now;
+            BatchNo = string.Empty;
+            PacketNo = string.Empty;
+            Quantity = 0;
+            TestingItem = "全检";
+            SingleIndexItem = string.Empty;
+            InspectionOrganization = string.Empty;
+            ProductUsers = string.Empty;
+            EditUser = string.Empty;
+            Telephone = string.Empty;
+            RandomTip = string.Empty;
+        }
+
+        private void AddSampleRegistration()
+        {
+            if (InspectApply == null) return;
+            _sampleRegistration = new SampleRegistration()
+            {
+                InspectApplyGuid = InspectApply.Guid,
+                SampleNo = SampleNo,
+                Department = Department,
+                EditTime = EditTime,
+                ProductDate = ProductDate,
+                BatchNo = BatchNo,
+                PacketNo = PacketNo,
+                Quantity = Quantity,
+                TestingItem = TestingItem,
+                SingleIndexItem = SingleIndexItem,
+                InspectionOrganization = InspectionOrganization,
+                ProductUsers = ProductUsers,
+                EditUser = EditUser,
+                Telephone = Telephone,
+                Year = App.CurrentUser!.WorkYear,
+            };
+            _sampleRegistrationService.Insert(_sampleRegistration);
+        }
+
+        public static ValidationResult? ValidatePacketNo(string packetNo, ValidationContext context)
+        {
+            var instance = (SampleRegistrationInputPageViewModel)context.ObjectInstance;
+            if (instance.InspectApply == null) return new ValidationResult("检验申请为空");
+
+            var detail = instance._inspectApplyDetailService.QueryNoTracking(x => x.ApplyGuid == instance.InspectApply.Guid).FirstOrDefault(x => x.PacketNo == packetNo);
+
+            return detail == null ? new ValidationResult("包号不存在") : ValidationResult.Success;
+        }
+
+        public static ValidationResult? ValidateQuantity(decimal quantity, ValidationContext context)
+        {
+            var instance = (SampleRegistrationInputPageViewModel)context.ObjectInstance;
+            if (instance.InspectApply == null) return new ValidationResult("检验申请为空");
+
+            var detail = instance._inspectApplyDetailService.QueryNoTracking(x => x.ApplyGuid == instance.InspectApply.Guid).FirstOrDefault(x => x.PacketNo == instance.PacketNo);
+
+            if (detail != null && quantity * 3 > detail.Quantity)
+            {
+                return new ValidationResult("抽样总数量不允许超出包号数量");
+            }
+
+            return ValidationResult.Success;
+        }
+
+        public static ValidationResult? ValidateSingleIndexItem(string singleIndexItem, ValidationContext context)
+        {
+            var instance = (SampleRegistrationInputPageViewModel)context.ObjectInstance;
+            if (instance.InspectApply == null) return ValidationResult.Success;
+
+            if (instance.TestingItem == "单项指标" && string.IsNullOrEmpty(singleIndexItem))
+            {
+                return new ValidationResult("单项指标内容不能为空");
+            }
+
+            return ValidationResult.Success;
+        }
+
+    }
+}

+ 357 - 0
UniformMaterialManagementSystem/ViewModels/SampleRegistrationManagePageViewModel.cs

@@ -0,0 +1,357 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
+using System.Text;
+using System.Windows;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Utils;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class SampleRegistrationManagePageViewModel : ObservableObject
+    {
+        [ObservableProperty]
+        private ObservableCollection<SampleRegistrationModel> _sampleRegistrations = [];
+
+        [ObservableProperty]
+        private SampleRegistrationModel? _selectedSampleRegistration;
+
+        private readonly IDataBaseService<SampleRegistration> _sampleService;
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+        private readonly IDataBaseService<InspectionOrganization> _organizationService;
+
+        public SampleRegistrationManagePageViewModel(IDataBaseService<SampleRegistration> sampleService, IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService)
+        {
+            _sampleService = sampleService;
+            _inspectApplyService = inspectApplyService;
+            _organizationService = organizationService;
+
+            //加载数据
+            LoadData();
+        }
+
+        /// <summary>
+        /// 加载数据
+        /// </summary>
+        [RelayCommand]
+        private void LoadData()
+        {
+            //询问是否保存
+            //if (!AskIsSave()) return;
+
+            var sampleRegistrations = _sampleService.Query()
+                .Include(x => x.InspectApply)
+                .ThenInclude(x => x.Material)
+                .Where(x => x.Year == App.CurrentUser!.WorkYear)
+                .ToList();
+
+            SampleRegistrations.Clear();
+            foreach (var sample in sampleRegistrations)
+            {
+                SampleRegistrations.Add(new SampleRegistrationModel(sample));
+            }
+        }
+
+        /// <summary>
+        /// 删除登记表
+        /// </summary>
+        [RelayCommand]
+        private void RemoveSampleRegistration()
+        {
+            if (SelectedSampleRegistration == null) return;
+
+            var result = MessageBox.Show($"确认删除编号为【{SelectedSampleRegistration.SampleNo}】抽样登记表吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (result != MessageBoxResult.OK) return;
+
+            //删除并反写检验申请单的送样状态为false
+            _sampleService.Delete(x => x.Guid == SelectedSampleRegistration.Guid);
+
+            var inspect = _inspectApplyService.Get(x => x.Guid == SelectedSampleRegistration.InspectApplyGuid);
+            if (inspect != null)
+            {
+                inspect.SampleStatus = false;
+            }
+            var success = _sampleService.SaveChanges();
+            if (success)
+            {
+                MessageBox.Show("删除成功!");
+                SampleRegistrations.Remove(SelectedSampleRegistration);
+            }
+        }
+
+        ///// <summary>
+        ///// 新增
+        ///// </summary>
+        //[RelayCommand]
+        //private void AddSampleRegistration()
+        //{
+        //    if (SelectedSampleRegistration != null)
+        //    {
+        //        //询问是否保存
+        //        if (!AskIsSave()) return;
+        //    }
+
+        //    /* 打开窗口,展示抽样状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
+        //    SelectInspectApplyWindowViewModel viewModel = new SelectInspectApplyWindowViewModel(_inspectApplyService, "SampleRegistration");
+        //    SelectInspectApplyWindow inspectApplyWindow = new SelectInspectApplyWindow(viewModel);
+
+        //    var result = inspectApplyWindow.ShowDialog();
+        //    if (result == null || !(bool)result) return;
+
+        //    var inspectApply = inspectApplyWindow.DataGridMain.SelectedItem as InspectApply;
+        //    if (inspectApply == null) return;
+
+        //    //新增抽样登记并设置默认值
+        //    SampleRegistration sampleRegistration = new SampleRegistration
+        //    {
+        //        InspectApply = inspectApply,
+        //        InspectApplyGuid = inspectApply.Guid,
+        //        SampleNo = inspectApply.ApplyNo.Replace("申请", ""),
+        //        EditTime = DateTime.Now,
+        //        ProductDate = DateTime.Now,
+        //        BatchNo = inspectApply.BatchNo,
+        //        TestingItem = "全检",
+        //        Department = App.CurrentUser!.SupervisionUnit.Name,
+        //        EditUser = App.CurrentUser.UserName,
+        //        Year = App.CurrentUser.WorkYear,
+        //    };
+        //    SampleRegistrationModel model = new SampleRegistrationModel(sampleRegistration);
+
+        //    SampleRegistrations.Add(model);
+
+        //    //选中当前行
+        //    SelectedSampleRegistration = model;
+        //}
+
+        ///// <summary>
+        ///// 保存
+        ///// </summary>
+        //[RelayCommand]
+        //private void SaveSampleRegistration()
+        //{
+        //    if (SelectedSampleRegistration == null) return;
+
+        //    //自定义校验
+        //    var validateDictionary = CustomValidate();
+        //    if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
+        //    {
+        //        MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
+        //        return;
+        //    }
+
+        //    //对新增或修改的抽样登记单进行保存
+        //    var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
+        //    if (sampleRegistration == null)  //新增
+        //    {
+        //        sampleRegistration = new SampleRegistration();
+        //        SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
+        //        _sampleService.Insert(sampleRegistration);
+        //    }
+        //    else  //修改
+        //    {
+        //        SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
+        //    }
+
+        //    //反写检验申请单的抽样送检状态
+        //    var inspectApply = _inspectApplyService.Get(x => x.Guid == sampleRegistration.InspectApplyGuid);
+        //    if (inspectApply != null)
+        //    {
+        //        inspectApply.SampleStatus = true;
+        //    }
+
+        //    var result = _sampleService.SaveChanges();
+
+        //    if (result)
+        //    {
+        //        MessageBox.Show("保存成功!");
+        //    }
+        //}
+
+        /// <summary>
+        /// 导出登记表
+        /// </summary>
+        [RelayCommand]
+        private void ExportSampleRegistration()
+        {
+            if (SelectedSampleRegistration == null)
+            {
+                MessageBox.Show("请先选中一行抽样登记表,再执行导出操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            //询问是否保存
+            //if (!AskIsSave()) return;
+
+            SampleRegistrationUtil.ExportSampleRegistrationFile(SelectedSampleRegistration);
+        }
+
+        /// <summary>
+        /// 随机抽取检测机构
+        /// </summary>
+        [RelayCommand]
+        private void RandomInspectionOrg()
+        {
+            if (SelectedSampleRegistration == null) return;
+
+            //获取检测机构数量
+            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
+            if (organizations.Count == 0)
+            {
+                SelectedSampleRegistration.RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
+                return;
+            }
+
+            //生成随机数
+            int random = RandomHelper.CreateRandom(3000);
+            int count = random % 5 + 1;
+
+            SelectedSampleRegistration.RandomTip = $"系统生成随机数为{random},将使用第{count}家检测机构。";
+
+            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
+            if (organization == null)
+            {
+                SelectedSampleRegistration.RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
+                return;
+            }
+
+            SelectedSampleRegistration.RandomTip = $"随机数:{random}";
+
+            StringBuilder sb = new StringBuilder();
+            sb.AppendLine("随机数:" + random);
+            sb.AppendLine("1.名称:" + organization.Name);
+            sb.AppendLine("2.地址:" + organization.Address);
+            sb.AppendLine("3.联系人:" + organization.Contacts);
+            sb.AppendLine("4.联系电话:" + organization.Telephone);
+
+            SelectedSampleRegistration.InspectionOrganization = sb.ToString();
+        }
+
+        /// <summary>
+        ///判断单据是否有修改,true:已修改 false:未修改
+        /// </summary>
+        private bool IsCurrentSampleChanged(SampleRegistrationModel sampleRegistrationModel)
+        {
+            var sampleRegistration = _sampleService.Get(x => x.Guid == sampleRegistrationModel.Guid);
+            if (sampleRegistration == null) //新增
+            {
+                return true;
+            }
+            else
+            {
+                sampleRegistrationModel.ModifySampleRegistration(sampleRegistration);
+                var state = _sampleService.Entry(sampleRegistration);
+                if (state == EntityState.Modified)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        ///// <summary>
+        ///// 询问是否保存
+        ///// </summary>
+        //private bool AskIsSave()
+        //{
+        //    if (SelectedSampleRegistration == null) return true;
+        //    var isChanged = IsCurrentSampleChanged(SelectedSampleRegistration);
+        //    if (!isChanged) return true;
+        //    var result = MessageBox.Show($"抽样登记表【{SelectedSampleRegistration.SampleNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
+
+        //    if (result == MessageBoxResult.Yes)
+        //    {
+        //        //自定义校验
+        //        var validateDictionary = CustomValidate();
+        //        if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
+        //        {
+        //            MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
+        //            return false;
+        //        }
+        //        SaveSampleRegistration();
+        //    }
+        //    else if (result == MessageBoxResult.No)
+        //    {
+        //        var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
+        //        if (sampleRegistration == null)//新增
+        //        {
+        //            SampleRegistrations.Remove(SelectedSampleRegistration);
+        //        }
+        //        else  //修改
+        //        {
+        //            _sampleService.SetEntryState(sampleRegistration, EntityState.Unchanged);
+        //            ModifyModelFromSampleRegistration(SelectedSampleRegistration, sampleRegistration);
+        //        }
+        //    }
+
+        //    return true;
+        //}
+
+        private Dictionary<string, string> CustomValidate()
+        {
+            Dictionary<string, string> result = new Dictionary<string, string>();
+            StringBuilder errorMessage = new StringBuilder();
+
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Department))
+            {
+                errorMessage.Append("单位不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.EditTime == null)
+            {
+                errorMessage.Append("时间不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.ProductDate == null)
+            {
+                errorMessage.Append("样品生产日期不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.PacketNo))
+            {
+                errorMessage.Append("包号不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.Quantity <= 0)
+            {
+                errorMessage.Append("数量不允许小于等于0!\n");
+            }
+            if (SelectedSampleRegistration?.TestingItem == "单项指标" && string.IsNullOrEmpty(SelectedSampleRegistration?.SingleIndexItem))
+            {
+                errorMessage.Append("检测项目为“单项指标”,单项指标内容不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.InspectionOrganization))
+            {
+                errorMessage.Append("检测机构不允许为空,请抽取检测机构!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.ProductUsers))
+            {
+                errorMessage.Append("生产企业人员不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.EditUser))
+            {
+                errorMessage.Append("承办人不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Telephone))
+            {
+                errorMessage.Append("联系电话不允许为空!\n");
+            }
+            result.Add("result", errorMessage.ToString());
+            return result;
+        }
+
+        private void ModifyModelFromSampleRegistration(SampleRegistrationModel model, SampleRegistration sampleRegistration)
+        {
+            model.Department = sampleRegistration.Department;
+            model.EditTime = sampleRegistration.EditTime;
+            model.ProductDate = sampleRegistration.ProductDate;
+            model.BatchNo = sampleRegistration.BatchNo;
+            model.PacketNo = sampleRegistration.PacketNo;
+            model.Quantity = sampleRegistration.Quantity;
+            model.TestingItem = sampleRegistration.TestingItem;
+            model.SingleIndexItem = sampleRegistration.SingleIndexItem;
+            model.InspectionOrganization = sampleRegistration.InspectionOrganization;
+            model.ProductUsers = sampleRegistration.ProductUsers;
+            model.EditUser = sampleRegistration.EditUser;
+            model.Telephone = sampleRegistration.Telephone;
+        }
+
+    }
+}

+ 0 - 422
UniformMaterialManagementSystem/ViewModels/SampleRegistrationPageViewModel.cs

@@ -1,422 +0,0 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Win32;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Text;
-using System.Windows;
-using UniformMaterialManagementSystem.Entities;
-using UniformMaterialManagementSystem.Models;
-using UniformMaterialManagementSystem.Services;
-using UniformMaterialManagementSystem.Utils;
-using UniformMaterialManagementSystem.Views;
-
-namespace UniformMaterialManagementSystem.ViewModels
-{
-    public partial class SampleRegistrationPageViewModel : ObservableObject
-    {
-        [ObservableProperty]
-        private List<int> _years = [];
-
-        [ObservableProperty]
-        private int _selectedYear = DateTime.Now.Year;
-
-        [ObservableProperty]
-        private ObservableCollection<SampleRegistrationModel> _sampleRegistrations = [];
-
-        [ObservableProperty]
-        private SampleRegistrationModel? _selectedSampleRegistration;
-
-        private readonly IDataBaseService<SampleRegistration> _sampleService;
-        private readonly IDataBaseService<InspectApply> _inspectApplyService;
-        private readonly IDataBaseService<InspectionOrganization> _organizationService;
-
-        public SampleRegistrationPageViewModel(IDataBaseService<SampleRegistration> sampleService, IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService)
-        {
-            _sampleService = sampleService;
-            _inspectApplyService = inspectApplyService;
-            _organizationService = organizationService;
-
-            //初始化年份
-            for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year + 1; i++)
-            {
-                Years.Add(i);
-            }
-
-            //加载数据
-            LoadData();
-        }
-
-        /// <summary>
-        /// 加载数据
-        /// </summary>
-        [RelayCommand]
-        private void LoadData()
-        {
-            //询问是否保存
-            if (!AskIsSave()) return;
-
-            var sampleRegistrations = _sampleService.Query()
-                .Include(x => x.InspectApply)
-                .ThenInclude(x => x.Material)
-                .Where(x => x.Year == SelectedYear)
-                .ToList();
-
-            SampleRegistrations.Clear();
-            foreach (var sample in sampleRegistrations)
-            {
-                SampleRegistrations.Add(new SampleRegistrationModel(sample));
-            }
-        }
-
-        /// <summary>
-        /// 新增
-        /// </summary>
-        [RelayCommand]
-        private void AddSampleRegistration()
-        {
-            if (SelectedSampleRegistration != null)
-            {
-                //询问是否保存
-                if (!AskIsSave()) return;
-            }
-
-            /* 打开窗口,展示抽样状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
-            SelectInspectApplyWindowViewModel viewModel = new SelectInspectApplyWindowViewModel(_inspectApplyService, "SampleRegistration");
-            SelectInspectApplyWindow inspectApplyWindow = new SelectInspectApplyWindow(viewModel);
-
-            var result = inspectApplyWindow.ShowDialog();
-            if (result == null || !(bool)result) return;
-
-            var inspectApply = inspectApplyWindow.DataGridMain.SelectedItem as InspectApply;
-            if (inspectApply == null) return;
-
-            //新增抽样登记并设置默认值
-            SampleRegistration sampleRegistration = new SampleRegistration
-            {
-                InspectApply = inspectApply,
-                InspectApplyGuid = inspectApply.Guid,
-                SampleNo = inspectApply.ApplyNo.Replace("申请", ""),
-                EditTime = DateTime.Now,
-                ProductDate = DateTime.Now,
-                BatchNo = inspectApply.BatchNo,
-                TestingItem = "全检",
-                Department = App.CurrentUser!.SupervisionUnit.Name,
-                EditUser = App.CurrentUser.UserName,
-                Year = App.CurrentUser.WorkYear,
-            };
-            SampleRegistrationModel model = new SampleRegistrationModel(sampleRegistration);
-
-            SampleRegistrations.Add(model);
-
-            //选中当前行
-            SelectedSampleRegistration = model;
-        }
-
-        /// <summary>
-        /// 保存
-        /// </summary>
-        [RelayCommand]
-        private void SaveSampleRegistration()
-        {
-            if (SelectedSampleRegistration == null) return;
-
-            //自定义校验
-            var validateDictionary = CustomValidate();
-            if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
-            {
-                MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
-                return;
-            }
-
-            //对新增或修改的抽样登记单进行保存
-            var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
-            if (sampleRegistration == null)  //新增
-            {
-                sampleRegistration = new SampleRegistration();
-                SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
-                _sampleService.Insert(sampleRegistration);
-            }
-            else  //修改
-            {
-                SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
-            }
-
-            //反写检验申请单的抽样送检状态
-            var inspectApply = _inspectApplyService.Get(x => x.Guid == sampleRegistration.InspectApplyGuid);
-            if (inspectApply != null)
-            {
-                inspectApply.SampleStatus = true;
-            }
-
-            var result = _sampleService.SaveChanges();
-
-            if (result)
-            {
-                MessageBox.Show("保存成功!");
-            }
-        }
-
-        /// <summary>
-        /// 导出登记表
-        /// </summary>
-        [RelayCommand]
-        private void ExportSampleRegistration()
-        {
-            if (SelectedSampleRegistration == null)
-            {
-                MessageBox.Show("请先选中一行抽样登记表,再执行导出操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                return;
-            }
-            //询问是否保存
-            if (!AskIsSave()) return;
-
-            const string templateFilePath = "Template\\被装材料产品抽样信息登记表模板.docx";
-            SaveFileDialog saveFileDialog = new SaveFileDialog()
-            {
-                Title = "请选择抽样信息登记表保存位置",
-                FileName = "抽样信息登记表-" + SelectedSampleRegistration.SampleNo + "-" + WordUtil.GenerateFileSerialNumber(),
-                Filter = "PDF文件格式 (*.pdf)|*.pdf",
-            };
-            if (saveFileDialog.ShowDialog() == false) return;
-            var destinationFile = saveFileDialog.FileName;
-
-            var dictionary = CreateDictionary(SelectedSampleRegistration);
-            var tempFile = $"Template\\temp_{WordUtil.GenerateFileSerialNumber()}.docx";
-
-            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
-            WordUtil.SaveWordToPdf(tempFile, destinationFile);
-
-            //删除临时文件
-            File.Delete(tempFile);
-
-            MessageBox.Show("文档已生成!");
-        }
-
-        /// <summary>
-        /// 随机抽取检测机构
-        /// </summary>
-        [RelayCommand]
-        private void RandomInspectionOrg()
-        {
-            if (SelectedSampleRegistration == null) return;
-
-            //获取检测机构数量
-            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
-            if (organizations.Count == 0)
-            {
-                //MessageBox.Show("没有要抽取的检测机构,请先维护检测机构信息!");
-                SelectedSampleRegistration.RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
-                return;
-            }
-
-            //生成随机数
-            int random = RandomHelper.CreateRandom(5);
-            int count = random == 0 ? organizations.Count : random;
-
-            //MessageBox.Show($"系统生成随机数为{random},将使用第{count}家检测机构。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
-            SelectedSampleRegistration.RandomTip = $"系统生成随机数为{random},将使用第{count}家检测机构。";
-
-            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
-            if (organization == null)
-            {
-                //MessageBox.Show($"第{count}家检测机构不存在,请确保检测机构序号正确!");
-                SelectedSampleRegistration.RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
-                return;
-            }
-
-            StringBuilder sb = new StringBuilder();
-            sb.AppendLine("1.名称:" + organization.Name);
-            sb.AppendLine("2.地址:" + organization.Address);
-            sb.AppendLine("3.联系人:" + organization.Contacts);
-            sb.AppendLine("4.联系电话:" + organization.Telephone);
-
-            SelectedSampleRegistration.InspectionOrganization = sb.ToString();
-        }
-
-        /// <summary>
-        ///判断单据是否有修改,true:已修改 false:未修改
-        /// </summary>
-        private bool IsCurrentSampleChanged(SampleRegistrationModel sampleRegistrationModel)
-        {
-            var sampleRegistration = _sampleService.Get(x => x.Guid == sampleRegistrationModel.Guid);
-            if (sampleRegistration == null) //新增
-            {
-                return true;
-            }
-            else
-            {
-                sampleRegistrationModel.ModifySampleRegistration(sampleRegistration);
-                var state = _sampleService.Entry(sampleRegistration);
-                if (state == EntityState.Modified)
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// 询问是否保存
-        /// </summary>
-        private bool AskIsSave()
-        {
-            if (SelectedSampleRegistration == null) return true;
-            var isChanged = IsCurrentSampleChanged(SelectedSampleRegistration);
-            if (!isChanged) return true;
-            var result = MessageBox.Show($"抽样登记表【{SelectedSampleRegistration.SampleNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
-
-            if (result == MessageBoxResult.Yes)
-            {
-                //自定义校验
-                var validateDictionary = CustomValidate();
-                if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
-                {
-                    MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
-                    return false;
-                }
-                SaveSampleRegistration();
-            }
-            else if (result == MessageBoxResult.No)
-            {
-                var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
-                if (sampleRegistration == null)//新增
-                {
-                    SampleRegistrations.Remove(SelectedSampleRegistration);
-                }
-                else  //修改
-                {
-                    _sampleService.SetEntryState(sampleRegistration, EntityState.Unchanged);
-                    ModifyModelFromSampleRegistration(SelectedSampleRegistration, sampleRegistration);
-                }
-            }
-
-            return true;
-        }
-
-        private Dictionary<string, string> CustomValidate()
-        {
-            Dictionary<string, string> result = new Dictionary<string, string>();
-            StringBuilder errorMessage = new StringBuilder();
-
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Department))
-            {
-                errorMessage.Append("单位不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.EditTime == null)
-            {
-                errorMessage.Append("时间不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.ProductDate == null)
-            {
-                errorMessage.Append("样品生产日期不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.PacketNo))
-            {
-                errorMessage.Append("包号不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.Quantity <= 0)
-            {
-                errorMessage.Append("数量不允许小于等于0!\n");
-            }
-            if (SelectedSampleRegistration?.TestingItem == "单项指标" && string.IsNullOrEmpty(SelectedSampleRegistration?.SingleIndexItem))
-            {
-                errorMessage.Append("检测项目为“单项指标”,单项指标内容不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.InspectionOrganization))
-            {
-                errorMessage.Append("检测机构不允许为空,请抽取检测机构!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.ProductUsers))
-            {
-                errorMessage.Append("生产企业人员不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.EditUser))
-            {
-                errorMessage.Append("承办人不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Telephone))
-            {
-                errorMessage.Append("联系电话不允许为空!\n");
-            }
-            result.Add("result", errorMessage.ToString());
-            return result;
-        }
-
-        private void ModifyModelFromSampleRegistration(SampleRegistrationModel model, SampleRegistration sampleRegistration)
-        {
-            model.Department = sampleRegistration.Department;
-            model.EditTime = sampleRegistration.EditTime;
-            model.ProductDate = sampleRegistration.ProductDate;
-            model.BatchNo = sampleRegistration.BatchNo;
-            model.PacketNo = sampleRegistration.PacketNo;
-            model.Quantity = sampleRegistration.Quantity;
-            model.TestingItem = sampleRegistration.TestingItem;
-            model.SingleIndexItem = sampleRegistration.SingleIndexItem;
-            model.InspectionOrganization = sampleRegistration.InspectionOrganization;
-            model.ProductUsers = sampleRegistration.ProductUsers;
-            model.EditUser = sampleRegistration.EditUser;
-            model.Telephone = sampleRegistration.Telephone;
-        }
-
-        private Dictionary<string, string> CreateDictionary(SampleRegistrationModel sampleRegistration)
-        {
-            Dictionary<string, string> dictionary = new()
-            {
-                { "SampleNo", sampleRegistration.SampleNo },
-                { "Department", sampleRegistration.Department },
-                { "EditTime", sampleRegistration.EditTime.ToString("yyyy年MM月dd日") }
-            };
-            //检验类别
-            switch (sampleRegistration.InspectApply.InspCategory)
-            {
-                case "首批检验":
-                    dictionary.Add("FirstSelected", "\u25a0");//选中框
-                    break;
-                case "出厂检验":
-                    dictionary.Add("SecondSelected", "\u25a0");//选中框
-                    break;
-            }
-            dictionary.Add("ProductName", sampleRegistration.InspectApply.ProductName);
-            dictionary.Add("Company", sampleRegistration.InspectApply.Company);
-            dictionary.Add("ProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
-            dictionary.Add("BatchNo", sampleRegistration.BatchNo);
-            dictionary.Add("PacketNo", sampleRegistration.PacketNo);
-            dictionary.Add("Quantity", sampleRegistration.Quantity + "\u00d7" + "3");
-            dictionary.Add("TestProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
-            dictionary.Add("TestBatchNo", sampleRegistration.BatchNo);
-            dictionary.Add("TestPacketNo", sampleRegistration.PacketNo);
-            dictionary.Add("TestQuantity", sampleRegistration.Quantity + "");
-            switch (sampleRegistration.TestingItem)
-            {
-                case "全检":
-                    dictionary.Add("TestAll", "\u25a0");
-                    break;
-                case "强制性指标":
-                    dictionary.Add("MandatoryTest", "\u25a0");
-                    break;
-                case "色牢度":
-                    dictionary.Add("ColorFastness", "\u25a0");
-                    break;
-                case "光谱":
-                    dictionary.Add("Spectrum", "\u25a0");
-                    break;
-                case "参考性指标":
-                    dictionary.Add("Reference", "\u25a0");
-                    break;
-                case "单项指标":
-                    dictionary.Add("Single", "\u25a0");
-
-                    break;
-            }
-            dictionary.Add("SingleIndexItem", sampleRegistration.SingleIndexItem ?? "");
-            dictionary.Add("InspectionOrganization", sampleRegistration.InspectionOrganization);
-            dictionary.Add("ProductUsers", sampleRegistration.ProductUsers ?? "");
-            dictionary.Add("EditUser", sampleRegistration.EditUser);
-            dictionary.Add("Telephone", sampleRegistration.Telephone ?? "");
-
-            return dictionary;
-        }
-    }
-}

+ 26 - 16
UniformMaterialManagementSystem/Views/FactoryLicense/FactoryLicenseInputPage.xaml

@@ -176,7 +176,7 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Document_Search_16}" />
+                                                        Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
                                                     <TextBlock Text="刷新" />
                                                 </StackPanel>
                                             </Border>
@@ -262,12 +262,6 @@
                         <Setter Property="VerticalAlignment" Value="Stretch" />
                         <Setter Property="VerticalContentAlignment" Value="Center" />
                     </Style>
-
-                    <Style x:Key="CheckBoxColumnElementStyle" TargetType="CheckBox">
-                        <Setter Property="HorizontalAlignment" Value="Center" />
-                        <Setter Property="VerticalAlignment" Value="Center" />
-                        <Setter Property="IsEnabled" Value="False" />
-                    </Style>
                 </control:FilterDataGrid.Resources>
 
                 <control:FilterDataGrid.Columns>
@@ -346,7 +340,7 @@
             HorizontalAlignment="Stretch" />
         <Grid Grid.Column="2" Background="White">
             <ScrollViewer>
-                <Grid Grid.Background="White">
+                <Grid Background="White">
                     <Grid.RowDefinitions>
                         <RowDefinition Height="50" />
                         <RowDefinition Height="40" />
@@ -518,6 +512,7 @@
                         <TextBox
                             Width="120"
                             VerticalAlignment="Center"
+                            IsReadOnly="True"
                             Text="{Binding FactoryQuantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                             TextWrapping="Wrap" />
                         <TextBlock VerticalAlignment="Center" Text="{Binding InspectApply.Material.MeasureUnit}" />
@@ -544,7 +539,7 @@
                         Grid.Row="8"
                         Grid.Column="1"
                         VerticalAlignment="Center"
-                        Text="{Binding Department}" />
+                        Text="{Binding Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="8"
                         Grid.Column="2"
@@ -556,7 +551,7 @@
                         Grid.Row="8"
                         Grid.Column="3"
                         VerticalAlignment="Center"
-                        Text="{Binding SignDate}" />
+                        Text="{Binding SignDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="9"
                         Grid.Column="0"
@@ -564,11 +559,16 @@
                         VerticalAlignment="Center"
                         Text="*承办人:"
                         TextWrapping="Wrap" />
-                    <TextBox
+                    <ComboBox
                         Grid.Row="9"
                         Grid.Column="1"
+                        Height="25"
                         VerticalAlignment="Center"
-                        Text="{Binding EditUser}" />
+                        VerticalContentAlignment="Center"
+                        FontSize="13"
+                        IsEditable="True"
+                        ItemsSource="{Binding UserNames}"
+                        Text="{Binding EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="9"
                         Grid.Column="2"
@@ -576,11 +576,16 @@
                         VerticalAlignment="Center"
                         Text="*批准人:"
                         TextWrapping="Wrap" />
-                    <TextBox
+                    <ComboBox
                         Grid.Row="9"
                         Grid.Column="3"
+                        Height="25"
                         VerticalAlignment="Center"
-                        Text="{Binding ApproveUser}" />
+                        VerticalContentAlignment="Center"
+                        FontSize="13"
+                        IsEditable="True"
+                        ItemsSource="{Binding UserNames}"
+                        Text="{Binding ApproveUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="10"
                         Grid.Column="0"
@@ -588,11 +593,16 @@
                         VerticalAlignment="Center"
                         Text="*审核人:"
                         TextWrapping="Wrap" />
-                    <TextBox
+                    <ComboBox
                         Grid.Row="10"
                         Grid.Column="1"
+                        Height="25"
                         VerticalAlignment="Center"
-                        Text="{Binding AuditUser}" />
+                        VerticalContentAlignment="Center"
+                        FontSize="13"
+                        IsEditable="True"
+                        ItemsSource="{Binding UserNames}"
+                        Text="{Binding AuditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                 </Grid>
             </ScrollViewer>
         </Grid>

+ 2 - 2
UniformMaterialManagementSystem/Views/FactoryLicense/FactoryLicenseManagePage.xaml

@@ -175,7 +175,7 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Document_Search_16}" />
+                                                        Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
                                                     <TextBlock Text="刷新" />
                                                 </StackPanel>
                                             </Border>
@@ -297,7 +297,7 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Dock_20}" />
+                                                        Text="{x:Static utils:RegularFontUtil.Clipboard_Arrow_Right_20}" />
                                                     <TextBlock Text="导出附表" />
                                                 </StackPanel>
                                             </Border>

+ 1 - 1
UniformMaterialManagementSystem/Views/InspectionRecordPage.xaml

@@ -304,7 +304,7 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Dock_20}" />
+                                                        Text="{x:Static utils:RegularFontUtil.Clipboard_Arrow_Right_20}" />
                                                     <TextBlock Text="导出附表" />
                                                 </StackPanel>
                                             </Border>

+ 7 - 10
UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportInputPage.xaml

@@ -838,18 +838,15 @@
                         HorizontalAlignment="Right"
                         Text="承办人:" />
 
-                    <!--<ComboBox
-                    x:Name="EditUserComboBox"
-                    Grid.Row="11"
-                    Grid.Column="1"
-                    Height="25"
-                    IsEditable="True"
-                    ItemsSource="{Binding DataContext.UserNames, RelativeSource={RelativeSource AncestorType=UserControl}}"
-                    LostFocus="Name_OnLostFocus"
-                    SelectedItem="{Binding SelectedInspectionReport.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />-->
-                    <TextBox
+                    <ComboBox
+                        x:Name="EditUserComboBox"
                         Grid.Row="11"
                         Grid.Column="1"
+                        Height="25"
+                        VerticalContentAlignment="Center"
+                        FontSize="13"
+                        IsEditable="True"
+                        ItemsSource="{Binding UserNames}"
                         Text="{Binding EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                 </Grid>
             </ScrollViewer>

+ 37 - 12
UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportManagePage.xaml

@@ -233,7 +233,7 @@
                                     </ControlTemplate>
                                 </Button.Template>
                             </Button>-->
-                            <Button
+                            <!--<Button
                                 x:Name="SaveButton"
                                 Click="SaveButton_OnClick"
                                 Command="{Binding SaveInspectionReportCommand}">
@@ -259,8 +259,8 @@
                                         </ControlTemplate.Triggers>
                                     </ControlTemplate>
                                 </Button.Template>
-                            </Button>
-                            <Separator />
+                            </Button>-->
+                            <!--<Separator />-->
                             <Button Command="{Binding ExportInspectionReportCommand}">
                                 <Button.Template>
                                     <ControlTemplate>
@@ -438,6 +438,7 @@
                     <TextBox
                         Grid.Row="2"
                         Grid.Column="1"
+                        IsReadOnly="True"
                         Text="{Binding SelectedInspectionReport.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="2"
@@ -447,6 +448,7 @@
                     <DatePicker
                         Grid.Row="2"
                         Grid.Column="3"
+                        IsEnabled="False"
                         Text="{Binding SelectedInspectionReport.ReportTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                     <TextBlock
                         Grid.Row="3"
@@ -598,6 +600,7 @@
                         Grid.Column="1"
                         Grid.ColumnSpan="3"
                         HorizontalScrollBarVisibility="Auto"
+                        IsReadOnly="True"
                         Text="{Binding SelectedInspectionReport.ReportBasis, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         TextWrapping="Wrap" />
                     <TextBlock
@@ -631,6 +634,7 @@
                             Foreground="Red"
                             GroupName="IsSampleGroup"
                             IsChecked="{Binding SelectedInspectionReport.IsSample, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            IsEnabled="False"
                             Unchecked="IsSampleRadioButton_Unchecked" />
                         <RadioButton
                             x:Name="NotSampleRadioButton"
@@ -640,7 +644,8 @@
                             VerticalContentAlignment="Center"
                             Content="未抽样送检"
                             GroupName="IsSampleGroup"
-                            IsChecked="True" />
+                            IsChecked="True"
+                            IsEnabled="False" />
                         <TextBox
                             Grid.Row="1"
                             Grid.Column="0"
@@ -649,6 +654,7 @@
                             HorizontalContentAlignment="Left"
                             VerticalContentAlignment="Top"
                             AcceptsReturn="True"
+                            IsReadOnly="True"
                             Text="{Binding SelectedInspectionReport.ReportDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                             TextWrapping="Wrap"
                             VerticalScrollBarVisibility="Auto" />
@@ -681,7 +687,8 @@
                             Content="合格"
                             Foreground="Green"
                             GroupName="ConclusionGroup"
-                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格}" />
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格}"
+                            IsEnabled="False" />
                         <RadioButton
                             x:Name="SecondQualifiedRadioButton"
                             Grid.Row="0"
@@ -691,7 +698,8 @@
                             Content="合格(初测不合格,复测合格)"
                             Foreground="DarkOrange"
                             GroupName="ConclusionGroup"
-                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格(初测不合格,复测合格)}" />
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格(初测不合格,复测合格)}"
+                            IsEnabled="False" />
                         <RadioButton
                             x:Name="UnQualifiedRadioButton"
                             Grid.Row="0"
@@ -701,7 +709,8 @@
                             Content="不合格"
                             Foreground="Red"
                             GroupName="ConclusionGroup"
-                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=不合格}" />
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=不合格}"
+                            IsEnabled="False" />
                         <!--<TextBox
                             x:Name="ConclusionTextBox"
                             Grid.Row="0"
@@ -717,6 +726,7 @@
                             HorizontalContentAlignment="Left"
                             VerticalContentAlignment="Top"
                             AcceptsReturn="True"
+                            IsReadOnly="True"
                             Text="{Binding SelectedInspectionReport.ConclusionDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                             TextWrapping="Wrap"
                             VerticalScrollBarVisibility="Auto" />
@@ -743,7 +753,11 @@
                             BorderThickness="1">
                             <ToolBarPanel>
                                 <ToolBar Background="White" ToolBarTray.IsLocked="True">
-                                    <Button HorizontalContentAlignment="Center" Command="{Binding AddInspectionReportDetailCommand}">
+                                    <Button
+                                        HorizontalContentAlignment="Center"
+                                        Command="{Binding AddInspectionReportDetailCommand}"
+                                        Foreground="Gray"
+                                        IsEnabled="False">
                                         <Button.Template>
                                             <ControlTemplate>
                                                 <Border
@@ -767,7 +781,10 @@
                                             </ControlTemplate>
                                         </Button.Template>
                                     </Button>
-                                    <Button Command="{Binding RemoveInspectionReportDetailCommand}">
+                                    <Button
+                                        Command="{Binding RemoveInspectionReportDetailCommand}"
+                                        Foreground="Gray"
+                                        IsEnabled="False">
                                         <Button.Template>
                                             <ControlTemplate>
                                                 <Border
@@ -834,7 +851,10 @@
                                 </Style>
                             </DataGrid.Resources>
                             <DataGrid.Columns>
-                                <DataGridTemplateColumn Width="100" Header="检验组">
+                                <DataGridTemplateColumn
+                                    Width="100"
+                                    Header="检验组"
+                                    IsReadOnly="True">
                                     <DataGridTemplateColumn.CellTemplate>
                                         <DataTemplate>
                                             <TextBlock
@@ -866,7 +886,8 @@
                                     Binding="{Binding SupervisionUnit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                                     ElementStyle="{StaticResource TextColumnElementStyle}"
-                                    Header="单位" />
+                                    Header="单位"
+                                    IsReadOnly="True" />
 
                                 <!--<DataGridTextColumn
                                     Width="100"
@@ -874,7 +895,10 @@
                                     EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                                     ElementStyle="{StaticResource TextColumnElementStyle}"
                                     Header="姓名" />-->
-                                <DataGridTemplateColumn Width="100" Header="姓名">
+                                <DataGridTemplateColumn
+                                    Width="100"
+                                    Header="姓名"
+                                    IsReadOnly="True">
                                     <DataGridTemplateColumn.CellTemplate>
                                         <DataTemplate>
                                             <TextBlock
@@ -917,6 +941,7 @@
                     <TextBox
                         Grid.Row="11"
                         Grid.Column="1"
+                        IsReadOnly="True"
                         Text="{Binding SelectedInspectionReport.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                 </Grid>
             </ScrollViewer>

+ 675 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml

@@ -0,0 +1,675 @@
+<UserControl
+    x:Class="UniformMaterialManagementSystem.Views.SampleRegistration.SampleRegistrationInputPage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:behaviors="clr-namespace:UniformMaterialManagementSystem.Behaviors"
+    xmlns:control="http://FilterDataGrid.Control.com/2024"
+    xmlns:converters="clr-namespace:UniformMaterialManagementSystem.Converters"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:filterDataGrid="http://FilterDataGrid.Control.com/2024"
+    xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views.SampleRegistration"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    mc:Ignorable="d">
+    <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
+        <!--  定义一个全局的TextBlock样式  -->
+        <Style TargetType="TextBlock">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Margin" Value="5" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="RadioButton">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+        </Style>
+        <Style TargetType="ComboBox">
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="DatePicker">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="TextBox">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
+            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition />
+                        <ColumnDefinition Width="Auto" />
+                        <ColumnDefinition Width="Auto" />
+                    </Grid.ColumnDefinitions>
+                    <Border
+                        Grid.Column="0"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="0,0,0,1">
+                        <ContentPresenter
+                            Margin="5,0"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center" />
+                    </Border>
+                    <Path
+                        x:Name="SortArrow"
+                        Grid.Column="1"
+                        Margin="0,0,5,0"
+                        VerticalAlignment="Center"
+                        Data="M 0 0 L 10 0 L 5 5 Z"
+                        Fill="Gray"
+                        Visibility="Collapsed" />
+                    <Thumb
+                        x:Name="PART_RightHeaderGripper"
+                        Grid.Column="2"
+                        Width="1"
+                        Height="25"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="1"
+                        Cursor="SizeWE" />
+                </Grid>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="SortDirection" Value="Ascending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+                <Trigger Property="SortDirection" Value="Descending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="FontWeight" Value="Bold" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Height" Value="40" />
+            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
+        </Style>
+
+        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="BorderThickness" Value="0,0,1,1" />
+            <Setter Property="BorderBrush" Value="LightSlateGray" />
+        </Style>
+
+        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="FontSize" Value="13" />
+            <Setter Property="Height" Value="26" />
+
+            <Style.Triggers>
+                <Trigger Property="AlternationIndex" Value="1">
+                    <Setter Property="Background" Value="WhiteSmoke" />
+                </Trigger>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+        <Style
+            x:Key="CustomCellStyle"
+            BasedOn="{StaticResource {x:Type DataGridCell}}"
+            TargetType="DataGridCell">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Padding" Value="10" />
+            <Style.Triggers>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                    <Setter Property="Foreground" Value="Black" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+
+    </UserControl.Resources>
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="Auto" />
+            <ColumnDefinition Width="2*" />
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="0">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <!--  菜单项  -->
+                <Border
+                    Grid.Row="0"
+                    BorderBrush="Gray"
+                    BorderThickness="1">
+                    <ToolBarPanel>
+                        <ToolBar Background="White" ToolBarTray.IsLocked="True">
+
+                            <Button Command="{Binding LoadDataCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="45"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
+                                                <TextBlock Text=" 刷新 " />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                            <Separator />
+
+                            <Button Command="{Binding SaveSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="100"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Save_32}" />
+                                                <TextBlock Text="保存并导出登记表" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                        </ToolBar>
+                    </ToolBarPanel>
+                </Border>
+            </Grid>
+            <filterDataGrid:FilterDataGrid
+                x:Name="DataGridMain"
+                Grid.Row="1"
+                behaviors:DataGridBehavior.RowNumbers="True"
+                AutoGenerateColumns="False"
+                Background="White"
+                CanUserAddRows="False"
+                CanUserReorderColumns="True"
+                CellStyle="{StaticResource CustomCellStyle}"
+                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
+                FilterLanguage="SimplifiedChinese"
+                HeadersVisibility="All"
+                HorizontalGridLinesBrush="LightSlateGray"
+                ItemsSource="{Binding InspectApplies, Mode=TwoWay}"
+                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
+                RowStyle="{StaticResource CustomRowStyle}"
+                SelectionMode="Single"
+                ShowRowsCount="True"
+                ShowStatusBar="True"
+                VerticalGridLinesBrush="LightSlateGray">
+
+                <!--  选择行事件  -->
+                <b:Interaction.Triggers>
+                    <b:EventTrigger EventName="MouseDoubleClick">
+                        <b:InvokeCommandAction Command="{Binding MouseDoubleClickCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
+                    </b:EventTrigger>
+                </b:Interaction.Triggers>
+
+                <control:FilterDataGrid.Resources>
+                    <!--  非编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="TextAlignment" Value="Center" />
+                    </Style>
+
+                    <!--  编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
+                        <Setter Property="HorizontalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalContentAlignment" Value="Center" />
+                    </Style>
+                </control:FilterDataGrid.Resources>
+
+                <control:FilterDataGrid.Columns>
+                    <control:FilterDataGridTextColumn
+                        Width="300"
+                        Binding="{Binding ApplyNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请表编号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding InspCategory}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="检验类别"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding ProductName}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="产品名称"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding Company}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="生产企业"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding BatchNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="材料批号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding InspQuantity}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="报检数量"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="150"
+                        Binding="{Binding InspDate, StringFormat=yyyy-MM-dd}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请检验日期"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding ApplyUser}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请人"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                </control:FilterDataGrid.Columns>
+            </filterDataGrid:FilterDataGrid>
+        </Grid>
+
+        <GridSplitter
+            Grid.Column="1"
+            Width="2"
+            HorizontalAlignment="Stretch" />
+        <Grid Grid.Column="2" Background="White">
+            <ScrollViewer>
+                <Grid Background="White">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="45" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="80" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="165" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
+
+                    <TextBlock
+                        Grid.Row="0"
+                        Grid.Column="0"
+                        Grid.ColumnSpan="5"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        FontSize="25"
+                        Text="被装材料产品抽样信息登记表" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="编号:" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding SampleNo}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*单位:" />
+                    <TextBox
+                        Grid.Row="2"
+                        Grid.Column="1"
+                        Text="{Binding Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*时间:" />
+                    <DatePicker
+                        Grid.Row="2"
+                        Grid.Column="3"
+                        Text="{Binding EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="3"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="类别:" />
+                    <Grid
+                        Grid.Row="3"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White"
+                        IsEnabled="False">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <TextBox
+                            x:Name="InspectCategory"
+                            Grid.Column="0"
+                            Text="{Binding InspectApply.InspCategory}"
+                            Visibility="Collapsed" />
+                        <RadioButton
+                            x:Name="FirstSelected"
+                            Grid.Column="0"
+                            HorizontalAlignment="Center"
+                            Content="首批检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}" />
+                        <RadioButton
+                            x:Name="SecondSelected"
+                            Grid.Column="1"
+                            HorizontalAlignment="Center"
+                            Content="出厂检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品名称:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="1"
+                        Text="{Binding InspectApply.Material.Name}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="生产企业:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="3"
+                        Text="{Binding InspectApply.Company}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品生产日期:"
+                        TextWrapping="Wrap" />
+                    <DatePicker
+                        Grid.Row="5"
+                        Grid.Column="1"
+                        Text="{Binding ProductDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*批号:" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="3"
+                        Text="{Binding BatchNo}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*包号:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="1"
+                        Text="{Binding PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="数量:" />
+                    <Grid
+                        Grid.Row="6"
+                        Grid.Column="3"
+                        Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="Auto" />
+                        </Grid.ColumnDefinitions>
+                        <TextBox Grid.Column="0" Text="{Binding Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        <TextBlock Grid.Column="1" Text="{Binding InspectApply.Material.MeasureUnit}" />
+                        <TextBlock Grid.Column="2" Text="共3份" />
+                    </Grid>
+
+                    <TextBlock
+                        Grid.Row="7"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测项目:"
+                        TextWrapping="Wrap" />
+                    <GroupBox
+                        Grid.Row="7"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        VerticalAlignment="Center"
+                        Header="检测项目">
+
+                        <WrapPanel
+                            AllowDrop="True"
+                            FlowDirection="LeftToRight"
+                            Orientation="Horizontal">
+                            <RadioButton
+                                x:Name="TestAllRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="全检"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=全检}" />
+                            <RadioButton
+                                x:Name="MandatoryTestRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="强制性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=强制性指标}" />
+                            <RadioButton
+                                x:Name="ColorFastnessRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="色牢度"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=色牢度}" />
+                            <RadioButton
+                                x:Name="SpectrumRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="光谱"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=光谱}" />
+                            <RadioButton
+                                x:Name="ReferenceRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="参考性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=参考性指标}" />
+                            <RadioButton
+                                x:Name="SingleRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="单项指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=单项指标}" />
+                            <TextBox Width="200" Text="{Binding SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        </WrapPanel>
+                    </GroupBox>
+                    <Button
+                        Grid.Row="8"
+                        Grid.Column="1"
+                        HorizontalAlignment="Left"
+                        Command="{Binding RandomInspectionOrgCommand}">
+                        <Button.Template>
+                            <ControlTemplate>
+                                <Border
+                                    Width="140"
+                                    Height="30"
+                                    Background="{TemplateBinding Background}"
+                                    CornerRadius="5">
+                                    <StackPanel
+                                        HorizontalAlignment="Center"
+                                        VerticalAlignment="Center"
+                                        Orientation="Horizontal">
+                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
+                                        <TextBlock
+                                            HorizontalAlignment="Center"
+                                            VerticalAlignment="Center"
+                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                            FontSize="20"
+                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
+                                    </StackPanel>
+                                </Border>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsMouseOver" Value="True">
+                                        <Setter Property="Background" Value="LightGray" />
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </Button.Template>
+                    </Button>
+                    <TextBlock
+                        Grid.Row="8"
+                        Grid.Column="2"
+                        Grid.ColumnSpan="2"
+                        HorizontalAlignment="Left"
+                        Foreground="DimGray"
+                        Text="{Binding RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="9"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*检测机构:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="9"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Height="150"
+                        AcceptsReturn="True"
+                        Text="{Binding InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="10"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*生产企业人员:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="10"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*承办人:"
+                        TextWrapping="Wrap" />
+                    <ComboBox
+                        Grid.Row="11"
+                        Grid.Column="1"
+                        Height="25"
+                        VerticalContentAlignment="Center"
+                        FontSize="13"
+                        IsEditable="True"
+                        ItemsSource="{Binding UserNames}"
+                        Text="{Binding EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*联系电话:" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="3"
+                        Text="{Binding Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                </Grid>
+            </ScrollViewer>
+
+
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 19 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml.cs

@@ -0,0 +1,19 @@
+using Microsoft.Extensions.DependencyInjection;
+using System.Windows.Controls;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views.SampleRegistration
+{
+    /// <summary>
+    /// SampleRegistrationInputPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class SampleRegistrationInputPage : UserControl
+    {
+        public SampleRegistrationInputPage()
+        {
+            InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService<SampleRegistrationInputPageViewModel>();
+        }
+    }
+}

+ 746 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml

@@ -0,0 +1,746 @@
+<UserControl
+    x:Class="UniformMaterialManagementSystem.Views.SampleRegistration.SampleRegistrationManagePage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:behaviors="clr-namespace:UniformMaterialManagementSystem.Behaviors"
+    xmlns:control="http://FilterDataGrid.Control.com/2024"
+    xmlns:converters="clr-namespace:UniformMaterialManagementSystem.Converters"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:filterDataGrid="http://FilterDataGrid.Control.com/2024"
+    xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    mc:Ignorable="d">
+
+    <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
+        <!--  定义一个全局的TextBlock样式  -->
+        <Style TargetType="TextBlock">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Margin" Value="5" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="RadioButton">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+        </Style>
+        <Style TargetType="ComboBox">
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="DatePicker">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="TextBox">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
+            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition />
+                        <ColumnDefinition Width="Auto" />
+                        <ColumnDefinition Width="Auto" />
+                    </Grid.ColumnDefinitions>
+                    <Border
+                        Grid.Column="0"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="0,0,0,1">
+                        <ContentPresenter
+                            Margin="5,0"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center" />
+                    </Border>
+                    <Path
+                        x:Name="SortArrow"
+                        Grid.Column="1"
+                        Margin="0,0,5,0"
+                        VerticalAlignment="Center"
+                        Data="M 0 0 L 10 0 L 5 5 Z"
+                        Fill="Gray"
+                        Visibility="Collapsed" />
+                    <Thumb
+                        x:Name="PART_RightHeaderGripper"
+                        Grid.Column="2"
+                        Width="1"
+                        Height="25"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="1"
+                        Cursor="SizeWE" />
+                </Grid>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="SortDirection" Value="Ascending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+                <Trigger Property="SortDirection" Value="Descending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="FontWeight" Value="Bold" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Height" Value="40" />
+            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
+        </Style>
+
+        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="BorderThickness" Value="0,0,1,1" />
+            <Setter Property="BorderBrush" Value="LightSlateGray" />
+        </Style>
+
+        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="FontSize" Value="13" />
+            <Setter Property="Height" Value="26" />
+
+            <Style.Triggers>
+                <Trigger Property="AlternationIndex" Value="1">
+                    <Setter Property="Background" Value="WhiteSmoke" />
+                </Trigger>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+        <Style
+            x:Key="CustomCellStyle"
+            BasedOn="{StaticResource {x:Type DataGridCell}}"
+            TargetType="DataGridCell">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Padding" Value="10" />
+            <Style.Triggers>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                    <Setter Property="Foreground" Value="Black" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+
+    </UserControl.Resources>
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="Auto" />
+            <ColumnDefinition Width="2*" />
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="0">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <!--  菜单项  -->
+                <Border
+                    Grid.Row="0"
+                    BorderBrush="Gray"
+                    BorderThickness="1">
+                    <ToolBarPanel>
+                        <ToolBar Background="White" ToolBarTray.IsLocked="True">
+
+                            <Button Command="{Binding LoadDataCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="45"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
+                                                <TextBlock Text=" 刷新 " />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                            <Separator />
+                            <!--<Button Command="{Binding AddSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="40"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Add_Circle_32}" />
+                                                <TextBlock Text="新增" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>-->
+                            <!--<Button Command="{Binding SaveSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="40"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Save_32}" />
+                                                <TextBlock Text="保存" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>-->
+                            <Button Command="{Binding RemoveSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="70"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Delete_48}" />
+                                                <TextBlock Text="删除登记表" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                            <Separator />
+                            <Button Command="{Binding ExportSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="60"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Dock_20}" />
+                                                <TextBlock Text="导出登记表" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+
+                        </ToolBar>
+                    </ToolBarPanel>
+                </Border>
+            </Grid>
+            <filterDataGrid:FilterDataGrid
+                x:Name="DataGridMain"
+                Grid.Row="1"
+                behaviors:DataGridBehavior.RowNumbers="True"
+                AutoGenerateColumns="False"
+                Background="White"
+                CanUserAddRows="False"
+                CanUserReorderColumns="True"
+                CellStyle="{StaticResource CustomCellStyle}"
+                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
+                FilterLanguage="SimplifiedChinese"
+                HeadersVisibility="All"
+                HorizontalGridLinesBrush="LightSlateGray"
+                ItemsSource="{Binding SampleRegistrations, Mode=TwoWay}"
+                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
+                RowStyle="{StaticResource CustomRowStyle}"
+                SelectedItem="{Binding SelectedSampleRegistration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                SelectionChanged="DataGridMain_OnSelectionChanged"
+                SelectionMode="Single"
+                ShowRowsCount="True"
+                ShowStatusBar="True"
+                VerticalGridLinesBrush="LightSlateGray">
+
+                <!--  选择行事件  -->
+                <!--<b:Interaction.Triggers>
+                    <b:EventTrigger EventName="SelectionChanged">
+                        <b:InvokeCommandAction Command="{Binding SampleRegistrationSelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
+                    </b:EventTrigger>
+                </b:Interaction.Triggers>-->
+
+                <control:FilterDataGrid.Resources>
+                    <!--  非编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="TextAlignment" Value="Center" />
+                    </Style>
+
+                    <!--  编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
+                        <Setter Property="HorizontalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalContentAlignment" Value="Center" />
+                    </Style>
+                </control:FilterDataGrid.Resources>
+
+                <control:FilterDataGrid.Columns>
+                    <DataGridTextColumn
+                        Width="60"
+                        Binding="{Binding Year}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="工作年度"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="300"
+                        Binding="{Binding SampleNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="抽样登记表编号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding InspectApply.Company}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="生产企业"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding EditTime, StringFormat=yyyy-MM-dd}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="抽样时间"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding BatchNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="批号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding PacketNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="包号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding EditUser}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="承办人"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                </control:FilterDataGrid.Columns>
+            </filterDataGrid:FilterDataGrid>
+        </Grid>
+
+        <GridSplitter
+            Grid.Column="1"
+            Width="2"
+            HorizontalAlignment="Stretch" />
+        <Grid Grid.Column="2" Background="White">
+            <ScrollViewer>
+                <Grid Background="White">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="45" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="80" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="150" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
+
+                    <TextBlock
+                        Grid.Row="0"
+                        Grid.Column="0"
+                        Grid.ColumnSpan="5"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        FontSize="25"
+                        Text="被装材料产品抽样信息登记表" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="编号:" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding SelectedSampleRegistration.SampleNo}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*单位:" />
+                    <TextBox
+                        Grid.Row="2"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*时间:" />
+                    <DatePicker
+                        Grid.Row="2"
+                        Grid.Column="3"
+                        IsEnabled="False"
+                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="3"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="类别:" />
+                    <Grid
+                        Grid.Row="3"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White"
+                        IsEnabled="False">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <RadioButton
+                            x:Name="FirstSelected"
+                            Grid.Column="0"
+                            HorizontalAlignment="Center"
+                            Content="首批检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding SelectedSampleRegistration.InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}" />
+                        <RadioButton
+                            x:Name="SecondSelected"
+                            Grid.Column="1"
+                            HorizontalAlignment="Center"
+                            Content="出厂检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding SelectedSampleRegistration.InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品名称:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="1"
+                        Text="{Binding SelectedSampleRegistration.InspectApply.Material.Name}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="生产企业:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="3"
+                        Text="{Binding SelectedSampleRegistration.InspectApply.Company}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品生产日期:"
+                        TextWrapping="Wrap" />
+                    <DatePicker
+                        Grid.Row="5"
+                        Grid.Column="1"
+                        IsEnabled="False"
+                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*批号:" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="3"
+                        Text="{Binding SelectedSampleRegistration.BatchNo}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="包号:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="数量:" />
+                    <Grid
+                        Grid.Row="6"
+                        Grid.Column="3"
+                        Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="Auto" />
+                        </Grid.ColumnDefinitions>
+                        <TextBox
+                            Grid.Column="0"
+                            IsReadOnly="True"
+                            Text="{Binding SelectedSampleRegistration.Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        <TextBlock Grid.Column="1" Text="{Binding SelectedSampleRegistration.InspectApply.Material.MeasureUnit}" />
+                        <TextBlock Grid.Column="2" Text="共3份" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="7"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测项目:"
+                        TextWrapping="Wrap" />
+                    <GroupBox
+                        Grid.Row="7"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        VerticalAlignment="Center"
+                        Header="检测项目"
+                        IsEnabled="False">
+
+                        <WrapPanel
+                            AllowDrop="True"
+                            FlowDirection="LeftToRight"
+                            Orientation="Horizontal">
+                            <RadioButton
+                                x:Name="TestAllRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="全检"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=全检}" />
+                            <RadioButton
+                                x:Name="MandatoryTestRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="强制性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=强制性指标}" />
+                            <RadioButton
+                                x:Name="ColorFastnessRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="色牢度"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=色牢度}" />
+                            <RadioButton
+                                x:Name="SpectrumRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="光谱"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=光谱}" />
+                            <RadioButton
+                                x:Name="ReferenceRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="参考性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=参考性指标}" />
+                            <RadioButton
+                                x:Name="SingleRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="单项指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=单项指标}" />
+                            <TextBox Width="200" Text="{Binding SelectedSampleRegistration.SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        </WrapPanel>
+                    </GroupBox>
+                    <Button
+                        Grid.Row="8"
+                        Grid.Column="1"
+                        HorizontalAlignment="Left"
+                        Command="{Binding RandomInspectionOrgCommand}"
+                        Foreground="Gray"
+                        IsEnabled="False">
+                        <Button.Template>
+                            <ControlTemplate>
+                                <Border
+                                    Width="140"
+                                    Height="30"
+                                    Background="{TemplateBinding Background}"
+                                    CornerRadius="5">
+                                    <StackPanel
+                                        HorizontalAlignment="Center"
+                                        VerticalAlignment="Center"
+                                        Orientation="Horizontal">
+                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
+                                        <TextBlock
+                                            HorizontalAlignment="Center"
+                                            VerticalAlignment="Center"
+                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                            FontSize="20"
+                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
+                                    </StackPanel>
+                                </Border>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsMouseOver" Value="True">
+                                        <Setter Property="Background" Value="LightGray" />
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </Button.Template>
+                    </Button>
+                    <TextBlock
+                        Grid.Row="8"
+                        Grid.Column="2"
+                        Grid.ColumnSpan="2"
+                        HorizontalAlignment="Left"
+                        Foreground="DimGray"
+                        Text="{Binding SelectedSampleRegistration.RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="9"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测机构:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="9"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Height="150"
+                        AcceptsReturn="True"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="10"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*生产企业人员:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="10"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*承办人:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*联系电话:" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="3"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                </Grid>
+            </ScrollViewer>
+
+
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 87 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml.cs

@@ -0,0 +1,87 @@
+using Microsoft.Extensions.DependencyInjection;
+using System.Collections.ObjectModel;
+using System.Windows.Controls;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views.SampleRegistration
+{
+    /// <summary>
+    /// SampleRegistrationPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class SampleRegistrationManagePage : UserControl
+    {
+        public SampleRegistrationManagePage()
+        {
+            InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService<SampleRegistrationManagePageViewModel>();
+        }
+
+        //private void RadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
+        //{
+        //    var testingItem = sender as RadioButton;
+        //    if (testingItem != null && testingItem.Content != null)
+        //    {
+        //        var testingItemText = testingItem.Content.ToString();
+        //        TestingItemTextBox.Text = testingItemText == null ? "" : testingItemText;
+        //    }
+        //}
+
+        private void DataGridMain_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var itemsSource = DataGridMain.ItemsSource as ObservableCollection<SampleRegistrationModel>;
+            var count = e.RemovedItems.Count;
+
+            //判断移除选中的行是否需要保存
+            if (count == 0) return;
+            SampleRegistrationModel? preSampleRegistration = e.RemovedItems[0] as SampleRegistrationModel;
+            if (preSampleRegistration == null) return;
+
+            //using SqliteContext context = new();
+            //var sampleRegistration = context.SampleRegistrations.Where(x => x.Guid == preSampleRegistration.Guid).ToList().FirstOrDefault();
+            //if (sampleRegistration == null)//新增行
+            //{
+            //    MessageBox.Show("数据已新增,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+            //    //选中原来行
+            //    //e.AddedItems.Clear();
+            //    DataGridMain.SelectedItem = preSampleRegistration;
+            //}
+            //else
+            //{
+            //    //判断是否修改
+            //    IDataBaseService<SampleRegistration> service = new DataBaseService<SampleRegistration>(context);
+            //    ModifySampleRegistrationFromModel(sampleRegistration, preSampleRegistration);
+            //    var state = service.Entry(sampleRegistration);
+            //    if (state == EntityState.Modified)
+            //    {
+            //        MessageBox.Show("数据已修改,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+            //        //选中原来行
+            //        //if (e.AddedItems.Count > 0)
+            //        //{
+            //        //    e.AddedItems[0] = preSampleRegistration;
+            //        //}
+            //        DataGridMain.SelectedItem = preSampleRegistration;
+            //    }
+            //}
+        }
+
+        private void ModifySampleRegistrationFromModel(Entities.SampleRegistration sampleRegistration, SampleRegistrationModel model)
+        {
+            sampleRegistration.Department = model.Department;
+            sampleRegistration.EditTime = model.EditTime;
+            sampleRegistration.ProductDate = model.ProductDate;
+            sampleRegistration.BatchNo = model.BatchNo;
+            sampleRegistration.PacketNo = model.PacketNo;
+            sampleRegistration.Quantity = model.Quantity;
+            sampleRegistration.TestingItem = model.TestingItem;
+            sampleRegistration.SingleIndexItem = model.SingleIndexItem;
+            sampleRegistration.InspectionOrganization = model.InspectionOrganization;
+            sampleRegistration.ProductUsers = model.ProductUsers;
+            sampleRegistration.EditUser = model.EditUser;
+            sampleRegistration.Telephone = model.Telephone;
+        }
+    }
+}

+ 9 - 717
UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml

@@ -2,730 +2,22 @@
     x:Class="UniformMaterialManagementSystem.Views.SampleRegistrationPage"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
-    xmlns:behaviors="clr-namespace:UniformMaterialManagementSystem.Behaviors"
-    xmlns:control="http://FilterDataGrid.Control.com/2024"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-    xmlns:filterDataGrid="http://FilterDataGrid.Control.com/2024"
     xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    xmlns:sample="clr-namespace:UniformMaterialManagementSystem.Views.SampleRegistration"
     d:DesignHeight="450"
     d:DesignWidth="800"
     mc:Ignorable="d">
-
-    <UserControl.Resources>
-        <!--  定义一个全局的TextBlock样式  -->
-        <Style TargetType="TextBlock">
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="Margin" Value="5" />
-            <Setter Property="VerticalAlignment" Value="Center" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="RadioButton">
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="VerticalAlignment" Value="Center" />
-        </Style>
-        <Style TargetType="ComboBox">
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="DatePicker">
-            <Setter Property="Height" Value="25" />
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="TextBox">
-            <Setter Property="Height" Value="25" />
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
-            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
-                <Grid>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition />
-                        <ColumnDefinition Width="Auto" />
-                        <ColumnDefinition Width="Auto" />
-                    </Grid.ColumnDefinitions>
-                    <Border
-                        Grid.Column="0"
-                        BorderBrush="#E9ECF1"
-                        BorderThickness="0,0,0,1">
-                        <ContentPresenter
-                            Margin="5,0"
-                            HorizontalAlignment="Center"
-                            VerticalAlignment="Center" />
-                    </Border>
-                    <Path
-                        x:Name="SortArrow"
-                        Grid.Column="1"
-                        Margin="0,0,5,0"
-                        VerticalAlignment="Center"
-                        Data="M 0 0 L 10 0 L 5 5 Z"
-                        Fill="Gray"
-                        Visibility="Collapsed" />
-                    <Thumb
-                        x:Name="PART_RightHeaderGripper"
-                        Grid.Column="2"
-                        Width="1"
-                        Height="25"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        BorderBrush="#E9ECF1"
-                        BorderThickness="1"
-                        Cursor="SizeWE" />
-                </Grid>
-            </Border>
-            <ControlTemplate.Triggers>
-                <Trigger Property="SortDirection" Value="Ascending">
-                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
-                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
-                </Trigger>
-                <Trigger Property="SortDirection" Value="Descending">
-                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
-                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
-                </Trigger>
-            </ControlTemplate.Triggers>
-        </ControlTemplate>
-
-        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="Foreground" Value="Black" />
-            <Setter Property="FontWeight" Value="Bold" />
-            <Setter Property="HorizontalContentAlignment" Value="Center" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Height" Value="40" />
-            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
-        </Style>
-
-        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="Foreground" Value="Black" />
-            <Setter Property="BorderThickness" Value="0,0,1,1" />
-            <Setter Property="BorderBrush" Value="LightSlateGray" />
-        </Style>
-
-        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="FontSize" Value="13" />
-            <Setter Property="Height" Value="26" />
-
-            <Style.Triggers>
-                <Trigger Property="AlternationIndex" Value="1">
-                    <Setter Property="Background" Value="WhiteSmoke" />
-                </Trigger>
-                <Trigger Property="IsSelected" Value="True">
-                    <Setter Property="Background" Value="LightBlue" />
-                </Trigger>
-            </Style.Triggers>
-        </Style>
-        <Style
-            x:Key="CustomCellStyle"
-            BasedOn="{StaticResource {x:Type DataGridCell}}"
-            TargetType="DataGridCell">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="HorizontalContentAlignment" Value="Center" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Padding" Value="10" />
-            <Style.Triggers>
-                <Trigger Property="IsSelected" Value="True">
-                    <Setter Property="Background" Value="LightBlue" />
-                    <Setter Property="Foreground" Value="Black" />
-                </Trigger>
-            </Style.Triggers>
-        </Style>
-
-    </UserControl.Resources>
     <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="Auto" />
-            <ColumnDefinition Width="2*" />
-        </Grid.ColumnDefinitions>
-        <Grid Grid.Column="0">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="Auto" />
-                <RowDefinition Height="*" />
-            </Grid.RowDefinitions>
-            <Grid Grid.Row="0">
-                <!--  菜单项  -->
-                <Border
-                    Grid.Row="0"
-                    BorderBrush="Gray"
-                    BorderThickness="1">
-                    <Grid Background="White">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="Auto" />
-                            <ColumnDefinition Width="*" />
-                        </Grid.ColumnDefinitions>
-                        <StackPanel
-                            Grid.Column="0"
-                            FlowDirection="LeftToRight"
-                            Orientation="Horizontal">
-
-                            <TextBlock Text="工作年度:" />
-                            <ComboBox
-                                Width="120"
-                                Height="23"
-                                IsEditable="True"
-                                ItemsSource="{Binding Years}"
-                                SelectedItem="{Binding SelectedYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-
-                        </StackPanel>
-                        <ToolBarPanel Grid.Column="1">
-                            <ToolBar Background="White" ToolBarTray.IsLocked="True">
-
-                                <Button Command="{Binding LoadDataCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="45"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Document_Search_16}" />
-                                                    <TextBlock Text=" 查询 " />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-                                <Separator />
-                                <Button Command="{Binding AddSampleRegistrationCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="40"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Add_Circle_32}" />
-                                                    <TextBlock Text="新增" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-                                <Button Command="{Binding SaveSampleRegistrationCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="40"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Save_32}" />
-                                                    <TextBlock Text="保存" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-                                <Separator />
-                                <Button Command="{Binding ExportSampleRegistrationCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="60"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Dock_20}" />
-                                                    <TextBlock Text="导出登记表" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-
-                            </ToolBar>
-                        </ToolBarPanel>
-                    </Grid>
-                </Border>
-            </Grid>
-            <filterDataGrid:FilterDataGrid
-                x:Name="DataGridMain"
-                Grid.Row="1"
-                behaviors:DataGridBehavior.RowNumbers="True"
-                AutoGenerateColumns="False"
-                Background="White"
-                CanUserAddRows="False"
-                CanUserReorderColumns="True"
-                CellStyle="{StaticResource CustomCellStyle}"
-                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
-                FilterLanguage="SimplifiedChinese"
-                HeadersVisibility="All"
-                HorizontalGridLinesBrush="LightSlateGray"
-                ItemsSource="{Binding SampleRegistrations, Mode=TwoWay}"
-                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
-                RowStyle="{StaticResource CustomRowStyle}"
-                SelectedItem="{Binding SelectedSampleRegistration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                SelectionChanged="DataGridMain_OnSelectionChanged"
-                SelectionMode="Single"
-                ShowRowsCount="True"
-                ShowStatusBar="True"
-                VerticalGridLinesBrush="LightSlateGray">
-
-                <!--  选择行事件  -->
-                <!--<b:Interaction.Triggers>
-                    <b:EventTrigger EventName="SelectionChanged">
-                        <b:InvokeCommandAction Command="{Binding SampleRegistrationSelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
-                    </b:EventTrigger>
-                </b:Interaction.Triggers>-->
-
-                <control:FilterDataGrid.Resources>
-                    <!--  非编辑模式下文本居中的样式  -->
-                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
-                        <Setter Property="HorizontalAlignment" Value="Center" />
-                        <Setter Property="VerticalAlignment" Value="Center" />
-                        <Setter Property="TextAlignment" Value="Center" />
-                    </Style>
-
-                    <!--  编辑模式下文本居中的样式  -->
-                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
-                        <Setter Property="HorizontalAlignment" Value="Stretch" />
-                        <Setter Property="VerticalAlignment" Value="Stretch" />
-                        <Setter Property="VerticalContentAlignment" Value="Center" />
-                    </Style>
-
-                    <Style x:Key="CheckBoxColumnElementStyle" TargetType="CheckBox">
-                        <Setter Property="HorizontalAlignment" Value="Center" />
-                        <Setter Property="VerticalAlignment" Value="Center" />
-                        <Setter Property="IsEnabled" Value="False" />
-                    </Style>
-                </control:FilterDataGrid.Resources>
-
-                <control:FilterDataGrid.Columns>
-                    <DataGridTextColumn
-                        Width="60"
-                        Binding="{Binding Year}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="工作年度"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="300"
-                        Binding="{Binding SampleNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="抽样登记表编号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="200"
-                        Binding="{Binding InspectApply.Company}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="生产企业"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="120"
-                        Binding="{Binding EditTime, StringFormat=yyyy-MM-dd}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="抽样时间"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="200"
-                        Binding="{Binding BatchNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="批号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="120"
-                        Binding="{Binding PacketNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="包号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-
-                    <control:FilterDataGridTextColumn
-                        Width="100"
-                        Binding="{Binding EditUser}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="承办人"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-
-                </control:FilterDataGrid.Columns>
-            </filterDataGrid:FilterDataGrid>
-        </Grid>
-
-        <GridSplitter
-            Grid.Column="1"
-            Width="2"
-            HorizontalAlignment="Stretch" />
-        <Grid Grid.Column="2" Background="White">
-            <ScrollViewer>
-                <Grid Background="White">
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="50" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="45" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="80" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="150" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-
-                    </Grid.RowDefinitions>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="2*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <TextBlock
-                        Grid.Row="0"
-                        Grid.Column="0"
-                        Grid.ColumnSpan="5"
-                        HorizontalAlignment="Center"
-                        VerticalAlignment="Center"
-                        FontSize="25"
-                        Text="被装材料产品抽样信息登记表" />
-                    <TextBlock
-                        Grid.Row="1"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="编号:" />
-                    <TextBlock
-                        Grid.Row="1"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Text="{Binding SelectedSampleRegistration.SampleNo}" />
-                    <TextBlock
-                        Grid.Row="2"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*单位:" />
-                    <TextBox
-                        Grid.Row="2"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="2"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*时间:" />
-                    <DatePicker
-                        Grid.Row="2"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="3"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="类别:" />
-                    <Grid
-                        Grid.Row="3"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Background="White">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="*" />
-                            <ColumnDefinition Width="*" />
-                        </Grid.ColumnDefinitions>
-                        <TextBox
-                            x:Name="InspectCategory"
-                            Grid.Column="0"
-                            Text="{Binding SelectedSampleRegistration.InspectApply.InspCategory}"
-                            TextChanged="InspectCategory_TextChanged"
-                            Visibility="Collapsed" />
-                        <RadioButton
-                            x:Name="FirstSelected"
-                            Grid.Column="0"
-                            HorizontalAlignment="Center"
-                            Content="首批检验"
-                            GroupName="CategoryGroup" />
-                        <RadioButton
-                            x:Name="SecondSelected"
-                            Grid.Column="1"
-                            HorizontalAlignment="Center"
-                            Content="出厂检验"
-                            GroupName="CategoryGroup" />
-                    </Grid>
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="样品名称:"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.InspectApply.Material.Name}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="生产企业:"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.InspectApply.Company}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="样品生产日期:"
-                        TextWrapping="Wrap" />
-                    <DatePicker
-                        Grid.Row="5"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*批号:" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.BatchNo}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="6"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="包号:" />
-                    <TextBox
-                        Grid.Row="6"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="6"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="数量:" />
-                    <TextBox
-                        Grid.Row="6"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="7"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="检测项目:"
-                        TextWrapping="Wrap" />
-                    <GroupBox
-                        Grid.Row="7"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        VerticalAlignment="Center"
-                        Header="检测项目">
-
-                        <WrapPanel
-                            AllowDrop="True"
-                            FlowDirection="LeftToRight"
-                            Orientation="Horizontal">
-                            <RadioButton
-                                x:Name="TestAllRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="全检"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="MandatoryTestRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="强制性指标"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="ColorFastnessRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="色牢度"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="SpectrumRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="光谱"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="ReferenceRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="参考性指标"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="SingleRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="单项指标"
-                                GroupName="TestingItemGroup" />
-                            <TextBox Width="200" Text="{Binding SelectedSampleRegistration.SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                            <TextBox
-                                x:Name="TestingItemTextBox"
-                                Text="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                                TextChanged="TestingItemTextBox_TextChanged"
-                                Visibility="Collapsed" />
-                        </WrapPanel>
-                    </GroupBox>
-                    <Button
-                        Grid.Row="8"
-                        Grid.Column="1"
-                        HorizontalAlignment="Left"
-                        Command="{Binding RandomInspectionOrgCommand}">
-                        <Button.Template>
-                            <ControlTemplate>
-                                <Border
-                                    Width="140"
-                                    Height="30"
-                                    Background="{TemplateBinding Background}"
-                                    CornerRadius="5">
-                                    <StackPanel
-                                        HorizontalAlignment="Center"
-                                        VerticalAlignment="Center"
-                                        Orientation="Horizontal">
-                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
-                                        <TextBlock
-                                            HorizontalAlignment="Center"
-                                            VerticalAlignment="Center"
-                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                            FontSize="20"
-                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
-                                    </StackPanel>
-                                </Border>
-                                <ControlTemplate.Triggers>
-                                    <Trigger Property="IsMouseOver" Value="True">
-                                        <Setter Property="Background" Value="LightGray" />
-                                    </Trigger>
-                                </ControlTemplate.Triggers>
-                            </ControlTemplate>
-                        </Button.Template>
-                    </Button>
-                    <TextBlock
-                        Grid.Row="8"
-                        Grid.Column="2"
-                        Grid.ColumnSpan="2"
-                        HorizontalAlignment="Left"
-                        Foreground="DimGray"
-                        Text="{Binding SelectedSampleRegistration.RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="9"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="检测机构:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="9"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Height="150"
-                        AcceptsReturn="True"
-                        Text="{Binding SelectedSampleRegistration.InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                        TextWrapping="Wrap"
-                        VerticalScrollBarVisibility="Auto" />
-                    <TextBlock
-                        Grid.Row="10"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*生产企业人员:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="10"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Text="{Binding SelectedSampleRegistration.ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="11"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*承办人:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="11"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="11"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*联系电话:" />
-                    <TextBox
-                        Grid.Row="11"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                </Grid>
-            </ScrollViewer>
-
-
-        </Grid>
+        <TabControl>
+            <TabItem Header="抽样登记录入">
+                <sample:SampleRegistrationInputPage />
+            </TabItem>
+            <TabItem Header="抽样登记管理">
+                <sample:SampleRegistrationManagePage />
+            </TabItem>
+        </TabControl>
 
     </Grid>
 </UserControl>

+ 12 - 122
UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml.cs

@@ -1,13 +1,17 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
 using System.Windows;
-using Microsoft.Extensions.DependencyInjection;
 using System.Windows.Controls;
-using Microsoft.EntityFrameworkCore;
-using UniformMaterialManagementSystem.Data;
-using UniformMaterialManagementSystem.Models;
-using UniformMaterialManagementSystem.ViewModels;
-using UniformMaterialManagementSystem.Entities;
-using UniformMaterialManagementSystem.Services;
+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 UniformMaterialManagementSystem.Views
 {
@@ -19,120 +23,6 @@ namespace UniformMaterialManagementSystem.Views
         public SampleRegistrationPage()
         {
             InitializeComponent();
-
-            this.DataContext = App.Current.Services.GetService<SampleRegistrationPageViewModel>();
-        }
-
-        private void InspectCategory_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var category = sender as TextBox;
-            if (category != null)
-            {
-                switch (category.Text)
-                {
-                    case "首批检验":
-                        FirstSelected.IsChecked = true;
-                        break;
-                    case "出厂检验":
-                        SecondSelected.IsChecked = true;
-                        break;
-                }
-            }
-        }
-
-        private void TestingItemTextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var testingItem = sender as TextBox;
-            if (testingItem != null)
-            {
-                switch (testingItem.Text)
-                {
-                    case "全检":
-                        TestAllRadioButton.IsChecked = true;
-                        break;
-                    case "强制性指标":
-                        MandatoryTestRadioButton.IsChecked = true;
-                        break;
-                    case "色牢度":
-                        ColorFastnessRadioButton.IsChecked = true;
-                        break;
-                    case "光谱":
-                        SpectrumRadioButton.IsChecked = true;
-                        break;
-                    case "参考性指标":
-                        ReferenceRadioButton.IsChecked = true;
-                        break;
-                    case "单项指标":
-                        SingleRadioButton.IsChecked = true;
-                        break;
-                }
-            }
-        }
-
-        private void RadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var testingItem = sender as RadioButton;
-            if (testingItem != null && testingItem.Content != null)
-            {
-                var testingItemText = testingItem.Content.ToString();
-                TestingItemTextBox.Text = testingItemText == null ? "" : testingItemText;
-            }
-        }
-
-        private void DataGridMain_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            var itemsSource = DataGridMain.ItemsSource as ObservableCollection<SampleRegistrationModel>;
-            var count = e.RemovedItems.Count;
-
-            //判断移除选中的行是否需要保存
-            if (count == 0) return;
-            SampleRegistrationModel? preSampleRegistration = e.RemovedItems[0] as SampleRegistrationModel;
-            if (preSampleRegistration == null) return;
-
-            //using SqliteContext context = new();
-            //var sampleRegistration = context.SampleRegistrations.Where(x => x.Guid == preSampleRegistration.Guid).ToList().FirstOrDefault();
-            //if (sampleRegistration == null)//新增行
-            //{
-            //    MessageBox.Show("数据已新增,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-
-            //    //选中原来行
-            //    //e.AddedItems.Clear();
-            //    DataGridMain.SelectedItem = preSampleRegistration;
-            //}
-            //else
-            //{
-            //    //判断是否修改
-            //    IDataBaseService<SampleRegistration> service = new DataBaseService<SampleRegistration>(context);
-            //    ModifySampleRegistrationFromModel(sampleRegistration, preSampleRegistration);
-            //    var state = service.Entry(sampleRegistration);
-            //    if (state == EntityState.Modified)
-            //    {
-            //        MessageBox.Show("数据已修改,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-
-            //        //选中原来行
-            //        //if (e.AddedItems.Count > 0)
-            //        //{
-            //        //    e.AddedItems[0] = preSampleRegistration;
-            //        //}
-            //        DataGridMain.SelectedItem = preSampleRegistration;
-            //    }
-            //}
-        }
-
-        private void ModifySampleRegistrationFromModel(SampleRegistration sampleRegistration, SampleRegistrationModel model)
-        {
-            sampleRegistration.Department = model.Department;
-            sampleRegistration.EditTime = model.EditTime;
-            sampleRegistration.ProductDate = model.ProductDate;
-            sampleRegistration.BatchNo = model.BatchNo;
-            sampleRegistration.PacketNo = model.PacketNo;
-            sampleRegistration.Quantity = model.Quantity;
-            sampleRegistration.TestingItem = model.TestingItem;
-            sampleRegistration.SingleIndexItem = model.SingleIndexItem;
-            sampleRegistration.InspectionOrganization = model.InspectionOrganization;
-            sampleRegistration.ProductUsers = model.ProductUsers;
-            sampleRegistration.EditUser = model.EditUser;
-            sampleRegistration.Telephone = model.Telephone;
         }
     }
 }