终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

80 行
2.7 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.Model;
  3. using BPASmartClient.MorkS.Model;
  4. using BPASmartClient.MorkS.View;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. namespace BPASmartClient.MorkS.ViewModel
  13. {
  14. internal class GoodsMakeViewModel : NotifyBase
  15. {
  16. public ObservableCollection<GoodsModel> GoodsModels { get; set; } = new ObservableCollection<GoodsModel>();
  17. public BPARelayCommand<string> SendOrderCommand { get; set; }
  18. public BPARelayCommand<string> DeleteOrderCommand { get; set; }
  19. public BPARelayCommand EditCommand { get; set; }
  20. public GoodsMakeViewModel()
  21. {
  22. Json<Recipes>.Read();
  23. GoodsModels = Json<Recipes>.Data.GoodsModels;
  24. ActionManage.GetInstance.Register(new Action<object>((res) =>
  25. {
  26. if (res != null && res is GoodsModel goods)
  27. {
  28. var result = GoodsModels.FirstOrDefault(p => p.OrderNum == goods.OrderNum);
  29. if (result == null)
  30. {
  31. GoodsModels.Add(goods);
  32. Json<Recipes>.Save();
  33. }
  34. else
  35. {
  36. MessageBox.Show("新增订单失败!","提示", MessageBoxButton.OK, MessageBoxImage.Warning);
  37. }
  38. }
  39. }), "orderEdit");
  40. SendOrderCommand = new BPARelayCommand<string>((s) =>
  41. {
  42. var res = GoodsModels.FirstOrDefault(p => p.OrderNum.Equals(s));
  43. if (res != null)
  44. {
  45. new MorksSimorderModel() { Bowloc = res.BowlLoc, NoodleLoc = res.NoodlesLoc }.Publish();
  46. }
  47. });
  48. EditCommand = new BPARelayCommand(() =>
  49. {
  50. GoodsEditView goodsEditView = new GoodsEditView();
  51. goodsEditView.ShowDialog();
  52. });
  53. DeleteOrderCommand = new BPARelayCommand<string>((res) =>
  54. {
  55. if (!string.IsNullOrEmpty(res))
  56. {
  57. var re = GoodsModels.FirstOrDefault(p=>p.OrderNum.Equals(res));
  58. if (re != null)
  59. {
  60. GoodsModels.Remove(re);
  61. Json<Recipes>.Save();
  62. }
  63. else
  64. {
  65. MessageBox.Show("未查找到当前订单,删除失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
  66. }
  67. }
  68. });
  69. }
  70. }
  71. }