feat: TBM 모바일 시스템 + 작업 분할/이동 + 권한 통합
TBM 시스템: - 4단계 워크플로우 (draft→세부편집→완료→작업보고) - 모바일 전용 TBM 페이지 (tbm-mobile.html) + 3단계 생성 위자드 - 작업자 작업 분할 (work_hours + split_seq) - 작업자 이동 보내기/빼오기 (tbm_transfers 테이블) - 생성 시 중복 배정 방지 (당일 배정 현황 조회) - 데스크탑 TBM 페이지 세부편집 기능 추가 작업보고서: - 모바일 전용 작업보고서 페이지 (report-create-mobile.html) - TBM에서 사전 등록된 work_hours 자동 반영 권한 시스템: - tkuser user_page_permissions 테이블과 system1 페이지 접근 연동 - pageAccessRoutes를 userRoutes보다 먼저 등록 (라우트 우선순위 수정) - TKUSER_DEFAULT_ACCESS 폴백 추가 (개인→부서→기본값 3단계) - 권한 캐시키 갱신 (userPageAccess_v2) 기타: - app-init.js 캐시 버스팅 (v=5) - iOS Safari touch-action: manipulation 적용 - KST 타임존 날짜 버그 수정 (toISOString UTC 이슈) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -333,6 +333,12 @@ function renderMap() {
|
||||
const visitorCount = visitors.reduce((sum, v) => sum + (v.visitor_count || 0), 0);
|
||||
drawWorkplaceRegion(region, workerCount, visitorCount);
|
||||
});
|
||||
|
||||
// 모바일일 때 전체화면 지도 버튼 표시
|
||||
const triggerBtn = document.getElementById('landscapeTriggerBtn');
|
||||
if (triggerBtn && window.innerWidth <= 768 && canvasImage && canvasImage.complete && mapRegions.length > 0) {
|
||||
triggerBtn.style.display = 'inline-flex';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,6 +459,213 @@ function selectWorkplace(region) {
|
||||
updateStepStatus();
|
||||
}
|
||||
|
||||
// ==================== 가로모드 전체화면 지도 ====================
|
||||
|
||||
function openLandscapeMap() {
|
||||
if (!canvasImage || !canvasImage.complete || mapRegions.length === 0) return;
|
||||
|
||||
const overlay = document.getElementById('landscapeOverlay');
|
||||
const inner = document.getElementById('landscapeInner');
|
||||
const lCanvas = document.getElementById('landscapeCanvas');
|
||||
if (!overlay || !lCanvas) return;
|
||||
|
||||
overlay.style.display = 'flex';
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
// 물리적 가로모드 여부
|
||||
const isPhysicalLandscape = window.innerWidth > window.innerHeight;
|
||||
inner.className = 'landscape-inner ' + (isPhysicalLandscape ? 'no-rotate' : 'rotated');
|
||||
|
||||
// 가용 영역
|
||||
const headerH = 52;
|
||||
const pad = 16;
|
||||
let availW, availH;
|
||||
if (isPhysicalLandscape) {
|
||||
availW = window.innerWidth - pad * 2;
|
||||
availH = window.innerHeight - headerH - pad * 2;
|
||||
} else {
|
||||
availW = window.innerHeight - pad * 2;
|
||||
availH = window.innerWidth - headerH - pad * 2;
|
||||
}
|
||||
|
||||
// 이미지 비율 유지
|
||||
const imgRatio = canvasImage.naturalWidth / canvasImage.naturalHeight;
|
||||
let cw, ch;
|
||||
if (availW / availH > imgRatio) {
|
||||
ch = availH;
|
||||
cw = ch * imgRatio;
|
||||
} else {
|
||||
cw = availW;
|
||||
ch = cw / imgRatio;
|
||||
}
|
||||
lCanvas.width = Math.round(cw);
|
||||
lCanvas.height = Math.round(ch);
|
||||
|
||||
drawLandscapeMap();
|
||||
|
||||
lCanvas.ontouchstart = handleLandscapeTouchStart;
|
||||
lCanvas.onclick = handleLandscapeClick;
|
||||
}
|
||||
|
||||
function drawLandscapeMap() {
|
||||
const lCanvas = document.getElementById('landscapeCanvas');
|
||||
if (!lCanvas || !canvasImage) return;
|
||||
const lCtx = lCanvas.getContext('2d');
|
||||
|
||||
lCtx.drawImage(canvasImage, 0, 0, lCanvas.width, lCanvas.height);
|
||||
|
||||
mapRegions.forEach(region => {
|
||||
const workers = todayWorkers.filter(w => w.workplace_id === region.workplace_id);
|
||||
const visitors = todayVisitors.filter(v => v.workplace_id === region.workplace_id);
|
||||
const workerCount = workers.reduce((sum, w) => sum + (w.member_count || 0), 0);
|
||||
const visitorCount = visitors.reduce((sum, v) => sum + (v.visitor_count || 0), 0);
|
||||
|
||||
const x1 = (region.x_start / 100) * lCanvas.width;
|
||||
const y1 = (region.y_start / 100) * lCanvas.height;
|
||||
const x2 = (region.x_end / 100) * lCanvas.width;
|
||||
const y2 = (region.y_end / 100) * lCanvas.height;
|
||||
const w = x2 - x1;
|
||||
const h = y2 - y1;
|
||||
const isSelected = region.workplace_id === selectedWorkplaceId;
|
||||
|
||||
let fillColor, strokeColor, textColor;
|
||||
if (isSelected) {
|
||||
fillColor = 'rgba(34, 197, 94, 0.5)';
|
||||
strokeColor = 'rgb(22, 163, 74)';
|
||||
textColor = '#15803d';
|
||||
} else if (workerCount > 0 && visitorCount > 0) {
|
||||
fillColor = 'rgba(34, 197, 94, 0.4)';
|
||||
strokeColor = 'rgb(22, 163, 74)';
|
||||
textColor = '#166534';
|
||||
} else if (workerCount > 0) {
|
||||
fillColor = 'rgba(59, 130, 246, 0.4)';
|
||||
strokeColor = 'rgb(37, 99, 235)';
|
||||
textColor = '#1e40af';
|
||||
} else if (visitorCount > 0) {
|
||||
fillColor = 'rgba(168, 85, 247, 0.4)';
|
||||
strokeColor = 'rgb(147, 51, 234)';
|
||||
textColor = '#7c3aed';
|
||||
} else {
|
||||
fillColor = 'rgba(107, 114, 128, 0.35)';
|
||||
strokeColor = 'rgb(75, 85, 99)';
|
||||
textColor = '#374151';
|
||||
}
|
||||
|
||||
lCtx.fillStyle = fillColor;
|
||||
lCtx.strokeStyle = strokeColor;
|
||||
lCtx.lineWidth = isSelected ? 4 : 2.5;
|
||||
lCtx.beginPath();
|
||||
lCtx.rect(x1, y1, w, h);
|
||||
lCtx.fill();
|
||||
lCtx.stroke();
|
||||
|
||||
const centerX = x1 + w / 2;
|
||||
const centerY = y1 + h / 2;
|
||||
|
||||
lCtx.font = 'bold 13px sans-serif';
|
||||
const textMetrics = lCtx.measureText(region.workplace_name);
|
||||
const textWidth = textMetrics.width + 12;
|
||||
const textHeight = 20;
|
||||
|
||||
lCtx.fillStyle = 'rgba(255, 255, 255, 0.9)';
|
||||
drawRoundRect(lCtx, centerX - textWidth / 2, centerY - textHeight / 2, textWidth, textHeight, 4);
|
||||
lCtx.fill();
|
||||
|
||||
lCtx.fillStyle = textColor;
|
||||
lCtx.textAlign = 'center';
|
||||
lCtx.textBaseline = 'middle';
|
||||
lCtx.fillText(region.workplace_name, centerX, centerY);
|
||||
|
||||
const total = workerCount + visitorCount;
|
||||
if (total > 0) {
|
||||
lCtx.font = 'bold 12px sans-serif';
|
||||
const countText = `${total}명`;
|
||||
const countMetrics = lCtx.measureText(countText);
|
||||
const countWidth = countMetrics.width + 10;
|
||||
const countHeight = 18;
|
||||
lCtx.fillStyle = strokeColor;
|
||||
drawRoundRect(lCtx, centerX - countWidth / 2, centerY + 12, countWidth, countHeight, 4);
|
||||
lCtx.fill();
|
||||
lCtx.fillStyle = '#ffffff';
|
||||
lCtx.fillText(countText, centerX, centerY + 21);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getLandscapeCoords(clientX, clientY) {
|
||||
const lCanvas = document.getElementById('landscapeCanvas');
|
||||
if (!lCanvas) return null;
|
||||
const rect = lCanvas.getBoundingClientRect();
|
||||
const inner = document.getElementById('landscapeInner');
|
||||
const isRotated = inner.classList.contains('rotated');
|
||||
|
||||
if (!isRotated) {
|
||||
const scaleX = lCanvas.width / rect.width;
|
||||
const scaleY = lCanvas.height / rect.height;
|
||||
return {
|
||||
x: (clientX - rect.left) * scaleX,
|
||||
y: (clientY - rect.top) * scaleY
|
||||
};
|
||||
}
|
||||
|
||||
const centerX = rect.left + rect.width / 2;
|
||||
const centerY = rect.top + rect.height / 2;
|
||||
const dx = clientX - centerX;
|
||||
const dy = clientY - centerY;
|
||||
const inverseDx = dy;
|
||||
const inverseDy = -dx;
|
||||
|
||||
const unrotatedW = rect.height;
|
||||
const unrotatedH = rect.width;
|
||||
|
||||
const canvasX = (inverseDx + unrotatedW / 2) / unrotatedW * lCanvas.width;
|
||||
const canvasY = (inverseDy + unrotatedH / 2) / unrotatedH * lCanvas.height;
|
||||
|
||||
return { x: canvasX, y: canvasY };
|
||||
}
|
||||
|
||||
function handleLandscapeTouchStart(e) {
|
||||
e.preventDefault();
|
||||
const touch = e.touches[0];
|
||||
const coords = getLandscapeCoords(touch.clientX, touch.clientY);
|
||||
if (coords) doLandscapeHitTest(coords.x, coords.y);
|
||||
}
|
||||
|
||||
function handleLandscapeClick(e) {
|
||||
const coords = getLandscapeCoords(e.clientX, e.clientY);
|
||||
if (coords) doLandscapeHitTest(coords.x, coords.y);
|
||||
}
|
||||
|
||||
function doLandscapeHitTest(cx, cy) {
|
||||
const lCanvas = document.getElementById('landscapeCanvas');
|
||||
if (!lCanvas) return;
|
||||
|
||||
for (const region of mapRegions) {
|
||||
const x1 = (region.x_start / 100) * lCanvas.width;
|
||||
const y1 = (region.y_start / 100) * lCanvas.height;
|
||||
const x2 = (region.x_end / 100) * lCanvas.width;
|
||||
const y2 = (region.y_end / 100) * lCanvas.height;
|
||||
|
||||
if (cx >= x1 && cx <= x2 && cy >= y1 && cy <= y2) {
|
||||
selectWorkplace(region);
|
||||
drawLandscapeMap();
|
||||
setTimeout(() => closeLandscapeMap(), 300);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function closeLandscapeMap() {
|
||||
const overlay = document.getElementById('landscapeOverlay');
|
||||
if (overlay) overlay.style.display = 'none';
|
||||
const lCanvas = document.getElementById('landscapeCanvas');
|
||||
if (lCanvas) {
|
||||
lCanvas.ontouchstart = null;
|
||||
lCanvas.onclick = null;
|
||||
}
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 목록 렌더링 (아코디언 방식)
|
||||
* 범주 1: 오늘 TBM 등록 작업 (해당 위치)
|
||||
|
||||
@@ -460,6 +460,102 @@
|
||||
#submitBtn:disabled { background: #d1d5db; cursor: not-allowed; }
|
||||
#submitBtn:not(:disabled):active { background: #dc2626; }
|
||||
|
||||
/* 가로모드 전체화면 지도 오버레이 */
|
||||
.landscape-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 10000;
|
||||
background: rgba(0, 0, 0, 0.95);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.landscape-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
.landscape-inner.rotated {
|
||||
width: 100vh;
|
||||
height: 100vw;
|
||||
transform: translate(-50%, -50%) rotate(90deg);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
}
|
||||
.landscape-inner.no-rotate {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
.landscape-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 1rem;
|
||||
background: linear-gradient(135deg, #ef4444, #dc2626);
|
||||
color: white;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.landscape-header h3 {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.landscape-close-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.landscape-canvas-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
background: #f1f5f9;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.landscape-canvas-wrap canvas {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.landscape-trigger-btn {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.landscape-trigger-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.5rem 0.875rem;
|
||||
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
margin-top: 0.5rem;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.landscape-trigger-btn:active {
|
||||
transform: scale(0.97);
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (min-width: 480px) {
|
||||
body { max-width: 480px; margin: 0 auto; min-height: 100vh; }
|
||||
@@ -514,6 +610,9 @@
|
||||
<div class="map-container">
|
||||
<canvas id="issueMapCanvas"></canvas>
|
||||
</div>
|
||||
<button type="button" class="landscape-trigger-btn" id="landscapeTriggerBtn" onclick="openLandscapeMap()" style="display:none;">
|
||||
📺 전체화면 지도로 선택
|
||||
</button>
|
||||
<div id="selectedLocationInfo" class="location-info empty">
|
||||
지도에서 작업장을 클릭하여 위치를 선택하세요
|
||||
</div>
|
||||
@@ -569,6 +668,19 @@
|
||||
<button type="button" id="submitBtn" disabled onclick="submitReport()">신고 제출</button>
|
||||
</div>
|
||||
|
||||
<!-- 가로모드 전체화면 지도 오버레이 -->
|
||||
<div id="landscapeOverlay" class="landscape-overlay" style="display:none;">
|
||||
<div id="landscapeInner" class="landscape-inner">
|
||||
<div class="landscape-header">
|
||||
<h3>🏭 작업장 선택</h3>
|
||||
<button type="button" class="landscape-close-btn" onclick="closeLandscapeMap()">×</button>
|
||||
</div>
|
||||
<div class="landscape-canvas-wrap">
|
||||
<canvas id="landscapeCanvas"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden file input for camera/gallery -->
|
||||
<input type="file" id="photoInput" accept="image/*" style="display:none">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user