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.

122 lines
3.2 KiB
C#

using Admin.Core.Model;
using Aucma.Scada.UI;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
namespace Aucma.Scada.UI.ViewModel.TaskInfo
{
public partial class TaskInfoViewModel : ObservableObject
{
public static readonly TaskInfoBusiness taskInfoBusiness = new TaskInfoBusiness();
public TaskInfoViewModel()
{
this.InStoreTask();
}
#region 参数定义
/// <summary>
/// 任务列表DataGrid
/// </summary>
private ObservableCollection<RealTaskInfo> taskInfoDataGrid;
public ObservableCollection<RealTaskInfo> TaskInfoDataGrid
{
get => taskInfoDataGrid;
set => SetProperty(ref taskInfoDataGrid, value);
}
/// <summary>
/// 记录列表DataGrid
/// </summary>
private ObservableCollection<RealTaskInfo> recordInfoDataGrid;
public ObservableCollection<RealTaskInfo> RecordInfoDataGrid
{
get => recordInfoDataGrid;
set => SetProperty(ref recordInfoDataGrid, value);
}
#endregion
/// <summary>
/// 出入库任务按钮事件
/// </summary>
[RelayCommand]
private void Task(object obj)
{
string info = obj as string;
switch (info)
{
case "inStore":
InStoreTask();
break;
case "outStore":
OutStoreTask();
break;
default:
break;
}
}
/// <summary>
/// 入库任务
/// </summary>
/// <param name="obj"></param>
private async void InStoreTask()
{
var models =await taskInfoBusiness.GetTaskInfos(1);
TaskInfoDataGrid = new ObservableCollection<RealTaskInfo>();
RecordInfoDataGrid = new ObservableCollection<RealTaskInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
if (arg.TaskStatus == 3)
{
RecordInfoDataGrid.Add(arg);
}
else
{
TaskInfoDataGrid.Add(arg);
}
});
}
}
/// <summary>
/// 出库任务
/// </summary>
/// <param name="obj"></param>
private async void OutStoreTask()
{
var models =await taskInfoBusiness.GetTaskInfos(2);
TaskInfoDataGrid = new ObservableCollection<RealTaskInfo>();
RecordInfoDataGrid = new ObservableCollection<RealTaskInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
if (arg.TaskStatus == 3)
{
RecordInfoDataGrid.Add(arg);
}
else
{
TaskInfoDataGrid.Add(arg);
}
});
}
}
}
}