From 228cc8c597df5da6dfb35d592f9c2c9e3860d778 Mon Sep 17 00:00:00 2001 From: ZhaoGang <15196688790@163.com> Date: Thu, 25 Jan 2024 16:48:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=9B=E9=80=89=E9=85=8D=E6=96=B9bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/RecipeReceiveViewModel.cs | 3 ++- .../ViewModel/RecipeSendDownViewModel.cs | 22 ++++++++++++++++--- .../ViewModel/SelectRecipesViewModel.cs | 1 + .../ViewModel/NewLocalRecipeViewModel.cs | 1 + .../ViewModel/RecipeReceiveViewModel.cs | 19 ++++++++++++++++ .../ViewModel/SelectRecipesViewModel.cs | 1 + 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index e257ddd8..533e7bc6 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -113,8 +113,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } Json.Data.Recipes.Clear(); - Json.Save(); Json.Data.SelectedRecipes.Clear(); + Json.Save(); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"本地配方已全部删除!"); MessageNotify.GetInstance.ShowUserLog($"手动清除所有配方。"); }); diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index 58ddc7d3..36a43654 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -36,7 +36,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel /// /// 筛选后的配方列表。 /// - public static ObservableCollection SelectedRecipes { get; set; } + public static ObservableCollection SelectedRecipes { get; set; } = new ObservableCollection(); @@ -45,8 +45,24 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RecipeSendDownViewModel() { + var tempcoll = new ObservableCollection(); + foreach (var item in Json.Data.SelectedRecipes) + { + if (!Json.Data.Recipes.Any(p => p.RecipeCode.Equals(item.RecipeCode) + && p.RecipeName.Equals(item.RecipeName) && p.IsWashingBarrel == item.IsWashingBarrel + && p.TrayCode == item.TrayCode)) + { + tempcoll.Add(item); + } + } + foreach (var item in tempcoll) + { + Json.Data.SelectedRecipes.Remove(item); + } + Json.Save(); + tempcoll.Clear(); - SelectedRecipes= Json.Data.SelectedRecipes; + SelectedRecipes = Json.Data.SelectedRecipes; StartCommand = new RelayCommand((recipeName) => { @@ -87,7 +103,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { var selectView = new SelectRecipesView(); selectView.ShowDialog(); - + SelectedRecipes.Clear(); Json.Data.SelectedRecipes.Clear(); foreach ( var recipe in SelectRecipesViewModel.SelectRecipes ) { diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs index a223edad..d2cbb316 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs @@ -17,6 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public SelectRecipesViewModel() { AllRecipes = new(); + SelectRecipes.Clear(); foreach (var item in Json.Data.SelectedRecipes) { SelectRecipes.Add(item); diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs index 186bcdee..ded83b19 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs @@ -242,6 +242,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel Json.Data.Recipes.Add(newRemoteRecipeData); //新增一条配方应该默认显示出来。 Json.Data.SelectedRecipes.Add(newRemoteRecipeData); + Json.Save(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"自定义配方添加完成!"); MessageNotify.GetInstance.ShowUserLog($"添加一个自定义配方,配方名称:【{RecipeName}】,配方编号:【{RecipeCode}】。"); } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs index 042058f0..6bd2a297 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs @@ -31,6 +31,22 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel NotUseSmallDosing = GVL_SmallStation.GetInstance.NotUseSmallStation; IsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; IsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseWindSend; + + var tempcoll = new ObservableCollection(); + foreach (var item in Json.Data.SelectedRecipes) + { + if (!Json.Data.Recipes.Any(p=>p.RecipeCode.Equals(item.RecipeCode)&&p.RecipeName.Equals(item.RecipeName)&&p.TrayCode==item.TrayCode)) + { + tempcoll.Add(item); + } + } + foreach (var item in tempcoll) + { + Json.Data.SelectedRecipes.Remove(item); + } + Json.Save(); + tempcoll.Clear(); + Recipes = Json.Data.Recipes; NewRecipe = new RelayCommand(() => @@ -48,6 +64,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel if (res != null) { Json.Data.Recipes.Remove(res); + Json.Save(); MessageNotify.GetInstance.ShowUserLog($"删除配方——{res.RecipeName}"); } } @@ -156,6 +173,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel //新增了配方之后应该默认显示出来。 Json.Data.SelectedRecipes.Add(newRemoteRecipedata); + Json.Save(); MessageNotify.GetInstance.ShowUserLog("新增一条本地模拟配方。"); } @@ -166,6 +184,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { Json.Data.Recipes.Clear(); Json.Data.SelectedRecipes.Clear(); + Json.Save(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"本地配方清空成功。"); MessageNotify.GetInstance.ShowUserLog("手动清除所有本地配方"); } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs index b5fec65e..28e6f8c5 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs @@ -18,6 +18,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public SelectRecipesViewModel() { AllRecipes = new(); + SelectRecipes.Clear(); foreach (var item in Json.Data.SelectedRecipes) { SelectRecipes.Add(item);