`;
trips.forEach((trip) => {
const recipeId = escapeHtml(trip.recipeId);
const hasAdjustedNorm = (trip.ingredients || []).some((ing) => ing.adjustedToday);
const hasReplacedIngredient = (trip.ingredients || []).some((ing) => ing.replacedToday);
const adjustBadge = hasAdjustedNorm
? '
' +
' сегодня изменили норму '
: "";
const replaceBadge = hasReplacedIngredient
? '
' +
' заменён компонент '
: "";
const ings = (trip.ingredients || [])
.map((ing) => {
const ingId = escapeHtml(ing.id);
const name = escapeHtml(ing.name);
const skipped = Boolean(ing.skippedToday);
const replaced = Boolean(ing.replacedToday);
const adjusted = Boolean(ing.adjustedToday);
const rowClass = skipped
? "zt-k-hub-plan-row--skipped"
: replaced
? "zt-k-hub-plan-row--replaced"
: adjusted
? "zt-k-hub-plan-row--adjusted"
: "";
const replaceTitle = replacementRowTitle(ing);
const adjustTitle = adjustmentRowTitle(ing);
const skipHint = skipped ? skippedIngredientHint(ing) : "";
const nameCell = skipped
? `
${renderSkipDot()}${name} `
: replaced
? `
${renderReplaceDot(replaceTitle)}${name} `
: adjusted
? `
${renderAdjustDot(adjustTitle)}${name} `
: `
${name} `;
const weightCell = skipped
? renderSkippedValueCell(skipHint)
: `
${escapeHtml(formatKg(ing.weightPerHead))} `;
const totalCell = skipped
? renderSkippedValueCell(skipHint)
: `
${escapeHtml(formatKg(ing.totalKg))} `;
let actionCell = "";
if (ing.id) {
if (skipped) {
actionCell = renderRowActionBtn(
"daily-plan-unskip-ingredient",
`data-recipe-id="${recipeId}" data-ingredient-id="${ingId}"`,
"Вернуть в план",
"fa-undo"
);
} else {
if (replaced) {
actionCell += renderRowActionBtn(
"daily-plan-undo-replace-ingredient",
`data-recipe-id="${recipeId}" data-ingredient-id="${ingId}"`,
"Отменить замену",
"fa-undo"
);
} else if (adjusted && ing.componentId) {
actionCell += renderRowActionBtn(
"daily-plan-undo-adjust-norm",
`data-component-id="${escapeHtml(ing.componentId)}"`,
"Вернуть норму",
"fa-undo"
);
} else {
actionCell += renderReplaceBtn(recipeId, ing);
}
actionCell += renderSkipActionBtn(
"daily-plan-skip-ingredient",
`data-recipe-id="${recipeId}" data-ingredient-id="${ingId}" data-label="${escapeHtml(ing.originalName || ing.name)}"`,
"Убрать компонент из плана на этот день"
);
}
}
return (
`
` +
`${nameCell}${weightCell}${totalCell}` +
`${actionCell} `
);
})
.join("");
const groups = (trip.unloadingGroups || [])
.map((g) => {
const groupId = escapeHtml(g.id);
const name = escapeHtml(g.name);
const skipped = Boolean(g.skippedToday);
const nameCell = skipped
? `
${renderSkipDot()}${name} `
: `
${name} `;
const weightCell = skipped
? '
— '
: `
${escapeHtml(g.weightKg)} `;
const distCell = skipped
? '
— '
: `
${escapeHtml(formatDistribution(g))} `;
let actionCell = "";
if (g.id) {
if (skipped) {
actionCell = renderRowActionBtn(
"daily-plan-unskip-unloading-group",
`data-recipe-id="${recipeId}" data-group-id="${groupId}"`,
"Вернуть в план",
"fa-undo"
);
} else {
actionCell = renderSkipActionBtn(
"daily-plan-skip-unloading-group",
`data-recipe-id="${recipeId}" data-group-id="${groupId}" data-label="${name}"`,
"Убрать группу из плана на этот день"
);
}
}
return (
`
` +
`${nameCell}${weightCell}${distCell}` +
`${actionCell} `
);
})
.join("");
html +=
'
' +
'' +
`
${escapeHtml(trip.recipeName)}${replaceBadge}${adjustBadge}` +
` (${escapeHtml(trip.headsPerTrip)} гол., ${escapeHtml(trip.mixingTimeSec)} с) ` +
'' +
' ' +
'Компонент кг/гол Всего, кг ' +
`${ings || '— '} ` +
`Итого по рейсу ${escapeHtml(formatKg(trip.totalWeightKg))}
`;
if (groups) {
html +=
'Выгрузка
' +
'Группа кг Распределение ' +
`${groups}
`;
}
html += " ";
});
html += "