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.

208 lines
6.1 KiB
C#

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