|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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];
- funcPar.ComboBoxItemsSource = FuncParHelpClass.GetParOptions(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>();
- }
- }
|