diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor
index b2e70b12..164113c3 100644
--- a/MP.SPEC/Components/ListPODL.razor
+++ b/MP.SPEC/Components/ListPODL.razor
@@ -25,7 +25,7 @@ else
- @if (!showRecipe)
+ @if (!showRecipeConf)
{
cloneRecord(record)" class="btn btn-info btn-sm mx-1" title="Duplica Record">
@if (record.IdxOdl == 0)
@@ -120,7 +120,7 @@ else
}
- @if (!showRecipe)
+ @if (!(showRecipeConf || showRecipeArch))
{
@record.IdxMacchina
@@ -152,11 +152,20 @@ else
- @if (showRecipe && currRecord != null)
+ @if (currRecord != null)
{
-
-
-
+ @if (showRecipeConf)
+ {
+
+
+
+ }
+ else if(showRecipeArch)
+ {
+
+
+
+ }
}
}
diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs
index b7dcf38a..294bea3b 100644
--- a/MP.SPEC/Components/ListPODL.razor.cs
+++ b/MP.SPEC/Components/ListPODL.razor.cs
@@ -112,15 +112,15 @@ namespace MP.SPEC.Components
{
currRecord = selRec;
currRecipePath = await MDService.MacchineRecipeConf(selRec.IdxMacchina);
- showRecipe = true;
+ showRecipeConf = true;
}
protected async Task doShowRecipeArch(PODLExpModel selRec)
{
currRecord = selRec;
currRecipeArchPath = await MDService.MacchineRecipeArchive(selRec.IdxMacchina);
- showRecipe = true;
+ showRecipeArch = true;
}
-
+
protected override async Task OnInitializedAsync()
{
@@ -158,7 +158,8 @@ namespace MP.SPEC.Components
{
currRecord = null;
currRecipePath = "";
- showRecipe = false;
+ showRecipeArch = false;
+ showRecipeConf = false;
await RecordSel.InvokeAsync(null);
}
@@ -257,7 +258,8 @@ namespace MP.SPEC.Components
private List? SearchRecords;
- private bool showRecipe = false;
+ private bool showRecipeConf = false;
+ private bool showRecipeArch = false;
#endregion Private Fields
@@ -289,7 +291,7 @@ namespace MP.SPEC.Components
private string mainCss
{
- get => showRecipe ? "col-6" : "col-12";
+ get => (showRecipeConf || showRecipeArch) ? "col-6" : "col-12";
}
private int numRecord
diff --git a/MP.SPEC/Components/RecipeMan.razor b/MP.SPEC/Components/RecipeArchMan.razor
similarity index 100%
rename from MP.SPEC/Components/RecipeMan.razor
rename to MP.SPEC/Components/RecipeArchMan.razor
diff --git a/MP.SPEC/Components/RecipeArchMan.razor.cs b/MP.SPEC/Components/RecipeArchMan.razor.cs
new file mode 100644
index 00000000..a090a1fc
--- /dev/null
+++ b/MP.SPEC/Components/RecipeArchMan.razor.cs
@@ -0,0 +1,268 @@
+using Microsoft.AspNetCore.Components;
+using MP.Data.MgModels;
+using MP.SPEC.Data;
+
+namespace MP.SPEC.Components
+{
+ public partial class RecipeArchMan
+ {
+ #region Public Properties
+
+ [Parameter]
+ public EventCallback CancelEvent { get; set; }
+
+ [Parameter]
+ public int IdxPODL { get; set; } = 0;
+
+ [Parameter]
+ public string RecipeArchPath { get; set; } = "";
+
+ #endregion Public Properties
+
+ #region Protected Fields
+
+ protected bool isLoading = false;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected RecipeModel? CurrRecipe { get; set; } = null;
+
+ [Inject]
+ protected MpDataService MDService { get; set; } = null!;
+
+ protected RecipeModel? OrigRecipe { get; set; } = null;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected async Task CancelHeadData()
+ {
+ await ReloadData();
+ }
+
+ protected Dictionary GetHeadListByType(string DictType)
+ {
+ Dictionary answ = new Dictionary();
+ // in primis il "selezionare"
+ answ.Add("", "--- Selezionare ---");
+ // cerco tipo in enums...
+ if (CurrRecipe != null && CurrRecipe.HeadConf.EnumVal.ContainsKey(DictType))
+ {
+ foreach (var item in CurrRecipe.HeadConf.EnumVal[DictType])
+ {
+ answ.Add(item.Key, item.Value);
+ }
+ }
+ return answ;
+ }
+
+ protected Dictionary GetRowListByType(string DictType)
+ {
+ Dictionary answ = new Dictionary();
+ // in primis il "selezionare"
+ answ.Add("", "--- Selezionare ---");
+ // cerco tipo in enums...
+ if (CurrRecipe != null && CurrRecipe.RowsConf.EnumVal.ContainsKey(DictType))
+ {
+ foreach (var item in CurrRecipe.RowsConf.EnumVal[DictType])
+ {
+ answ.Add(item.Key, item.Value);
+ }
+ }
+ return answ;
+ }
+
+ protected override async Task OnParametersSetAsync()
+ {
+ await ReloadData();
+ }
+
+ protected async Task SaveHeadData()
+ {
+ if (CurrRecipe != null)
+ {
+ await MDService.RecipeSetByPODL(CurrRecipe);
+ await ReloadData();
+ }
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private bool showAllRows = false;
+ private bool showHead = true;
+ private Dictionary showRows = new Dictionary();
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ private bool needSave
+ {
+ get
+ {
+ bool answ = false;
+ if (CurrRecipe != null && OrigRecipe != null)
+ {
+ answ = !(CurrRecipe.HeadVal.SequenceEqual(OrigRecipe.HeadVal));
+ if (!answ)
+ {
+ // verifico nu righe...
+ answ = (CurrRecipe.RowsVal.Count != OrigRecipe.RowsVal.Count);
+ if (!answ)
+ {
+ try
+ {
+ foreach (var item in CurrRecipe.RowsVal)
+ {
+ answ = !(item.Value.SequenceEqual(OrigRecipe.RowsVal[item.Key]));
+ if (answ)
+ {
+ break;
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ answ = true;
+ }
+ }
+ }
+ }
+ return answ;
+ }
+ }
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private async Task addRow()
+ {
+ isLoading = true;
+ if (CurrRecipe != null)
+ {
+ // preparo dizionario valori calcolati
+ Dictionary CalcArgs = await getCalcArgs();
+ int newNumRow = CurrRecipe.RowsVal.Count + 1;
+ CalcArgs.Add("RowNum", $"{newNumRow}");
+ CalcArgs.Add("RowTot", $"{newNumRow}");
+ // metodo x avere nuova
+ var rowElem = CurrRecipe.getNewRow(CalcArgs);
+ // effettuo aggiunta riga...
+ CurrRecipe.RowsVal.Add($"{newNumRow}", rowElem);
+ fixRowsShowStatus();
+ }
+ isLoading = false;
+ await Task.Delay(1);
+ }
+
+ ///
+ /// Elimino riga (ultima)...
+ ///
+ ///
+ ///
+ private async Task deleteRow(string rowNum)
+ {
+ isLoading = true;
+ if (CurrRecipe != null)
+ {
+ // verifico esista...
+ if (CurrRecipe.RowsVal.ContainsKey(rowNum))
+ {
+ CurrRecipe.RowsVal.Remove(rowNum);
+ fixRowsShowStatus();
+ }
+ }
+ isLoading = false;
+ await Task.Delay(1);
+ }
+
+ private void fixRowsShowStatus()
+ {
+ // sistemo lista bool x righe
+ showRows = new Dictionary();
+ if (CurrRecipe != null)
+ {
+ for (int i = 1; i <= CurrRecipe.RowsVal.Count; i++)
+ {
+ showRows.Add($"{i}", false);
+ }
+ }
+ }
+
+ ///
+ /// Prepara Dict args calcolati x creazione ricetta
+ ///
+ ///
+ private async Task> getCalcArgs()
+ {
+ // preparo dizionario valori calcolati
+ Dictionary CalcArgs = new Dictionary();
+ // aggiungo dati PODL
+ CalcArgs.Add("IdxPODL", $"{IdxPODL}");
+ CalcArgs.Add("CodePODL", $"PODL{IdxPODL:00000000}");
+ // recupero altri dati da PODL
+ var rowPodl = await MDService.PODL_getByKey(IdxPODL);
+ if (rowPodl != null)
+ {
+ CalcArgs.Add("CodArticolo", rowPodl.CodArticolo);
+ CalcArgs.Add("DescArticolo", rowPodl.ArticoloNav.DescArticolo);
+ }
+
+ return CalcArgs;
+ }
+
+ private async Task ReloadData()
+ {
+ await Task.Delay(1);
+ isLoading = true;
+ if (IdxPODL != 0 && !string.IsNullOrEmpty(RecipeArchPath))
+ {
+ CurrRecipe = new RecipeModel();
+ // effettua ricerca ricetta su MongoDb
+ CurrRecipe = await MDService.RecipeGetByPODL(IdxPODL);
+ // se non trova crea nuova...
+ if (CurrRecipe == null)
+ {
+ Dictionary CalcArgs = await getCalcArgs();
+ CurrRecipe = MDService.InitRecipe(RecipeArchPath, IdxPODL, CalcArgs);
+ // la salvo...
+ await MDService.RecipeSetByPODL(CurrRecipe);
+ }
+ // rileggo la default
+ OrigRecipe = await MDService.RecipeGetByPODL(IdxPODL);
+ fixRowsShowStatus();
+ }
+ await Task.Delay(1);
+ isLoading = false;
+ }
+
+ private void toggleHead()
+ {
+ showHead = !showHead;
+ }
+
+ private async Task toggleRow(string rowNum)
+ {
+ showRows[rowNum] = !showRows[rowNum];
+ await Task.Delay(1);
+ }
+
+ private async Task toggleRows()
+ {
+ showAllRows = !showAllRows;
+ foreach (var item in showRows)
+ {
+ showRows[item.Key] = showAllRows;
+ }
+ await Task.Delay(1);
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.SPEC/Components/RecipeConfMan.razor b/MP.SPEC/Components/RecipeConfMan.razor
new file mode 100644
index 00000000..60b1f72b
--- /dev/null
+++ b/MP.SPEC/Components/RecipeConfMan.razor
@@ -0,0 +1,152 @@
+@using MP.Data.MgModels;
+
+@if (isLoading)
+{
+
+}
+else
+{
+
+
+
+
+
+
Righe Ricetta
+
+
+ Add
+
+ @if (showAllRows)
+ {
+
+ }
+ else
+ {
+
+ }
+
+
+
+ @if (CurrRecipe?.RowsVal != null)
+ {
+ int rowTot = CurrRecipe.RowsVal.Count;
+ int rowNum = 0;
+ @foreach (var riga in CurrRecipe.RowsVal)
+ {
+ rowNum++;
+
+
+ # @riga.Key
+
+
+ @if (rowNum == rowTot)
+ {
+ deleteRow(riga.Key)" title="Rimuovi Ultima Riga">
+ }
+ toggleRow(riga.Key)">
+ @if (showRows[riga.Key])
+ {
+
+ }
+ else
+ {
+
+ }
+
+
+
+ @if (showRows[riga.Key])
+ {
+
+ @foreach (var item in riga.Value)
+ {
+
+ }
+
+ }
+ }
+ }
+
+
+}
diff --git a/MP.SPEC/Components/RecipeMan.razor.cs b/MP.SPEC/Components/RecipeConfMan.razor.cs
similarity index 99%
rename from MP.SPEC/Components/RecipeMan.razor.cs
rename to MP.SPEC/Components/RecipeConfMan.razor.cs
index 6fcb6e38..10d26502 100644
--- a/MP.SPEC/Components/RecipeMan.razor.cs
+++ b/MP.SPEC/Components/RecipeConfMan.razor.cs
@@ -7,7 +7,7 @@ using Newtonsoft.Json;
namespace MP.SPEC.Components
{
- public partial class RecipeMan
+ public partial class RecipeConfMan
{
#region Public Properties