|
@@ -1,4 +1,5 @@
|
|
-using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
+using System.Collections.ObjectModel;
|
|
|
|
+using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations;
|
|
@@ -30,6 +31,29 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
[Required(ErrorMessage = "单位类型不能为空")]
|
|
[Required(ErrorMessage = "单位类型不能为空")]
|
|
private string _selectedUnitType = string.Empty;
|
|
private string _selectedUnitType = string.Empty;
|
|
|
|
|
|
|
|
+ partial void OnSelectedUnitTypeChanged(string value)
|
|
|
|
+ {
|
|
|
|
+ List<Company> list;
|
|
|
|
+ if (value.StartsWith("Material"))
|
|
|
|
+ {
|
|
|
|
+ list = _companies.Where(x => x is { Category: "material", IsEnabled: true }).ToList();
|
|
|
|
+ }
|
|
|
|
+ else if (value.StartsWith("Product"))
|
|
|
|
+ {
|
|
|
|
+ list = _companies.Where(x => x is { Category: "product", IsEnabled: true }).ToList();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list = _companies.ToList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CompanyList.Clear();
|
|
|
|
+ foreach (var company in list)
|
|
|
|
+ {
|
|
|
|
+ CompanyList.Add(company);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
[ObservableProperty]
|
|
[ObservableProperty]
|
|
private ICollection<SupervisionUnit> _units = [];
|
|
private ICollection<SupervisionUnit> _units = [];
|
|
|
|
|
|
@@ -37,11 +61,12 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
[Required(ErrorMessage = "单位不能为空")]
|
|
[Required(ErrorMessage = "单位不能为空")]
|
|
private SupervisionUnit _selectedUnit = null!;
|
|
private SupervisionUnit _selectedUnit = null!;
|
|
|
|
|
|
|
|
+ private readonly ICollection<Company> _companies;
|
|
|
|
+
|
|
[ObservableProperty]
|
|
[ObservableProperty]
|
|
- private ICollection<Company> _companyList = [];
|
|
|
|
|
|
+ private ObservableCollection<Company> _companyList = [];
|
|
|
|
|
|
[ObservableProperty]
|
|
[ObservableProperty]
|
|
- [Required(ErrorMessage = "公司不能为空")]
|
|
|
|
private Company? _selectedCompany;
|
|
private Company? _selectedCompany;
|
|
|
|
|
|
[ObservableProperty]
|
|
[ObservableProperty]
|
|
@@ -75,7 +100,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
_roles[unitType.Key] = roles.First(r => r.Name == unitType.Key);
|
|
_roles[unitType.Key] = roles.First(r => r.Name == unitType.Key);
|
|
}
|
|
}
|
|
|
|
|
|
- CompanyList = context.Companies.ToList();
|
|
|
|
|
|
+ _companies = context.Companies.ToList();
|
|
|
|
|
|
Units = context.SupervisionUnits.ToList();
|
|
Units = context.SupervisionUnits.ToList();
|
|
}
|
|
}
|