From 28cb87275ca3873cbef562e5da3e552beb4ca310 Mon Sep 17 00:00:00 2001 From: liuwf Date: Thu, 30 Nov 2023 17:44:06 +0800 Subject: [PATCH] =?UTF-8?q?change-=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=E8=B4=A8=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Aucma.Core.ProductOffLine.csproj | 3 + .../ViewModels/QualityItemViewModel.cs | 128 ++++++++++++++++++ .../ViewModels/SelectQualityViewModel.cs | 27 ++++ .../Views/QualityWindow.xaml | 94 +++++++++++++ .../Views/QualityWindow.xaml.cs | 33 +++++ .../Views/SelectQualityView.xaml | 2 +- .../Views/SelectQualityView.xaml.cs | 10 +- 7 files changed, 293 insertions(+), 4 deletions(-) create mode 100644 Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs create mode 100644 Aucma.Core.ProductOffLine/Views/QualityWindow.xaml create mode 100644 Aucma.Core.ProductOffLine/Views/QualityWindow.xaml.cs diff --git a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj index 4ca354a2..8c1f341f 100644 --- a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj +++ b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj @@ -85,6 +85,9 @@ + + Code + Code diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs new file mode 100644 index 00000000..06fbbf6b --- /dev/null +++ b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs @@ -0,0 +1,128 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +using Aucma.Core.ProductOffLine.Models; +using Aucma.Core.ProductOffLine.Views; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Documents; +using System.Windows.Input; + +namespace Aucma.Core.ProductOffLine.ViewModels +{ + public partial class QualityItemViewModel : ObservableObject + { + public RelayCommand CloseWindowCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + + private readonly IBaseQualityInspectionItemInfoServices? _baseQualityInspectionItemInfoServices; + public QualityItemViewModel(QualityInspectionModel info) { + _baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService(); + CloseWindowCommand = new RelayCommand(t => CloseWindow(t)); + SaveCommand = new RelayCommand(updateDirection); + PlanInfo = info; + if("是".Equals(info.IsInSpection)){ + IsSelectedOptionA = true; + } + else + { + IsSelectedOptionB = true; + } + } + + + + private QualityInspectionModel planInfo = new QualityInspectionModel(); + public QualityInspectionModel PlanInfo + { + get { return planInfo; } + set { + planInfo = value; + OnPropertyChanged(nameof(PlanInfo)); + } + } + + #region 单选框 + private bool _isSelectedOptionA; + public bool IsSelectedOptionA + { + get { return _isSelectedOptionA; } + set + { + if (_isSelectedOptionA != value) + { + _isSelectedOptionA = value; + OnPropertyChanged(nameof(IsSelectedOptionA)); + + // 如果选择了A选项,将B选项设为false + if (_isSelectedOptionA) + { + IsSelectedOptionB = false; + } + } + } + } + + private bool _isSelectedOptionB; + public bool IsSelectedOptionB + { + get { return _isSelectedOptionB; } + set + { + if (_isSelectedOptionB != value) + { + _isSelectedOptionB = value; + OnPropertyChanged(nameof(IsSelectedOptionB)); + + // 如果选择了B选项,将A选项设为false + if (_isSelectedOptionB) + { + IsSelectedOptionA = false; + } + } + } + } + #endregion + + //关闭窗口 + private void CloseWindow(object parameter) + { + var window = parameter as Window; + if (window != null) + { + window.Close(); + } + + } + private async void updateDirection() + { + BaseQualityInspectionItemInfo info = await _baseQualityInspectionItemInfoServices.FirstAsync(x=>x.ObjId==PlanInfo.ObjId); + if (IsSelectedOptionA) + { + info.IsInSpection = "1"; + } + else + { + info.IsInSpection = "0"; + } + bool result = await _baseQualityInspectionItemInfoServices.UpdateAsync(info); + if (result) + { + MessageBox.Show(info.QualityDefectName+"质检项修改成功"); + } + } + + + } +} diff --git a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs index 969d9088..cb5d3be0 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs @@ -29,6 +29,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels { public ICommand QueryCommand { get; set; } + public RelayCommand MouseClickCommand { get; set; } public ICommand SaveCommand { get; set; } private readonly IBaseQualityInspectionItemInfoServices? _baseQualityInspectionItemInfoServices; @@ -37,6 +38,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels _baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService(); QueryCommand = new RelayCommand(ExecuteQuery); + MouseClickCommand = new RelayCommand(MouseClick); SaveCommand = new RelayCommand(ExecuteSave); Init(); @@ -60,6 +62,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels } } + public void MouseClick(object obj) + { + + var info = SelectedDataItem as QualityInspectionModel; + if (info != null) + { + QualityWindow quantityIssuedWindow = new QualityWindow(info); + quantityIssuedWindow.ShowDialog(); + } + + } + private async void ExecuteSave() { List list = new List(); @@ -94,6 +108,19 @@ namespace Aucma.Core.ProductOffLine.ViewModels + private QualityInspectionModel selectedDataItem; + public QualityInspectionModel SelectedDataItem + { + get { return selectedDataItem; } + set + { + selectedDataItem = value; + OnPropertyChanged(); + } + } + + + #region 初始化datagrid private ObservableCollection qualityItemGrid = new ObservableCollection(); public ObservableCollection QualityItemGrid diff --git a/Aucma.Core.ProductOffLine/Views/QualityWindow.xaml b/Aucma.Core.ProductOffLine/Views/QualityWindow.xaml new file mode 100644 index 00000000..2437acf3 --- /dev/null +++ b/Aucma.Core.ProductOffLine/Views/QualityWindow.xaml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +