Преглед на файлове

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

宝臣 王 преди 3 месеца
родител
ревизия
13d1d6e100
променени са 21 файла, в които са добавени 1640 реда и са изтрити 103 реда
  1. BIN
      Document/被装材料业务系统需求描述 v1.docx
  2. BIN
      Document/被装材料数据库设计.docx
  3. 2 0
      UniformMaterialManagementSystem/App.xaml.cs
  4. 1 1
      UniformMaterialManagementSystem/Data/SqliteContext.cs
  5. 1 1
      UniformMaterialManagementSystem/Entities/InspectionReport.cs
  6. 2 0
      UniformMaterialManagementSystem/Services/DataBaseService.cs
  7. 2 0
      UniformMaterialManagementSystem/Services/IDataBaseService.cs
  8. BIN
      UniformMaterialManagementSystem/Template/军需物资质量监督检验报告模板.docx
  9. 3 0
      UniformMaterialManagementSystem/UniformMaterialManagementSystem.csproj
  10. 28 15
      UniformMaterialManagementSystem/ViewModels/ContractPageViewModel.cs
  11. 3 1
      UniformMaterialManagementSystem/ViewModels/InspectApplyPageViewModel.cs
  12. 1 2
      UniformMaterialManagementSystem/ViewModels/InspectionRecordPageViewModel.cs
  13. 537 0
      UniformMaterialManagementSystem/ViewModels/InspectionReportPageViewModel.cs
  14. 49 0
      UniformMaterialManagementSystem/ViewModels/SelectInspectApplyToReportWindowViewModel.cs
  15. 8 1
      UniformMaterialManagementSystem/Views/ContractPage.xaml
  16. 6 1
      UniformMaterialManagementSystem/Views/ContractPage.xaml.cs
  17. 4 1
      UniformMaterialManagementSystem/Views/InspectApplyPage.xaml
  18. 584 67
      UniformMaterialManagementSystem/Views/InspectionReportPage.xaml
  19. 68 13
      UniformMaterialManagementSystem/Views/InspectionReportPage.xaml.cs
  20. 294 0
      UniformMaterialManagementSystem/Views/SelectInspectApplyToReportWindow.xaml
  21. 47 0
      UniformMaterialManagementSystem/Views/SelectInspectApplyToReportWindow.xaml.cs

BIN
Document/被装材料业务系统需求描述 v1.docx


BIN
Document/被装材料数据库设计.docx


+ 2 - 0
UniformMaterialManagementSystem/App.xaml.cs

@@ -80,6 +80,8 @@ namespace UniformMaterialManagementSystem
             services.AddTransient<InspectionRecordPageViewModel>();
             services.AddTransient<ContractPageViewModel>();
             services.AddTransient<DeliveryReceiptViewModel>();
+            services.AddTransient<InspectionReportPageViewModel>();
+            services.AddTransient<SelectInspectApplyToReportWindowViewModel>();
 
             // Service 注册
             services.AddScoped(typeof(IDataBaseService<>), typeof(DataBaseService<>));

+ 1 - 1
UniformMaterialManagementSystem/Data/SqliteContext.cs

@@ -93,7 +93,7 @@ namespace UniformMaterialManagementSystem.Data
 
             modelBuilder.Entity<InspectionReportDetail>()
                 .HasOne(p => p.InspectionReport)
-                .WithMany(x => x.InspectReportDetails)
+                .WithMany(x => x.InspectionReportDetails)
                 .HasForeignKey(p => p.InspectionReportGuid);
 
         }

+ 1 - 1
UniformMaterialManagementSystem/Entities/InspectionReport.cs

@@ -40,7 +40,7 @@ namespace UniformMaterialManagementSystem.Entities
 
         public InspectApply InspectApply { get; set; } = null!;
 
-        public ObservableCollection<InspectionReportDetail> InspectReportDetails { get; set; } = null!;
+        public ObservableCollection<InspectionReportDetail> InspectionReportDetails { get; set; } = null!;
 
     }
 }

+ 2 - 0
UniformMaterialManagementSystem/Services/DataBaseService.cs

@@ -129,6 +129,8 @@ namespace UniformMaterialManagementSystem.Services
 
         public EntityState Entry(TEntity entity) => context.Entry(entity).State;
 
+        public void SetEntryState(TEntity entity, EntityState state) => context.Entry(entity).State = state;
+
         #endregion
 
         #region Save

+ 2 - 0
UniformMaterialManagementSystem/Services/IDataBaseService.cs

@@ -55,6 +55,8 @@ namespace UniformMaterialManagementSystem.Services
 
         EntityState Entry(TEntity entity);
 
+        void SetEntryState(TEntity entity, EntityState state);
+
         #endregion
 
         #region Aggregate

BIN
UniformMaterialManagementSystem/Template/军需物资质量监督检验报告模板.docx


+ 3 - 0
UniformMaterialManagementSystem/UniformMaterialManagementSystem.csproj

@@ -71,6 +71,9 @@
 		<None Update="Template\军需物资质量检验申请表模板.docx">
 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 		</None>
+		<None Update="Template\军需物资质量监督检验报告模板.docx">
+		  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</None>
 		<None Update="Template\附件1被装材料采购合同明细数据模板.xlsx">
 		  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 		</None>

+ 28 - 15
UniformMaterialManagementSystem/ViewModels/ContractPageViewModel.cs

@@ -1,20 +1,15 @@
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
-
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Win32;
-
 using System.Collections.ObjectModel;
 using System.ComponentModel.DataAnnotations;
-using System.Data;
 using System.IO;
 using System.Text;
 using System.Windows;
-
 using UniformMaterialManagementSystem.Entities;
 using UniformMaterialManagementSystem.Services;
 using UniformMaterialManagementSystem.Utils;
-using UniformMaterialManagementSystem.Views;
 
 namespace UniformMaterialManagementSystem.ViewModels
 {
@@ -64,9 +59,6 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private bool _isUpload;
 
-        //[ObservableProperty]
-        //private bool _isCompany;
-
         [ObservableProperty]
         private ObservableCollection<ContractDetail> _contractDetails = [];
 
@@ -143,11 +135,8 @@ namespace UniformMaterialManagementSystem.ViewModels
                 Materials.Add(material);
             }
 
-            //获取是否材料企业用户
-            //IsCompany = InspectApplyUtil.GetIsCompanyUser();
-
-            //默认材料企业
-            SelectedMaterialCompany = MaterialCompanies.FirstOrDefault(c => c.Guid == App.CurrentUser.CompanyGuid);
+            //默认材料企业或成品企业
+            SetDefaultCompany();
 
             //默认填报人
             EditUser = App.CurrentUser.UserName;
@@ -156,6 +145,27 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         #region 合同录入相关方法
 
