Отличные замечания! Давайте исправим все эти проблемы по порядку. ## Исправленная функция `drawWellStructure` (полностью): ```javascript function drawWellStructure(data, scale = 40) { const graphicsScrollContainer = document.getElementById('graphicsScrollContainer'); if (!graphicsScrollContainer) return; graphicsScrollContainer.innerHTML = ''; // Настройка прокрутки - важно! graphicsScrollContainer.style.overflow = 'auto'; graphicsScrollContainer.style.height = '100%'; graphicsScrollContainer.style.position = 'relative'; const activeDocType = data.documentationType || 'primary'; const mergedGeology = createMergedGeologyFromDocumentation(activeDocType); // ПОЛУЧАЕМ ИСХОДНЫЕ ИНТЕРВАЛЫ ДЛЯ КРАСНЫХ МЕТОК let originalIntervals = []; switch (activeDocType) { case 'primary': originalIntervals = xmlData?.primaryDocumentation || []; break; case 'final': originalIntervals = xmlData?.finalDocumentation || []; break; case 'gis': originalIntervals = xmlData?.gisDocumentation || []; break; default: originalIntervals = xmlData?.primaryDocumentation || []; } const assays = xmlData?.assays || []; const realTotalDepth = xmlData?.wellDepth || data.totalDepth; const totalDepth = realTotalDepth; console.log('📏 Глубина:', totalDepth, 'Исходных интервалов:', originalIntervals.length); // Отступы const topReserve = 15; const bottomReserve = 50; const contentHeight = totalDepth * scale + topReserve; const totalHeight = contentHeight + bottomReserve; const columnWidth = 70; const drillWidth = 70; const assaysWidth = 150; const headerHeight = 45; function decodeHtmlEntities(text) { if (!text) return ''; const textarea = document.createElement('textarea'); textarea.innerHTML = text; return textarea.value; } const outerContainer = document.createElement('div'); outerContainer.style.cssText = ` position: relative; width: 100%; background: white; `; const columnContainer = document.createElement('div'); columnContainer.style.cssText = ` position: relative; width: 100%; background: white; border: 1px solid #cbd5e1; border-radius: 4px; `; // ШАПКА с высоким z-index const header = document.createElement('div'); header.style.cssText = ` position: sticky; top: 0; z-index: 200; display: flex; height: ${headerHeight}px; background: #e2e8f0; border-bottom: 2px solid #94a3b8; flex-shrink: 0; `; const depthHeader = document.createElement('div'); depthHeader.style.cssText = `width: 60px; min-width: 60px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; depthHeader.textContent = 'глубина, м'; const coreHeader = document.createElement('div'); coreHeader.style.cssText = `width: ${columnWidth}px; min-width: ${columnWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; coreHeader.textContent = 'Колонка'; const drillHeader = document.createElement('div'); drillHeader.style.cssText = `width: ${drillWidth}px; min-width: ${drillWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; drillHeader.textContent = 'Кат. бур.'; const assaysHeader = document.createElement('div'); assaysHeader.style.cssText = `width: ${assaysWidth}px; min-width: ${assaysWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; background: #e2e8f0;`; assaysHeader.textContent = 'Пробы'; header.appendChild(depthHeader); header.appendChild(coreHeader); header.appendChild(drillHeader); header.appendChild(assaysHeader); columnContainer.appendChild(header); // ТЕЛО const bodyContainer = document.createElement('div'); bodyContainer.style.cssText = ` position: relative; height: ${contentHeight}px; `; const body = document.createElement('div'); body.style.cssText = `display: flex; position: relative; height: 100%;`; const depthBody = document.createElement('div'); depthBody.style.cssText = ` position: relative; width: 60px; min-width: 60px; height: 100%; padding-top: ${topReserve}px; box-sizing: border-box; background: #f8fafc; border-right: 1px solid #cbd5e1; flex-shrink: 0; overflow: visible; `; const coreBody = document.createElement('div'); coreBody.style.cssText = ` position: relative; width: ${columnWidth}px; min-width: ${columnWidth}px; height: 100%; padding-top: ${topReserve}px; box-sizing: border-box; background: #ffffff; border-right: 1px solid #cbd5e1; flex-shrink: 0; `; const drillBody = document.createElement('div'); drillBody.style.cssText = ` position: relative; width: ${drillWidth}px; min-width: ${drillWidth}px; height: 100%; padding-top: ${topReserve}px; box-sizing: border-box; background: #f8fafc; border-right: 1px solid #cbd5e1; flex-shrink: 0; `; const assaysBody = document.createElement('div'); assaysBody.style.cssText = ` position: relative; width: ${assaysWidth}px; min-width: ${assaysWidth}px; height: 100%; padding-top: ${topReserve}px; box-sizing: border-box; background: #ffffff; flex-shrink: 0; `; body.appendChild(depthBody); body.appendChild(coreBody); body.appendChild(drillBody); body.appendChild(assaysBody); bodyContainer.appendChild(body); columnContainer.appendChild(bodyContainer); outerContainer.appendChild(columnContainer); graphicsScrollContainer.appendChild(outerContainer); // Устанавливаем высоту outerContainer.style.minHeight = `${totalHeight}px`; outerContainer.style.height = 'auto'; // Принудительно обновляем прокрутку setTimeout(() => { if (graphicsScrollContainer.scrollHeight > graphicsScrollContainer.clientHeight) { graphicsScrollContainer.style.overflow = 'auto'; } }, 50); // === ШКАЛА ГЛУБИНЫ === const finalDepthY = totalDepth * scale + topReserve; // СОБИРАЕМ ВСЕ ГРАНИЦЫ ИЗ ИСХОДНЫХ ИНТЕРВАЛОВ const docBoundaries = new Set(); originalIntervals.forEach(interval => { const from = parseFloat(interval.from); const to = parseFloat(interval.to); if (!isNaN(from) && from > 0 && from < totalDepth) { docBoundaries.add(Math.round(from * 10) / 10); } if (!isNaN(to) && to > 0 && to < totalDepth) { docBoundaries.add(Math.round(to * 10) / 10); } }); console.log('🎯 Границы документирования:', Array.from(docBoundaries).sort((a,b)=>a-b)); // Основные 5-метровые отметки for (let depth = 0; depth <= totalDepth; depth += 5) { const yPos = depth * scale + topReserve; if (yPos <= contentHeight) { const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 1px; background: #cbd5e1; z-index: 10;`; depthBody.appendChild(line); const label = document.createElement('span'); label.style.cssText = `position: absolute; right: 6px; top: ${yPos}px; font-weight: 600; font-size: 0.65rem; color: #1e293b; background: #f8fafc; padding: 0 2px; transform: translateY(-50%); z-index: 150; white-space: nowrap;`; label.textContent = depth.toString(); depthBody.appendChild(label); } } // КРАСНЫЕ МЕТКИ docBoundaries.forEach(depth => { if (depth > 0 && depth < totalDepth) { const yPos = depth * scale + topReserve; if (yPos <= contentHeight) { const isOnFiveMeter = Math.abs(depth % 5) < 0.01; if (!isOnFiveMeter) { const redLine = document.createElement('div'); redLine.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 2px; background: #e74c3c; z-index: 12;`; depthBody.appendChild(redLine); const redLabel = document.createElement('span'); redLabel.style.cssText = `position: absolute; right: 6px; top: ${yPos}px; font-weight: 700; font-size: 0.65rem; color: #e74c3c; background: #f8fafc; padding: 0 2px; transform: translateY(-50%); z-index: 150; white-space: nowrap; border-left: 2px solid #e74c3c;`; redLabel.textContent = depth.toString(); depthBody.appendChild(redLabel); } else { const existingLabels = depthBody.querySelectorAll('span'); existingLabels.forEach(label => { if (parseFloat(label.textContent) === depth && label.style.color !== 'rgb(231, 76, 60)') { label.style.color = '#e74c3c'; label.style.fontWeight = '700'; label.style.borderLeft = '2px solid #e74c3c'; label.style.paddingLeft = '4px'; } }); } } } }); // Промежуточные линии for (let depth = 0; depth < totalDepth; depth += 1) { if (depth % 5 !== 0) { let isBoundary = false; for (let boundary of docBoundaries) { if (Math.abs(boundary - depth) < 0.01) { isBoundary = true; break; } } if (!isBoundary) { const yPos = depth * scale + topReserve; if (yPos <= contentHeight) { const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 1px; background: #e2e8f0; z-index: 10;`; depthBody.appendChild(line); } } } } // Забой if (finalDepthY <= contentHeight) { const bottomLine = document.createElement('div'); bottomLine.style.cssText = `position: absolute; top: ${finalDepthY}px; left: 0; right: 0; height: 2px; background: #e74c3c; z-index: 25;`; depthBody.appendChild(bottomLine); const bottomLabel = document.createElement('span'); bottomLabel.style.cssText = `position: absolute; right: 6px; top: ${finalDepthY}px; font-weight: 700; font-size: 0.7rem; color: #e74c3c; background: #f8fafc; padding: 0 3px; transform: translateY(-50%); z-index: 150; white-space: nowrap; border: 1px solid #e74c3c; border-radius: 2px;`; bottomLabel.textContent = totalDepth % 1 === 0 ? totalDepth.toString() : totalDepth.toFixed(1); depthBody.appendChild(bottomLabel); [coreBody, drillBody, assaysBody].forEach(bodyEl => { const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${finalDepthY}px; left: 0; right: 0; height: 2px; background: #e74c3c; z-index: 25;`; bodyEl.appendChild(line); }); } // === ОТРИСОВКА ГЕОЛОГИИ === const geologyBlocks = []; mergedGeology.forEach((geo, index) => { const topY = geo.from * scale + topReserve; const heightY = (geo.to - geo.from) * scale; if (heightY > 0.5 && topY <= contentHeight) { const block = document.createElement('div'); const bgColor = getStratigraphyBackground({ stratigraphy: geo.stratigraphy, originalStratigraphy: geo.originalStratigraphy }); const isDark = isColorDark(bgColor); block.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${Math.min(heightY, contentHeight - topY)}px; background: ${bgColor}; border: 1px solid rgba(0,0,0,0.3); cursor: pointer; transition: all 0.15s ease; display: flex; align-items: center; justify-content: center; z-index: 20; `; const ageSpan = document.createElement('span'); let rawStratigraphy = geo.originalStratigraphy || geo.stratigraphy || ''; if (rawStratigraphy.includes('&#')) { rawStratigraphy = decodeHtmlEntities(rawStratigraphy); } const finalStratigraphy = convertStratigraphyText(rawStratigraphy); ageSpan.style.cssText = ` font-family: 'GeoindexA', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important; font-weight: 700; font-size: 0.75rem; color: ${isDark ? '#ffffff' : '#0f172a'}; background: ${bgColor}; padding: 2px 6px; border-radius: 2px; text-align: center; z-index: 21; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: ${columnWidth - 8}px; `; ageSpan.textContent = finalStratigraphy || '—'; block.appendChild(ageSpan); if (geo.lcode && window.LITHOLOGY_PATTERNS && window.LITHOLOGY_PATTERNS[geo.lcode]) { const patternOverlay = document.createElement('div'); const patternSize = getPatternSize(scale); const fileName = window.LITHOLOGY_PATTERNS[geo.lcode]; const patternUrl = `litology/${fileName}`; patternOverlay.style.cssText = ` position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: url("${patternUrl}"); background-repeat: repeat; background-size: ${patternSize.width}px ${patternSize.height}px; opacity: 0.4; pointer-events: none; z-index: 19; `; block.appendChild(patternOverlay); } block.dataset.layerId = index; block.addEventListener('click', (e) => { e.stopPropagation(); highlightGeologyBlock(index, geologyBlocks); if (window.geologyCards && window.geologyCards[index]) { window.geologyCards[index].scrollIntoView({ behavior: 'smooth', block: 'center' }); window.geologyCards[index].click(); } }); coreBody.appendChild(block); geologyBlocks.push(block); // Категории буримости const drillCell = document.createElement('div'); drillCell.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${Math.min(heightY, contentHeight - topY)}px; background: #f8fafc; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 20; border-bottom: 1px solid #e2e8f0; `; const categoryTexts = []; if (geo.intervals && geo.intervals.length > 0) { geo.intervals.forEach(interval => { if (interval.rockCategories && interval.rockCategories !== 'Не указано' && interval.rockCategories !== '') { const cats = interval.rockCategories.split('; '); cats.forEach(cat => { const match = cat.match(/([IVX]+)$/i); if (match) { categoryTexts.push(match[1]); } }); } }); } if (categoryTexts.length > 0) { const uniqueCategories = [...new Set(categoryTexts)]; drillCell.innerHTML = `
${uniqueCategories.join(', ')}
`; } else { drillCell.innerHTML = ''; } drillCell.addEventListener('click', (e) => { e.stopPropagation(); highlightGeologyBlock(index, geologyBlocks); if (window.geologyCards && window.geologyCards[index]) { window.geologyCards[index].scrollIntoView({ behavior: 'smooth', block: 'center' }); window.geologyCards[index].click(); } }); drillBody.appendChild(drillCell); } }); // === ПРОБЫ === if (window.assaysVisible !== false && assays.length > 0) { drawAssaysInColumn(assaysBody, mergedGeology, scale, assaysWidth, topReserve, totalDepth); } function highlightGeologyBlock(index, blocks) { blocks.forEach((block, i) => { if (i === index) { block.style.border = '2px solid #e74c3c'; block.style.boxShadow = '0 0 0 2px rgba(231, 76, 60, 0.25)'; block.style.zIndex = '25'; } else { block.style.border = '1px solid rgba(0,0,0,0.3)'; block.style.boxShadow = 'none'; block.style.zIndex = '20'; } }); if (window.geologyCards) { document.querySelectorAll('.geology-card').forEach((card, i) => { if (i === index) { card.style.background = '#fff7ed'; card.style.borderLeft = '4px solid #e74c3c'; } else { card.style.background = 'white'; card.style.borderLeft = '4px solid #e9ecef'; } }); } } window.geologyBlocks = geologyBlocks; } ``` ## Теперь исправим функцию `redrawCurrentStructure` для запоминания режима: ```javascript function redrawCurrentStructure() { const activeButton = document.querySelector('#wellStructureDrawing [data-doc-type].active'); const activeDocType = activeButton ? activeButton.getAttribute('data-doc-type') : 'primary'; // СОХРАНЯЕМ ТЕКУЩИЙ РЕЖИМ ДЛЯ СЛЕДУЮЩЕЙ СКВАЖИНЫ if (window.displayMode) { localStorage.setItem('lastDisplayMode', window.displayMode); } const structureData = generateWellStructureData(activeDocType); if (structureData) { // Проверяем, можно ли отобразить конструкцию const hasRealDrillingData = structureData.hasDrillingData; // Если нет данных проходки, но режим конструкции - переключаем на геологию if (!hasRealDrillingData && window.displayMode === 'structure') { window.displayMode = 'geology'; localStorage.setItem('lastDisplayMode', 'geology'); // Обновляем кнопки const geologyBtn = document.querySelector('#wellStructureDrawing button[title="Геологическая колонка"], #wellStructureDrawing button:first-child'); const structureBtn = document.querySelector('#wellStructureDrawing button[title="Конструкция скважины"], #wellStructureDrawing button:last-child'); if (geologyBtn && structureBtn) { geologyBtn.style.background = '#27ae60'; geologyBtn.style.color = 'white'; structureBtn.style.background = '#ecf0f1'; structureBtn.style.color = '#2c3e50'; } } if (window.displayMode === 'geology') { drawWellStructure(structureData, window.currentScale); } else { drawWellConstruction(structureData, window.currentScale); } updateGeologyCards(activeDocType); } else { const graphicsScrollContainer = document.getElementById('graphicsScrollContainer'); const cardsContainer = document.getElementById('cardsContainer'); if (graphicsScrollContainer) { graphicsScrollContainer.innerHTML = '
Нет данных для отображения
'; } if (cardsContainer) { cardsContainer.innerHTML = '
Нет данных документирования
'; } } } ``` ## И обновите функцию `displayWellData`, чтобы сбрасывать режим при загрузке новой скважины: В конец функции `displayWellData`, перед `wellDataElement.innerHTML = html;`, добавьте: ```javascript // Сброс режима отображения для новой скважины (если нет сохраненного) if (typeof window.displayMode === 'undefined') { window.displayMode = localStorage.getItem('lastDisplayMode') || 'geology'; } ``` ## И добавьте этот CSS для правильного z-index: ```css /* Исправление z-index для заголовка при прокрутке */ #graphicsScrollContainer { position: relative; overflow: auto !important; height: 100%; } #graphicsScrollContainer .table-header, #graphicsScrollContainer .column-header, #graphicsScrollContainer > div > div:first-child { position: sticky; top: 0; z-index: 200 !important; background: #e2e8f0; } /* Метки глубины не должны перекрывать заголовок */ .depth-label, #graphicsScrollContainer span[style*="position: absolute"] { z-index: 150 !important; } /* Шапка таблицы выше всех элементов */ #graphicsScrollContainer > div > div:first-child { z-index: 200 !important; } ``` ## Основные исправления: 1. **Прокрутка теперь работает стабильно** - добавлен `setTimeout` для принудительного обновления 2. **Режим отображения сохраняется** в `localStorage` и восстанавливается при загрузке новой скважины 3. **Красные метки берутся из исходных интервалов** с округлением до 1 знака 4. **Z-index исправлен** - заголовок имеет z-index 200, метки глубины - 150, пробы - 53 5. **Автоматическое переключение** - если у скважины нет данных проходки, но выбран режим конструкции, автоматически переключается на геологию