Browse Source

recipe table编辑页面
1.增加表同名判断
2。clear功能:table1保留一步,其他table清除所有步

huangping 1 month ago
parent
commit
36dbc661a6

+ 1 - 1
FrameworkLocal/UIClient/CenterViews/Editors/Recipe/RecipeDataBase.cs

@@ -281,7 +281,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
         }
 
 
-        public string TableName => Tables.Count > 0 ? Tables.FirstOrDefault(x => x.Index == TableIndex).Name : "";
+        public string TableName => Tables.Count > 0&&TableIndex>-1 ? Tables.FirstOrDefault(x => x.Index == TableIndex)?.Name : "";
 
         private DateTime deviseTime;
         public DateTime ReviseTime

+ 40 - 10
Furnace/FurnaceUI/Views/Recipes/RecipeTableSelectDialogViewModel.cs

@@ -62,22 +62,34 @@ namespace FurnaceUI.Views.Recipes
 
         }
         public void Clear()
-        {
+        {  
+            if (SelectedIndex < 0)
+            {
+                DialogBox.ShowWarning("No table is selected");
+                return;
+            }
             if (!DialogBox.Confirm("Clear this table?"))
                 return;
             // SelectedTable.Name = "";
             SelectedTable.EndStatus = "";
-            if (SelectedTable.TableData.Steps.Count > 1)
-            {
-                while (SelectedTable.TableData.Steps.Count > 1)
+            if (SelectedTable.TableData.Steps.Count > 0)
+            {   
+                if (SelectedIndex == 0)
                 {
-                    SelectedTable.TableData.Steps.RemoveAt(1);
+                    if (SelectedTable.TableData.Steps.Count < 2)
+                    {
+                        DialogBox.ShowInfo("Table1 have one step at least");
+                        return;
+                    }
+                    var step = SelectedTable.TableData.Steps.First();                    
+                    if (step != null)
+                    {
+                        SelectedTable.TableData.Steps.Clear();
+                        SelectedTable.TableData.Steps.Add(step);
+                    }
                 }
-            }
-            else
-            {
-                SelectedTable.TableData = new RecipeDataBase();
-            }
+                else SelectedTable.TableData.Steps.Clear();
+            }     
         }
 
         public void NotSelect()
@@ -99,6 +111,24 @@ namespace FurnaceUI.Views.Recipes
             }
             else
             {
+                for(int i = 0; i < Recipe.Tables.Count; i++)
+                {
+                    if (Recipe.Tables[i].TableData?.Steps?.Count > 0)
+                    { 
+                        var tablename = Recipe.Tables[i].Name.Trim();
+                        for (int j = i + 1; j < Recipe.Tables.Count; j++)
+                        {
+                            if (Recipe.Tables[j].TableData?.Steps?.Count>0)
+                            {
+                                if (tablename == Recipe.Tables[j].Name.Trim())
+                                {
+                                    DialogBox.ShowError($"Table{i + 1} and Table{j + 1} couldn't have same table name [{tablename}]");
+                                    return;
+                                }
+                            }
+                        }
+                    }
+                }                
                 Recipe.TableIndex = SelectedTable.Index;
                 Recipe.Steps.Clear();
                 SelectedTable.TableData.Steps.ToList().ForEach(x =>