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 参数定义 /// /// 任务列表DataGrid /// private ObservableCollection taskInfoDataGrid; public ObservableCollection TaskInfoDataGrid { get => taskInfoDataGrid; set => SetProperty(ref taskInfoDataGrid, value); } /// /// 记录列表DataGrid /// private ObservableCollection recordInfoDataGrid; public ObservableCollection RecordInfoDataGrid { get => recordInfoDataGrid; set => SetProperty(ref recordInfoDataGrid, value); } #endregion /// /// 出入库任务按钮事件 /// [RelayCommand] private void Task(object obj) { string info = obj as string; switch (info) { case "inStore": InStoreTask(); break; case "outStore": OutStoreTask(); break; default: break; } } /// /// 入库任务 /// /// private async void InStoreTask() { var models =await taskInfoBusiness.GetTaskInfos(1); TaskInfoDataGrid = new ObservableCollection(); RecordInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { if (arg.TaskStatus == 3) { RecordInfoDataGrid.Add(arg); } else { TaskInfoDataGrid.Add(arg); } }); } } /// /// 出库任务 /// /// private async void OutStoreTask() { var models =await taskInfoBusiness.GetTaskInfos(2); TaskInfoDataGrid = new ObservableCollection(); RecordInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { if (arg.TaskStatus == 3) { RecordInfoDataGrid.Add(arg); } else { TaskInfoDataGrid.Add(arg); } }); } } } }