终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

108 строки
4.2 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. funcPar.ComboBoxItemsSource = FuncParHelpClass.GetParOptions(item.ParName);
  33. }
  34. FuncPars.Add(funcPar);
  35. }
  36. }
  37. }
  38. }, "OpenFuncEditView", true);
  39. SaveParamCommand = new BPARelayCommand(() =>
  40. {
  41. foreach (var item in FuncPars)
  42. {
  43. if (item.ParValue == null || String.IsNullOrEmpty(item.ParValue.ToString()) || item.ParValue.ToString().Length <= 0)
  44. {
  45. MessageNotify.GetInstance.ShowDialog("请输入参数后再重试!", DialogType.Error);
  46. return;
  47. }
  48. if (item.IsUseComboBox)
  49. {
  50. switch (FuncName)
  51. {
  52. case EFunc.添加调料:
  53. item.Id = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  54. break;
  55. case EFunc.添加主料:
  56. item.Id = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  57. break;
  58. case EFunc.添加辅料:
  59. item.Id = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
  60. break;
  61. default:
  62. break;
  63. }
  64. }
  65. }
  66. //关闭视图窗口。
  67. ActionManage.GetInstance.Send(true, "CloseFuncParmEditView");
  68. });
  69. }
  70. private void AddTestData()
  71. {
  72. //FuncName = "加热启动";
  73. FuncPars = new ObservableCollection<FuncParHelpClass>();
  74. for (int i = 1; i < 3; i++)
  75. {
  76. FuncPars.Add(new FuncParHelpClass()
  77. {
  78. ParName = $"{i}样参数",
  79. ParUnit = $"{i}样单位",
  80. ParDescribe = $"{i}样参数的描述",
  81. ParValue = i.ToString(),
  82. });
  83. }
  84. }
  85. /// <summary>保存参数。</summary>
  86. public BPARelayCommand SaveParamCommand { get; set; }
  87. private EFunc _FuncName;
  88. /// <summary>功能名称。</summary>
  89. public EFunc FuncName
  90. {
  91. get { return _FuncName; }
  92. set { _FuncName = value; OnPropertyChanged(); }
  93. }
  94. public static ObservableCollection<FuncParHelpClass> FuncPars { get; set; } = new ObservableCollection<FuncParHelpClass>();
  95. }
  96. }