|
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.MorkCL.HelpClass;
- using BPASmartClient.MorkCL.Server;
-
- namespace BPASmartClient.MorkCL.ViewModel
- {
- public class EditFunctionParamViewModel : NotifyBase
- {
- public EditFunctionParamViewModel()
- {
- //AddTestData();
- ActionManage.GetInstance.Register((object o) =>
- {
- FuncPars.Clear();
- if (o != null && o is FuncModel funcSet)
- {
- FuncName = funcSet.eFunc;
- if (funcSet.funcPars != null)
- {
- foreach (FuncPar item in funcSet.funcPars)
- {
- var funcPar = new FuncParHelpClass()
- {
- ParName = item.ParName,
- ParValue = item.ParValue,
- ParUnit = item.ParUnit,
- ParDescribe = item.ParDescribe,
- };
- if (FuncParHelpClass.ParOptions.ContainsKey(item.ParName))
- {
- funcPar.IsUseComboBox = true;
- funcPar.ComboBoxItemsSource = FuncParHelpClass.ParOptions[item.ParName];
- }
- FuncPars.Add(funcPar);
- }
- }
- }
- }, "OpenFuncEditView", true);
-
- SaveParamCommand = new BPARelayCommand(() =>
- {
- foreach (var item in FuncPars)
- {
- if (item.ParValue == null || String.IsNullOrEmpty(item.ParValue.ToString()) || item.ParValue.ToString().Length <= 0)
- {
- MessageNotify.GetInstance.ShowDialog("请输入参数后再重试!", DialogType.Error);
- return;
- }
- if (item.IsUseComboBox)
- {
- switch (FuncName)
- {
- case EFunc.添加调料:
- item.Id = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
- break;
-
- case EFunc.添加主料:
- item.Id = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
- break;
-
- case EFunc.添加辅料:
- item.Id = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
- break;
-
- default:
- break;
- }
- }
- }
- //关闭视图窗口。
- ActionManage.GetInstance.Send("CloseFuncParmEditView", true);
- });
- }
-
- private void AddTestData()
- {
- //FuncName = "加热启动";
-
- FuncPars = new ObservableCollection<FuncParHelpClass>();
- for (int i = 1; i < 3; i++)
- {
- FuncPars.Add(new FuncParHelpClass()
- {
- ParName = $"{i}样参数",
- ParUnit = $"{i}样单位",
- ParDescribe = $"{i}样参数的描述",
- ParValue = i.ToString(),
- });
- }
- }
-
- /// <summary>保存参数。</summary>
- public BPARelayCommand SaveParamCommand { get; set; }
-
- private EFunc _FuncName;
-
- /// <summary>功能名称。</summary>
- public EFunc FuncName
- {
- get { return _FuncName; }
- set { _FuncName = value; OnPropertyChanged(); }
- }
-
- public static ObservableCollection<FuncParHelpClass> FuncPars { get; set; } = new ObservableCollection<FuncParHelpClass>();
- }
- }
|