using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using BPA.Helper; using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.SmallBatchingSystem.Views; using BPA.Helper; namespace BPASmartClient.SmallBatchingSystem.ViewModels { public class OutletManagementViewModel : BaseModel { public OutletManagementViewModel() { AddCommand = new BPARelayCommand(() => { NewOutletView newOutletView = new NewOutletView(); newOutletView.ShowDialog(); }); SaveCommand = new BPARelayCommand(() => { Json.Save(); }); OutletInfoModels = Json.Data.OutletInfoModels; RemoveCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { var res = Json.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString()); if (res != null) { if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.OutletName}】出料口,删除后数据将永久丢失!无法找回", DialogType.Warning)) { Json.Data.OutletInfoModels.Remove(res); Control.GetInstance.OperationLog($"{res.OutletName} 删除成功"); } } } }); DetailsCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { var res = Json.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString()); if (res != null) { NewOutletView newOutletView = new NewOutletView(); ActionManage.GetInstance.Send("OpenNewOutlet", res); newOutletView.ShowDialog(); } } }); } public ObservableCollection OutletInfoModels { get; set; } } }