fix: 작업자/프로젝트 관리 페이지 모듈 로딩 및 DB 스키마 동기화 수정

## 수정 내용

### 1. JavaScript 모듈 로딩 문제 수정
- ES6 import 사용 파일에 type="module" 속성 추가
- api-config.js, load-navbar.js, worker-management.js, project-management.js

### 2. DB 스키마 불일치 해결
- workers 테이블 실제 구조에 맞게 코드 수정
- 존재하지 않는 컬럼 제거: phone_number, email, hire_date, department, notes
- 실제 컬럼 사용: join_date, salary, annual_leave

### 3. 백엔드 수정
- workerModel.js: create, update 함수를 실제 테이블 구조에 맞게 수정
- workerController.js: 상세 로깅 추가

### 4. 프론트엔드 수정
- worker-management.js: 데이터 전송 구조 수정
- api-config.js: 에러 로깅 개선
- HTML 파일: 스크립트 type="module" 추가 및 버전 업데이트

### 5. 개발 문서
- 개발로그 추가: 2026-01-19_작업자관리_스키마_동기화.md

## 영향 범위
- 작업자 관리 페이지: 상태 변경 기능 정상화
- 프로젝트 관리 페이지: 모듈 로딩 오류 수정

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-01-19 08:35:36 +09:00
parent 79bd9324ca
commit 344ad35651
7 changed files with 471 additions and 73 deletions

View File

@@ -15,24 +15,23 @@ const create = async (worker, callback) => {
const db = await getDb();
const {
worker_name,
job_type = 'worker',
phone_number = null,
email = null,
hire_date = null,
department = null,
notes = null,
job_type = null,
join_date = null,
salary = null,
annual_leave = null,
status = 'active'
} = worker;
const [result] = await db.query(
`INSERT INTO workers
(worker_name, job_type, phone_number, email, hire_date, department, notes, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
[worker_name, job_type, phone_number, email, formatDate(hire_date), department, notes, status]
(worker_name, job_type, join_date, salary, annual_leave, status)
VALUES (?, ?, ?, ?, ?, ?)`,
[worker_name, job_type, formatDate(join_date), salary, annual_leave, status]
);
callback(null, result.insertId);
} catch (err) {
console.error('❌ create 함수 에러:', err);
callback(err);
}
};
@@ -80,39 +79,57 @@ const update = async (worker, callback) => {
worker_name,
job_type,
status,
phone_number,
email,
hire_date,
department,
notes
join_date,
salary,
annual_leave
} = worker;
const [result] = await db.query(
`UPDATE workers
SET worker_name = ?,
job_type = ?,
status = ?,
phone_number = ?,
email = ?,
hire_date = ?,
department = ?,
notes = ?
WHERE worker_id = ?`,
[
worker_name,
job_type,
status,
phone_number,
email,
formatDate(hire_date),
department,
notes,
worker_id
]
);
// 업데이트할 필드만 동적으로 구성
const updates = [];
const values = [];
if (worker_name !== undefined) {
updates.push('worker_name = ?');
values.push(worker_name);
}
if (job_type !== undefined) {
updates.push('job_type = ?');
values.push(job_type);
}
if (status !== undefined) {
updates.push('status = ?');
values.push(status);
}
if (join_date !== undefined) {
updates.push('join_date = ?');
values.push(formatDate(join_date));
}
if (salary !== undefined) {
updates.push('salary = ?');
values.push(salary);
}
if (annual_leave !== undefined) {
updates.push('annual_leave = ?');
values.push(annual_leave);
}
if (updates.length === 0) {
callback(new Error('업데이트할 필드가 없습니다'));
return;
}
values.push(worker_id); // WHERE 조건용
const query = `UPDATE workers SET ${updates.join(', ')} WHERE worker_id = ?`;
console.log('🔍 실행할 SQL:', query);
console.log('🔍 SQL 파라미터:', values);
const [result] = await db.query(query, values);
callback(null, result.affectedRows);
} catch (err) {
console.error('❌ update 함수 에러:', err);
callback(new Error(err.message || String(err)));
}
};