@@ -4789,15 +4789,19 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Для кормоцеха: добавляем target_component_id
|
||||
// Для кормоцеха: добавляем target_component_id и привязку к кормоцеху
|
||||
if (currentDispenserType === 'mill') {
|
||||
const targetComponentSelect = document.getElementById('targetComponentSelect');
|
||||
if (targetComponentSelect) {
|
||||
recipeData.target_component_id = targetComponentSelect.value || null;
|
||||
}
|
||||
if (selectedDispenser) {
|
||||
recipeData.dispenser_id = selectedDispenser;
|
||||
}
|
||||
}
|
||||
|
||||
let url, method;
|
||||
const wasCreate = !selectedRecipe;
|
||||
if (selectedRecipe) {
|
||||
url = `/api/recipes/${selectedRecipe}`;
|
||||
method = 'PUT';
|
||||
@@ -4825,10 +4829,23 @@
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
throw new Error(errorData.message || 'Ошибка при сохранении рейса');
|
||||
const detail = errorData.message || errorData.detail;
|
||||
let message = 'Ошибка при сохранении рейса';
|
||||
if (typeof detail === 'string') {
|
||||
if (response.status === 401) {
|
||||
message = 'Сессия истекла. Войдите снова.';
|
||||
} else {
|
||||
message = detail;
|
||||
}
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
if (wasCreate && result && result.id) {
|
||||
selectedRecipe = result.id;
|
||||
pageState.set({ selectedRecipe });
|
||||
}
|
||||
const savedRecipeName = document.getElementById('recipeName')?.value?.trim();
|
||||
notyf.success('Сохранено', {
|
||||
record: savedRecipeName ? { recipeName: savedRecipeName } : undefined,
|
||||
@@ -5055,6 +5072,13 @@
|
||||
showRecipeEdit,
|
||||
loadRecipes,
|
||||
loadPeriods,
|
||||
selectPeriod,
|
||||
persistRecipe: (closeAfterSave) => doSaveRecipe(!!closeAfterSave),
|
||||
toggleUnloadingBlocks: () => recipesEditorController.toggleUnloadingBlocks(),
|
||||
resetDeletedEntities: () => {
|
||||
deletedIngredientIds = [];
|
||||
deletedGroupIds = [];
|
||||
},
|
||||
ensureComponentsLoaded: async () => {
|
||||
if (!componentsCache) {
|
||||
await loadComponents();
|
||||
|
||||
Reference in New Issue
Block a user