using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; using Aucma.Core.BoxFoam.Models; using Aucma.Core.BoxFoam.Views.UserPage; 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 AfterFoamingPageModelView : ObservableObject { private readonly IBaseSpaceDetailServices? _spaceDetailService; private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices; public AfterFoamingPageModelView() { _spaceDetailService = App.ServiceProvider.GetService(); _baseSpaceInfoServices = App.ServiceProvider.GetService(); this.LoadSpaceStoreMedthAsync(); } #region 加载泡后库货道信息 /// /// 加载泡后库货道信息 /// private void LoadSpaceStoreMedthAsync() { string storeCode = Appsettings.app("StoreInfo", "AfterStoreCode");//泡前库code var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode)).Result;//仓库 if (baseSpaceInfolist == null) return; foreach (var item in baseSpaceInfolist) { SpaceInfoModel model = new SpaceInfoModel(); model.spaceCode = item.SpaceCode; model.spaceStock = item.SpaceStock; model.onTheWay = item.OnRouteAmount; model.totalAmount = item.SpaceStock + item.OnRouteAmount; model.materialType = item.MaterialType; model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White"; if (item.SpaceStatus == 2) { model.setEnable = "False"; model.inStoreFlag = "Red";//item.inStoreFlag == 2 ? "Red" : "White"; model.isFlag = "Red"; } else { model.isFlag = item.IsFlag.ToString(); //禁用状态 } model.onlyOne = 1; model.spaceType = item.SpaceType; Shapes.Add(model); } } #endregion #region 初始化 private ObservableCollection _shapes = new ObservableCollection(); public ObservableCollection Shapes { get => _shapes; set => SetProperty(ref _shapes, value); } #endregion #region 明细 [RelayCommand] private void SpaceDetail(string info) { string storeCode = Appsettings.app("StoreInfo", "AfterStoreCode");//泡前库code List list = _spaceDetailService.GetSpaceDetailsBySpaceCode(storeCode, info).Result; RefreshSpaceDetails(list); } /// /// 刷新货道明细列表 /// /// private void RefreshSpaceDetails(List spaceDetails) { SpaceDetailDataGrid = new ObservableCollection(); if (spaceDetails != null) { spaceDetails.ForEach( arg => { SpaceDetailDataGrid.Add(arg); }); } } private ObservableCollection spaceDetailDataGrid; public ObservableCollection SpaceDetailDataGrid { get => spaceDetailDataGrid; set => SetProperty(ref spaceDetailDataGrid, value); } #endregion } }