]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 08:05:10 +0000 (11:05 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 08:05:10 +0000 (11:05 +0300)
erp24/web/js/autoplannogramma/autoplannogramma.js

index 25a22b288fd7814fb960a4d32759fb878ee1d8dd..ee2c80fa0cb900acfa767e95cedf529bc2925c6e 100644 (file)
@@ -118,8 +118,8 @@ $('.subcategory .list-group-item').on('click', function (e) {
                 const isVisible = $(`table tbody tr:first td:eq(${index})`).is(':visible');
                 if (!isVisible) return;
 
-                const val = valuesMap[storeId] || {quantity: '', id: '', title: {}};
-                const tooltipTitle = $('<div>').text(generateTitleString(val.title)).html(); // экранирование
+                const tooltipTitle = generateTitleString(val.title);
+                const encodedTooltip = $('<div>').text(tooltipTitle).html(); // безопасно экранируем
 
                 const td = $(`
                     <td data-store-id="${storeId}">
@@ -129,8 +129,9 @@ $('.subcategory .list-group-item').on('click', function (e) {
                                    data-id="${val.id}"
                                    data-guid="${item.product_id}"
                                    data-store_id="${storeId}"
-                                   title="${tooltipTitle}"
-                                   data-bs-toggle="tooltip" data-bs-placement="top"
+                                   title="${encodedTooltip}"
+                                   data-bs-toggle="tooltip"
+                                   data-bs-placement="top"
                                    data-original-value="${val.quantity}">
                             <button class="reject-btn border-0 bg-transparent cursor-pointer">
                                 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
@@ -371,26 +372,26 @@ function getMonthNumberByWeek(week, year) {
     return startMonth;
 }
 
-function buildForecastTooltip(week, storeId, guid) {
-    console.log(week, storeId, guid);
-    const weekData = forecastCache[week];
-    if (!weekData) return null;
+function generateTitleString(titleObj) {
+    if (!titleObj || typeof titleObj !== 'object') return '';
 
-    const storeData = weekData[storeId];
-    if (!storeData) return null;
+    const typeTitles = {
+        offline: '📦 Оффлайн',
+        online: '🌐 Онлайн',
+        marketplace: '🛒 Маркетплейс'
+    };
 
-    const productData = storeData[guid];
-    if (!productData) return null;
+    let parts = [];
 
-    let tooltip = `<div><strong>Прогноз:</strong><br>`;
-    for (const [type, groups] of Object.entries(productData)) {
-        tooltip += `<div><em>${type}</em><ul>`;
-        for (const [group, value] of Object.entries(groups)) {
-            tooltip += `<li>${group}: ${value}</li>`;
-        }
-        tooltip += `</ul></div>`;
+    for (const [typeKey, typeValue] of Object.entries(titleObj)) {
+        if (!typeValue || typeof typeValue !== 'object') continue;
+
+        let lines = Object.entries(typeValue)
+            .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`);
+
+        parts.push(`${typeTitles[typeKey] || typeKey}:\n${lines.join('\n')}`);
     }
-    tooltip += `</div>`;
 
-    return tooltip;
+    return parts.join('\n\n');
 }
+