using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Service; using Aucma.Core.BoxFoaming.Models; using Aucma.Core.BoxFoaming.Views.UserPage; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using log4net; using MaterialDesignThemes.Wpf; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.ObjectModel; using System.Threading.Tasks; using System.Windows; namespace Aucma.Core.BoxFoaming.ViewModels { public partial class BeforeFoamingPageModelView : ObservableObject { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel)); private readonly IBaseSpaceDetailServices? _baseSpaceDetailServices; private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices; public BeforeFoamingPageModelView() { _baseSpaceDetailServices = App.ServiceProvider.GetService(); _baseSpaceInfoServices = App.ServiceProvider.GetService(); this.LoadSpaceStoreMedthAsync(); } #region 加载泡前库货道信息 /// /// 加载泡前库货道信息 /// private async void LoadSpaceStoreMedthAsync() { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code var baseSpaceInfolist = await _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode));//仓库 Shapes.Clear(); foreach (var item in baseSpaceInfolist) { Shapes.Add(new SpaceInfoModel() { spaceCode = item.SpaceCode, spaceStock = item.SpaceStock, onTheWay = item.OnRouteAmount, totalAmount = item.SpaceStock + item.OnRouteAmount, materialType = item.MaterialType, inStoreFlag = item.SpaceStatus, outStoreFlag = item.OutStoreFlag, unusualFlag = item.UnusualFlag == 2 ? "red" : "white", isFlag = item.IsFlag,//禁用状态 onlyOne = 1, spaceType = item.SpaceType }); } } #endregion #region 初始化 private ObservableCollection _space = new ObservableCollection(); public ObservableCollection Shapes { get { return _space; } set { _space = value; OnPropertyChanged();//属性通知 } } #endregion #region 货道明细 [RelayCommand] private void SpaceDetail(string spaceCode) { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode); page.ShowDialog(); } #endregion #region 禁用货道 [RelayCommand] private async Task IsEnableSpace(string spaceCode) { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code var list= await _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode) && d.SpaceCode.Equals(spaceCode)); list.ForEach(d => { d.SpaceStatus = 2; }); var result= await _baseSpaceInfoServices.UpdateAsync(list); if (result) { MessageBox.Show($"禁用货道[{spaceCode}] 成功!"); LoadSpaceStoreMedthAsync(); } else { MessageBox.Show($"禁用货道[{spaceCode}] 失败!"); } } #endregion #region 入库 [RelayCommand] private void EnterSpace(string spaceCode) { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode); page.ShowDialog(); } #endregion #region 出库 [RelayCommand] private void OutSpace(string spaceCode) { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode); page.ShowDialog(); } #endregion } }