using Admin.Core.Common; using Admin.Core.IService; using Aucma.Core.BoxFoam.Models; using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; /* * 货道明细 * */ namespace Aucma.Core.BoxFoam.ViewModels { public partial class SpaceDetailModelView : ObservableObject { public readonly IBaseSpaceDetailServices? _baseSpaceDetailServices; public SpaceDetailModelView() { } public SpaceDetailModelView(string storeCode,string spaceCode) { _baseSpaceDetailServices = App.ServiceProvider.GetService(); LoadData(storeCode, spaceCode); } #region 加载DataGrid数据 private async void LoadData(string storeCode, string spaceCode) { spaceDetilDataGrid.Clear(); var list = await _baseSpaceDetailServices.QueryAsync(d => d.StoreCode.Equals(storeCode) && d.SpaceCode.Equals(spaceCode)); foreach (var item in list.OrderBy(d => d.CreatedTime)) { spaceDetilDataGrid.Add(new SpaceDetailView() { ObjId = item.ObjId, StoreCode = item.StoreCode, SpaceCode = item.SpaceCode, MaterialCode = item.MaterialCode, MaterialName = item.MaterialName, MaterialType = item.MaterialType, CreatedTime = item.CreatedTime }); }; } #endregion #region 初始化datagrid private ObservableCollection spaceDetilDataGrid = new ObservableCollection(); public ObservableCollection SpaceDetilDataGrid { get => spaceDetilDataGrid; set => SetProperty(ref spaceDetilDataGrid, value); } #endregion } }