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.

226 lines
7.6 KiB
C#

using Admin.Core.Model;
using Aucma.Scada.UI.Common;
using Aucma.Scada.UI;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
1 year ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using System.Windows;
namespace Aucma.Scada.UI.ViewModel.InventoryInfo
{
public partial class ShellInventoryViewModel : ObservableObject
1 year ago
{
[DllImport("user32.dll")]
public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time);
private ObservableCollection<BaseSpaceInfo> spaceItems = new ObservableCollection<BaseSpaceInfo>();
private InventoryInfoBusiness inventoryInfoBusiness = new InventoryInfoBusiness();// InventoryInfoBusiness.Instance;
1 year ago
private OutStoreBusiness outStoreBusiness = new OutStoreBusiness();// OutStoreBusiness.Instance;
1 year ago
private InStoreBusiness inStoreBusiness = new InStoreBusiness();// InStoreBusiness.Instance;
1 year ago
private AppConfig appConfig = new AppConfig();//AppConfig.Instance;
1 year ago
public ShellInventoryViewModel()
{
outStoreBusiness.RefreshStoreStockEvent += Query;
inStoreBusiness.RefreshInStoreTaskEvent += RefreshSpaceInfo;
Query();
}
#region 参数定义
public ObservableCollection<BaseSpaceInfo> _shapes;
public ObservableCollection<BaseSpaceInfo> Shapes
{
get => _shapes;
set => SetProperty(ref _shapes, value);
1 year ago
}
private ObservableCollection<BaseSpaceDetail> spaceDetailDataGrid;
public ObservableCollection<BaseSpaceDetail> SpaceDetailDataGrid
{
get => spaceDetailDataGrid;
set => SetProperty(ref spaceDetailDataGrid, value);
1 year ago
}
#endregion
1 year ago
private void Query()
{
App.Current.Dispatcher.Invoke((Action)(async () =>
1 year ago
{
var info =await inventoryInfoBusiness.GetSpaceInfos(appConfig.shellStoreCode);
1 year ago
if (info != null)
{
if (spaceItems.Count > 0)
{
spaceItems.Clear();
}
foreach (var item in info)
{
spaceItems.Add(item);
}
Shapes = spaceItems;
}
}));
}
private void RefreshSpaceInfo(object obj = null, bool isFinish = true)
{
Query();
}
/// <summary>
/// 货道入库标识设置
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void UpdateInStoreFlag(object obj)
1 year ago
{
string info = obj as string;
bool result =await inventoryInfoBusiness.UpdateInStoreFlag(appConfig.shellStoreCode, info);
1 year ago
if (result)
{
Query();
MessageBoxTimeoutA((IntPtr)0, $"货道入库状态修改成功3秒后关闭提示", "提示", 0, 0, 3000);
}
else
{
MessageBox.Show("货道入库状态修改失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
/// <summary>
/// 货道出库标识设置
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void UpdateOutStoreFlag(object obj)
1 year ago
{
string info = obj as string;
bool result =await inventoryInfoBusiness.UpdateOutStoreFlag(appConfig.shellStoreCode, info);
1 year ago
if (result)
{
Query();
MessageBoxTimeoutA((IntPtr)0, $"货道出库状态修改成功3秒后关闭提示", "提示", 0, 0, 3000);
}
else
{
MessageBox.Show("货道出库状态修改失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
/// <summary>
/// 货道异常标识设置
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void UpdateUnusualFlag(object obj)
1 year ago
{
string info = obj as string;
bool result =await inventoryInfoBusiness.UpdateUnusualFlag(appConfig.shellStoreCode, info);
1 year ago
if (result)
{
Query();
MessageBoxTimeoutA((IntPtr)0, $"货道异常标识修改成功3秒后关闭提示", "提示", 0, 0, 3000);
}
else
{
MessageBox.Show("货道异常标识修改失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
/// <summary>
/// 修改货道状态
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void UpdateSpaceStatus(object obj)
1 year ago
{
string info = obj as string;
bool result =await inventoryInfoBusiness.UpdateSpaceStatus(appConfig.shellStoreCode, info);
1 year ago
if (result)
{
Query();
MessageBoxTimeoutA((IntPtr)0, $"货道状态修改成功3秒后关闭提示", "提示", 0, 0, 3000);
}
else
{
MessageBox.Show("货道状态修改失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
/// <summary>
/// 货道明细
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void SpaceDetail(object obj)
1 year ago
{
string info = obj as string;
//SpaceDetailWindow spaceDetailWindow = new SpaceDetailWindow(appConfig.shellStoreCode, info);
//spaceDetailWindow.Show();
//inventoryInfoBusiness.RefreshBaseSpaceDetails(appConfig.shellStoreCode, info);
var list =await inventoryInfoBusiness.GetBaseSpaceDetails(appConfig.shellStoreCode, info);
1 year ago
RefreshSpaceDetails(list);
}
/// <summary>
/// 刷新货道明细列表
/// </summary>
/// <param name="spaceDetails"></param>
[RelayCommand]
1 year ago
private void RefreshSpaceDetails(List<BaseSpaceDetail> spaceDetails)
{
SpaceDetailDataGrid = new ObservableCollection<BaseSpaceDetail>();
if (spaceDetails != null)
{
spaceDetails.ForEach(
arg =>
{
SpaceDetailDataGrid.Add(arg);
});
}
}
/// <summary>
/// 手动出一个
/// </summary>
/// <param name="obj"></param>
[RelayCommand]
private async void OutOnlyOne(object obj)
1 year ago
{
string info = obj as string;
bool result =await outStoreBusiness.OutOnlyOneBySpaceCode(appConfig.shellStoreCode, info);
1 year ago
if (result)
{
Query();
MessageBoxTimeoutA((IntPtr)0, $"出库任务创建成功3秒后关闭提示", "提示", 0, 0, 3000);
}
else
{
MessageBox.Show("出库任务创建失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
}
}