feat(schedule): 공정표 제품유형 + 표준공정 자동생성
Backend: - product_types 참조 테이블 + projects.product_type_id FK (tkuser 마이그레이션) - schedule_entries에 work_type_id, risk_assessment_id, source 컬럼 추가 - schedule_phases에 product_type_id 추가 (phase 오염 방지) - generateFromTemplate: tksafety 템플릿 기반 공정 자동 생성 (트랜잭션) - phase 매칭 3단계 우선순위 (전용→범용→신규) - 간트 데이터 NULL 날짜 guard 추가 - system1 startup 마이그레이션 러너 추가 Frontend: - tkuser 프로젝트 추가/수정 폼에 제품유형 드롭다운 추가 - 프로젝트 목록에 제품유형 뱃지 표시 - 공정표 툴바에 "표준공정 생성" 버튼 + 모달 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
document.getElementById('btnAddEntry').classList.remove('hidden');
|
document.getElementById('btnAddEntry').classList.remove('hidden');
|
||||||
document.getElementById('btnBatchAdd').classList.remove('hidden');
|
document.getElementById('btnBatchAdd').classList.remove('hidden');
|
||||||
document.getElementById('btnAddMilestone').classList.remove('hidden');
|
document.getElementById('btnAddMilestone').classList.remove('hidden');
|
||||||
|
const btnGen = document.getElementById('btnGenTemplate');
|
||||||
|
if (btnGen) btnGen.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load collapse state
|
// Load collapse state
|
||||||
|
|||||||
@@ -110,6 +110,9 @@
|
|||||||
<button class="zoom-btn px-3 py-1.5 rounded-lg text-sm border" data-zoom="year">연간</button>
|
<button class="zoom-btn px-3 py-1.5 rounded-lg text-sm border" data-zoom="year">연간</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 ml-auto">
|
<div class="flex items-center gap-2 ml-auto">
|
||||||
|
<button id="btnGenTemplate" class="hidden bg-indigo-600 text-white px-3 py-1.5 rounded-lg text-sm hover:bg-indigo-700" onclick="openTemplateModal()">
|
||||||
|
<i class="fas fa-wand-magic-sparkles mr-1"></i>표준공정 생성
|
||||||
|
</button>
|
||||||
<button id="btnAddEntry" class="hidden bg-orange-600 text-white px-3 py-1.5 rounded-lg text-sm hover:bg-orange-700">
|
<button id="btnAddEntry" class="hidden bg-orange-600 text-white px-3 py-1.5 rounded-lg text-sm hover:bg-orange-700">
|
||||||
<i class="fas fa-plus mr-1"></i>항목 추가
|
<i class="fas fa-plus mr-1"></i>항목 추가
|
||||||
</button>
|
</button>
|
||||||
@@ -315,7 +318,95 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 표준공정 생성 모달 -->
|
||||||
|
<div id="templateModal" class="modal-overlay hidden">
|
||||||
|
<div class="modal-content p-6" style="max-width: 400px;">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<h3 class="text-lg font-bold"><i class="fas fa-wand-magic-sparkles text-indigo-500 mr-2"></i>표준공정 생성</h3>
|
||||||
|
<button onclick="closeTemplateModal()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-1">프로젝트</label>
|
||||||
|
<select id="tmplProjectSelect" class="input-field w-full rounded-lg px-3 py-2 text-sm"></select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-1">제품유형</label>
|
||||||
|
<select id="tmplProductType" class="input-field w-full rounded-lg px-3 py-2 text-sm">
|
||||||
|
<option value="">선택</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-gray-500"><i class="fas fa-info-circle mr-1"></i>선택한 제품유형의 표준공정이 자동으로 생성됩니다</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-2 mt-5">
|
||||||
|
<button onclick="closeTemplateModal()" class="px-4 py-2 border rounded-lg text-sm text-gray-600 hover:bg-gray-50">취소</button>
|
||||||
|
<button onclick="generateTemplate()" class="px-4 py-2 bg-indigo-600 text-white rounded-lg text-sm hover:bg-indigo-700">
|
||||||
|
<i class="fas fa-wand-magic-sparkles mr-1"></i>생성
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/tkfb-core.js?v=2026031701"></script>
|
<script src="/static/js/tkfb-core.js?v=2026031701"></script>
|
||||||
<script src="/js/schedule.js?v=2026031701"></script>
|
<script src="/js/schedule.js?v=2026031701"></script>
|
||||||
|
<script>
|
||||||
|
// 표준공정 생성 모달
|
||||||
|
async function openTemplateModal() {
|
||||||
|
const modal = document.getElementById('templateModal');
|
||||||
|
const projSel = document.getElementById('tmplProjectSelect');
|
||||||
|
const typeSel = document.getElementById('tmplProductType');
|
||||||
|
|
||||||
|
// 프로젝트 목록 로드
|
||||||
|
try {
|
||||||
|
const r = await apiFetch('/api/schedule/product-types');
|
||||||
|
typeSel.innerHTML = '<option value="">선택</option>';
|
||||||
|
(r.data || []).forEach(pt => {
|
||||||
|
typeSel.innerHTML += `<option value="${pt.code}">${pt.code} - ${escHtml(pt.name)}</option>`;
|
||||||
|
});
|
||||||
|
} catch(e) { console.warn('제품유형 로드 실패:', e); }
|
||||||
|
|
||||||
|
// 프로젝트 목록 (기존 gantt에서 사용 중인 projects 변수 활용)
|
||||||
|
if (typeof allProjects !== 'undefined' && allProjects.length) {
|
||||||
|
projSel.innerHTML = allProjects.map(p =>
|
||||||
|
`<option value="${p.project_id}">${escHtml(p.job_no)} - ${escHtml(p.project_name)}</option>`
|
||||||
|
).join('');
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const r = await apiFetch('/api/projects/active');
|
||||||
|
const projs = r.data || [];
|
||||||
|
projSel.innerHTML = projs.map(p =>
|
||||||
|
`<option value="${p.project_id}">${escHtml(p.job_no)} - ${escHtml(p.project_name)}</option>`
|
||||||
|
).join('');
|
||||||
|
} catch(e) { projSel.innerHTML = '<option>프로젝트 로드 실패</option>'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeTemplateModal() {
|
||||||
|
document.getElementById('templateModal').classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateTemplate() {
|
||||||
|
const projectId = document.getElementById('tmplProjectSelect').value;
|
||||||
|
const productTypeCode = document.getElementById('tmplProductType').value;
|
||||||
|
if (!projectId || !productTypeCode) {
|
||||||
|
showToast('프로젝트와 제품유형을 선택해주세요', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const r = await apiFetch('/api/schedule/generate-from-template', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ project_id: parseInt(projectId), product_type_code: productTypeCode })
|
||||||
|
});
|
||||||
|
showToast(r.message || `${r.data.created}개 표준공정이 생성되었습니다`);
|
||||||
|
closeTemplateModal();
|
||||||
|
if (typeof loadGanttData === 'function') loadGanttData();
|
||||||
|
} catch(e) {
|
||||||
|
showToast(e.message || '표준공정 생성 실패', 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -470,6 +470,12 @@
|
|||||||
<input type="date" id="newDueDate" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
<input type="date" id="newDueDate" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-medium text-gray-600 mb-1">제품유형</label>
|
||||||
|
<select id="newProductType" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
||||||
|
<option value="">선택</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-medium text-gray-600 mb-1">현장</label>
|
<label class="block text-xs font-medium text-gray-600 mb-1">현장</label>
|
||||||
<input type="text" id="newSite" class="input-field w-full px-3 py-1.5 rounded-lg text-sm" placeholder="설치 현장">
|
<input type="text" id="newSite" class="input-field w-full px-3 py-1.5 rounded-lg text-sm" placeholder="설치 현장">
|
||||||
@@ -1147,6 +1153,12 @@
|
|||||||
<input type="date" id="editDueDate" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
<input type="date" id="editDueDate" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-medium text-gray-600 mb-1">제품유형</label>
|
||||||
|
<select id="editProductType" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
||||||
|
<option value="">선택</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-medium text-gray-600 mb-1">현장</label>
|
<label class="block text-xs font-medium text-gray-600 mb-1">현장</label>
|
||||||
<input type="text" id="editSite" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
<input type="text" id="editSite" class="input-field w-full px-3 py-1.5 rounded-lg text-sm">
|
||||||
@@ -2393,7 +2405,7 @@
|
|||||||
<script src="/static/js/tkuser-tabs.js?v=2026032301"></script>
|
<script src="/static/js/tkuser-tabs.js?v=2026032301"></script>
|
||||||
<!-- JS: Individual modules -->
|
<!-- JS: Individual modules -->
|
||||||
<script src="/static/js/tkuser-users.js?v=2026032502"></script>
|
<script src="/static/js/tkuser-users.js?v=2026032502"></script>
|
||||||
<script src="/static/js/tkuser-projects.js?v=2026031401"></script>
|
<script src="/static/js/tkuser-projects.js?v=2026032601"></script>
|
||||||
<script src="/static/js/tkuser-departments.js?v=2026032302"></script>
|
<script src="/static/js/tkuser-departments.js?v=2026032302"></script>
|
||||||
<script src="/static/js/tkuser-issue-types.js?v=2026031401"></script>
|
<script src="/static/js/tkuser-issue-types.js?v=2026031401"></script>
|
||||||
<script src="/static/js/tkuser-workplaces.js?v=2026031401"></script>
|
<script src="/static/js/tkuser-workplaces.js?v=2026031401"></script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* ===== Projects CRUD ===== */
|
/* ===== Projects CRUD ===== */
|
||||||
let projects = [], projectsLoaded = false;
|
let projects = [], projectsLoaded = false, productTypesCache = [];
|
||||||
|
|
||||||
function statusBadge(status, isActive) {
|
function statusBadge(status, isActive) {
|
||||||
if (!isActive || isActive === 0 || isActive === false) return '<span class="px-1.5 py-0.5 rounded text-xs bg-gray-100 text-gray-400">비활성</span>';
|
if (!isActive || isActive === 0 || isActive === false) return '<span class="px-1.5 py-0.5 rounded text-xs bg-gray-100 text-gray-400">비활성</span>';
|
||||||
@@ -7,8 +7,23 @@ function statusBadge(status, isActive) {
|
|||||||
return '<span class="px-1.5 py-0.5 rounded text-xs bg-emerald-50 text-emerald-600">진행중</span>';
|
return '<span class="px-1.5 py-0.5 rounded text-xs bg-emerald-50 text-emerald-600">진행중</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadProductTypes() {
|
||||||
|
try {
|
||||||
|
const r = await api('/projects/product-types');
|
||||||
|
productTypesCache = r.data || [];
|
||||||
|
['newProductType', 'editProductType'].forEach(id => {
|
||||||
|
const sel = document.getElementById(id); if (!sel) return;
|
||||||
|
const val = sel.value;
|
||||||
|
sel.innerHTML = '<option value="">선택</option>';
|
||||||
|
productTypesCache.forEach(pt => { const o = document.createElement('option'); o.value = pt.id; o.textContent = `${pt.code} - ${pt.name}`; sel.appendChild(o); });
|
||||||
|
sel.value = val;
|
||||||
|
});
|
||||||
|
} catch(e) { console.warn('제품유형 로드 실패:', e); }
|
||||||
|
}
|
||||||
|
|
||||||
async function loadProjects() {
|
async function loadProjects() {
|
||||||
try {
|
try {
|
||||||
|
await loadProductTypes();
|
||||||
const r = await api('/projects'); projects = r.data || r;
|
const r = await api('/projects'); projects = r.data || r;
|
||||||
projectsLoaded = true;
|
projectsLoaded = true;
|
||||||
displayProjects();
|
displayProjects();
|
||||||
@@ -26,6 +41,7 @@ function displayProjects() {
|
|||||||
<div class="text-sm font-medium text-gray-800 truncate"><i class="fas fa-folder mr-1.5 text-gray-400 text-xs"></i>${escapeHtml(p.project_name)}</div>
|
<div class="text-sm font-medium text-gray-800 truncate"><i class="fas fa-folder mr-1.5 text-gray-400 text-xs"></i>${escapeHtml(p.project_name)}</div>
|
||||||
<div class="text-xs text-gray-500 flex items-center gap-1.5 mt-0.5 flex-wrap">
|
<div class="text-xs text-gray-500 flex items-center gap-1.5 mt-0.5 flex-wrap">
|
||||||
<span class="font-mono">${escapeHtml(p.job_no)}</span>
|
<span class="font-mono">${escapeHtml(p.job_no)}</span>
|
||||||
|
${p.product_type_code?`<span class="px-1.5 py-0.5 rounded bg-indigo-50 text-indigo-600 font-medium">${escapeHtml(p.product_type_code)}</span>`:''}
|
||||||
${p.site?`<span class="px-1.5 py-0.5 rounded bg-amber-50 text-amber-600">${escapeHtml(p.site)}</span>`:''}
|
${p.site?`<span class="px-1.5 py-0.5 rounded bg-amber-50 text-amber-600">${escapeHtml(p.site)}</span>`:''}
|
||||||
${p.pm?`<span class="px-1.5 py-0.5 rounded bg-slate-50 text-slate-500">${escapeHtml(p.pm)}</span>`:''}
|
${p.pm?`<span class="px-1.5 py-0.5 rounded bg-slate-50 text-slate-500">${escapeHtml(p.pm)}</span>`:''}
|
||||||
${statusBadge(p.project_status, p.is_active)}
|
${statusBadge(p.project_status, p.is_active)}
|
||||||
@@ -48,7 +64,8 @@ document.getElementById('addProjectForm').addEventListener('submit', async e =>
|
|||||||
contract_date: document.getElementById('newContractDate').value || null,
|
contract_date: document.getElementById('newContractDate').value || null,
|
||||||
due_date: document.getElementById('newDueDate').value || null,
|
due_date: document.getElementById('newDueDate').value || null,
|
||||||
site: document.getElementById('newSite').value.trim() || null,
|
site: document.getElementById('newSite').value.trim() || null,
|
||||||
pm: document.getElementById('newPm').value.trim() || null
|
pm: document.getElementById('newPm').value.trim() || null,
|
||||||
|
product_type_id: document.getElementById('newProductType').value ? parseInt(document.getElementById('newProductType').value) : null
|
||||||
})});
|
})});
|
||||||
showToast('프로젝트가 추가되었습니다.'); document.getElementById('addProjectForm').reset(); await loadProjects();
|
showToast('프로젝트가 추가되었습니다.'); document.getElementById('addProjectForm').reset(); await loadProjects();
|
||||||
} catch(e) { showToast(e.message, 'error'); }
|
} catch(e) { showToast(e.message, 'error'); }
|
||||||
@@ -63,6 +80,7 @@ function editProject(id) {
|
|||||||
document.getElementById('editDueDate').value = formatDate(p.due_date);
|
document.getElementById('editDueDate').value = formatDate(p.due_date);
|
||||||
document.getElementById('editSite').value = p.site || '';
|
document.getElementById('editSite').value = p.site || '';
|
||||||
document.getElementById('editPm').value = p.pm || '';
|
document.getElementById('editPm').value = p.pm || '';
|
||||||
|
document.getElementById('editProductType').value = p.product_type_id || '';
|
||||||
document.getElementById('editProjectStatus').value = p.project_status || 'active';
|
document.getElementById('editProjectStatus').value = p.project_status || 'active';
|
||||||
document.getElementById('editIsActive').value = p.is_active ? '1' : '0';
|
document.getElementById('editIsActive').value = p.is_active ? '1' : '0';
|
||||||
document.getElementById('editProjectModal').classList.remove('hidden');
|
document.getElementById('editProjectModal').classList.remove('hidden');
|
||||||
@@ -79,6 +97,7 @@ document.getElementById('editProjectForm').addEventListener('submit', async e =>
|
|||||||
due_date: document.getElementById('editDueDate').value || null,
|
due_date: document.getElementById('editDueDate').value || null,
|
||||||
site: document.getElementById('editSite').value.trim() || null,
|
site: document.getElementById('editSite').value.trim() || null,
|
||||||
pm: document.getElementById('editPm').value.trim() || null,
|
pm: document.getElementById('editPm').value.trim() || null,
|
||||||
|
product_type_id: document.getElementById('editProductType').value ? parseInt(document.getElementById('editProductType').value) : null,
|
||||||
project_status: document.getElementById('editProjectStatus').value,
|
project_status: document.getElementById('editProjectStatus').value,
|
||||||
is_active: document.getElementById('editIsActive').value === '1'
|
is_active: document.getElementById('editIsActive').value === '1'
|
||||||
})});
|
})});
|
||||||
|
|||||||
Reference in New Issue
Block a user