Browse Source

修改配方下发判断逻辑。

master
ZhaoGang 1 year ago
parent
commit
5f588b2339
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs

+ 8
- 4
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -36,7 +36,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
/// <summary> /// <summary>
/// 筛选后的配方列表。 /// 筛选后的配方列表。
/// </summary> /// </summary>
public static ObservableCollection<RecipeData> SelectedRecipes { get; set; } = Json<LocalRecipe>.Data.SelectedRecipes;
public static ObservableCollection<RecipeData> SelectedRecipes { get; set; }




@@ -45,6 +45,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel


public RecipeSendDownViewModel() public RecipeSendDownViewModel()
{ {

SelectedRecipes= Json<LocalRecipe>.Data.SelectedRecipes;

StartCommand = new RelayCommand<string>((recipeName) => StartCommand = new RelayCommand<string>((recipeName) =>
{ {
if (recipeName != null) if (recipeName != null)
@@ -59,7 +62,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null) if (res != null)
{ {
if (!Json<RemoteRecipe>.Data.Recipes.Contains(res))
if (!Json<RemoteRecipe>.Data.Recipes.Any(p=>p.RecipeCode==res.RecipeCode))
{ {
res.RecipesSource = RecipeSource.本地; res.RecipesSource = RecipeSource.本地;
Json<RemoteRecipe>.Data.Recipes.Add(res); Json<RemoteRecipe>.Data.Recipes.Add(res);
@@ -87,12 +90,13 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Json<LocalRecipe>.Data.SelectedRecipes.Clear(); Json<LocalRecipe>.Data.SelectedRecipes.Clear();
foreach ( var recipe in SelectRecipesViewModel.SelectRecipes ) foreach ( var recipe in SelectRecipesViewModel.SelectRecipes )
{ {
if ( recipe != null && !Json<LocalRecipe>.Data.SelectedRecipes.Contains(recipe))
if ( recipe != null && !Json<LocalRecipe>.Data.SelectedRecipes.Any(p=>p.RecipeCode==recipe.RecipeCode))
{ {
Json<LocalRecipe>.Data.SelectedRecipes.Add(recipe); Json<LocalRecipe>.Data.SelectedRecipes.Add(recipe);
} }
} }
//不保存会导致下次打开本地配方下发页面,会重新读取之前存储的文件。
Json<LocalRecipe>.Save();
}); });
} }
} }


Loading…
Cancel
Save