You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AUCMA_SCADA/Aucma.Core.BoxFoam/ViewModels/ShellInventoryViewModel.cs

97 lines
3.0 KiB
C#

1 year ago
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<IBaseSpaceInfoServices>();
_spaceDetailService = App.ServiceProvider.GetService<IBaseSpaceDetailServices>();
Task.WaitAll(Query());
}
private async Task Query()
{
var storeCode = Appsettings.app("StoreInfo", "StoreCode");
List<BaseSpaceInfo> info = await _spaceInfoService.QueryAsync(d => d.StoreCode.Equals(storeCode));
if (info != null)
{
foreach (BaseSpaceInfo info2 in info)
{
shapes.Add(info2);
}
}
}
/// <summary>
/// 货道明细
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void SpaceDetail(object obj)
{
string info = obj as string;
var storeCode = Appsettings.app("StoreInfo", "StoreCode");
List<BaseSpaceDetail> list = await _spaceDetailService.GetSpaceDetailsBySpaceCode(storeCode, info);
RefreshSpaceDetails(list);
}
/// <summary>
/// 刷新货道明细列表
/// </summary>
/// <param name="spaceDetails"></param>
private void RefreshSpaceDetails(List<BaseSpaceDetail> spaceDetails)
{
SpaceDetailDataGrid = new ObservableCollection<BaseSpaceDetail>();
if (spaceDetails != null)
{
spaceDetails.ForEach(
arg =>
{
SpaceDetailDataGrid.Add(arg);
});
}
}
#region 初始化datagrid
private ObservableCollection<BaseSpaceInfo> shapes = new ObservableCollection<BaseSpaceInfo>();
public ObservableCollection<BaseSpaceInfo> Shapes
{
get { return shapes; }
set
{
shapes = value;
OnPropertyChanged();//属性通知
}
}
#endregion
private ObservableCollection<BaseSpaceDetail> spaceDetailDataGrid;
public ObservableCollection<BaseSpaceDetail> SpaceDetailDataGrid
{
get { return spaceDetailDataGrid; }
set
{
spaceDetailDataGrid = value;
OnPropertyChanged();//属性通知
}
}
}
}