- tkuser 서비스 신규 추가 (API + Web) - 사용자/권한/프로젝트/부서/작업자/작업장/설비/작업/휴가 통합 관리 - 작업장 탭: 공장→작업장 드릴다운 네비게이션 + 구역지도 클릭 연동 - 작업 탭: 공정(work_types)→작업(tasks) 계층 관리 - 휴가 탭: 유형 관리 + 연차 배정(근로기준법 자동계산) - 전 시스템 SSO 쿠키 인증으로 통합 (.technicalkorea.net 공유) - System 2: 작업 이슈 리포트 기능 강화 - System 3: tkuser API 연동, 페이지 권한 체계 적용 - docker-compose에 tkuser-api, tkuser-web 서비스 추가 - ARCHITECTURE.md, DEPLOYMENT.md 문서 작성 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
155 lines
3.4 KiB
JavaScript
155 lines
3.4 KiB
JavaScript
/**
|
|
* Workplace Management - Utilities
|
|
* 작업장 관리 관련 유틸리티 함수들
|
|
*/
|
|
|
|
class WorkplaceUtils {
|
|
constructor() {
|
|
console.log('[WorkplaceUtils] 초기화 완료');
|
|
}
|
|
|
|
/**
|
|
* 날짜 포맷팅
|
|
*/
|
|
formatDate(dateString) {
|
|
if (!dateString) return '';
|
|
const date = new Date(dateString);
|
|
return date.toLocaleDateString('ko-KR', {
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit'
|
|
});
|
|
}
|
|
|
|
/**
|
|
* API URL 생성
|
|
*/
|
|
getApiBaseUrl() {
|
|
return window.API_BASE_URL || 'http://localhost:30005/api';
|
|
}
|
|
|
|
/**
|
|
* 이미지 URL 생성
|
|
*/
|
|
getFullImageUrl(imagePath) {
|
|
if (!imagePath) return null;
|
|
if (imagePath.startsWith('http')) return imagePath;
|
|
return `${this.getApiBaseUrl()}${imagePath}`.replace('/api/', '/');
|
|
}
|
|
|
|
/**
|
|
* 작업장 용도 아이콘 반환
|
|
*/
|
|
getPurposeIcon(purpose) {
|
|
const icons = {
|
|
'작업구역': '🔧',
|
|
'설비': '⚙️',
|
|
'휴게시설': '☕',
|
|
'회의실': '💼',
|
|
'창고': '📦',
|
|
'기타': '📍'
|
|
};
|
|
return purpose ? (icons[purpose] || '📍') : '🏗️';
|
|
}
|
|
|
|
/**
|
|
* 퍼센트를 픽셀로 변환
|
|
*/
|
|
percentToPixel(percent, canvasSize) {
|
|
return (percent / 100) * canvasSize;
|
|
}
|
|
|
|
/**
|
|
* 픽셀을 퍼센트로 변환
|
|
*/
|
|
pixelToPercent(pixel, canvasSize) {
|
|
return (pixel / canvasSize) * 100;
|
|
}
|
|
|
|
/**
|
|
* 영역 좌표 정규화 (음수 처리)
|
|
*/
|
|
normalizeRect(rect, canvasWidth, canvasHeight) {
|
|
const xPercent = this.pixelToPercent(
|
|
Math.min(rect.x, rect.x + rect.width),
|
|
canvasWidth
|
|
);
|
|
const yPercent = this.pixelToPercent(
|
|
Math.min(rect.y, rect.y + rect.height),
|
|
canvasHeight
|
|
);
|
|
const widthPercent = this.pixelToPercent(
|
|
Math.abs(rect.width),
|
|
canvasWidth
|
|
);
|
|
const heightPercent = this.pixelToPercent(
|
|
Math.abs(rect.height),
|
|
canvasHeight
|
|
);
|
|
|
|
return { xPercent, yPercent, widthPercent, heightPercent };
|
|
}
|
|
}
|
|
|
|
// 전역 인스턴스 생성
|
|
window.WorkplaceUtils = new WorkplaceUtils();
|
|
|
|
// 하위 호환성: 기존 함수들
|
|
window.formatDate = (dateString) => window.WorkplaceUtils.formatDate(dateString);
|
|
|
|
// 토스트 메시지 표시
|
|
window.showToast = function(message, type = 'info') {
|
|
// 기존 토스트 제거
|
|
const existingToast = document.querySelector('.toast');
|
|
if (existingToast) {
|
|
existingToast.remove();
|
|
}
|
|
|
|
// 새 토스트 생성
|
|
const toast = document.createElement('div');
|
|
toast.className = `toast toast-${type}`;
|
|
toast.textContent = message;
|
|
|
|
// 스타일 적용
|
|
Object.assign(toast.style, {
|
|
position: 'fixed',
|
|
top: '20px',
|
|
right: '20px',
|
|
padding: '12px 24px',
|
|
borderRadius: '8px',
|
|
color: 'white',
|
|
fontWeight: '500',
|
|
zIndex: '1000',
|
|
transform: 'translateX(100%)',
|
|
transition: 'transform 0.3s ease'
|
|
});
|
|
|
|
// 타입별 배경색
|
|
const colors = {
|
|
success: '#10b981',
|
|
error: '#ef4444',
|
|
warning: '#f59e0b',
|
|
info: '#3b82f6'
|
|
};
|
|
toast.style.backgroundColor = colors[type] || colors.info;
|
|
|
|
document.body.appendChild(toast);
|
|
|
|
// 애니메이션
|
|
setTimeout(() => {
|
|
toast.style.transform = 'translateX(0)';
|
|
}, 100);
|
|
|
|
// 자동 제거
|
|
setTimeout(() => {
|
|
toast.style.transform = 'translateX(100%)';
|
|
setTimeout(() => {
|
|
if (toast.parentNode) {
|
|
toast.remove();
|
|
}
|
|
}, 300);
|
|
}, 3000);
|
|
};
|
|
|
|
console.log('[Module] workplace-management/utils.js 로드 완료');
|