终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrderListDialogViewModel.cs 4.0 KiB

2 年之前
1 年之前
2 年之前
1 年之前
2 年之前
2 年之前
2 年之前
1 年之前
2 年之前
1 年之前
2 年之前
1 年之前
2 年之前
1 年之前
1 年之前
1 年之前
2 年之前
1 年之前
1 年之前
2 年之前
1 年之前
2 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.Linq;
  4. using System.Threading;
  5. using BPA.Message;
  6. using BPA.Message.Enum;
  7. using BPA.Helper;
  8. using BPASmartClient.Model;
  9. namespace BPASmartClient.ViewModel
  10. {
  11. public class OrderListDialogViewModel : NotifyBase
  12. {
  13. public static bool IsAutoClose = false;
  14. public OrderListDialogViewModel()
  15. {
  16. Init();
  17. }
  18. private void Init()
  19. {
  20. CloseButton();
  21. CancelButton();
  22. ConfirmButton();
  23. if (Json<KeepDataBase>.Data.orderLists.Count > 0)
  24. {
  25. MessageLog.GetInstance.Show($"ǰʣ{Json<KeepDataBase>.Data.orderLists.Count}");
  26. TaskManage.GetInstance.Start(new Action(() =>
  27. {
  28. Thread.Sleep(10000);
  29. if (!IsAutoClose) ActionManage.GetInstance.Send(false, "Close");
  30. }), "ʱ˳");
  31. }
  32. }
  33. /// <summary>
  34. /// رհť
  35. /// </summary>
  36. private void CloseButton()
  37. {
  38. CloseCommand = new BPARelayCommand(() =>
  39. {
  40. Json<KeepDataBase>.Data.orderLists.Clear();
  41. ActionManage.GetInstance.Send(false, "Close");
  42. Json<KeepDataBase>.Save();
  43. });
  44. }
  45. /// <summary>
  46. /// ȡť
  47. /// </summary>
  48. private void CancelButton()
  49. {
  50. CancelCommand = new BPARelayCommand(() =>
  51. {
  52. Json<KeepDataBase>.Data.orderLists.Clear();
  53. ActionManage.GetInstance.Send(false, "Close");
  54. Json<KeepDataBase>.Save();
  55. });
  56. }
  57. /// <summary>
  58. /// ȷť
  59. /// </summary>
  60. private void ConfirmButton()
  61. {
  62. ConfirmCommand = new BPARelayCommand(() =>
  63. {
  64. Json<KeepDataBase>.Data.orderLists.Clear();
  65. //var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
  66. var res = orderStatusLists.Where(p => p.morkOrderPushes.Where(s => s.IsSelected == true).ToList().Count > 0).ToList();
  67. if (res != null)
  68. {
  69. Json<KeepDataBase>.Data.orderLists.Clear();
  70. foreach (var item in orderStatusLists)
  71. {
  72. ObservableCollection<MorkOrder> morkOrders = new ObservableCollection<MorkOrder>();
  73. foreach (var mork in item.morkOrderPushes)
  74. {
  75. if (mork.IsSelected) morkOrders.Add(mork);
  76. }
  77. Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
  78. {
  79. DeviceId = item.DeviceId,
  80. IsAllSelect = item.IsAllSelect,
  81. morkOrderPushes = morkOrders,
  82. });
  83. /*
  84. foreach (var mo in morkOrders)
  85. {
  86. DoOrderEvent de = new DoOrderEvent();
  87. de.DeviceId = int.Parse(item.DeviceId);
  88. de.MorkOrder = mo.OrderPush;
  89. EventBus.GetInstance.Publish(de);
  90. }*/
  91. }
  92. }
  93. ActionManage.GetInstance.Send(true, "Close");
  94. });
  95. }
  96. public BPARelayCommand CloseCommand { get; set; }
  97. public BPARelayCommand CancelCommand { get; set; }
  98. public BPARelayCommand ConfirmCommand { get; set; }
  99. public ObservableCollection<OrderData> orderStatusLists
  100. {
  101. get { return Json<KeepDataBase>.Data.orderLists; }
  102. set { Json<KeepDataBase>.Data.orderLists = value; }
  103. }
  104. }
  105. }