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.SmallBatchingSystem.Views; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; namespace BPASmartClient.SmallBatchingSystem.ViewModels { public class OutletManagementViewModel : BaseModel { public OutletManagementViewModel() { AddCommand = new RelayCommand(() => { NewOutletView newOutletView = new NewOutletView(); newOutletView.ShowDialog(); }); SaveCommand = new RelayCommand(() => { Json.Save(); }); OutletInfoModels = Json.Data.OutletInfoModels; RemoveCommand = new RelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { var res = Json.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString()); if (res != null) { Json.Data.OutletInfoModels.Remove(res); Control.GetInstance.OperationLog($"{res.OutletName} 删除成功"); } } }); DetailsCommand = new RelayCommand((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; } } }