终端一体化运控平台
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.
 
 
 

106 lines
4.1 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.MorkCL.HelpClass;
  3. using BPASmartClient.MorkCL.Server;
  4. namespace BPASmartClient.MorkCL.ViewModel
  5. {
  6. public class EditFunctionParamViewModel : NotifyBase
  7. {
  8. public EditFunctionParamViewModel()
  9. {
  10. //AddTestData();
  11. ActionManage.GetInstance.Register((object o) =>
  12. {
  13. FuncPars.Clear();
  14. if (o != null && o is FuncModel funcSet)
  15. {
  16. FuncName = funcSet.eFunc;
  17. if (funcSet.funcPars != null)
  18. {
  19. foreach (FuncPar item in funcSet.funcPars)
  20. {
  21. var funcPar = new FuncParHelpClass()
  22. {
  23. ParName = item.ParName,
  24. ParValue = item.ParValue,
  25. ParUnit = item.ParUnit,
  26. ParDescribe = item.ParDescribe,
  27. };
  28. if (FuncParHelpClass.ParOptions.ContainsKey(item.ParName))
  29. {
  30. funcPar.IsUseComboBox = true;
  31. funcPar.ComboBoxItemsSource = FuncParHelpClass.ParOptions[item.ParName];
  32. }
  33. FuncPars.Add(funcPar);
  34. }
  35. }
  36. }
  37. }, "OpenFuncEditView", true);
  38. SaveParamCommand = new BPARelayCommand(() =>
  39. {
  40. foreach (var item in FuncPars)
  41. {
  42. if (item.ParValue == null || String.IsNullOrEmpty(item.ParValue.ToString()) || item.ParValue.ToString().Length <= 0)
  43. {
  44. MessageNotify.GetInstance.ShowDialog("请输入参数后再重试!", DialogType.Error);
  45. return;
  46. }
  47. if (item.IsUseComboBox)
  48. {
  49. switch (FuncName)
  50. {
  51. case EFunc.添加调料:
  52. item.Id = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  53. break;
  54. case EFunc.添加主料:
  55. item.Id = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  56. break;
  57. case EFunc.添加辅料:
  58. item.Id = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  59. break;
  60. default:
  61. break;
  62. }
  63. }
  64. }
  65. //关闭视图窗口。
  66. ActionManage.GetInstance.Send("CloseFuncParmEditView", true);
  67. });
  68. }
  69. private void AddTestData()
  70. {
  71. //FuncName = "加热启动";
  72. FuncPars = new ObservableCollection<FuncParHelpClass>();
  73. for (int i = 1; i < 3; i++)
  74. {
  75. FuncPars.Add(new FuncParHelpClass()
  76. {
  77. ParName = $"{i}样参数",
  78. ParUnit = $"{i}样单位",
  79. ParDescribe = $"{i}样参数的描述",
  80. ParValue = i.ToString(),
  81. });
  82. }
  83. }
  84. /// <summary>保存参数。</summary>
  85. public BPARelayCommand SaveParamCommand { get; set; }
  86. private EFunc _FuncName;
  87. /// <summary>功能名称。</summary>
  88. public EFunc FuncName
  89. {
  90. get { return _FuncName; }
  91. set { _FuncName = value; OnPropertyChanged(); }
  92. }
  93. public static ObservableCollection<FuncParHelpClass> FuncPars { get; set; } = new ObservableCollection<FuncParHelpClass>();
  94. }
  95. }