|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using BPASmart.Model;
- using BPASmart.RecipeManagement.View;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.Helper;
- using BPASmartClient.RecipeManagement.View;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace BPASmart.RecipeManagement.ViewModel
- {
- public class RecipeManagerViewModel : ObservableObject
- {
- public ObservableCollection<Recipes> RecipeList { get; set; } = Json<LocalRecipes>.Data.locaRecipes;
- /// <summary>
- /// 创建配方
- /// </summary>
- public RelayCommand CreateRecipeCommand { get; set; }
-
- public RelayCommand<object> EditRecipeCommand { get; set; }
- public RelayCommand<object> DeleteRecipeCommand { get; set; }
-
- /// <summary>
- /// 配方工艺
- /// </summary>
- public RelayCommand<object> PecipeSettingCommand { get; set; }
- /// <summary>
- /// 配方下发
- /// </summary>
- public RelayCommand<object> PecipeStartCommand { get; set; }
-
- private void EditRecipe(object o)
- {
- if (o == null) return;
- if (o is int item && item >= 0)
- {
- Globle.GlobleData.ChangeRecipes = new Recipes();
- Globle.GlobleData.ChangeRecipes = RecipeList[item];
- RecipesConfigure recipesConfigure = new RecipesConfigure();
- recipesConfigure.ShowDialog();
- }
- }
-
- private void DeleteRecipe(object o)
- {
- if (o == null) return;
- if (o is int i && i >= 0)
- {
- RecipeList.RemoveAt(i);
- Json<LocalRecipes>.Save();
- }
- }
-
- private void PecipeSetting(object o)
- {
- if (o == null) return;
- if (o is string id)
- {
- var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == id);
- if (res != null)
- {
- Globle.GlobleData.recipeTechnologyProcess = null;
- Globle.GlobleData.recipeTechnologyProcess = res;
- TechnologyProcess technologyProcess = new TechnologyProcess();
- technologyProcess.ShowDialog();
-
- }
- }
- }
-
- private void PecipeStart(object o)
- {
- if (o == null) return;
- if (o is string id)
- {
- var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == id);
- if (res != null)
- {
- //下发配方
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"配方下发成功!");
- }
- }
- }
-
- public RecipeManagerViewModel()
- {
- CreateRecipeCommand = new RelayCommand(() =>
- {
- Globle.GlobleData.ChangeRecipes = null;
- RecipesConfigure recipesConfigure = new RecipesConfigure();
- recipesConfigure.ShowDialog();
- });
-
- EditRecipeCommand = new RelayCommand<object>(EditRecipe);
-
- DeleteRecipeCommand = new RelayCommand<object>(DeleteRecipe);
-
- PecipeSettingCommand = new RelayCommand<object>(PecipeSetting);
-
- PecipeStartCommand = new RelayCommand<object>(PecipeStart);
-
- }
- }
- }
|