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.
AUCMA_SCADA/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs

164 lines
4.3 KiB
C#

using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Aucma.Core.Palletiz.Business;
using Aucma.Core.Palletiz.Models;
12 months ago
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Elasticsearch.Net.Specification.MachineLearningApi;
12 months ago
using log4net;
using Microsoft.Extensions.DependencyInjection;
12 months ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
12 months ago
namespace Aucma.Core.Palletiz.ViewModels
{
public partial class HandPalletizViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(HandPalletizViewModel));
public static StackInfoModel tempStackInfo = new StackInfoModel();
private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
private readonly IRecordInStoreServices _recordInstoreServices;
private readonly ICodeBindingRecordServices? _codeBindingRecordServices;
/// <summary>
/// 手动入库委托
/// </summary>
public delegate void HandSend(string spaceArea, string asciiStr);
public static event HandSend? HandSendEvent;
public HandPalletizViewModel()
{
_codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
init();
12 months ago
}
public void init()
12 months ago
{
List<ProductAllModel> list = _codeBindingRecordServices.GetAllProductModel();
if (list == null || list.Count == 0) return;
list = list.OrderBy(x => x.ProductMasterModel).ToList();
MaterialDataGrid.Clear();
Application.Current.Dispatcher.Invoke(() =>
12 months ago
{
foreach (ProductAllModel info in list)
{
MaterialDataGrid.Add(info);
}
});
}
#region 鼠标双击事件
/// <summary>
/// 鼠标双击事件
/// </summary>
/// <param name="obj"></param>
public void MouseClick(object obj)
{
var info = SelectedDataItem;
if (info != null)
12 months ago
{
ProductCode = info.ProductCode;
ProductModel = info.ProductModel;
12 months ago
}
}
#endregion
12 months ago
#region 初始化下拉列表
/// <summary>
/// 初始化下拉列表
/// </summary>
private ProductAllModel selectedDataItem;
public ProductAllModel SelectedDataItem
12 months ago
{
get { return selectedDataItem; }
set => SetProperty(ref selectedDataItem, value);
12 months ago
}
#endregion
#region 分垛信息下传
/// <summary>
/// 分垛信息下传
/// </summary>
[RelayCommand]
public void Save(Window window)
{
if (string.IsNullOrEmpty(ProductCode))
{
MessageBox.Show("请先选择产品型号");
return;
}
HandSendEvent?.Invoke("A", productCode);
MessageBox.Show("手动入库成功");
window.Close();
// 入库
}
12 months ago
/// <summary>
/// 分垛信息下传
/// </summary>
[RelayCommand]
public void Cancel(Window window)
12 months ago
{
window.Close();
12 months ago
}
#endregion
#region 初始化datagrid产品信息
12 months ago
/// <summary>
/// 初始化物料信息
12 months ago
/// </summary>
private ObservableCollection<ProductAllModel> materialDataGrid = new ObservableCollection<ProductAllModel>();
public ObservableCollection<ProductAllModel> MaterialDataGrid
12 months ago
{
get { return materialDataGrid; }
set => SetProperty(ref materialDataGrid, value);
12 months ago
}
#endregion
#region 选中条码
private string productCode;
public string ProductCode
{
get => productCode;
set => SetProperty(ref productCode, value);
}
#endregion
#region 选中型号
private string productModel;
public string ProductModel
{
get => productModel;
set => SetProperty(ref productModel, value);
}
#endregion
12 months ago
}
}