+        /// <summary>
+        /// 默认材料企业或成品企业
+        /// </summary>
+        private void SetDefaultCompany()
+        {
+            var currentRoleType = CommonUtil.GetRoleType();
+            if (currentRoleType == RoleType.MaterialCompany)
+            {
+                SelectedMaterialCompany = MaterialCompanies.FirstOrDefault(c => c.Guid == App.CurrentUser!.CompanyGuid);
+            }
+            else if (currentRoleType == RoleType.ProductCompany)
+            {
+                SelectedProductCompany = ProductCompanies.FirstOrDefault(c => c.Guid == App.CurrentUser!.CompanyGuid);
+            }
+            else
+            {
+                SelectedMaterialCompany = null;
+                SelectedProductCompany = null;
+            }
+        }
+
         /// <summary>
         /// 查询未导出合同
         /// </summary>
@@ -439,6 +449,9 @@ namespace UniformMaterialManagementSystem.ViewModels
 
                 /* 重新加载数据 */
                 LoadUnExportData();
+
+                /* 清空界面数据 */
+                ClearInput();
             }
         }
 
@@ -670,10 +683,10 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         private void ClearInput()
         {
-            //SelectedProductCompany = null;
+            SetDefaultCompany();
             ContractNo = string.Empty;
             SigningDate = DateTime.Now;
-            //EditUser = string.Empty;
+            EditUser = App.CurrentUser!.UserName;
             EditDate = DateTime.Now;
             Telephone = string.Empty;
             Attachment = null;

+ 3 - 1
UniformMaterialManagementSystem/ViewModels/InspectApplyPageViewModel.cs

@@ -15,6 +15,7 @@ using UniformMaterialManagementSystem.Utils;
 using UniformMaterialManagementSystem.Views;
 using DocumentFormat.OpenXml.Wordprocessing;
 using InspectApplyContractDetail = UniformMaterialManagementSystem.Entities.InspectApplyContractDetail;
+using DocumentFormat.OpenXml.Spreadsheet;
 
 namespace UniformMaterialManagementSystem.ViewModels
 {
@@ -465,7 +466,8 @@ namespace UniformMaterialManagementSystem.ViewModels
             {
                 InspectApplyDetail applyDetail = new InspectApplyDetail();
                 applyDetail.PacketNo = dr["包号"].ToString();
-                applyDetail.Quantity = double.Parse(dr["数量"].ToString());
+                double quantity = double.Parse(dr["数量"].ToString());
+                applyDetail.Quantity = Math.Round(quantity, 2);
                 applyDetail.Note = dr["备注"].ToString();
                 InspectApplyDetails.Add(applyDetail);
             }

+ 1 - 2
UniformMaterialManagementSystem/ViewModels/InspectionRecordPageViewModel.cs

@@ -77,9 +77,8 @@ namespace UniformMaterialManagementSystem.ViewModels
                 Companies.Add(row.Name);
             }
             //初始化检验类别
-            InspectCategories.Add("首件检验");
+            InspectCategories.Add("报样检验");
             InspectCategories.Add("首批检验");
-            InspectCategories.Add("生产过程");
             InspectCategories.Add("出厂检验");
 
             //初始化年份

+ 537 - 0
UniformMaterialManagementSystem/ViewModels/InspectionReportPageViewModel.cs

@@ -0,0 +1,537 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Text;
+using System.Windows;
+using Microsoft.Win32;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Views;
+using UniformMaterialManagementSystem.Utils;
+using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class InspectionReportPageViewModel : ObservableValidator
+    {
+
+        [ObservableProperty]
+        private ObservableCollection<InspectionReport> _inspectionReports = [];
+
+        [ObservableProperty]
+        private InspectionReport? _selectedInspectionReport;
+
+        [ObservableProperty]
+        private string? _purchaseCompanyNames;
+
+        [ObservableProperty]
+        private string? _contractNos;
+
+        [ObservableProperty]
+        private List<int> _years = [];
+
+        [ObservableProperty]
+        private List<string> _jobCategories = [];
+
+        [ObservableProperty]
+        private List<string> _userNames = [];
+
+        [ObservableProperty]
+        private int _selectedYear = DateTime.Now.Year;
+
+        private InspectionReportDetail? _selectedInspectionReportDetail;
+
+        private readonly IDataBaseService<InspectionReport> _inspectionReportService;
+
+        private readonly IDataBaseService<InspectionReportDetail> _inspectionReportDetailService;
+
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+
+        public InspectionReportPageViewModel(IDataBaseService<InspectionReport> inspectionReportService, IDataBaseService<InspectionReportDetail> inspectionReportDetailService, IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<User> userService)
+        {
+            _inspectionReportService = inspectionReportService;
+            _inspectionReportDetailService = inspectionReportDetailService;
+            _inspectApplyService = inspectApplyService;
+
+            //初始化年份
+            int currYear = DateTime.Now.Year;
+            for (int i = currYear - 10; i <= currYear + 1; i++)
+            {
+                Years.Add(i);
+            }
+
+            //初始化职位类别
+            JobCategories.Add("组长");
+            JobCategories.Add("成员");
+
+            //初始化人员
+            var userList = userService.QueryNoTracking(x =>
+                x.IsEnabled && x.SupervisionUnitGuid == App.CurrentUser!.SupervisionUnitGuid && string.IsNullOrEmpty(x.CompanyName)).ToList();
+            foreach (var user in userList)
+            {
+                UserNames.Add(user.UserName);
+            }
+
+            /* 加载数据 */
+            LoadData();
+        }
+
+        /// <summary>
+        /// 加载数据
+        /// </summary>
+        [RelayCommand]
+        private void LoadData()
+        {
+            //询问是否保存
+            AskIsSave();
+
+            var inspectionReports = _inspectionReportService.Query()
+                .Include(x => x.InspectionReportDetails)
+                .Include(x => x.InspectApply)
+                .ThenInclude(x => x.Material)
+                .Include(x => x.InspectApply)
+                .ThenInclude(x => x.InspectApplyContractDetails)
+                .Where(x => x.InspectApply.Year == SelectedYear)
+                .ToList();
+
+            InspectionReports.Clear();
+            foreach (var report in inspectionReports)
+            {
+                InspectionReports.Add(report);
+            }
+        }
+
+        /// <summary>
+        /// 判断单据是否有修改
+        /// </summary>
+        private bool IsSelectedChanged()
+        {
+            if (SelectedInspectionReport == null) return false;
+            var state = _inspectionReportService.Entry(SelectedInspectionReport);
+            if (state != EntityState.Unchanged) return true;
+
+            var reportDetails = SelectedInspectionReport.InspectionReportDetails;
+            var existDetails = _inspectionReportDetailService.Query(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
+
+            foreach (var detail in reportDetails)  //新增行或修改行操作
+            {
+                var detailState = _inspectionReportDetailService.Entry(detail);
+                if (detailState != EntityState.Unchanged)
+                {
+                    return true;
+                }
+            }
+
+            foreach (var detail in existDetails) //删除行操作
+            {
+                var detailState = _inspectionReportDetailService.Entry(detail);
+                if (detailState == EntityState.Deleted)
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// 选择行改变事件
+        /// </summary>
+        [RelayCommand]
+        private void InspectionReportSelectionChanged(InspectionReport inspectionReport)
+        {
+            AskIsSave();
+
+            /* 绑定当前行数据*/
+            SelectedInspectionReport = inspectionReport;
+
+            //获取合同信息
+            var dictionary = GetContractInformation(SelectedInspectionReport);
+
+            PurchaseCompanyNames = dictionary.ContainsKey("CompanyNames") ? dictionary["CompanyNames"] : string.Empty;
+
+            ContractNos = dictionary.ContainsKey("ContractNos") ? dictionary["ContractNos"] : string.Empty;
+        }
+
+        /// <summary>
+        /// 询问是否保存更改
+        /// </summary>
+        private void AskIsSave()
+        {
+            var changed = IsSelectedChanged();
+            if (changed)
+            {
+                var result = MessageBox.Show($"检验报告编号【{SelectedInspectionReport?.ReportNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
+                if (result == MessageBoxResult.Yes)
+                {
+                    //保存上一行的修改
+                    SaveInspectionReport();
+                }
+                else
+                {
+                    //放弃更改
+                    var state = _inspectionReportService.Entry(SelectedInspectionReport);
+                    if (state == EntityState.Detached) //新增行直接移除
+                    {
+                        InspectionReports.Remove(SelectedInspectionReport);
+                    }
+
+                    _inspectionReportService.SetEntryState(SelectedInspectionReport, EntityState.Unchanged);
+
+                    var details = _inspectionReportDetailService.GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
+                    SelectedInspectionReport.InspectionReportDetails.Clear();
+                    foreach (var detail in details) //重新将数据库的数据赋值过来,并设置跟踪状态Unchanged
+                    {
+                        SelectedInspectionReport.InspectionReportDetails.Add(detail);
+                        _inspectionReportDetailService.SetEntryState(detail, EntityState.Unchanged);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 根据检验申请-合同信息拼接采购机构名称
+        /// </summary>
+        private Dictionary<string, string> GetContractInformation(InspectionReport? inspectionReport)
+        {
+            Dictionary<string, string> dictionary = new Dictionary<string, string>();
+            StringBuilder purchaseCompanyNames = new StringBuilder();
+            StringBuilder contractNos = new StringBuilder();
+            if (inspectionReport == null) return dictionary;
+            var contractDetails = inspectionReport.InspectApply.InspectApplyContractDetails;
+            foreach (var detail in contractDetails)
+            {
+                purchaseCompanyNames.Append(detail.PurchaseCompany).Append("\n");
+                contractNos.Append(detail.ContractNo).Append("\n");
+            }
+            dictionary.Add("CompanyNames", purchaseCompanyNames.ToString());
+            dictionary.Add("ContractNos", contractNos.ToString());
+
+            return dictionary;
+        }
+
+        /// <summary>
+        /// 新增检验报告
+        /// </summary>
+        [RelayCommand]
+        public void AddInspectionReport()
+        {
+            AskIsSave();
+
+            /* 打开窗口,展示检验报告状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
+            SelectInspectApplyToReportWindow inspectApplyWindow = new SelectInspectApplyToReportWindow();
+            var result = inspectApplyWindow.ShowDialog();
+            if (result == null || !(bool)result) return;
+
+            var inspectApply = inspectApplyWindow.DataGridMain.SelectedItem as InspectApply;
+            if (inspectApply == null) return;
+
+            //新增检验报告并设置默认值
+            InspectionReport inspectionReport = new InspectionReport
+            {
+                InspectApply = inspectApply,
+                ReportNo = inspectApply.ApplyNo.Replace("申请", ""),
+                Department = App.CurrentUser!.SupervisionUnit.Name,
+                ReportTime = DateTime.Now,
+                ReportBasis = "依据" + inspectApply.Material.NormName,
+                Conclusion = "合格",
+                EditUser = App.CurrentUser!.UserName,
+                InspectionReportDetails = []
+            };
+
+            InspectionReports.Add(inspectionReport);
+
+            //选中当前行
+            InspectionReportSelectionChanged(inspectionReport);
+        }
+
+        /// <summary>
+        /// 新增验收组
+        /// </summary>
+        [RelayCommand]
+        private void AddInspectionReportDetail()
+        {
+            if (SelectedInspectionReport == null) return;
+
+            InspectionReportDetail newDetail = new InspectionReportDetail
+            {
+                InspectionReportGuid = SelectedInspectionReport.Guid,
+                SupervisionUnit = App.CurrentUser!.SupervisionUnit.Name
+            };
+
+            SelectedInspectionReport.InspectionReportDetails.Add(newDetail); //sql执行update操作,有异常
+        }
+
+        /// <summary>
+        /// 验收组选中行改变事件
+        /// </summary>
+        [RelayCommand]
+        private void SelectedInspectionReportDetailChanged(InspectionReportDetail reportDetail)
+        {
+            _selectedInspectionReportDetail = reportDetail;
+        }
+
+        /// <summary>
+        /// 删除验收组
+        /// </summary>
+        [RelayCommand]
+        private void RemoveInspectionReportDetail()
+        {
+            if (_selectedInspectionReportDetail == null)
+            {
+                MessageBox.Show("请先选中一行再进行操作!");
+                return;
+            }
+
+            SelectedInspectionReport?.InspectionReportDetails.Remove(_selectedInspectionReportDetail);
+        }
+
+        /// <summary>
+        /// 保存检验报告
+        /// </summary>
+        [RelayCommand]
+        private void SaveInspectionReport()
+        {
+            if (SelectedInspectionReport == null) return;
+
+            /* 自定义校验 */
+            Dictionary<string, string> dictionary = CustomValidate();
+            if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
+            {
+                MessageBox.Show(dictionary["result"], "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                return;
+            }
+
+            var state = _inspectionReportService.Entry(SelectedInspectionReport);
+            switch (state)
+            {
+                case EntityState.Detached:
+                case EntityState.Added:
+                    _inspectionReportService.Insert(SelectedInspectionReport);
+                    break;
+
+                case EntityState.Modified:
+                    _inspectionReportService.Update(SelectedInspectionReport);
+                    break;
+            }
+
+            //处理明细表新增行(无法跟踪明细表的新增行)
+            var existReportDetails = _inspectionReportDetailService.GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
+            foreach (var detail in SelectedInspectionReport.InspectionReportDetails)
+            {
+                var existDetail = existReportDetails.FirstOrDefault(x => x.Guid == detail.Guid);
+                if (existDetail == null)
+                {
+                    _inspectionReportDetailService.Insert(detail);
+                }
+            }
+
+            /* 反写检验申请单的检验报告状态为true */
+            var inpecApply = _inspectApplyService.Get(x => x.Guid == SelectedInspectionReport.InspectApplyGuid);
+            if (inpecApply != null)
+            {
+                inpecApply.ReportStatus = true;
+            }
+
+            var result = _inspectionReportService.SaveChanges();
+            if (result)
+            {
+                MessageBox.Show("保存成功!");
+            }
+        }
+
+        /// <summary>
+        /// 导出检验报告
+        /// </summary>
+        [RelayCommand]
+        private void ExportInspectionReport()
+        {
+            if (SelectedInspectionReport == null) return;
+
+            const string templateFilePath = "Template\\军需物资质量监督检验报告模板.docx";
+            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            {
+                Title = "请选择检验报告保存位置",
+                FileName = "被装材料检验报告-" + SelectedInspectionReport.ReportNo + "-" + WordUtil.GenerateFileSerialNumber(),
+                Filter = "PDF文件格式 (*.pdf)|*.pdf",
+            };
+            if (saveFileDialog.ShowDialog() == false) return;
+            var destinationFile = saveFileDialog.FileName;
+
+            var dictionary = CreateDictionary(SelectedInspectionReport);
+            var tempFile = "Template\\temp.docx";
+
+            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
+            WordUtil.SaveWordToPdf(tempFile, destinationFile);
+
+            //删除临时文件
+            File.Delete(tempFile);
+
+            MessageBox.Show("文档已生成!");
+
+
+
+        }
+
+        private Dictionary<string, string> CreateDictionary(InspectionReport inspectionReport)
+        {
+            Dictionary<string, string> dictionary = new Dictionary<string, string>();
+            dictionary.Add("ReportNo", inspectionReport.ReportNo);
+            dictionary.Add("Department", inspectionReport.Department);
+            dictionary.Add("ReportTime", inspectionReport.ReportTime.ToString("yyyy-MM-dd"));
+            //检验类别
+            switch (inspectionReport.InspectApply.InspCategory)
+            {
+                case "报样检验":
+                    dictionary.Add("FirstSelected", "\u25a0");//选中框
+                    break;
+                case "首批检验":
+                    dictionary.Add("SecondSelected", "\u25a0");//选中框
+                    break;
+                case "过程检验":
+                    dictionary.Add("ThirdSelected", "\u25a0");//选中框
+                    break;
+                case "出厂检验":
+                    dictionary.Add("ForthSelected", "\u25a0");//选中框
+                    break;
+            }
+            dictionary.Add("ProductName", inspectionReport.InspectApply.ProductName);
+            dictionary.Add("Company", inspectionReport.InspectApply.Company);
+            dictionary.Add("InspQuantity", inspectionReport.InspectApply.InspQuantity + inspectionReport.InspectApply.Material.MeasureUnit);
+            dictionary.Add("ProductDate", inspectionReport.InspectApply.StartProductDate.ToString("yyyy-MM") + "至" + inspectionReport.InspectApply.EndProductDate.ToString("yyyy-MM"));
+
+            //采购机构、合同号
+            StringBuilder purchaseCompanies = new StringBuilder();
+            StringBuilder contractNos = new StringBuilder();
+            foreach (var detail in inspectionReport.InspectApply.InspectApplyContractDetails)
+            {
+                purchaseCompanies.Append(detail.PurchaseCompanyShortName).Append("、");
+                contractNos.Append(detail.ContractNo).Append("、");
+            }
+            dictionary.Add("PurchaseCompany", purchaseCompanies.ToString().Substring(0, purchaseCompanies.Length - 1));
+            dictionary.Add("ContractNumber", contractNos.ToString().Substring(0, contractNos.Length - 1));
+
+            dictionary.Add("ReportBasis", inspectionReport.ReportBasis);
+            dictionary.Add("ReportDesc", inspectionReport.ReportDesc);
+            dictionary.Add("ConclusionDesc", inspectionReport.ConclusionDesc);
+
+            //验收组
+            for (int i = 0; i < 5; i++)
+            {
+                if (i< inspectionReport.InspectionReportDetails.Count)
+                {
+                    var detail = inspectionReport.InspectionReportDetails[i];
+                    dictionary.Add("JobCategory" + i, detail.JobCategory);
+                    dictionary.Add("SupervisionUnit" + i, detail.SupervisionUnit);
+                    dictionary.Add("Inspector" + i, detail.Inspector);
+                }
+                else
+                {
+                    dictionary.Add("JobCategory" + i, string.Empty);
+                    dictionary.Add("SupervisionUnit" + i, string.Empty);
+                    dictionary.Add("Inspector" + i, string.Empty);
+                }
+            }
+
+            dictionary.Add("EditUser",inspectionReport.EditUser);
+
+            return dictionary;
+        }
+
+        /// <summary>
+        /// 自定义校验
+        /// </summary>
+        private Dictionary<string, string> CustomValidate()
+        {
+            Dictionary<string, string> result = new Dictionary<string, string>();
+            StringBuilder errorMessage = new StringBuilder();
+
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.Department))
+            {
+                errorMessage.Append("检验部门不允许为空!\n");
+            }
+            if (SelectedInspectionReport?.ReportTime == null)
+            {
+                errorMessage.Append("检验时间不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.ReportBasis))
+            {
+                errorMessage.Append("检验依据不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.ReportDesc))
+            {
+                errorMessage.Append("检验情况及主要问题不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.Conclusion))
+            {
+                errorMessage.Append("检验结论不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.ConclusionDesc))
+            {
+                errorMessage.Append("检验结论不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedInspectionReport?.EditUser))
+            {
+                errorMessage.Append("承办人不允许为空!\n");
+            }
+
+            //校验验收组
+            var details = SelectedInspectionReport?.InspectionReportDetails;
+            if (details == null || details.Count == 0)
+            {
+                errorMessage.Append("验收组不允许为空!\n");
+            }
+            else
+            {
+                int leaderCount = 0;
+                int memberCount = 0;
+                for (int i = 0; i < details.Count; i++)
+                {
+                    var detail = details[i];
+                    if (string.IsNullOrEmpty(detail.JobCategory))
+                    {
+                        errorMessage.Append($"验收组中第{i + 1}行检验组不允许为空!\n");
+                    }
+                    if (string.IsNullOrEmpty(detail.SupervisionUnit))
+                    {
+                        errorMessage.Append($"验收组中第{i + 1}行单位不允许为空!\n");
+                    }
+                    if (string.IsNullOrEmpty(detail.Inspector))
+                    {
+                        errorMessage.Append($"验收组中第{i + 1}行姓名不允许为空!\n");
+                    }
+
+                    if (detail.JobCategory == "组长")
+                    {
+                        leaderCount++;
+                    }
+                    else if (detail.JobCategory == "成员")
+                    {
+                        memberCount++;
+                    }
+                }
+
+                if (leaderCount != 1)
+                {
+                    errorMessage.Append("验收组中至少包含1名组长,不能超过1名组长!\n");
+                }
+
+                if (memberCount < 1)
+                {
+                    errorMessage.Append("验收组中至少包含1名成员!\n");
+                }
+            }
+
+            var isRepeat = SelectedInspectionReport?.InspectionReportDetails.GroupBy(x => x.Inspector).Any(g => g.Count() > 1);
+            if (isRepeat != null && (bool)isRepeat)
+            {
+                errorMessage.Append("验收组姓名有重复,请检查!\n");
+            }
+
+            result.Add("result", errorMessage.ToString());
+            return result;
+        }
+    }
+}

+ 49 - 0
UniformMaterialManagementSystem/ViewModels/SelectInspectApplyToReportWindowViewModel.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Services;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class SelectInspectApplyToReportWindowViewModel :ObservableObject
+    {
+        
+        [ObservableProperty] 
+        private ObservableCollection<InspectApply>  _inspectApplies = [];
+
+        private InspectApply? _selectedInspectApply;
+
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+            
+        public SelectInspectApplyToReportWindowViewModel(IDataBaseService<InspectApply> inspectApplyService)
+        {
+            _inspectApplyService = inspectApplyService;
+
+            var inspectApplyList = _inspectApplyService.Query(x => !x.ReportStatus)
+                .Include(x=>x.InspectApplyContractDetails)
+                .Include(x=>x.Material).ToList();
+            foreach (var inspectApply in inspectApplyList)
+            {
+                InspectApplies.Add(inspectApply);
+            }
+        }
+
+        /// <summary>
+        /// 选择行改变事件
+        /// </summary>
+        [RelayCommand]
+        private void InspectApplySelectionChanged(InspectApply inspectApply)
+        {
+            _selectedInspectApply = inspectApply;
+        }
+
+    }
+}

+ 8 - 1
UniformMaterialManagementSystem/Views/ContractPage.xaml

@@ -221,7 +221,7 @@
                                             </ControlTemplate>
                                         </Button.Template>
                                     </Button>
-                                    <Button Command="{Binding SaveContractCommand}">
+                                    <Button x:Name="SaveButton" Command="{Binding SaveContractCommand}" Click="SaveButton_Click">
                                         <Button.Template>
                                             <ControlTemplate>
                                                 <Border
@@ -879,6 +879,13 @@
                                                 IsColumnFiltered="True"
                                                 IsInteger="False"
                                                 StringFormat="{}{0:F2}" />
+
+                                            <!--<DataGridTextColumn
+                                                Width="150"
+                                                Binding="{Binding UnitPrice, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                                EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                                                ElementStyle="{StaticResource TextColumnElementStyle}"
+                                                Header="单价" />-->
                                         </control:FilterDataGrid.Columns>
                                     </control:FilterDataGrid>
 

+ 6 - 1
UniformMaterialManagementSystem/Views/ContractPage.xaml.cs

@@ -52,6 +52,11 @@ namespace UniformMaterialManagementSystem.Views
             }
         }
 
+        private void SaveButton_Click(object sender, RoutedEventArgs e)
+        {
+            DataGridMain.CommitEdit();
+        }
+
         //private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
         //{
         //    if (bool.Parse(IsCompanyTextBox.Text))
@@ -62,7 +67,7 @@ namespace UniformMaterialManagementSystem.Views
         //    {
         //        MaterialCompanyComboBox.IsEnabled = true;
         //    }
-            
+
         //}
     }
 }

+ 4 - 1
UniformMaterialManagementSystem/Views/InspectApplyPage.xaml

@@ -1053,10 +1053,13 @@
                                         x:Name="Quantity"
                                         Width="200"
                                         Binding="{Binding Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                        DecimalInputLimit="2"
                                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                                         ElementStyle="{StaticResource TextColumnElementStyle}"
                                         Header="数量*"
-                                        IsColumnFiltered="True" />
+                                        IsColumnFiltered="True"
+                                        IsInteger="False"
+                                        StringFormat="{}{0:F2}" />
                                     <control:FilterDataGridTextColumn
                                         x:Name="Note"
                                         Width="200"

+ 584 - 67
UniformMaterialManagementSystem/Views/InspectionReportPage.xaml

@@ -30,9 +30,14 @@
             <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">
@@ -214,7 +219,7 @@
                 FilterLanguage="SimplifiedChinese"
                 HeadersVisibility="All"
                 HorizontalGridLinesBrush="LightSlateGray"
-                ItemsSource="{Binding InspectApplies, Mode=TwoWay}"
+                ItemsSource="{Binding InspectionReports, Mode=TwoWay}"
                 RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
                 RowStyle="{StaticResource CustomRowStyle}"
                 SelectionMode="Single"
@@ -225,7 +230,7 @@
                 <!--  选择行事件  -->
                 <b:Interaction.Triggers>
                     <b:EventTrigger EventName="SelectionChanged">
-                        <b:InvokeCommandAction Command="{Binding InspectApplySelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
+                        <b:InvokeCommandAction Command="{Binding InspectionReportSelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
                     </b:EventTrigger>
                 </b:Interaction.Triggers>
 
@@ -254,73 +259,44 @@
                 <control:FilterDataGrid.Columns>
                     <DataGridTextColumn
                         Width="60"
-                        Binding="{Binding Year}"
+                        Binding="{Binding InspectApply.Year}"
                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                         ElementStyle="{StaticResource TextColumnElementStyle}"
                         Header="工作年度"
                         IsReadOnly="True" />
                     <control:FilterDataGridTextColumn
                         Width="300"
-                        Binding="{Binding ApplyNo}"
+                        Binding="{Binding ReportNo}"
                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                         ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="检验申请表编号"
+                        Header="检验报告编号"
                         IsColumnFiltered="True"
                         IsReadOnly="True" />
                     <control:FilterDataGridTextColumn
                         Width="120"
-                        Binding="{Binding InspCategory}"
+                        Binding="{Binding ReportTime}"
                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                         ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="检验类别"
+                        Header="检验时间"
                         IsColumnFiltered="True"
                         IsReadOnly="True" />
                     <control:FilterDataGridTextColumn
-                        Width="300"
-                        Binding="{Binding ProductName}"
+                        Width="100"
+                        Binding="{Binding Conclusion}"
                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                         ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="产品名称"
+                        Header="检验结论"
                         IsColumnFiltered="True"
                         IsReadOnly="True" />
                     <control:FilterDataGridTextColumn
-                        Width="200"
-                        Binding="{Binding Company}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="生产企业"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridNumericColumn
-                        Width="150"
-                        Binding="{Binding InspQuantity}"
+                        Width="100"
+                        Binding="{Binding EditUser}"
                         EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
                         ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="报检数量"
+                        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="150"
-                        Binding="{Binding ApplyUser}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="录入人"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridCheckBoxColumn
-                        Width="130"
-                        Binding="{Binding ReportStatus}"
-                        ElementStyle="{StaticResource CheckBoxColumnElementStyle}"
-                        Header="检验报告生成状态"
-                        IsColumnFiltered="True" />
+
                 </control:FilterDataGrid.Columns>
             </filterDataGrid:FilterDataGrid>
         </Grid>
@@ -341,7 +317,31 @@
                 BorderThickness="1">
                 <ToolBarPanel>
                     <ToolBar Background="White" ToolBarTray.IsLocked="True">
-                        <Button Command="{Binding SaveInspectApplyCommand}">
+                        <Button Command="{Binding AddInspectionReportCommand}">
+                            <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 SaveInspectionReportCommand}">
                             <Button.Template>
                                 <ControlTemplate>
                                     <Border
@@ -353,7 +353,7 @@
                                                 HorizontalAlignment="Center"
                                                 FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                 FontSize="20"
-                                                Text="{x:Static utils:RegularFontUtil.Save_Arrow_Right_20}" />
+                                                Text="{x:Static utils:RegularFontUtil.Save_32}" />
                                             <TextBlock Text="保存" />
                                         </StackPanel>
                                     </Border>
@@ -365,33 +365,550 @@
                                 </ControlTemplate>
                             </Button.Template>
                         </Button>
+                        <Separator />
+                        <Button Command="{Binding ExportInspectionReportCommand}">
+                            <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 Grid.Row="1" Background="White">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="50" />
-                    <RowDefinition Height="30" />
-                    <RowDefinition Height="30" />
-                    <RowDefinition Height="30" />
-                </Grid.RowDefinitions>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="*" />
-                </Grid.ColumnDefinitions>
+            <ScrollViewer Grid.Row="1">
+                <Grid Grid.Row="1" Background="White">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="60" />
+                        <RowDefinition Height="35" />
+                        <RowDefinition Height="150" />
+                        <RowDefinition Height="170" />
+                        <RowDefinition Height="200" />
+                        <RowDefinition Height="35" />
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
 
-                <TextBlock
-                    Grid.Row="0"
-                    Grid.Column="0"
-                    Grid.ColumnSpan="4"
-                    HorizontalAlignment="Center"
-                    VerticalAlignment="Center"
-                    FontSize="25"
-                    Text="军需物资质量监督检验报告" />
+                    <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"
+                        Text="检验报告编号:" />
+                    <TextBox
+                        Grid.Row="1"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedInspectionReport.ReportNo}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="*检验部门:" />
+                    <TextBox
+                        Grid.Row="2"
+                        Grid.Column="1"
+                        Text="{Binding SelectedInspectionReport.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        Text="*检验时间:" />
+                    <DatePicker
+                        Grid.Row="2"
+                        Grid.Column="3"
+                        Text="{Binding SelectedInspectionReport.ReportTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="3"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="检验类别:" />
+                    <StackPanel
+                        Grid.Row="3"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        VerticalAlignment="Center">
+                        <Grid VerticalAlignment="Center" Background="White">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="*" />
+                                <ColumnDefinition Width="*" />
+                                <ColumnDefinition Width="*" />
+                                <ColumnDefinition Width="*" />
+                            </Grid.ColumnDefinitions>
+                            <RadioButton
+                                x:Name="FirstRadioButton"
+                                Grid.Column="0"
+                                Content="报样检验"
+                                GroupName="InspectType"
+                                IsEnabled="False" />
+                            <RadioButton
+                                x:Name="SecondRadioButton"
+                                Grid.Column="1"
+                                Content="首批检验"
+                                GroupName="InspectType"
+                                IsEnabled="False" />
+                            <RadioButton
+                                x:Name="ThirdRadioButton"
+                                Grid.Column="2"
+                                Content="生产过程"
+                                GroupName="InspectType"
+                                IsEnabled="False" />
+                            <RadioButton
+                                x:Name="ForthRadioButton"
+                                Grid.Column="3"
+                                Content="出厂检验"
+                                GroupName="InspectType"
+                                IsEnabled="False" />
+                            <TextBox
+                                x:Name="InspectTypeText"
+                                Grid.Column="0"
+                                Text="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                TextChanged="InspectTypeText_TextChanged"
+                                Visibility="Collapsed" />
+                        </Grid>
+                    </StackPanel>
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="产品名称:" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="1"
+                        Text="{Binding SelectedInspectionReport.InspectApply.Material.Name}" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        Text="生产企业:" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="3"
+                        Text="{Binding SelectedInspectionReport.InspectApply.Company}" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="产品数量:" />
+                    <Grid
+                        Grid.Row="5"
+                        Grid.Column="1"
+                        Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <TextBlock Grid.Column="0" Text="{Binding SelectedInspectionReport.InspectApply.InspQuantity}" />
+                        <TextBlock Grid.Column="1" Text="{Binding SelectedInspectionReport.InspectApply.Material.MeasureUnit}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        Text="生产日期:" />
+                    <Grid
+                        Grid.Row="5"
+                        Grid.Column="3"
+                        Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <TextBlock Grid.Column="0" Text="{Binding SelectedInspectionReport.InspectApply.StartProductDate, StringFormat=yyyy年MM月}" />
+                        <TextBlock Grid.Column="1" Text="至" />
+                        <TextBlock Grid.Column="2" Text="{Binding SelectedInspectionReport.InspectApply.EndProductDate, StringFormat=yyyy年MM月}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="采购机构:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="1"
+                        Height="60"
+                        IsReadOnly="True"
+                        Text="{Binding PurchaseCompanyNames}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        Text="合同编号:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="3"
+                        Height="60"
+                        IsReadOnly="True"
+                        Text="{Binding ContractNos}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="7"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="*检验依据:" />
+                    <TextBox
+                        Grid.Row="7"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding SelectedInspectionReport.ReportBasis, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="8"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*检验情况及主要问题:"
+                        TextWrapping="Wrap" />
+                    <Grid
+                        Grid.Row="8"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White">
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="30" />
+                            <RowDefinition Height="*" />
+                        </Grid.RowDefinitions>
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <RadioButton
+                            x:Name="IsSampleRadioButton"
+                            Grid.Row="0"
+                            Grid.Column="0"
+                            Padding="10,0,10,0"
+                            VerticalContentAlignment="Center"
+                            Content="抽样送检"
+                            Foreground="Red"
+                            GroupName="IsSampleGroup" />
+                        <RadioButton
+                            x:Name="NotSampleRadioButton"
+                            Grid.Row="0"
+                            Grid.Column="1"
+                            Padding="10,0,10,0"
+                            VerticalContentAlignment="Center"
+                            Content="未抽样送检"
+                            GroupName="IsSampleGroup" />
+                        <TextBox
+                            x:Name="IsSampleTextBox"
+                            Grid.Row="0"
+                            Grid.Column="2"
+                            Text="{Binding SelectedInspectionReport.IsSample, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            TextChanged="IsSampleTextBox_TextChanged"
+                            Visibility="Collapsed" />
+                        <TextBox
+                            Grid.Row="1"
+                            Grid.Column="0"
+                            Grid.ColumnSpan="3"
+                            Height="120"
+                            HorizontalContentAlignment="Left"
+                            VerticalContentAlignment="Top"
+                            AcceptsReturn="True"
+                            Text="{Binding SelectedInspectionReport.ReportDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            TextWrapping="Wrap"
+                            VerticalScrollBarVisibility="Auto" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="9"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="*检验结论:" />
+                    <Grid
+                        Grid.Row="9"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White">
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="30" />
+                            <RowDefinition Height="*" />
+                        </Grid.RowDefinitions>
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="Auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <RadioButton
+                            x:Name="FirstQualifiedRadioButton"
+                            Grid.Row="0"
+                            Grid.Column="0"
+                            Padding="10,0,10,0"
+                            VerticalContentAlignment="Center"
+                            Checked="ConclusionGroupRadioButton_Checked"
+                            Content="合格"
+                            Foreground="Green"
+                            GroupName="ConclusionGroup"
+                            IsChecked="True" />
+                        <RadioButton
+                            x:Name="SecondQualifiedRadioButton"
+                            Grid.Row="0"
+                            Grid.Column="1"
+                            Padding="10,0,10,0"
+                            VerticalContentAlignment="Center"
+                            Checked="ConclusionGroupRadioButton_Checked"
+                            Content="合格(初测不合格,复测合格)"
+                            Foreground="DarkOrange"
+                            GroupName="ConclusionGroup" />
+                        <RadioButton
+                            x:Name="UnQualifiedRadioButton"
+                            Grid.Row="0"
+                            Grid.Column="2"
+                            Padding="10,0,10,0"
+                            VerticalContentAlignment="Center"
+                            Checked="ConclusionGroupRadioButton_Checked"
+                            Content="不合格"
+                            Foreground="Red"
+                            GroupName="ConclusionGroup" />
+                        <TextBox
+                            x:Name="ConclusionTextBox"
+                            Grid.Row="0"
+                            Grid.Column="2"
+                            Text="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            TextChanged="ConclusionTextBox_TextChanged"
+                            Visibility="Collapsed" />
+                        <TextBox
+                            Grid.Row="1"
+                            Grid.Column="0"
+                            Grid.ColumnSpan="3"
+                            Height="120"
+                            HorizontalContentAlignment="Left"
+                            VerticalContentAlignment="Top"
+                            AcceptsReturn="True"
+                            Text="{Binding SelectedInspectionReport.ConclusionDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                            TextWrapping="Wrap"
+                            VerticalScrollBarVisibility="Auto" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="10"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*验收组:" />
+                    <Grid
+                        Grid.Row="10"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White">
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="Auto" />
+                            <RowDefinition Height="*" />
+                        </Grid.RowDefinitions>
+                        <!--  子菜单项  -->
+                        <Border
+                            Grid.Row="0"
+                            BorderBrush="Gray"
+                            BorderThickness="1">
+                            <ToolBarPanel>
+                                <ToolBar Background="White" ToolBarTray.IsLocked="True">
+                                    <Button HorizontalContentAlignment="Center" Command="{Binding AddInspectionReportDetailCommand}">
+                                        <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_Square_20}" />
+                                                        <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 RemoveInspectionReportDetailCommand}">
+                                        <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.Dismiss_Square_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>
+                        <DataGrid
+                            x:Name="DataGridDetail"
+                            Grid.Row="1"
+                            behaviors:DataGridBehavior.RowNumbers="True"
+                            AutoGenerateColumns="False"
+                            Background="White"
+                            CanUserAddRows="False"
+                            CanUserReorderColumns="True"
+                            CellStyle="{StaticResource CustomCellStyle}"
+                            ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
+                            HeadersVisibility="All"
+                            HorizontalGridLinesBrush="LightSlateGray"
+                            ItemsSource="{Binding SelectedInspectionReport.InspectionReportDetails, Mode=TwoWay}"
+                            RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
+                            RowStyle="{StaticResource CustomRowStyle}"
+                            SelectionMode="Single"
+                            VerticalGridLinesBrush="LightSlateGray">
+                            <!--  选择行事件  -->
+                            <b:Interaction.Triggers>
+                                <b:EventTrigger EventName="SelectionChanged">
+                                    <b:InvokeCommandAction Command="{Binding SelectedInspectionReportDetailChangedCommand}" CommandParameter="{Binding ElementName=DataGridDetail, Path=SelectedItem}" />
+                                </b:EventTrigger>
+                            </b:Interaction.Triggers>
 
-            </Grid>
+                            <DataGrid.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>
+                            </DataGrid.Resources>
+                            <DataGrid.Columns>
+                                <DataGridTemplateColumn Width="100" Header="检验组">
+                                    <DataGridTemplateColumn.CellTemplate>
+                                        <DataTemplate>
+                                            <TextBlock
+                                                HorizontalAlignment="Center"
+                                                VerticalAlignment="Center"
+                                                Text="{Binding JobCategory}" />
+                                        </DataTemplate>
+                                    </DataGridTemplateColumn.CellTemplate>
+                                    <DataGridTemplateColumn.CellEditingTemplate>
+                                        <DataTemplate>
+                                            <ComboBox
+                                                Height="25"
+                                                Background="White"
+                                                ItemsSource="{Binding DataContext.JobCategories, RelativeSource={RelativeSource AncestorType=UserControl}}"
+                                                SelectedItem="{Binding JobCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                                        </DataTemplate>
+                                    </DataGridTemplateColumn.CellEditingTemplate>
+                                </DataGridTemplateColumn>
+
+                                <!--<DataGridTextColumn
+                                    Width="100"
+                                    Binding="{Binding JobCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                                    Header="检验组" />-->
+
+                                <DataGridTextColumn
+                                    Width="300"
+                                    Binding="{Binding SupervisionUnit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                                    Header="单位" />
+
+                                <!--<DataGridTextColumn
+                                    Width="100"
+                                    Binding="{Binding Inspector, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                                    Header="姓名" />-->
+                                <DataGridTemplateColumn Width="100" Header="姓名">
+                                    <DataGridTemplateColumn.CellTemplate>
+                                        <DataTemplate>
+                                            <TextBlock
+                                                HorizontalAlignment="Center"
+                                                VerticalAlignment="Center"
+                                                Text="{Binding Inspector}" />
+                                        </DataTemplate>
+                                    </DataGridTemplateColumn.CellTemplate>
+                                    <DataGridTemplateColumn.CellEditingTemplate>
+                                        <DataTemplate>
+                                            <ComboBox
+                                                Height="25"
+                                                Background="White"
+                                                IsEditable="True"
+                                                ItemsSource="{Binding DataContext.UserNames, RelativeSource={RelativeSource AncestorType=UserControl}}"
+                                                SelectedItem="{Binding Inspector, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                                        </DataTemplate>
+                                    </DataGridTemplateColumn.CellEditingTemplate>
+                                </DataGridTemplateColumn>
+                            </DataGrid.Columns>
+                        </DataGrid>
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        Text="承办人:" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="1"
+                        Text="{Binding SelectedInspectionReport.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                </Grid>
+            </ScrollViewer>
 
 
         </Grid>

+ 68 - 13
UniformMaterialManagementSystem/Views/InspectionReportPage.xaml.cs

@@ -1,17 +1,6 @@
-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 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;
+using UniformMaterialManagementSystem.ViewModels;
 
 namespace UniformMaterialManagementSystem.Views
 {
@@ -23,6 +12,72 @@ namespace UniformMaterialManagementSystem.Views
         public InspectionReportPage()
         {
             InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService<InspectionReportPageViewModel>();
+
+        }
+
+        private void InspectTypeText_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            var inspectType = InspectTypeText.Text;
+            switch (inspectType)
+            {
+                case "报样检验":
+                    FirstRadioButton.IsChecked = true;
+                    break;
+                case "首批检验":
+                    SecondRadioButton.IsChecked = true;
+                    break;
+                case "过程检验":
+                    ThirdRadioButton.IsChecked = true;
+                    break;
+                case "出厂检验":
+                    ForthRadioButton.IsChecked = true;
+                    break;
+            }
+        }
+
+        private void IsSampleTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            var isSample = IsSampleTextBox.Text;
+            if (!string.IsNullOrEmpty(isSample) && bool.Parse(isSample))
+            {
+                IsSampleRadioButton.IsChecked = true;
+            }
+            else
+            {
+                NotSampleRadioButton.IsChecked = true;
+            }
         }
+
+        private void ConclusionTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            var conclusion = ConclusionTextBox.Text;
+            switch (conclusion)
+            {
+                case "合格":
+                    FirstQualifiedRadioButton.IsChecked = true;
+                    break;
+                case "合格(初测不合格,复测合格)":
+                    SecondQualifiedRadioButton.IsChecked = true;
+                    break;
+                case "不合格":
+                    UnQualifiedRadioButton.IsChecked = true;
+                    break;
+            }
+        }
+
+        private void ConclusionGroupRadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
+        {
+            var radioButton = (RadioButton)sender;
+            if (radioButton.GroupName == "ConclusionGroup")
+            {
+                if (radioButton.Content != null && ConclusionTextBox != null)
+                {
+                    ConclusionTextBox.Text = radioButton.Content.ToString();
+                }
+            }
+        }
+
     }
 }

+ 294 - 0
UniformMaterialManagementSystem/Views/SelectInspectApplyToReportWindow.xaml

@@ -0,0 +1,294 @@
+<Window
+    x:Class="UniformMaterialManagementSystem.Views.SelectInspectApplyToReportWindow"
+    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"
+    Title="选择检验申请单生成检验报告"
+    Width="1000"
+    Height="600"
+    mc:Ignorable="d">
+    <Window.Resources>
+        <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>
+    </Window.Resources>
+    <Grid Background="White">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto" />
+            <RowDefinition Height="*" />
+        </Grid.RowDefinitions>
+
+        <!--  菜单项  -->
+        <Border
+            Grid.Row="0"
+            BorderBrush="Gray"
+            BorderThickness="1">
+            <ToolBarPanel>
+                <ToolBar Background="White" ToolBarTray.IsLocked="True">
+                    <Button
+                        x:Name="ConfirmButton"
+                        HorizontalContentAlignment="Center"
+                        Click="ConfirmButton_Click">
+                        <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.Arrow_Sync_Checkmark_20}" />
+                                        <TextBlock Text="确认选择" />
+                                    </StackPanel>
+                                </Border>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsMouseOver" Value="True">
+                                        <Setter Property="Background" Value="LightGray" />
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </Button.Template>
+                    </Button>
+                    <Button
+                        x:Name="CancelButton"
+                        HorizontalContentAlignment="Center"
+                        Click="CancelButton_Click">
+                        <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.Arrow_Sync_Dismiss_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>
+
+        <!--  表格  -->
+        <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="SelectionChanged">
+                    <b:InvokeCommandAction Command="{Binding InspectApplySelectionChangedCommand}" 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>
+                <control:FilterDataGridTextColumn
+                    Width="300"
+                    Binding="{Binding ApplyNo, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="检验申请编号"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridTextColumn
+                    Width="100"
+                    Binding="{Binding InspCategory, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="检验类别"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridTextColumn
+                    Width="250"
+                    Binding="{Binding ProductName, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="产品名称"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridTextColumn
+                    Width="200"
+                    Binding="{Binding Company, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="生产企业"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridTextColumn
+                    Width="120"
+                    Binding="{Binding InspDate, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="申请检验时间"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridTextColumn
+                    Width="100"
+                    Binding="{Binding ApplyUser, Mode=OneTime}"
+                    EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                    ElementStyle="{StaticResource TextColumnElementStyle}"
+                    Header="申请人"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+                <control:FilterDataGridCheckBoxColumn
+                    Width="150"
+                    Binding="{Binding ReportStatus, Mode=OneTime}"
+                    ElementStyle="{StaticResource CheckBoxColumnElementStyle}"
+                    Header="检验报告生成状态"
+                    IsColumnFiltered="True"
+                    IsReadOnly="True" />
+
+            </control:FilterDataGrid.Columns>
+        </filterDataGrid:FilterDataGrid>
+    </Grid>
+</Window>

+ 47 - 0
UniformMaterialManagementSystem/Views/SelectInspectApplyToReportWindow.xaml.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views
+{
+    /// <summary>
+    /// SelectInspectApplyToReportWindow.xaml 的交互逻辑
+    /// </summary>
+    public partial class SelectInspectApplyToReportWindow : Window
+    {
+        public SelectInspectApplyToReportWindow()
+        {
+            InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService(typeof(SelectInspectApplyToReportWindowViewModel));
+        }
+
+        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
+        {
+            var inspectApply = DataGridMain.SelectedItem as InspectApply;
+            if (inspectApply == null)
+            {
+                MessageBox.Show("未选中任何行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            this.DialogResult = true;
+        }
+
+        private void CancelButton_Click(object sender, RoutedEventArgs e)
+        {
+            this.DialogResult = false;
+        }
+    }
+}