using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.ViewModels; using Admin.Core.Service; using Aucma.Core.BoxFoam.Models; 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 LinerInventoryViewModel : ObservableObject { private IBaseSpaceInfoServices _baseSpaceInfoServices; private IBaseSpaceDetailServices _spaceDetailService; public LinerInventoryViewModel() { _baseSpaceInfoServices = App.ServiceProvider.GetService(); _spaceDetailService = App.ServiceProvider.GetService(); Query(); } private void Query() { var storeCode = Appsettings.app("StoreInfo", "LinerInventory"); 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); } } /// /// 货道明细 /// /// [RelayCommand] private void SpaceDetail(string info) { var storeCode = Appsettings.app("StoreInfo", "LinerInventory");//内胆库号 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); }); } } #region 初始化datagrid private ObservableCollection _shapes = new ObservableCollection(); public ObservableCollection Shapes { get => _shapes; set => SetProperty(ref _shapes, value); } #endregion private ObservableCollection spaceDetailDataGrid; public ObservableCollection SpaceDetailDataGrid { get => spaceDetailDataGrid; set => SetProperty(ref spaceDetailDataGrid, value); } } }