|
- using BPA.Models;
- using BPASmartClient.Helper;
- using BPASmartClient.MorkF.Model;
- 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;
-
- namespace BPASmartClient.MorkF.ViewModel
- {
-
- partial class LocalMenuViewModel:ObservableObject
- {
- public ObservableCollection<PotActions> PotActionStep { get; set; } = new ObservableCollection<PotActions>();
-
-
- public ObservableCollection<string> strPotActions { get; set; } = new ObservableCollection<string>();
-
-
-
- public RelayCommand<object> Delete { get; set; }
- public RelayCommand AddFryTime { get; set; }
- public RelayCommand Save { get; set; }
-
- private void Deleted(object o)
- {
- if (o == null) return;
- if(o is PotActions p)
- {
- PotActionStep.Remove(p);
- }
- for (int i = 0; i < PotActionStep.Count; i++)
- {
- PotActionStep[i].FryTime = i + 1;
- }
- }
-
-
- public LocalMenuViewModel()
- {
- if(Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions.Count > 0)
- {
- PotActionStep.Clear();
- PotActionStep = new ObservableCollection<PotActions>(Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions);
- }
- Delete = new RelayCommand<object>(Deleted);
- AddFryTime = new RelayCommand(() =>
- {
- List<SeasoningList> seasoningLists = new List<SeasoningList>();
- seasoningLists.Add(new SeasoningList { Loc = 0,Qty = 0});
- PotActionStep.Add(new BPA.Models.PotActions
- {
- FryTime = PotActionStep.Count +1,
- During =0,
- SeasoningLists = seasoningLists,
- });
- });
-
- Save = new RelayCommand(new Action(() =>
- {
- Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey = 11;
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions = new List<PotActions>(PotActionStep);
- Json<LocalPotStep>.Save();
- ActionManage.GetInstance.Send("LocalMenuClose");
- }));
-
- foreach(var pot in Enum.GetNames(typeof(StirFryPotActionEnum)))
- {
- strPotActions.Add(pot);
- }
-
- ActionManage.GetInstance.Register(new Action(()=>
- {
-
- for (int i = 0; i < Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions.Count; i++)
- {
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions[i].FryTime = i + 1;
- }
- }), "SortFryTime");
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o == null) return ;
- if(o is int[] ints)
- {
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions[ints[0]].FryTime = ints[1]+1;
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions[ints[1]].FryTime = ints[0]+1;
- var res = Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions[ints[0]];
-
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions.Remove(res);
- Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions.Insert(ints[1],res);
-
- }
-
-
- }), "PotActionStep");
-
-
- }
- }
- }
|