终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

87 rader
3.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPASmartClient.Helper;
  11. using Microsoft.Toolkit.Mvvm.Input;
  12. using BPASmartClient.JXJFoodSmallStation.Model;
  13. using BPASmartClient.JXJFoodSmallStation.View;
  14. using BPASmartClient.CustomResource.UserControls;
  15. using BPASmartClient.CustomResource.UserControls.Model;
  16. using BPASmartClient.CustomResource.UserControls.Enum;
  17. using System.Windows.Media;
  18. using BPASmartClient.CustomResource.UserControls.MessageShow;
  19. using BPASmartClient.CustomResource.Pages.Model;
  20. using BPASmartClient.Model;
  21. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  22. {
  23. public class RecipeSettingsViewModel : ObservableObject
  24. {
  25. public RecipeSettingsViewModel()
  26. {
  27. Recipes = Json<LocaPar>.Data.Recipes;
  28. NewMaterital = new RelayCommand(() =>
  29. {
  30. NewMaterialView newMateritalView = new NewMaterialView();
  31. newMateritalView.ShowDialog();
  32. });
  33. NewRecipe = new RelayCommand(() =>
  34. {
  35. NewRecipeView nrv = new NewRecipeView();
  36. nrv.ShowDialog();
  37. MessageLog.GetInstance.ShowUserLog("新建配方");
  38. });
  39. SaveRecipe = new RelayCommand(() =>
  40. {
  41. Json<LocaPar>.Save();
  42. MessageLog.GetInstance.ShowUserLog("保存配方");
  43. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
  44. });
  45. RemoveCommand = new RelayCommand<object>((o) =>
  46. {
  47. if (o is string str)
  48. {
  49. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  50. if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
  51. MessageLog.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}");
  52. }
  53. });
  54. DetailsCommand = new RelayCommand<object>((o) =>
  55. {
  56. if (o != null && o is string str)
  57. {
  58. ActionManage.GetInstance.CancelRegister("Details");
  59. NewRecipeView nrv = new NewRecipeView();
  60. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  61. ActionManage.GetInstance.Send("Details", res);
  62. nrv.ShowDialog();
  63. MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
  64. }
  65. });
  66. }
  67. public RelayCommand NewMaterital { get; set; }
  68. public RelayCommand NewRecipe { get; set; }
  69. public RelayCommand SaveRecipe { get; set; }
  70. public RelayCommand<object> EditCommand { get; set; }
  71. public RelayCommand<object> DetailsCommand { get; set; }
  72. public RelayCommand<object> RemoveCommand { get; set; }
  73. public ObservableCollection<RecipeModel> Recipes { get; set; }
  74. }
  75. }