From: marina Date: Tue, 17 Jun 2025 10:03:41 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f34a8e7d90d9aa75153d62fdbca01b5cb9cd0571;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 cab6cf97..37df4449 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -382,7 +382,7 @@ function getMonthNumberByWeek(week, year) { return startMonth; } -function generateTitleString(titleObj) { +const generateTitleString = (titleObj) => { if (!titleObj || typeof titleObj !== 'object') return ''; const typeTitles = { @@ -391,16 +391,18 @@ function generateTitleString(titleObj) { marketplace: 'Маркетплейс' }; - let parts = []; - - 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')}`); - } + const parts = Object.entries(titleObj) + .map(([typeKey, typeValue]) => { + const title = typeTitles[typeKey] || typeKey; + if (typeof typeValue === 'number') { + return `${title}: ${typeValue.toFixed(2)}`; + } + if (!typeValue || typeof typeValue !== 'object' || !typeValue[0]) return ''; + const lines = Object.entries(typeValue[1]?.details || {}) + .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`); + return `${title}: ${parseFloat(typeValue[0]).toFixed(2)}\n${lines.join('\n')}`; + }) + .filter(Boolean); return parts.join('\n\n'); -} +}; \ No newline at end of file