using System; using CommunityToolkit.Mvvm.Input; using Aucma.Core.Palletiz.Business; using Admin.Core.Model; using Aucma.Core.Palletiz.Models; using Microsoft.Extensions.DependencyInjection; using System.Collections.ObjectModel; using System.Linq; using GalaSoft.MvvmLight; using Aucma.Core.Palletiz.Views; /* * 成品分垛入库首页信息 * 2024-02-28 */ namespace Aucma.Core.Palletiz.ViewModels { internal class IndexControlViewModel : ViewModelBase { private InStoreBusiness inStoreBusiness; public IndexControlViewModel() { new InStoreBusiness().Init(); SelectTypeViewModel.RefreshPageEvent += Init; this.inStoreBusiness = App.ServiceProvider.GetService(); InStoreBusiness.RefreshMsgEvent += RefreshMsg; InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo; UpdateInStoreFlagCommand = new RelayCommand(obj => { Console.WriteLine($"{obj};设置"); BaseSpaceInfo space = inStoreBusiness.GetSpaceinfosById(obj); if(space != null ) { SelectType direct = new SelectType(space); direct.ShowDialog(); } }); this.Init(); InStoreAmount = inStoreAmount + "19"; } #region 参数定义 public string productSNCode = string.Empty; public string ProductSNCode { get { return this.productSNCode; } set { productSNCode = value; RaisePropertyChanged(nameof(ProductSNCode)); } } public string productModel = string.Empty; public string ProductModel { get { return this.productModel; } set { productModel = value; RaisePropertyChanged(nameof(ProductModel)); } } public string orderCode = string.Empty; public string OrderCode { get { return this.orderCode; } set { orderCode = value; RaisePropertyChanged(nameof(OrderCode)); } } public string productScanTime = string.Empty; public string ProductScanTime { get { return this.productScanTime; } set { productScanTime = value; RaisePropertyChanged(nameof(ProductScanTime)); } } public string msg = string.Empty; public string Msg { get { return this.msg; } set { msg = value; RaisePropertyChanged(nameof(Msg)); } } public string inStoreAmount = "入库数量:"; public string InStoreAmount { get { return this.inStoreAmount; } set { inStoreAmount = value; RaisePropertyChanged(nameof(InStoreAmount)); } } /// /// A区域货道集合 /// public ObservableCollection _areaA_SpaceInfo; public ObservableCollection AreaA_SpaceInfo { get { return _areaA_SpaceInfo; } set { _areaA_SpaceInfo = value; RaisePropertyChanged(nameof(AreaA_SpaceInfo)); } } /// /// B区域货道集合 /// public ObservableCollection _areaB_SpaceInfo; public ObservableCollection AreaB_SpaceInfo { get { return _areaB_SpaceInfo; } set { _areaB_SpaceInfo = value; RaisePropertyChanged(nameof(AreaB_SpaceInfo)); } } #endregion public RelayCommand UpdateInStoreFlagCommand { get; set; } private ObservableCollection spaceItems = new ObservableCollection(); /// /// 刷新界面提示信息 /// /// public void RefreshMsg(string msg) { Msg = msg; } /// /// 刷新界面扫码信息 /// /// /// /// public void RefreshProductInfo(string productCode, string productModel, string orderCode) { ProductSNCode = productCode; ProductModel = productModel; OrderCode = orderCode; ProductScanTime = DateTime.Now.ToString(); } private void Init() { App.Current.Dispatcher.BeginInvoke((Action)(() => { var info = inStoreBusiness.GetBaseSpaceinfos("A"); if (info != null) { if (spaceItems.Count > 0) { spaceItems.Clear(); } info = info.OrderBy(x => x.ObjId).ToList(); foreach (var item in info) { spaceItems.Add(item); } AreaA_SpaceInfo = spaceItems; } })); App.Current.Dispatcher.BeginInvoke((Action)(() => { var info = inStoreBusiness.GetBaseSpaceinfos("A"); if (info != null) { if (spaceItems.Count > 0) { spaceItems.Clear(); } info = info.OrderBy(x => x.ObjId).ToList(); foreach (var item in info) { spaceItems.Add(item); } AreaB_SpaceInfo = spaceItems; } })); } } }