using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using BPASmartClient.SmallBatchingSystem.Views; using System.Collections.ObjectModel; using BPA.Helper; using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.SmallBatchingSystem.ViewModels { public class SiloManagementViewModel : BaseModel { public SiloManagementViewModel() { AddCommand = new RelayCommand(() => { NewSiloView newSiloView = new NewSiloView(); newSiloView.ShowDialog(); }); SaveCommand = new RelayCommand(() => { Json.Save(); }); SiloInfoModels = Json.Data.SiloInfoModels; RemoveCommand = new RelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { var res = Json.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == o.ToString()); if (res != null) { if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.SiloName}】原料,删除后数据将永久丢失!无法找回", DialogType.Warning)) { Json.Data.SiloInfoModels.Remove(res); Control.GetInstance.NotifyPrompt($"{res.SiloName} 删除成功"); Control.GetInstance.OperationLog($"{res.SiloName} 删除成功"); } } } }); DetailsCommand = new RelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { var res = Json.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == o.ToString()); if (res != null) { NewSiloView newSiloView = new NewSiloView(); ActionManage.GetInstance.Send("OpenNewSilo", res); newSiloView.ShowDialog(); Control.GetInstance.OperationLog($"{res.SiloName} 编辑完成"); } } }); } public ObservableCollection SiloInfoModels { get; set; } } }