终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OutletManagementViewModel.cs 2.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BPA.Helper;
  8. using BPASmartClient.SmallBatchingSystem.Views;
  9. using Microsoft.Toolkit.Mvvm.ComponentModel;
  10. using Microsoft.Toolkit.Mvvm.Input;
  11. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  12. {
  13. public class OutletManagementViewModel : BaseModel
  14. {
  15. public OutletManagementViewModel()
  16. {
  17. AddCommand = new RelayCommand(() =>
  18. {
  19. NewOutletView newOutletView = new NewOutletView();
  20. newOutletView.ShowDialog();
  21. });
  22. SaveCommand = new RelayCommand(() => { Json<ConfigInfoModel>.Save(); });
  23. OutletInfoModels = Json<ConfigInfoModel>.Data.OutletInfoModels;
  24. RemoveCommand = new RelayCommand<object>((o) =>
  25. {
  26. if (!string.IsNullOrEmpty(o?.ToString()))
  27. {
  28. var res = Json<ConfigInfoModel>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString());
  29. if (res != null)
  30. {
  31. Json<ConfigInfoModel>.Data.OutletInfoModels.Remove(res);
  32. Control.GetInstance.OperationLog($"{res.OutletName} 删除成功");
  33. }
  34. }
  35. });
  36. DetailsCommand = new RelayCommand<object>((o) =>
  37. {
  38. if (!string.IsNullOrEmpty(o?.ToString()))
  39. {
  40. var res = Json<ConfigInfoModel>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString());
  41. if (res != null)
  42. {
  43. NewOutletView newOutletView = new NewOutletView();
  44. ActionManage.GetInstance.Send("OpenNewOutlet", res);
  45. newOutletView.ShowDialog();
  46. }
  47. }
  48. });
  49. }
  50. public ObservableCollection<OutletInfoModel> OutletInfoModels { get; set; }
  51. }
  52. }