|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.SmallBatchingSystem.Views;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
-
- namespace BPASmartClient.SmallBatchingSystem.ViewModels
- {
- public class RecipeViewModel : BaseModel
- {
- public RecipeViewModel()
- {
- AddCommand = new RelayCommand(() =>
- {
- NewRecipeView newOutletView = new NewRecipeView();
- newOutletView.ShowDialog();
- });
- SaveCommand = new RelayCommand(() => { Json<ConfigInfoModel>.Save(); Control.GetInstance.NotifyPrompt("配方保存成功"); });
- RecipeInfoModels = Json<ConfigInfoModel>.Data.Recipes;
- RemoveCommand = new RelayCommand<object>((o) =>
- {
- if (!string.IsNullOrEmpty(o?.ToString()))
- {
- var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
- if (res != null)
- {
- if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.RecipeName}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning))
- {
- Json<ConfigInfoModel>.Data.Recipes.Remove(res);
- Control.GetInstance.NotifyPrompt($"{res.RecipeName} 删除成功");
- Control.GetInstance.OperationLog($"{res.RecipeName} 删除成功");
- }
- }
- }
- });
-
- DetailsCommand = new RelayCommand<object>((o) =>
- {
- if (!string.IsNullOrEmpty(o?.ToString()))
- {
- var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
- if (res != null)
- {
- NewRecipeView newOutletView = new NewRecipeView();
- ActionManage.GetInstance.Send("OpenNewRecipe", res);
- newOutletView.ShowDialog();
- Control.GetInstance.OperationLog($"{res.RecipeName} 编辑完成");
- }
- }
- });
- }
-
- public ObservableCollection<RecipeInfo> RecipeInfoModels { get; set; }
- }
- }
|