From: marina Date: Tue, 17 Jun 2025 06:08:52 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=9d30585761a4fcf63d34fb6f864d44e5cb63ffde;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index f8df9689..08b49083 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -373,4 +373,49 @@ function getMonthNumberByWeek(week, year) { return startMonth; } return startMonth; -} \ No newline at end of file +} + +document.addEventListener("DOMContentLoaded", async () => { + const week = '23'; + const month = 6; + const storeId = 6; + const year = new Date().getFullYear(); + + if (!week) return; + + try { + const response = await fetch(`/auto-plannogramma/weekly-bouquet-products-forecast?month=${month}&year=${year}&week=${week}&storeId=${storeId}`); + const json = await response.json(); + if (json.success && json.data) { + Object.assign(forecastCache, json.data); + } + console.log(json); + console.log(forecastCache); + } catch (e) { + console.error("Ошибка загрузки прогнозов:", e); + } +}); + +function buildForecastTooltip(week, storeId, guid) { + console.log(week, storeId, guid); + const weekData = forecastCache[week]; + if (!weekData) return null; + + const storeData = weekData[storeId]; + if (!storeData) return null; + + const productData = storeData[guid]; + if (!productData) return null; + + let tooltip = `
Прогноз:
`; + for (const [type, groups] of Object.entries(productData)) { + tooltip += `
${type}
    `; + for (const [group, value] of Object.entries(groups)) { + tooltip += `
  • ${group}: ${value}
  • `; + } + tooltip += `
`; + } + tooltip += `
`; + + return tooltip; +}