using Admin.Core.IService; using Admin.Core.Model; using Aucma.Core.Palletiz.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using log4net; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.ObjectModel; using System.Linq; namespace Aucma.Core.Palletiz.ViewModels { public partial class PalletizPageViewModel : ObservableObject { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(PalletizPageViewModel)); private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices; public PalletizPageViewModel() { _baseSpaceInfoServices = App.ServiceProvider.GetService(); LoadDataGrid(); // SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; } public void LoadDataGrid() { Spaces.Clear(); var spaceList = _baseSpaceInfoServices.Query(X => X.StoreCode.Contains("FDK")).OrderBy(x=>x.ObjId); foreach(BaseSpaceInfo space in spaceList) { Spaces.Add(space); } } #region 初始化 private ObservableCollection _spaces = new ObservableCollection(); public ObservableCollection Spaces { get => _spaces; set => SetProperty(ref _spaces, value); } #endregion public void MouseClick(object obj) { var info = SelectedDataItem as BaseSpaceInfo; if (info != null) { SelectType direct = new SelectType(info); direct.ShowDialog(); } } private BaseSpaceInfo selectedDataItem; public BaseSpaceInfo SelectedDataItem { get { return selectedDataItem; } set { selectedDataItem = value; OnPropertyChanged(); } } [RelayCommand] public void AddStore() { SplitPlanView plan = new SplitPlanView(); plan.Show(); } } }