|
- 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 BPA.Helper;
-
-
- namespace BPASmartClient.SmallBatchingSystem.ViewModels
- {
- public class RecipeViewModel : BaseModel
- {
- public RecipeViewModel()
- {
- AddCommand = new BPARelayCommand(() =>
- {
- NewRecipeView newOutletView = new NewRecipeView();
- newOutletView.ShowDialog();
- });
- SaveCommand = new BPARelayCommand(() => { Json<ConfigInfoModel>.Save(); Control.GetInstance.NotifyPrompt("配方保存成功"); });
- RecipeInfoModels = Json<ConfigInfoModel>.Data.Recipes;
- RemoveCommand = new BPARelayCommand<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 BPARelayCommand<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; }
- }
- }
|