/** * Вкладка «Сравнение» на /reports. */ (function (global) { const COPY = () => global.WespAnalyticsCopy || {}; function escapeHtml(value) { return String(value ?? "") .replace(/&/g, "&") .replace(//g, ">"); } function getDateParams() { const from = document.getElementById("date-from")?.value || ""; const to = document.getElementById("date-to")?.value || ""; return { date_from: from, date_to: to }; } function buildUrl() { const params = global.WespReportsFilters?.buildAnalyticsParams?.() || new URLSearchParams(getDateParams()); return `/api/analytics/plan-fact?${params.toString()}`; } function barWidth(value, max) { if (!max || max <= 0) return 0; return Math.min(100, (Number(value) / max) * 100); } function faultBadge(fault, executionLabel) { const c = COPY().comparison || {}; if (fault === "execution") { return `${escapeHtml( executionLabel || c.noteExecution || "" )}`; } if (fault === "excluded" || fault === "zootech_ok") { return `${escapeHtml(c.noteExcluded || "")}`; } if (fault === "adjusted" || fault === "zootech") { return `${escapeHtml(c.noteAdjusted || "")}`; } return ""; } function legendHtml() { const c = COPY().comparison || {}; return ( `
${escapeHtml( COPY().comparison?.mixerRemainderLabel || "Остаток в миксере" )}: ${sign}${kg.toFixed(1)} кг
` ); })() : ""; const when = item.startTime ? escapeHtml(item.startTime.slice(0, 16).replace("T", " ")) : ""; const unloadingSection = groups.length || mixer ? sectionHtml( COPY().comparison?.sectionUnloading || "Выгрузка", legendHtml() + unloadHtml + mixerHtml ) : ""; return ( `${escapeHtml(COPY().comparison?.empty || "")}
Загрузка сравнения…
${escapeHtml(err.message)}