@@ -9,6 +9,10 @@ export function createRecipesOperationsController({
|
||||
showRecipeEdit,
|
||||
loadRecipes,
|
||||
loadPeriods,
|
||||
selectPeriod,
|
||||
persistRecipe,
|
||||
toggleUnloadingBlocks,
|
||||
resetDeletedEntities,
|
||||
ensureComponentsLoaded,
|
||||
setUnloadingLinkBroken,
|
||||
initializeUnloadingLinkButton,
|
||||
@@ -185,8 +189,15 @@ export function createRecipesOperationsController({
|
||||
}
|
||||
|
||||
try {
|
||||
setSelectedPeriod(periodId);
|
||||
if (typeof selectPeriod === "function") {
|
||||
await selectPeriod(periodId);
|
||||
} else {
|
||||
setSelectedPeriod(periodId);
|
||||
}
|
||||
setSelectedRecipe(null);
|
||||
if (typeof resetDeletedEntities === "function") {
|
||||
resetDeletedEntities();
|
||||
}
|
||||
|
||||
await ensureComponentsLoaded();
|
||||
|
||||
@@ -228,6 +239,9 @@ export function createRecipesOperationsController({
|
||||
}
|
||||
|
||||
setUnloadingLinkBroken(Boolean(copiedRecipeData.unloading_link_broken));
|
||||
if (typeof toggleUnloadingBlocks === "function") {
|
||||
toggleUnloadingBlocks();
|
||||
}
|
||||
initializeUnloadingLinkButton();
|
||||
updateTripPercentFieldState();
|
||||
|
||||
@@ -247,17 +261,19 @@ export function createRecipesOperationsController({
|
||||
|
||||
showRecipeEdit(true);
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.resolve(recalculateWeights()).catch((err) => console.error("Ошибка при расчете:", err));
|
||||
}, 100);
|
||||
setTimeout(() => {
|
||||
Promise.resolve(updateTotalValues()).catch((err) => console.error("Ошибка при расчете:", err));
|
||||
}, 100);
|
||||
await Promise.all([
|
||||
Promise.resolve(recalculateWeights()).catch((err) => console.error("Ошибка при расчете:", err)),
|
||||
Promise.resolve(updateTotalValues?.()).catch((err) => console.error("Ошибка при расчете:", err)),
|
||||
]);
|
||||
|
||||
if (typeof persistRecipe !== "function") {
|
||||
throw new Error("Сохранение рейса недоступно");
|
||||
}
|
||||
await persistRecipe(true);
|
||||
notyf.success("Рейс вставлен из буфера");
|
||||
} catch (error) {
|
||||
console.error("Ошибка при вставке рейса:", error);
|
||||
notyf.error("Ошибка при вставке рейса");
|
||||
notyf.error(error.message || "Ошибка при вставке рейса");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,9 +301,10 @@ export function createRecipesOperationsController({
|
||||
trip_percent: recipe.trip_percent ?? recipe.tripPercent ?? 100,
|
||||
ingredients: (recipe.ingredients || []).map((ing) => ({
|
||||
component_id: ing.component_id,
|
||||
weight_per_head: ing.weight_per_head,
|
||||
amount: ing.amount,
|
||||
dry_matter: ing.dry_matter,
|
||||
weight_per_head: ing.weight_per_head ?? ing.weightPerHead,
|
||||
amount: ing.amount ?? ing.tripWeight,
|
||||
dry_matter: ing.dry_matter ?? ing.dryMatter,
|
||||
dry_matter_per_head: ing.dry_matter_per_head ?? ing.dryMatterPerHead,
|
||||
order: ing.order,
|
||||
})),
|
||||
unloading_link_broken: Boolean(
|
||||
|
||||
Reference in New Issue
Block a user