using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Aucma.Core.BoxFoam.ViewModels { public partial class ShellInventoryViewModel : ObservableObject { private IBaseSpaceInfoServices _spaceInfoService; private IBaseSpaceDetailServices _spaceDetailService; public ShellInventoryViewModel() { _spaceInfoService = App.ServiceProvider.GetService(); _spaceDetailService = App.ServiceProvider.GetService(); Task.WaitAll(Query()); } private async Task Query() { var storeCode = Appsettings.app("StoreInfo", "StoreCode"); List info = await _spaceInfoService.QueryAsync(d => d.StoreCode.Equals(storeCode)); if (info != null) { foreach (BaseSpaceInfo info2 in info) { shapes.Add(info2); } } } /// /// 货道明细 /// /// [RelayCommand] private async void SpaceDetail(object obj) { string info = obj as string; var storeCode = Appsettings.app("StoreInfo", "StoreCode"); List list = await _spaceDetailService.GetSpaceDetailsBySpaceCode(storeCode, info); RefreshSpaceDetails(list); } /// /// 刷新货道明细列表 /// /// private void RefreshSpaceDetails(List spaceDetails) { SpaceDetailDataGrid = new ObservableCollection(); if (spaceDetails != null) { spaceDetails.ForEach( arg => { SpaceDetailDataGrid.Add(arg); }); } } #region 初始化datagrid private ObservableCollection shapes = new ObservableCollection(); public ObservableCollection Shapes { get { return shapes; } set { shapes = value; OnPropertyChanged();//属性通知 } } #endregion private ObservableCollection spaceDetailDataGrid; public ObservableCollection SpaceDetailDataGrid { get { return spaceDetailDataGrid; } set { spaceDetailDataGrid = value; OnPropertyChanged();//属性通知 } } } }