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.

224 lines
6.3 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;
10 months ago
using Aucma.Core.Palletiz.Views;
10 months ago
using CommunityToolkit.Mvvm.ComponentModel;
using System.Threading.Tasks;
using static Aucma.Core.Palletiz.ViewModels.StatisticsPageViewModel;
/*
*
* 2024-02-28
*/
namespace Aucma.Core.Palletiz.ViewModels
{
10 months ago
internal class IndexControlViewModel : ObservableObject
{
private InStoreBusiness inStoreBusiness;
1 year ago
public IndexControlViewModel()
{
new InStoreBusiness().Init();
10 months ago
SelectTypeViewModel.RefreshPageEvent += Init;
StatisticsPageViewModel.CountInstoreEvent += CountInstore;
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)
10 months ago
{
SelectType direct = new SelectType(space);
direct.ShowDialog();
}
});
this.Init();
10 months ago
InStoreTaskContent = new StatisticsPageView();
1 year ago
}
12 months ago
public void CountInstore(int count)
{
InStoreAmount = "入库数量:";
InStoreAmount = inStoreAmount + count;
}
#region 参数定义
12 months ago
10 months ago
public string productSNCode = string.Empty;
public string ProductSNCode
{
get { return this.productSNCode; }
10 months ago
set => SetProperty(ref productSNCode, value);
10 months ago
}
public string productModel = string.Empty;
10 months ago
public string ProductModel
{
get { return this.productModel; }
10 months ago
set => SetProperty(ref productModel, value);
10 months ago
}
public string orderCode = string.Empty;
public string OrderCode
{
get { return this.orderCode; }
10 months ago
set => SetProperty(ref orderCode, value);
10 months ago
}
public string productScanTime = string.Empty;
public string ProductScanTime
{
get { return this.productScanTime; }
10 months ago
set => SetProperty(ref productScanTime, value);
10 months ago
}
public string msg = string.Empty;
public string Msg
{
get { return this.msg; }
10 months ago
set => SetProperty(ref msg, value);
10 months ago
}
public string inStoreAmount = "入库数量:";
public string InStoreAmount
12 months ago
{
get { return this.inStoreAmount; }
10 months ago
set => SetProperty(ref inStoreAmount, value);
12 months ago
}
10 months ago
public System.Windows.Controls.UserControl _content;
public System.Windows.Controls.UserControl InStoreTaskContent
{
get { return this._content; }
10 months ago
set => SetProperty(ref _content, value);
10 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; }
10 months ago
set => SetProperty(ref _areaA_SpaceInfo, value);
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; }
10 months ago
set => SetProperty(ref _areaB_SpaceInfo, value);
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 async Task Init()
1 year ago
{
await Task.Run(() =>
{
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;
}));
}
});
}
}
}