feat: 구매/안전 시스템 전면 개편 — tkpurchase 개편 + tksafety 신규 + 권한 보강
Phase 1: tkuser 협력업체 CRUD 이관 (읽기전용 → 전체 CRUD) Phase 2: tkpurchase 개편 — 일용공 신청/확정, 작업일정, 업무현황, 계정관리, 협력업체 포털 Phase 3: tksafety 신규 시스템 — 방문관리 + 안전교육 신고 Phase 4: SSO 인증 보강 (partner_company_id JWT, 만료일 체크), 권한 테이블 기반 접근 제어 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
80
tkpurchase/api/controllers/checkinController.js
Normal file
80
tkpurchase/api/controllers/checkinController.js
Normal file
@@ -0,0 +1,80 @@
|
||||
const checkinModel = require('../models/checkinModel');
|
||||
|
||||
// 일정별 체크인 목록
|
||||
async function list(req, res) {
|
||||
try {
|
||||
const rows = await checkinModel.findBySchedule(req.params.scheduleId);
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Checkin list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 내 체크인 (협력업체 포탈 - 오늘)
|
||||
async function myCheckins(req, res) {
|
||||
try {
|
||||
const companyId = req.user.partner_company_id;
|
||||
if (!companyId) {
|
||||
return res.status(403).json({ success: false, error: '협력업체 계정이 아닙니다' });
|
||||
}
|
||||
const rows = await checkinModel.findTodayByCompany(companyId);
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Checkin myCheckins error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 체크인
|
||||
async function checkIn(req, res) {
|
||||
try {
|
||||
const { schedule_id, company_id, worker_names, actual_worker_count } = req.body;
|
||||
if (!schedule_id) {
|
||||
return res.status(400).json({ success: false, error: '일정을 선택해주세요' });
|
||||
}
|
||||
const resolvedCompanyId = company_id || req.user.partner_company_id;
|
||||
if (!resolvedCompanyId) {
|
||||
return res.status(400).json({ success: false, error: '업체 정보가 필요합니다' });
|
||||
}
|
||||
const data = {
|
||||
schedule_id,
|
||||
company_id: resolvedCompanyId,
|
||||
checked_by: req.user.user_id || req.user.id,
|
||||
worker_names,
|
||||
actual_worker_count,
|
||||
notes: req.body.notes
|
||||
};
|
||||
const row = await checkinModel.checkIn(data);
|
||||
res.status(201).json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Checkin checkIn error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 체크아웃
|
||||
async function checkOut(req, res) {
|
||||
try {
|
||||
const row = await checkinModel.checkOut(req.params.id);
|
||||
if (!row) return res.status(404).json({ success: false, error: '체크인 기록을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Checkin checkOut error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 체크인 정보 수정
|
||||
async function update(req, res) {
|
||||
try {
|
||||
const row = await checkinModel.update(req.params.id, req.body);
|
||||
if (!row) return res.status(404).json({ success: false, error: '체크인 기록을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Checkin update error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { list, myCheckins, checkIn, checkOut, update };
|
||||
126
tkpurchase/api/controllers/dayLaborController.js
Normal file
126
tkpurchase/api/controllers/dayLaborController.js
Normal file
@@ -0,0 +1,126 @@
|
||||
const dayLaborModel = require('../models/dayLaborModel');
|
||||
const { getPool } = require('../models/partnerModel');
|
||||
|
||||
// 일용직 요청 목록
|
||||
async function list(req, res) {
|
||||
try {
|
||||
const { status, date_from, date_to, department_id, page, limit } = req.query;
|
||||
const rows = await dayLaborModel.findAll({
|
||||
status,
|
||||
date_from,
|
||||
date_to,
|
||||
department_id: department_id ? parseInt(department_id) : undefined,
|
||||
page: page ? parseInt(page) : 1,
|
||||
limit: limit ? parseInt(limit) : 50
|
||||
});
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('DayLabor list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일용직 요청 상세
|
||||
async function getById(req, res) {
|
||||
try {
|
||||
const row = await dayLaborModel.findById(req.params.id);
|
||||
if (!row) return res.status(404).json({ success: false, error: '요청을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('DayLabor get error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일용직 요청 등록
|
||||
async function create(req, res) {
|
||||
try {
|
||||
const { work_date, worker_count } = req.body;
|
||||
if (!work_date) {
|
||||
return res.status(400).json({ success: false, error: '작업일은 필수입니다' });
|
||||
}
|
||||
if (!worker_count || worker_count < 1) {
|
||||
return res.status(400).json({ success: false, error: '작업인원은 1명 이상이어야 합니다' });
|
||||
}
|
||||
const data = {
|
||||
...req.body,
|
||||
requester_id: req.user.user_id || req.user.id
|
||||
};
|
||||
const row = await dayLaborModel.create(data);
|
||||
res.status(201).json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('DayLabor create error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일용직 요청 승인
|
||||
async function approve(req, res) {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
const approvedBy = req.user.user_id || req.user.id;
|
||||
const row = await dayLaborModel.approve(id, approvedBy);
|
||||
if (!row) return res.status(404).json({ success: false, error: '요청을 찾을 수 없습니다' });
|
||||
|
||||
// 승인 시 안전교육 보고서 자동 생성
|
||||
if (row.status === 'approved') {
|
||||
try {
|
||||
const db = getPool();
|
||||
await db.query(
|
||||
`INSERT INTO safety_education_reports (target_type, target_id, education_date, status, registered_by)
|
||||
VALUES ('day_labor', ?, ?, 'planned', ?)`,
|
||||
[id, row.work_date, approvedBy]
|
||||
);
|
||||
} catch (safetyErr) {
|
||||
console.error('Safety report auto-create error:', safetyErr);
|
||||
// 안전교육 보고서 생성 실패해도 승인은 유지
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('DayLabor approve error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일용직 요청 거절
|
||||
async function reject(req, res) {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
const approvedBy = req.user.user_id || req.user.id;
|
||||
const { notes } = req.body;
|
||||
const row = await dayLaborModel.reject(id, approvedBy, notes);
|
||||
if (!row) return res.status(404).json({ success: false, error: '요청을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('DayLabor reject error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일용직 요청 완료
|
||||
async function complete(req, res) {
|
||||
try {
|
||||
const row = await dayLaborModel.complete(req.params.id);
|
||||
if (!row) return res.status(404).json({ success: false, error: '요청을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('DayLabor complete error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 통계
|
||||
async function stats(req, res) {
|
||||
try {
|
||||
const { date_from, date_to } = req.query;
|
||||
const rows = await dayLaborModel.getStats({ date_from, date_to });
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('DayLabor stats error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { list, getById, create, approve, reject, complete, stats };
|
||||
80
tkpurchase/api/controllers/partnerAccountController.js
Normal file
80
tkpurchase/api/controllers/partnerAccountController.js
Normal file
@@ -0,0 +1,80 @@
|
||||
const partnerAccountModel = require('../models/partnerAccountModel');
|
||||
const { getPool } = require('../models/partnerModel');
|
||||
|
||||
// 업체별 계정 목록
|
||||
async function listByCompany(req, res) {
|
||||
try {
|
||||
const rows = await partnerAccountModel.findByCompany(req.params.companyId);
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('PartnerAccount listByCompany error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 계정 생성
|
||||
async function create(req, res) {
|
||||
try {
|
||||
const { username, password, name, partner_company_id, account_expires_at } = req.body;
|
||||
if (!username || !username.trim()) {
|
||||
return res.status(400).json({ success: false, error: '아이디는 필수입니다' });
|
||||
}
|
||||
if (!password || password.length < 4) {
|
||||
return res.status(400).json({ success: false, error: '비밀번호는 4자 이상이어야 합니다' });
|
||||
}
|
||||
if (!name || !name.trim()) {
|
||||
return res.status(400).json({ success: false, error: '이름은 필수입니다' });
|
||||
}
|
||||
if (!partner_company_id) {
|
||||
return res.status(400).json({ success: false, error: '업체를 선택해주세요' });
|
||||
}
|
||||
|
||||
// 아이디 중복 확인
|
||||
const db = getPool();
|
||||
const [existing] = await db.query('SELECT user_id FROM sso_users WHERE username = ?', [username]);
|
||||
if (existing.length > 0) {
|
||||
return res.status(400).json({ success: false, error: '이미 사용 중인 아이디입니다' });
|
||||
}
|
||||
|
||||
const account = await partnerAccountModel.create({
|
||||
username, password, name, partner_company_id, account_expires_at
|
||||
});
|
||||
|
||||
// 기본 권한 부여
|
||||
await partnerAccountModel.grantDefaultPermissions(account.user_id);
|
||||
|
||||
res.status(201).json({ success: true, data: account });
|
||||
} catch (err) {
|
||||
if (err.code === 'ER_DUP_ENTRY') {
|
||||
return res.status(400).json({ success: false, error: '이미 사용 중인 아이디입니다' });
|
||||
}
|
||||
console.error('PartnerAccount create error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 계정 수정
|
||||
async function update(req, res) {
|
||||
try {
|
||||
const account = await partnerAccountModel.update(req.params.id, req.body);
|
||||
if (!account) return res.status(404).json({ success: false, error: '계정을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: account });
|
||||
} catch (err) {
|
||||
console.error('PartnerAccount update error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 계정 비활성화
|
||||
async function deactivate(req, res) {
|
||||
try {
|
||||
const account = await partnerAccountModel.update(req.params.id, { is_active: false });
|
||||
if (!account) return res.status(404).json({ success: false, error: '계정을 찾을 수 없습니다' });
|
||||
res.json({ success: true, message: '비활성화 완료' });
|
||||
} catch (err) {
|
||||
console.error('PartnerAccount deactivate error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { listByCompany, create, update, deactivate };
|
||||
110
tkpurchase/api/controllers/scheduleController.js
Normal file
110
tkpurchase/api/controllers/scheduleController.js
Normal file
@@ -0,0 +1,110 @@
|
||||
const scheduleModel = require('../models/scheduleModel');
|
||||
|
||||
// 일정 목록
|
||||
async function list(req, res) {
|
||||
try {
|
||||
const { company_id, date_from, date_to, status, page, limit } = req.query;
|
||||
const rows = await scheduleModel.findAll({
|
||||
company_id: company_id ? parseInt(company_id) : undefined,
|
||||
date_from,
|
||||
date_to,
|
||||
status,
|
||||
page: page ? parseInt(page) : 1,
|
||||
limit: limit ? parseInt(limit) : 50
|
||||
});
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Schedule list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일정 상세
|
||||
async function getById(req, res) {
|
||||
try {
|
||||
const row = await scheduleModel.findById(req.params.id);
|
||||
if (!row) return res.status(404).json({ success: false, error: '일정을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Schedule get error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 내 일정 (협력업체 포탈)
|
||||
async function mySchedules(req, res) {
|
||||
try {
|
||||
const companyId = req.user.partner_company_id;
|
||||
if (!companyId) {
|
||||
return res.status(403).json({ success: false, error: '협력업체 계정이 아닙니다' });
|
||||
}
|
||||
const rows = await scheduleModel.findByCompanyToday(companyId);
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Schedule mySchedules error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일정 등록
|
||||
async function create(req, res) {
|
||||
try {
|
||||
const { company_id, work_date } = req.body;
|
||||
if (!company_id) {
|
||||
return res.status(400).json({ success: false, error: '업체를 선택해주세요' });
|
||||
}
|
||||
if (!work_date) {
|
||||
return res.status(400).json({ success: false, error: '작업일은 필수입니다' });
|
||||
}
|
||||
const data = {
|
||||
...req.body,
|
||||
registered_by: req.user.user_id || req.user.id
|
||||
};
|
||||
const row = await scheduleModel.create(data);
|
||||
res.status(201).json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Schedule create error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일정 수정
|
||||
async function update(req, res) {
|
||||
try {
|
||||
const row = await scheduleModel.update(req.params.id, req.body);
|
||||
if (!row) return res.status(404).json({ success: false, error: '일정을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Schedule update error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일정 상태 변경
|
||||
async function updateStatus(req, res) {
|
||||
try {
|
||||
const { status } = req.body;
|
||||
if (!status) {
|
||||
return res.status(400).json({ success: false, error: '상태값은 필수입니다' });
|
||||
}
|
||||
const row = await scheduleModel.updateStatus(req.params.id, status);
|
||||
if (!row) return res.status(404).json({ success: false, error: '일정을 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('Schedule updateStatus error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 일정 삭제
|
||||
async function deleteSchedule(req, res) {
|
||||
try {
|
||||
await scheduleModel.deleteSchedule(req.params.id);
|
||||
res.json({ success: true, message: '삭제 완료' });
|
||||
} catch (err) {
|
||||
console.error('Schedule delete error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { list, getById, mySchedules, create, update, updateStatus, deleteSchedule };
|
||||
118
tkpurchase/api/controllers/workReportController.js
Normal file
118
tkpurchase/api/controllers/workReportController.js
Normal file
@@ -0,0 +1,118 @@
|
||||
const workReportModel = require('../models/workReportModel');
|
||||
const checkinModel = require('../models/checkinModel');
|
||||
|
||||
// 작업보고 목록
|
||||
async function list(req, res) {
|
||||
try {
|
||||
const { company_id, date_from, date_to, schedule_id, confirmed, page, limit } = req.query;
|
||||
const rows = await workReportModel.findAll({
|
||||
company_id: company_id ? parseInt(company_id) : undefined,
|
||||
date_from,
|
||||
date_to,
|
||||
schedule_id: schedule_id ? parseInt(schedule_id) : undefined,
|
||||
confirmed,
|
||||
page: page ? parseInt(page) : 1,
|
||||
limit: limit ? parseInt(limit) : 50
|
||||
});
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('WorkReport list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 작업보고 상세
|
||||
async function getById(req, res) {
|
||||
try {
|
||||
const row = await workReportModel.findById(req.params.id);
|
||||
if (!row) return res.status(404).json({ success: false, error: '작업보고를 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('WorkReport get error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 내 작업보고 (협력업체 포탈)
|
||||
async function myReports(req, res) {
|
||||
try {
|
||||
const companyId = req.user.partner_company_id;
|
||||
if (!companyId) {
|
||||
return res.status(403).json({ success: false, error: '협력업체 계정이 아닙니다' });
|
||||
}
|
||||
const { date_from, date_to, page, limit } = req.query;
|
||||
const rows = await workReportModel.findAll({
|
||||
company_id: companyId,
|
||||
date_from,
|
||||
date_to,
|
||||
page: page ? parseInt(page) : 1,
|
||||
limit: limit ? parseInt(limit) : 50
|
||||
});
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('WorkReport myReports error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 작업보고 등록
|
||||
async function create(req, res) {
|
||||
try {
|
||||
const { checkin_id, company_id, report_date } = req.body;
|
||||
|
||||
if (!report_date) {
|
||||
return res.status(400).json({ success: false, error: '보고일은 필수입니다' });
|
||||
}
|
||||
|
||||
// checkin_id가 있으면 유효성 검증
|
||||
if (checkin_id) {
|
||||
const checkin = await checkinModel.findById(checkin_id);
|
||||
if (!checkin) {
|
||||
return res.status(400).json({ success: false, error: '유효하지 않은 체크인 ID입니다' });
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedCompanyId = company_id || req.user.partner_company_id;
|
||||
if (!resolvedCompanyId) {
|
||||
return res.status(400).json({ success: false, error: '업체 정보가 필요합니다' });
|
||||
}
|
||||
|
||||
const data = {
|
||||
...req.body,
|
||||
company_id: resolvedCompanyId,
|
||||
reporter_id: req.user.user_id || req.user.id
|
||||
};
|
||||
const row = await workReportModel.create(data);
|
||||
res.status(201).json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('WorkReport create error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 작업보고 수정
|
||||
async function update(req, res) {
|
||||
try {
|
||||
const row = await workReportModel.update(req.params.id, req.body);
|
||||
if (!row) return res.status(404).json({ success: false, error: '작업보고를 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('WorkReport update error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// 작업보고 확인
|
||||
async function confirm(req, res) {
|
||||
try {
|
||||
const confirmedBy = req.user.user_id || req.user.id;
|
||||
const row = await workReportModel.confirm(req.params.id, confirmedBy);
|
||||
if (!row) return res.status(404).json({ success: false, error: '작업보고를 찾을 수 없습니다' });
|
||||
res.json({ success: true, data: row });
|
||||
} catch (err) {
|
||||
console.error('WorkReport confirm error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { list, getById, myReports, create, update, confirm };
|
||||
@@ -2,8 +2,11 @@ const express = require('express');
|
||||
const cors = require('cors');
|
||||
const cron = require('node-cron');
|
||||
const partnerRoutes = require('./routes/partnerRoutes');
|
||||
const dailyVisitRoutes = require('./routes/dailyVisitRoutes');
|
||||
const dailyVisitModel = require('./models/dailyVisitModel');
|
||||
const dayLaborRoutes = require('./routes/dayLaborRoutes');
|
||||
const scheduleRoutes = require('./routes/scheduleRoutes');
|
||||
const checkinRoutes = require('./routes/checkinRoutes');
|
||||
const workReportRoutes = require('./routes/workReportRoutes');
|
||||
const partnerAccountRoutes = require('./routes/partnerAccountRoutes');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
@@ -14,6 +17,7 @@ const allowedOrigins = [
|
||||
'https://tkqc.technicalkorea.net',
|
||||
'https://tkuser.technicalkorea.net',
|
||||
'https://tkpurchase.technicalkorea.net',
|
||||
'https://tksafety.technicalkorea.net',
|
||||
];
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
allowedOrigins.push('http://localhost:30080', 'http://localhost:30480');
|
||||
@@ -34,7 +38,11 @@ app.get('/health', (req, res) => {
|
||||
|
||||
// Routes
|
||||
app.use('/api/partners', partnerRoutes);
|
||||
app.use('/api/daily-visits', dailyVisitRoutes);
|
||||
app.use('/api/day-labor', dayLaborRoutes);
|
||||
app.use('/api/schedules', scheduleRoutes);
|
||||
app.use('/api/checkins', checkinRoutes);
|
||||
app.use('/api/work-reports', workReportRoutes);
|
||||
app.use('/api/partner-accounts', partnerAccountRoutes);
|
||||
|
||||
// 404
|
||||
app.use((req, res) => {
|
||||
@@ -50,16 +58,6 @@ app.use((err, req, res, next) => {
|
||||
});
|
||||
});
|
||||
|
||||
// 자정 자동 체크아웃 (매일 23:59 KST)
|
||||
cron.schedule('59 23 * * *', async () => {
|
||||
try {
|
||||
const result = await dailyVisitModel.autoCheckoutAll();
|
||||
console.log(`Auto checkout: ${result.affectedRows} visits`);
|
||||
} catch (e) {
|
||||
console.error('Auto checkout failed:', e);
|
||||
}
|
||||
}, { timezone: 'Asia/Seoul' });
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`tkpurchase-api running on port ${PORT}`);
|
||||
});
|
||||
|
||||
67
tkpurchase/api/models/checkinModel.js
Normal file
67
tkpurchase/api/models/checkinModel.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const { getPool } = require('./partnerModel');
|
||||
|
||||
async function findBySchedule(scheduleId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT pc.*, pco.company_name, su.name AS checked_by_name
|
||||
FROM partner_checkins pc
|
||||
LEFT JOIN partner_companies pco ON pc.company_id = pco.id
|
||||
LEFT JOIN sso_users su ON pc.checked_by = su.user_id
|
||||
WHERE pc.schedule_id = ?
|
||||
ORDER BY pc.check_in_time DESC`, [scheduleId]);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT pc.*, pco.company_name, su.name AS checked_by_name
|
||||
FROM partner_checkins pc
|
||||
LEFT JOIN partner_companies pco ON pc.company_id = pco.id
|
||||
LEFT JOIN sso_users su ON pc.checked_by = su.user_id
|
||||
WHERE pc.id = ?`, [id]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function findTodayByCompany(companyId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT pc.*, ps.work_description, ps.workplace_name
|
||||
FROM partner_checkins pc
|
||||
LEFT JOIN partner_schedules ps ON pc.schedule_id = ps.id
|
||||
WHERE pc.company_id = ? AND DATE(pc.check_in_time) = CURDATE()
|
||||
ORDER BY pc.check_in_time DESC`, [companyId]);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function checkIn(data) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO partner_checkins (schedule_id, company_id, checked_by, check_in_time, worker_names, actual_worker_count, notes)
|
||||
VALUES (?, ?, ?, NOW(), ?, ?, ?)`,
|
||||
[data.schedule_id, data.company_id, data.checked_by,
|
||||
data.worker_names ? JSON.stringify(data.worker_names) : null,
|
||||
data.actual_worker_count || null, data.notes || null]);
|
||||
return findById(result.insertId);
|
||||
}
|
||||
|
||||
async function checkOut(id) {
|
||||
const db = getPool();
|
||||
await db.query('UPDATE partner_checkins SET check_out_time = NOW() WHERE id = ? AND check_out_time IS NULL', [id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function update(id, data) {
|
||||
const db = getPool();
|
||||
const fields = [];
|
||||
const values = [];
|
||||
if (data.worker_names !== undefined) { fields.push('worker_names = ?'); values.push(data.worker_names ? JSON.stringify(data.worker_names) : null); }
|
||||
if (data.actual_worker_count !== undefined) { fields.push('actual_worker_count = ?'); values.push(data.actual_worker_count || null); }
|
||||
if (data.notes !== undefined) { fields.push('notes = ?'); values.push(data.notes || null); }
|
||||
if (fields.length === 0) return findById(id);
|
||||
values.push(id);
|
||||
await db.query(`UPDATE partner_checkins SET ${fields.join(', ')} WHERE id = ?`, values);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
module.exports = { findBySchedule, findById, findTodayByCompany, checkIn, checkOut, update };
|
||||
85
tkpurchase/api/models/dayLaborModel.js
Normal file
85
tkpurchase/api/models/dayLaborModel.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const { getPool } = require('./partnerModel');
|
||||
|
||||
async function findAll({ status, date_from, date_to, department_id, page = 1, limit = 50 } = {}) {
|
||||
const db = getPool();
|
||||
let sql = `SELECT dlr.*, su.name AS requester_name, sa.name AS approver_name, d.department_name
|
||||
FROM day_labor_requests dlr
|
||||
LEFT JOIN sso_users su ON dlr.requester_id = su.user_id
|
||||
LEFT JOIN sso_users sa ON dlr.approved_by = sa.user_id
|
||||
LEFT JOIN departments d ON dlr.department_id = d.department_id
|
||||
WHERE 1=1`;
|
||||
const params = [];
|
||||
if (status) { sql += ' AND dlr.status = ?'; params.push(status); }
|
||||
if (date_from) { sql += ' AND dlr.work_date >= ?'; params.push(date_from); }
|
||||
if (date_to) { sql += ' AND dlr.work_date <= ?'; params.push(date_to); }
|
||||
if (department_id) { sql += ' AND dlr.department_id = ?'; params.push(department_id); }
|
||||
sql += ' ORDER BY dlr.work_date DESC, dlr.created_at DESC';
|
||||
const offset = (page - 1) * limit;
|
||||
sql += ' LIMIT ? OFFSET ?';
|
||||
params.push(limit, offset);
|
||||
const [rows] = await db.query(sql, params);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT dlr.*, su.name AS requester_name, sa.name AS approver_name, d.department_name
|
||||
FROM day_labor_requests dlr
|
||||
LEFT JOIN sso_users su ON dlr.requester_id = su.user_id
|
||||
LEFT JOIN sso_users sa ON dlr.approved_by = sa.user_id
|
||||
LEFT JOIN departments d ON dlr.department_id = d.department_id
|
||||
WHERE dlr.id = ?`, [id]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function create(data) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO day_labor_requests (requester_id, department_id, work_date, worker_count, work_description, workplace_name, notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[data.requester_id, data.department_id || null, data.work_date, data.worker_count || 1,
|
||||
data.work_description || null, data.workplace_name || null, data.notes || null]);
|
||||
return findById(result.insertId);
|
||||
}
|
||||
|
||||
async function approve(id, approvedBy) {
|
||||
const db = getPool();
|
||||
await db.query(
|
||||
`UPDATE day_labor_requests SET status = 'approved', approved_by = ?, approved_at = NOW() WHERE id = ? AND status = 'pending'`,
|
||||
[approvedBy, id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function reject(id, approvedBy, notes) {
|
||||
const db = getPool();
|
||||
await db.query(
|
||||
`UPDATE day_labor_requests SET status = 'rejected', approved_by = ?, approved_at = NOW(), notes = CONCAT(IFNULL(notes,''), ?, '') WHERE id = ? AND status = 'pending'`,
|
||||
[approvedBy, notes ? '\n[거절사유] ' + notes : '', id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function complete(id) {
|
||||
const db = getPool();
|
||||
await db.query(`UPDATE day_labor_requests SET status = 'completed' WHERE id = ? AND status = 'approved'`, [id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function markSafetyReported(id) {
|
||||
const db = getPool();
|
||||
await db.query(`UPDATE day_labor_requests SET safety_reported = TRUE WHERE id = ?`, [id]);
|
||||
}
|
||||
|
||||
async function getStats({ date_from, date_to } = {}) {
|
||||
const db = getPool();
|
||||
let dateFilter = '';
|
||||
const params = [];
|
||||
if (date_from) { dateFilter += ' AND work_date >= ?'; params.push(date_from); }
|
||||
if (date_to) { dateFilter += ' AND work_date <= ?'; params.push(date_to); }
|
||||
const [rows] = await db.query(
|
||||
`SELECT status, COUNT(*) AS cnt, SUM(worker_count) AS total_workers
|
||||
FROM day_labor_requests WHERE 1=1 ${dateFilter} GROUP BY status`, params);
|
||||
return rows;
|
||||
}
|
||||
|
||||
module.exports = { findAll, findById, create, approve, reject, complete, markSafetyReported, getStats };
|
||||
62
tkpurchase/api/models/partnerAccountModel.js
Normal file
62
tkpurchase/api/models/partnerAccountModel.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const { getPool } = require('./partnerModel');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
async function findByCompany(companyId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT user_id, username, name, role, partner_company_id, account_expires_at, is_active, created_at
|
||||
FROM sso_users WHERE partner_company_id = ?
|
||||
ORDER BY name`, [companyId]);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(userId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT user_id, username, name, role, partner_company_id, account_expires_at, is_active, created_at
|
||||
FROM sso_users WHERE user_id = ?`, [userId]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function create(data) {
|
||||
const db = getPool();
|
||||
const hash = await bcrypt.hash(data.password, 10);
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO sso_users (username, password_hash, name, role, partner_company_id, account_expires_at, is_active)
|
||||
VALUES (?, ?, ?, 'user', ?, ?, TRUE)`,
|
||||
[data.username, hash, data.name, data.partner_company_id,
|
||||
data.account_expires_at || null]);
|
||||
return findById(result.insertId);
|
||||
}
|
||||
|
||||
async function update(userId, data) {
|
||||
const db = getPool();
|
||||
const fields = [];
|
||||
const values = [];
|
||||
if (data.name !== undefined) { fields.push('name = ?'); values.push(data.name); }
|
||||
if (data.account_expires_at !== undefined) { fields.push('account_expires_at = ?'); values.push(data.account_expires_at || null); }
|
||||
if (data.is_active !== undefined) { fields.push('is_active = ?'); values.push(data.is_active); }
|
||||
if (data.password) {
|
||||
const hash = await bcrypt.hash(data.password, 10);
|
||||
fields.push('password_hash = ?');
|
||||
values.push(hash);
|
||||
}
|
||||
if (fields.length === 0) return findById(userId);
|
||||
values.push(userId);
|
||||
await db.query(`UPDATE sso_users SET ${fields.join(', ')} WHERE user_id = ?`, values);
|
||||
return findById(userId);
|
||||
}
|
||||
|
||||
async function grantDefaultPermissions(userId) {
|
||||
const db = getPool();
|
||||
const pages = ['purchasing_partner_portal', 'purchasing_partner_checkin'];
|
||||
for (const page of pages) {
|
||||
await db.query(
|
||||
`INSERT INTO user_page_permissions (user_id, page_name, can_access)
|
||||
VALUES (?, ?, TRUE)
|
||||
ON DUPLICATE KEY UPDATE can_access = TRUE`,
|
||||
[userId, page]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { findByCompany, findById, create, update, grantDefaultPermissions };
|
||||
84
tkpurchase/api/models/scheduleModel.js
Normal file
84
tkpurchase/api/models/scheduleModel.js
Normal file
@@ -0,0 +1,84 @@
|
||||
const { getPool } = require('./partnerModel');
|
||||
|
||||
async function findAll({ company_id, date_from, date_to, status, page = 1, limit = 50 } = {}) {
|
||||
const db = getPool();
|
||||
let sql = `SELECT ps.*, pc.company_name, su.name AS registered_by_name
|
||||
FROM partner_schedules ps
|
||||
LEFT JOIN partner_companies pc ON ps.company_id = pc.id
|
||||
LEFT JOIN sso_users su ON ps.registered_by = su.user_id
|
||||
WHERE 1=1`;
|
||||
const params = [];
|
||||
if (company_id) { sql += ' AND ps.company_id = ?'; params.push(company_id); }
|
||||
if (date_from) { sql += ' AND ps.work_date >= ?'; params.push(date_from); }
|
||||
if (date_to) { sql += ' AND ps.work_date <= ?'; params.push(date_to); }
|
||||
if (status) { sql += ' AND ps.status = ?'; params.push(status); }
|
||||
sql += ' ORDER BY ps.work_date DESC, ps.created_at DESC';
|
||||
const offset = (page - 1) * limit;
|
||||
sql += ' LIMIT ? OFFSET ?';
|
||||
params.push(limit, offset);
|
||||
const [rows] = await db.query(sql, params);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT ps.*, pc.company_name, su.name AS registered_by_name
|
||||
FROM partner_schedules ps
|
||||
LEFT JOIN partner_companies pc ON ps.company_id = pc.id
|
||||
LEFT JOIN sso_users su ON ps.registered_by = su.user_id
|
||||
WHERE ps.id = ?`, [id]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function findByCompanyToday(companyId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT ps.*, pc.company_name
|
||||
FROM partner_schedules ps
|
||||
LEFT JOIN partner_companies pc ON ps.company_id = pc.id
|
||||
WHERE ps.company_id = ? AND ps.work_date = CURDATE()
|
||||
ORDER BY ps.created_at DESC`, [companyId]);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function create(data) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO partner_schedules (company_id, work_date, work_description, workplace_name, expected_workers, registered_by, notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[data.company_id, data.work_date, data.work_description || null,
|
||||
data.workplace_name || null, data.expected_workers || null,
|
||||
data.registered_by, data.notes || null]);
|
||||
return findById(result.insertId);
|
||||
}
|
||||
|
||||
async function update(id, data) {
|
||||
const db = getPool();
|
||||
const fields = [];
|
||||
const values = [];
|
||||
if (data.company_id !== undefined) { fields.push('company_id = ?'); values.push(data.company_id); }
|
||||
if (data.work_date !== undefined) { fields.push('work_date = ?'); values.push(data.work_date); }
|
||||
if (data.work_description !== undefined) { fields.push('work_description = ?'); values.push(data.work_description || null); }
|
||||
if (data.workplace_name !== undefined) { fields.push('workplace_name = ?'); values.push(data.workplace_name || null); }
|
||||
if (data.expected_workers !== undefined) { fields.push('expected_workers = ?'); values.push(data.expected_workers || null); }
|
||||
if (data.notes !== undefined) { fields.push('notes = ?'); values.push(data.notes || null); }
|
||||
if (data.status !== undefined) { fields.push('status = ?'); values.push(data.status); }
|
||||
if (fields.length === 0) return findById(id);
|
||||
values.push(id);
|
||||
await db.query(`UPDATE partner_schedules SET ${fields.join(', ')} WHERE id = ?`, values);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function updateStatus(id, status) {
|
||||
const db = getPool();
|
||||
await db.query('UPDATE partner_schedules SET status = ? WHERE id = ?', [status, id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function deleteSchedule(id) {
|
||||
const db = getPool();
|
||||
await db.query('DELETE FROM partner_schedules WHERE id = ?', [id]);
|
||||
}
|
||||
|
||||
module.exports = { findAll, findById, findByCompanyToday, create, update, updateStatus, deleteSchedule };
|
||||
87
tkpurchase/api/models/workReportModel.js
Normal file
87
tkpurchase/api/models/workReportModel.js
Normal file
@@ -0,0 +1,87 @@
|
||||
const { getPool } = require('./partnerModel');
|
||||
|
||||
async function findAll({ company_id, date_from, date_to, schedule_id, confirmed, page = 1, limit = 50 } = {}) {
|
||||
const db = getPool();
|
||||
let sql = `SELECT wr.*, pc.company_name, ps.work_description AS schedule_description,
|
||||
su_reporter.name AS reporter_name, su_confirmer.name AS confirmed_by_name
|
||||
FROM partner_work_reports wr
|
||||
LEFT JOIN partner_companies pc ON wr.company_id = pc.id
|
||||
LEFT JOIN partner_schedules ps ON wr.schedule_id = ps.id
|
||||
LEFT JOIN sso_users su_reporter ON wr.reporter_id = su_reporter.user_id
|
||||
LEFT JOIN sso_users su_confirmer ON wr.confirmed_by = su_confirmer.user_id
|
||||
WHERE 1=1`;
|
||||
const params = [];
|
||||
if (company_id) { sql += ' AND wr.company_id = ?'; params.push(company_id); }
|
||||
if (date_from) { sql += ' AND wr.report_date >= ?'; params.push(date_from); }
|
||||
if (date_to) { sql += ' AND wr.report_date <= ?'; params.push(date_to); }
|
||||
if (schedule_id) { sql += ' AND wr.schedule_id = ?'; params.push(schedule_id); }
|
||||
if (confirmed === 'true' || confirmed === '1') { sql += ' AND wr.confirmed_by IS NOT NULL'; }
|
||||
if (confirmed === 'false' || confirmed === '0') { sql += ' AND wr.confirmed_by IS NULL'; }
|
||||
sql += ' ORDER BY wr.report_date DESC, wr.created_at DESC';
|
||||
const offset = (page - 1) * limit;
|
||||
sql += ' LIMIT ? OFFSET ?';
|
||||
params.push(limit, offset);
|
||||
const [rows] = await db.query(sql, params);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT wr.*, pc.company_name, ps.work_description AS schedule_description,
|
||||
su_reporter.name AS reporter_name, su_confirmer.name AS confirmed_by_name
|
||||
FROM partner_work_reports wr
|
||||
LEFT JOIN partner_companies pc ON wr.company_id = pc.id
|
||||
LEFT JOIN partner_schedules ps ON wr.schedule_id = ps.id
|
||||
LEFT JOIN sso_users su_reporter ON wr.reporter_id = su_reporter.user_id
|
||||
LEFT JOIN sso_users su_confirmer ON wr.confirmed_by = su_confirmer.user_id
|
||||
WHERE wr.id = ?`, [id]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function findByCheckin(checkinId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
`SELECT wr.*, pc.company_name
|
||||
FROM partner_work_reports wr
|
||||
LEFT JOIN partner_companies pc ON wr.company_id = pc.id
|
||||
WHERE wr.checkin_id = ?`, [checkinId]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function create(data) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO partner_work_reports (schedule_id, checkin_id, company_id, report_date, reporter_id, actual_workers, work_content, progress_rate, issues, next_plan)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[data.schedule_id || null, data.checkin_id || null, data.company_id,
|
||||
data.report_date, data.reporter_id, data.actual_workers || null,
|
||||
data.work_content || null, data.progress_rate || null,
|
||||
data.issues || null, data.next_plan || null]);
|
||||
return findById(result.insertId);
|
||||
}
|
||||
|
||||
async function update(id, data) {
|
||||
const db = getPool();
|
||||
const fields = [];
|
||||
const values = [];
|
||||
if (data.actual_workers !== undefined) { fields.push('actual_workers = ?'); values.push(data.actual_workers || null); }
|
||||
if (data.work_content !== undefined) { fields.push('work_content = ?'); values.push(data.work_content || null); }
|
||||
if (data.progress_rate !== undefined) { fields.push('progress_rate = ?'); values.push(data.progress_rate || null); }
|
||||
if (data.issues !== undefined) { fields.push('issues = ?'); values.push(data.issues || null); }
|
||||
if (data.next_plan !== undefined) { fields.push('next_plan = ?'); values.push(data.next_plan || null); }
|
||||
if (fields.length === 0) return findById(id);
|
||||
values.push(id);
|
||||
await db.query(`UPDATE partner_work_reports SET ${fields.join(', ')} WHERE id = ?`, values);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
async function confirm(id, confirmedBy) {
|
||||
const db = getPool();
|
||||
await db.query(
|
||||
'UPDATE partner_work_reports SET confirmed_by = ?, confirmed_at = NOW() WHERE id = ? AND confirmed_by IS NULL',
|
||||
[confirmedBy, id]);
|
||||
return findById(id);
|
||||
}
|
||||
|
||||
module.exports = { findAll, findById, findByCheckin, create, update, confirm };
|
||||
@@ -8,6 +8,7 @@
|
||||
"dev": "node --watch index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
|
||||
14
tkpurchase/api/routes/checkinRoutes.js
Normal file
14
tkpurchase/api/routes/checkinRoutes.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/checkinController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
router.get('/schedule/:scheduleId', ctrl.list);
|
||||
router.get('/my', ctrl.myCheckins); // partner portal
|
||||
router.post('/', ctrl.checkIn); // partner can do this
|
||||
router.put('/:id/checkout', ctrl.checkOut);
|
||||
router.put('/:id', ctrl.update);
|
||||
|
||||
module.exports = router;
|
||||
16
tkpurchase/api/routes/dayLaborRoutes.js
Normal file
16
tkpurchase/api/routes/dayLaborRoutes.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth, requirePage } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/dayLaborController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
router.get('/', ctrl.list);
|
||||
router.get('/stats', ctrl.stats);
|
||||
router.get('/:id', ctrl.getById);
|
||||
router.post('/', ctrl.create); // any authenticated user can request
|
||||
router.put('/:id/approve', requirePage('purchasing_daylabor'), ctrl.approve);
|
||||
router.put('/:id/reject', requirePage('purchasing_daylabor'), ctrl.reject);
|
||||
router.put('/:id/complete', requirePage('purchasing_daylabor'), ctrl.complete);
|
||||
|
||||
module.exports = router;
|
||||
13
tkpurchase/api/routes/partnerAccountRoutes.js
Normal file
13
tkpurchase/api/routes/partnerAccountRoutes.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth, requirePage } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/partnerAccountController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
router.get('/company/:companyId', requirePage('purchasing_accounts'), ctrl.listByCompany);
|
||||
router.post('/', requirePage('purchasing_accounts'), ctrl.create);
|
||||
router.put('/:id', requirePage('purchasing_accounts'), ctrl.update);
|
||||
router.delete('/:id', requirePage('purchasing_accounts'), ctrl.deactivate);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,20 +1,14 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth, requirePage } = require('../middleware/auth');
|
||||
const { requireAuth } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/partnerController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
// Read-only: CRUD는 tkuser로 이관됨
|
||||
router.get('/search', ctrl.searchCompanies);
|
||||
router.get('/', ctrl.list);
|
||||
router.get('/:id', ctrl.getById);
|
||||
router.post('/', requirePage('purchasing_partner'), ctrl.create);
|
||||
router.put('/:id', requirePage('purchasing_partner'), ctrl.update);
|
||||
router.delete('/:id', requirePage('purchasing_partner'), ctrl.deactivate);
|
||||
|
||||
router.get('/:id/workers', ctrl.listWorkers);
|
||||
router.post('/:id/workers', requirePage('purchasing_partner'), ctrl.createWorker);
|
||||
router.put('/workers/:id', requirePage('purchasing_partner'), ctrl.updateWorker);
|
||||
router.delete('/workers/:id', requirePage('purchasing_partner'), ctrl.deactivateWorker);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
16
tkpurchase/api/routes/scheduleRoutes.js
Normal file
16
tkpurchase/api/routes/scheduleRoutes.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth, requirePage } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/scheduleController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
router.get('/', ctrl.list);
|
||||
router.get('/my', ctrl.mySchedules); // partner portal
|
||||
router.get('/:id', ctrl.getById);
|
||||
router.post('/', requirePage('purchasing_schedule'), ctrl.create);
|
||||
router.put('/:id', requirePage('purchasing_schedule'), ctrl.update);
|
||||
router.put('/:id/status', requirePage('purchasing_schedule'), ctrl.updateStatus);
|
||||
router.delete('/:id', requirePage('purchasing_schedule'), ctrl.deleteSchedule);
|
||||
|
||||
module.exports = router;
|
||||
15
tkpurchase/api/routes/workReportRoutes.js
Normal file
15
tkpurchase/api/routes/workReportRoutes.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { requireAuth, requirePage } = require('../middleware/auth');
|
||||
const ctrl = require('../controllers/workReportController');
|
||||
|
||||
router.use(requireAuth);
|
||||
|
||||
router.get('/', ctrl.list);
|
||||
router.get('/my', ctrl.myReports); // partner portal
|
||||
router.get('/:id', ctrl.getById);
|
||||
router.post('/', ctrl.create); // partner can create
|
||||
router.put('/:id', ctrl.update);
|
||||
router.put('/:id/confirm', requirePage('purchasing_workreport'), ctrl.confirm);
|
||||
|
||||
module.exports = router;
|
||||
@@ -2,7 +2,11 @@ FROM nginx:alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY index.html /usr/share/nginx/html/index.html
|
||||
COPY partner.html /usr/share/nginx/html/partner.html
|
||||
COPY daylabor.html /usr/share/nginx/html/daylabor.html
|
||||
COPY schedule.html /usr/share/nginx/html/schedule.html
|
||||
COPY workreport.html /usr/share/nginx/html/workreport.html
|
||||
COPY accounts.html /usr/share/nginx/html/accounts.html
|
||||
COPY partner-portal.html /usr/share/nginx/html/partner-portal.html
|
||||
COPY static/ /usr/share/nginx/html/static/
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
137
tkpurchase/web/accounts.html
Normal file
137
tkpurchase/web/accounts.html
Normal file
@@ -0,0 +1,137 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>계정 관리 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="bg-emerald-700 text-white sticky top-0 z-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between items-center h-14">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-truck text-xl text-emerald-200"></i>
|
||||
<h1 class="text-lg font-semibold">TK 구매관리</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div id="headerUserName" class="text-sm font-medium hidden sm:block">-</div>
|
||||
<div id="headerUserAvatar" class="w-8 h-8 bg-emerald-600 rounded-full flex items-center justify-center text-sm font-semibold">-</div>
|
||||
<button onclick="doLogout()" class="text-emerald-200 hover:text-white" title="로그아웃"><i class="fas fa-sign-out-alt"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 fade-in">
|
||||
<div class="flex gap-6">
|
||||
<!-- Sidebar Nav -->
|
||||
<nav id="sideNav" class="hidden lg:flex flex-col gap-1 w-48 flex-shrink-0 pt-2"></nav>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex gap-5">
|
||||
<!-- 업체 목록 (왼쪽) -->
|
||||
<div class="w-64 flex-shrink-0">
|
||||
<div class="bg-white rounded-xl shadow-sm p-4">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-3">
|
||||
<i class="fas fa-building text-emerald-500 mr-2"></i>협력업체
|
||||
</h2>
|
||||
<input type="text" id="companyFilter" class="input-field w-full px-3 py-2 rounded-lg text-sm mb-3" placeholder="업체 검색..." oninput="filterCompanyList()">
|
||||
<div id="companyList" class="space-y-1 max-h-[60vh] overflow-y-auto">
|
||||
<p class="text-gray-400 text-center text-sm py-4">로딩 중...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정 목록 (오른쪽) -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-base font-semibold text-gray-800">
|
||||
<i class="fas fa-users text-blue-500 mr-2"></i>
|
||||
<span id="selectedCompanyName">업체를 선택하세요</span>
|
||||
</h2>
|
||||
<button id="addAccountBtn" onclick="openAddAccount()" class="hidden px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 font-medium">
|
||||
<i class="fas fa-user-plus mr-1"></i>계정 추가
|
||||
</button>
|
||||
</div>
|
||||
<div id="accountList">
|
||||
<p class="text-gray-400 text-center py-8 text-sm">왼쪽에서 업체를 선택하세요</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정 추가 모달 -->
|
||||
<div id="addAccountModal" class="hidden modal-overlay" onclick="if(event.target===this)closeAddAccount()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">계정 추가</h3>
|
||||
<button onclick="closeAddAccount()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="addAccountForm" onsubmit="submitAddAccount(event)">
|
||||
<div class="space-y-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">사용자 ID <span class="text-red-400">*</span></label>
|
||||
<input type="text" id="addUsername" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="로그인 ID" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비밀번호 <span class="text-red-400">*</span></label>
|
||||
<input type="password" id="addPassword" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="비밀번호" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">이름 <span class="text-red-400">*</span></label>
|
||||
<input type="text" id="addName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="담당자 이름" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">계정 만료일</label>
|
||||
<input type="date" id="addExpiresAt" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeAddAccount()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">추가</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정 수정 모달 -->
|
||||
<div id="editAccountModal" class="hidden modal-overlay" onclick="if(event.target===this)closeEditAccount()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">계정 수정</h3>
|
||||
<button onclick="closeEditAccount()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="editAccountForm" onsubmit="submitEditAccount(event)">
|
||||
<input type="hidden" id="editAccountId">
|
||||
<div class="space-y-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">이름</label>
|
||||
<input type="text" id="editName" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">계정 만료일</label>
|
||||
<input type="date" id="editExpiresAt" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeEditAccount()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">저장</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-accounts.js?v=20260312"></script>
|
||||
<script>initAccountsPage();</script>
|
||||
</body>
|
||||
</html>
|
||||
151
tkpurchase/web/daylabor.html
Normal file
151
tkpurchase/web/daylabor.html
Normal file
@@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>일용공 신청 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="bg-emerald-700 text-white sticky top-0 z-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between items-center h-14">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-truck text-xl text-emerald-200"></i>
|
||||
<h1 class="text-lg font-semibold">TK 구매관리</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div id="headerUserName" class="text-sm font-medium hidden sm:block">-</div>
|
||||
<div id="headerUserAvatar" class="w-8 h-8 bg-emerald-600 rounded-full flex items-center justify-center text-sm font-semibold">-</div>
|
||||
<button onclick="doLogout()" class="text-emerald-200 hover:text-white" title="로그아웃"><i class="fas fa-sign-out-alt"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 fade-in">
|
||||
<div class="flex gap-6">
|
||||
<!-- Sidebar Nav -->
|
||||
<nav id="sideNav" class="hidden lg:flex flex-col gap-1 w-48 flex-shrink-0 pt-2"></nav>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<!-- 필터 및 추가 버튼 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-4 mb-5">
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">시작일</label>
|
||||
<input type="date" id="filterDateFrom" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">종료일</label>
|
||||
<input type="date" id="filterDateTo" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">상태</label>
|
||||
<select id="filterStatus" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">전체</option>
|
||||
<option value="pending">대기</option>
|
||||
<option value="approved">승인</option>
|
||||
<option value="rejected">거절</option>
|
||||
<option value="completed">완료</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">부서</label>
|
||||
<select id="filterDepartment" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">전체</option>
|
||||
<option value="생산">생산</option>
|
||||
<option value="품질">품질</option>
|
||||
<option value="구매">구매</option>
|
||||
<option value="설계">설계</option>
|
||||
<option value="영업">영업</option>
|
||||
</select>
|
||||
</div>
|
||||
<button onclick="loadDayLabor()" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg text-sm hover:bg-gray-200">
|
||||
<i class="fas fa-search mr-1"></i>조회
|
||||
</button>
|
||||
<div class="flex-1"></div>
|
||||
<button onclick="openAddDayLabor()" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 font-medium">
|
||||
<i class="fas fa-plus mr-1"></i>일용공 신청
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 테이블 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">
|
||||
<i class="fas fa-hard-hat text-amber-500 mr-2"></i>일용공 신청 목록
|
||||
</h2>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="visit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>신청일</th>
|
||||
<th>작업일</th>
|
||||
<th>신청자</th>
|
||||
<th class="hide-mobile">부서</th>
|
||||
<th class="text-center">인원</th>
|
||||
<th>작업장</th>
|
||||
<th>상태</th>
|
||||
<th class="text-right">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dayLaborTableBody">
|
||||
<tr><td colspan="8" class="text-center text-gray-400 py-8">로딩 중...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- 페이지네이션 -->
|
||||
<div id="dayLaborPagination" class="flex justify-center items-center gap-2 mt-4"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 신청 모달 -->
|
||||
<div id="addDayLaborModal" class="hidden modal-overlay" onclick="if(event.target===this)closeAddDayLabor()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">일용공 신청</h3>
|
||||
<button onclick="closeAddDayLabor()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="addDayLaborForm" onsubmit="submitAddDayLabor(event)">
|
||||
<div class="space-y-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업일 <span class="text-red-400">*</span></label>
|
||||
<input type="date" id="addWorkDate" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">인원 <span class="text-red-400">*</span></label>
|
||||
<input type="number" id="addWorkerCount" min="1" value="1" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업내용</label>
|
||||
<textarea id="addWorkDescription" rows="3" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="작업 내용을 입력하세요"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업장</label>
|
||||
<input type="text" id="addWorkplaceName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="작업 장소">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비고</label>
|
||||
<textarea id="addNotes" rows="2" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="추가 사항"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeAddDayLabor()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">신청</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-daylabor.js?v=20260312"></script>
|
||||
<script>initDayLaborPage();</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>방문 관리 - TK 구매관리</title>
|
||||
<title>대시보드 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
@@ -36,231 +36,57 @@
|
||||
<!-- 통계 카드 -->
|
||||
<div class="grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-emerald-600" id="statTotal">0</div>
|
||||
<div class="stat-label">오늘 방문</div>
|
||||
<div class="stat-value text-amber-600" id="statPending">0</div>
|
||||
<div class="stat-label">일용공 신청</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-blue-600" id="statCheckedIn">0</div>
|
||||
<div class="stat-value text-blue-600" id="statSchedules">0</div>
|
||||
<div class="stat-label">오늘 일정</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-red-600" id="statUnconfirmed">0</div>
|
||||
<div class="stat-label">미확인 업무현황</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-emerald-600" id="statCheckins">0</div>
|
||||
<div class="stat-label">체크인 중</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-gray-600" id="statCheckedOut">0</div>
|
||||
<div class="stat-label">체크아웃</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value text-purple-600" id="statVisitors">0</div>
|
||||
<div class="stat-label">총 인원</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 빠른 등록 폼 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5 mb-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4"><i class="fas fa-plus-circle text-emerald-500 mr-2"></i>방문 등록</h2>
|
||||
<form id="visitForm">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
<!-- 업체 -->
|
||||
<div class="sm:col-span-2 relative">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">업체</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex-1 relative">
|
||||
<input type="text" id="companySearch" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="업체명 검색...">
|
||||
<div id="companyDropdown" class="hidden absolute z-10 w-full mt-1 bg-white border rounded-lg shadow-lg max-h-48 overflow-y-auto"></div>
|
||||
</div>
|
||||
<div class="hidden flex-1">
|
||||
<input type="text" id="manualCompanyName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="업체명 직접입력">
|
||||
</div>
|
||||
<label class="flex items-center gap-1 text-xs text-gray-500 whitespace-nowrap cursor-pointer">
|
||||
<input type="checkbox" id="manualCompanyToggle" class="rounded">
|
||||
<span>직접입력</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 방문자명 -->
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">방문자명 <span class="text-red-400">*</span></label>
|
||||
<input type="text" id="visitorName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="대표 방문자" required>
|
||||
</div>
|
||||
<!-- 인원 -->
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">인원</label>
|
||||
<div class="flex items-center gap-1">
|
||||
<button type="button" id="countMinus" class="w-9 h-9 flex items-center justify-center border rounded-lg hover:bg-gray-50 text-gray-600"><i class="fas fa-minus text-xs"></i></button>
|
||||
<input type="number" id="visitorCount" value="1" min="1" class="input-field w-14 text-center px-1 py-2 rounded-lg text-sm">
|
||||
<button type="button" id="countPlus" class="w-9 h-9 flex items-center justify-center border rounded-lg hover:bg-gray-50 text-gray-600"><i class="fas fa-plus text-xs"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 목적 -->
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">방문 목적 <span class="text-red-400">*</span></label>
|
||||
<select id="visitPurpose" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
<option value="">선택</option>
|
||||
<option value="day_labor">일용공</option>
|
||||
<option value="equipment_repair">설비수리</option>
|
||||
<option value="inspection">검사</option>
|
||||
<option value="delivery">납품/배송</option>
|
||||
<option value="safety_audit">안전점검</option>
|
||||
<option value="client_audit">고객심사</option>
|
||||
<option value="construction">공사</option>
|
||||
<option value="other">기타</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- 작업장 -->
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업장</label>
|
||||
<input type="text" id="workplaceName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="작업장소">
|
||||
</div>
|
||||
<!-- 안전교육 -->
|
||||
<div class="flex items-end pb-1">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" id="safetyCheck" class="h-5 w-5 text-emerald-500 rounded border-gray-300">
|
||||
<span class="text-sm text-gray-700">안전교육 이수</span>
|
||||
</label>
|
||||
</div>
|
||||
<!-- 목적 상세 -->
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">목적 상세</label>
|
||||
<input type="text" id="purposeDetail" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="상세 내용">
|
||||
</div>
|
||||
<!-- 두 컬럼 레이아웃 -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5">
|
||||
<!-- 최근 일용공 신청 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-base font-semibold text-gray-800">
|
||||
<i class="fas fa-hard-hat text-amber-500 mr-2"></i>최근 일용공 신청
|
||||
</h2>
|
||||
<a href="/daylabor.html" class="text-xs text-emerald-600 hover:text-emerald-700 font-medium">전체보기 →</a>
|
||||
</div>
|
||||
|
||||
<!-- 추가 정보 (접이식) -->
|
||||
<div class="mt-3">
|
||||
<button type="button" onclick="toggleExtra()" class="text-sm text-gray-500 hover:text-gray-700 flex items-center gap-1">
|
||||
<i id="extraToggleIcon" class="fas fa-chevron-down text-xs"></i>추가 정보
|
||||
</button>
|
||||
<div id="extraFields" class="collapsible-content">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3 mt-2">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">차량번호</label>
|
||||
<input type="text" id="vehicleNumber" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="12가 3456">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">담당부서</label>
|
||||
<select id="managingDept" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">선택</option>
|
||||
<option value="생산">생산</option>
|
||||
<option value="품질">품질</option>
|
||||
<option value="구매">구매</option>
|
||||
<option value="설계">설계</option>
|
||||
<option value="영업">영업</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비고</label>
|
||||
<input type="text" id="visitNotes" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="메모">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end mt-4">
|
||||
<button type="submit" class="px-6 py-2.5 bg-emerald-600 text-white rounded-lg hover:bg-emerald-700 text-sm font-medium">
|
||||
<i class="fas fa-check mr-2"></i>등록
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 오늘 방문 현황 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-base font-semibold text-gray-800"><i class="fas fa-list text-emerald-500 mr-2"></i>오늘 방문 현황</h2>
|
||||
<div class="flex gap-2">
|
||||
<button onclick="exportVisits()" class="text-xs text-gray-500 hover:text-gray-700 border px-3 py-1.5 rounded-lg hover:bg-gray-50">
|
||||
<i class="fas fa-download mr-1"></i>CSV
|
||||
</button>
|
||||
<button onclick="doBulkCheckout()" class="text-xs text-blue-600 hover:text-blue-800 border border-blue-200 px-3 py-1.5 rounded-lg hover:bg-blue-50">
|
||||
<i class="fas fa-check-double mr-1"></i>전체 마감
|
||||
</button>
|
||||
<div id="recentDayLabor" class="space-y-2">
|
||||
<p class="text-gray-400 text-center py-4 text-sm">로딩 중...</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="visit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>업체</th>
|
||||
<th>방문자</th>
|
||||
<th class="text-center">인원</th>
|
||||
<th>목적</th>
|
||||
<th class="hide-mobile">안전교육</th>
|
||||
<th>체크인</th>
|
||||
<th>상태</th>
|
||||
<th class="text-right">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="visitTableBody">
|
||||
<tr><td colspan="8" class="text-center text-gray-400 py-8">로딩 중...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 오늘 협력업체 일정 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-base font-semibold text-gray-800">
|
||||
<i class="fas fa-calendar-day text-blue-500 mr-2"></i>오늘 협력업체 일정
|
||||
</h2>
|
||||
<a href="/schedule.html" class="text-xs text-emerald-600 hover:text-emerald-700 font-medium">전체보기 →</a>
|
||||
</div>
|
||||
<div id="todaySchedules" class="space-y-2">
|
||||
<p class="text-gray-400 text-center py-4 text-sm">로딩 중...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 수정 모달 -->
|
||||
<div id="editVisitModal" class="hidden modal-overlay" onclick="if(event.target===this)closeEditVisit()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">방문 수정</h3>
|
||||
<button onclick="closeEditVisit()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="editVisitForm">
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">방문자명</label>
|
||||
<input type="text" id="editVisitorName" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">인원</label>
|
||||
<input type="number" id="editVisitorCount" min="1" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">목적</label>
|
||||
<select id="editPurpose" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
<option value="day_labor">일용공</option>
|
||||
<option value="equipment_repair">설비수리</option>
|
||||
<option value="inspection">검사</option>
|
||||
<option value="delivery">납품/배송</option>
|
||||
<option value="safety_audit">안전점검</option>
|
||||
<option value="client_audit">고객심사</option>
|
||||
<option value="construction">공사</option>
|
||||
<option value="other">기타</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">목적 상세</label>
|
||||
<input type="text" id="editPurposeDetail" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업장</label>
|
||||
<input type="text" id="editWorkplace" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">차량번호</label>
|
||||
<input type="text" id="editVehicle" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div class="flex items-end pb-1">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" id="editSafetyCheck" class="h-5 w-5 text-emerald-500 rounded">
|
||||
<span class="text-sm">안전교육 이수</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비고</label>
|
||||
<input type="text" id="editNotes" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeEditVisit()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">저장</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-visit.js?v=20260312"></script>
|
||||
<script>initVisitPage();</script>
|
||||
<script src="/static/js/tkpurchase-dashboard.js?v=20260312"></script>
|
||||
<script>initDashboard();</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
59
tkpurchase/web/partner-portal.html
Normal file
59
tkpurchase/web/partner-portal.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>협력업체 포털 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="bg-emerald-700 text-white sticky top-0 z-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between items-center h-14">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-truck text-xl text-emerald-200"></i>
|
||||
<h1 class="text-lg font-semibold">TK 구매관리</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div id="headerUserName" class="text-sm font-medium hidden sm:block">-</div>
|
||||
<div id="headerUserAvatar" class="w-8 h-8 bg-emerald-600 rounded-full flex items-center justify-center text-sm font-semibold">-</div>
|
||||
<button onclick="doLogout()" class="text-emerald-200 hover:text-white" title="로그아웃"><i class="fas fa-sign-out-alt"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-4 fade-in">
|
||||
<!-- 환영 메시지 -->
|
||||
<div class="bg-emerald-50 rounded-xl p-5 mb-5">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-12 h-12 bg-emerald-100 rounded-full flex items-center justify-center">
|
||||
<i class="fas fa-building text-emerald-600 text-xl"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-emerald-800" id="welcomeCompanyName">-</h2>
|
||||
<p class="text-sm text-emerald-600">오늘의 작업 일정을 확인하고 업무현황을 입력해주세요.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 오늘 일정 카드 -->
|
||||
<div id="scheduleCards" class="space-y-4">
|
||||
<p class="text-gray-400 text-center py-8 text-sm">로딩 중...</p>
|
||||
</div>
|
||||
|
||||
<!-- 일정 없을 때 -->
|
||||
<div id="noScheduleMessage" class="hidden bg-white rounded-xl shadow-sm p-8 text-center">
|
||||
<i class="fas fa-calendar-times text-gray-300 text-4xl mb-3"></i>
|
||||
<p class="text-gray-500">오늘 예정된 작업 일정이 없습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-partner-portal.js?v=20260312"></script>
|
||||
<script>initPartnerPortal();</script>
|
||||
</body>
|
||||
</html>
|
||||
193
tkpurchase/web/schedule.html
Normal file
193
tkpurchase/web/schedule.html
Normal file
@@ -0,0 +1,193 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>작업일정 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="bg-emerald-700 text-white sticky top-0 z-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between items-center h-14">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-truck text-xl text-emerald-200"></i>
|
||||
<h1 class="text-lg font-semibold">TK 구매관리</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div id="headerUserName" class="text-sm font-medium hidden sm:block">-</div>
|
||||
<div id="headerUserAvatar" class="w-8 h-8 bg-emerald-600 rounded-full flex items-center justify-center text-sm font-semibold">-</div>
|
||||
<button onclick="doLogout()" class="text-emerald-200 hover:text-white" title="로그아웃"><i class="fas fa-sign-out-alt"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 fade-in">
|
||||
<div class="flex gap-6">
|
||||
<!-- Sidebar Nav -->
|
||||
<nav id="sideNav" class="hidden lg:flex flex-col gap-1 w-48 flex-shrink-0 pt-2"></nav>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<!-- 필터 및 추가 버튼 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-4 mb-5">
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">업체 검색</label>
|
||||
<input type="text" id="filterCompany" class="input-field px-3 py-2 rounded-lg text-sm" placeholder="업체명">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">시작일</label>
|
||||
<input type="date" id="filterDateFrom" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">종료일</label>
|
||||
<input type="date" id="filterDateTo" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">상태</label>
|
||||
<select id="filterStatus" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">전체</option>
|
||||
<option value="scheduled">예정</option>
|
||||
<option value="in_progress">진행중</option>
|
||||
<option value="completed">완료</option>
|
||||
<option value="cancelled">취소</option>
|
||||
</select>
|
||||
</div>
|
||||
<button onclick="loadSchedules()" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg text-sm hover:bg-gray-200">
|
||||
<i class="fas fa-search mr-1"></i>조회
|
||||
</button>
|
||||
<div class="flex-1"></div>
|
||||
<button onclick="openAddSchedule()" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 font-medium">
|
||||
<i class="fas fa-plus mr-1"></i>일정 등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 테이블 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">
|
||||
<i class="fas fa-calendar-alt text-blue-500 mr-2"></i>작업일정 목록
|
||||
</h2>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="visit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>업체</th>
|
||||
<th>작업일</th>
|
||||
<th>작업내용</th>
|
||||
<th class="hide-mobile">작업장</th>
|
||||
<th class="text-center">예상인원</th>
|
||||
<th>상태</th>
|
||||
<th class="text-right">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="scheduleTableBody">
|
||||
<tr><td colspan="7" class="text-center text-gray-400 py-8">로딩 중...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="schedulePagination" class="flex justify-center items-center gap-2 mt-4"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 등록 모달 -->
|
||||
<div id="addScheduleModal" class="hidden modal-overlay" onclick="if(event.target===this)closeAddSchedule()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">일정 등록</h3>
|
||||
<button onclick="closeAddSchedule()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="addScheduleForm" onsubmit="submitAddSchedule(event)">
|
||||
<div class="space-y-3">
|
||||
<div class="relative">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">업체 <span class="text-red-400">*</span></label>
|
||||
<input type="text" id="addCompanySearch" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="업체명 검색..." autocomplete="off">
|
||||
<input type="hidden" id="addCompanyId">
|
||||
<div id="addCompanyDropdown" class="hidden absolute z-10 w-full mt-1 bg-white border rounded-lg shadow-lg max-h-48 overflow-y-auto"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업일 <span class="text-red-400">*</span></label>
|
||||
<input type="date" id="addWorkDate" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업내용</label>
|
||||
<textarea id="addWorkDescription" rows="3" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="작업 내용"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업장</label>
|
||||
<input type="text" id="addWorkplaceName" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="작업 장소">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">예상인원</label>
|
||||
<input type="number" id="addExpectedWorkers" min="0" value="0" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비고</label>
|
||||
<textarea id="addNotes" rows="2" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="추가 사항"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeAddSchedule()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">등록</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 수정 모달 -->
|
||||
<div id="editScheduleModal" class="hidden modal-overlay" onclick="if(event.target===this)closeEditSchedule()">
|
||||
<div class="modal-content p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-semibold">일정 수정</h3>
|
||||
<button onclick="closeEditSchedule()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<form id="editScheduleForm" onsubmit="submitEditSchedule(event)">
|
||||
<input type="hidden" id="editScheduleId">
|
||||
<div class="space-y-3">
|
||||
<div class="relative">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">업체 <span class="text-red-400">*</span></label>
|
||||
<input type="text" id="editCompanySearch" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="업체명 검색..." autocomplete="off">
|
||||
<input type="hidden" id="editCompanyId">
|
||||
<div id="editCompanyDropdown" class="hidden absolute z-10 w-full mt-1 bg-white border rounded-lg shadow-lg max-h-48 overflow-y-auto"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업일 <span class="text-red-400">*</span></label>
|
||||
<input type="date" id="editWorkDate" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업내용</label>
|
||||
<textarea id="editWorkDescription" rows="3" class="input-field w-full px-3 py-2 rounded-lg text-sm"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업장</label>
|
||||
<input type="text" id="editWorkplaceName" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">예상인원</label>
|
||||
<input type="number" id="editExpectedWorkers" min="0" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">비고</label>
|
||||
<textarea id="editNotes" rows="2" class="input-field w-full px-3 py-2 rounded-lg text-sm"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-4 gap-2">
|
||||
<button type="button" onclick="closeEditSchedule()" class="px-4 py-2 border rounded-lg text-sm hover:bg-gray-50">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">저장</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-schedule.js?v=20260312"></script>
|
||||
<script>initSchedulePage();</script>
|
||||
</body>
|
||||
</html>
|
||||
184
tkpurchase/web/static/js/tkpurchase-accounts.js
Normal file
184
tkpurchase/web/static/js/tkpurchase-accounts.js
Normal file
@@ -0,0 +1,184 @@
|
||||
/* tkpurchase-accounts.js - Partner account management */
|
||||
|
||||
let allCompanies = [];
|
||||
let selectedCompanyId = null;
|
||||
|
||||
async function loadCompaniesForAccounts() {
|
||||
try {
|
||||
const r = await api('/partners?limit=200');
|
||||
allCompanies = r.data || [];
|
||||
renderCompanyList(allCompanies);
|
||||
} catch(e) {
|
||||
console.warn('Load companies error:', e);
|
||||
document.getElementById('companyList').innerHTML = '<p class="text-red-400 text-center text-sm py-4">로딩 실패</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function renderCompanyList(list) {
|
||||
const container = document.getElementById('companyList');
|
||||
if (!list.length) {
|
||||
container.innerHTML = '<p class="text-gray-400 text-center text-sm py-4">등록된 업체가 없습니다</p>';
|
||||
return;
|
||||
}
|
||||
container.innerHTML = list.map(c => {
|
||||
const active = c.id === selectedCompanyId;
|
||||
return `<button onclick="selectCompanyForAccounts(${c.id})" class="w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${active ? 'bg-emerald-50 text-emerald-700 font-medium' : 'text-gray-700 hover:bg-gray-50'}">
|
||||
<i class="fas fa-building mr-2 ${active ? 'text-emerald-500' : 'text-gray-400'}"></i>${escapeHtml(c.name)}
|
||||
</button>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function filterCompanyList() {
|
||||
const q = document.getElementById('companyFilter').value.trim().toLowerCase();
|
||||
const filtered = q ? allCompanies.filter(c => (c.name || '').toLowerCase().includes(q)) : allCompanies;
|
||||
renderCompanyList(filtered);
|
||||
}
|
||||
|
||||
async function selectCompanyForAccounts(id) {
|
||||
selectedCompanyId = id;
|
||||
const company = allCompanies.find(c => c.id === id);
|
||||
document.getElementById('selectedCompanyName').textContent = company ? company.name + ' - 계정 목록' : '계정 목록';
|
||||
document.getElementById('addAccountBtn').classList.remove('hidden');
|
||||
|
||||
// Re-render company list to highlight selection
|
||||
filterCompanyList();
|
||||
|
||||
// Load accounts
|
||||
try {
|
||||
const r = await api('/partners/' + id + '/accounts');
|
||||
renderAccountList(r.data || []);
|
||||
} catch(e) {
|
||||
console.warn('Load accounts error:', e);
|
||||
document.getElementById('accountList').innerHTML = '<p class="text-red-400 text-center py-4 text-sm">계정 로딩 실패</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function renderAccountList(list) {
|
||||
const container = document.getElementById('accountList');
|
||||
if (!list.length) {
|
||||
container.innerHTML = '<p class="text-gray-400 text-center py-8 text-sm">등록된 계정이 없습니다</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = `<div class="space-y-3">${list.map(a => {
|
||||
const isExpired = a.account_expires_at && new Date(a.account_expires_at) < new Date();
|
||||
const statusBadge = !a.is_active
|
||||
? '<span class="badge badge-gray">비활성</span>'
|
||||
: isExpired
|
||||
? '<span class="badge badge-red">만료</span>'
|
||||
: '<span class="badge badge-green">활성</span>';
|
||||
|
||||
return `<div class="border rounded-lg p-4 ${!a.is_active ? 'bg-gray-50 opacity-60' : ''}">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 bg-emerald-100 rounded-full flex items-center justify-center text-emerald-700 font-semibold">
|
||||
${(a.name || a.username || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-800">${escapeHtml(a.name || '')}</div>
|
||||
<div class="text-xs text-gray-500">${escapeHtml(a.username || '')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
${statusBadge}
|
||||
<button onclick="openEditAccount(${a.id}, '${escapeHtml(a.name || '')}', '${a.account_expires_at ? formatDate(a.account_expires_at) : ''}')" class="text-blue-600 hover:text-blue-800 text-xs p-1" title="수정">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
${a.is_active ? `<button onclick="deactivateAccount(${a.id})" class="text-red-500 hover:text-red-700 text-xs p-1" title="비활성화">
|
||||
<i class="fas fa-user-slash"></i>
|
||||
</button>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 flex gap-4 text-xs text-gray-500">
|
||||
<span><i class="fas fa-calendar mr-1"></i>만료: ${a.account_expires_at ? formatDate(a.account_expires_at) : '무기한'}</span>
|
||||
${a.last_login_at ? `<span><i class="fas fa-sign-in-alt mr-1"></i>최근 로그인: ${formatDateTime(a.last_login_at)}</span>` : ''}
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('')}</div>`;
|
||||
}
|
||||
|
||||
/* ===== Add Account ===== */
|
||||
function openAddAccount() {
|
||||
if (!selectedCompanyId) { showToast('업체를 먼저 선택하세요', 'error'); return; }
|
||||
document.getElementById('addAccountForm').reset();
|
||||
// Default expiration: 1 year from now
|
||||
const oneYear = new Date();
|
||||
oneYear.setFullYear(oneYear.getFullYear() + 1);
|
||||
document.getElementById('addExpiresAt').value = oneYear.toISOString().substring(0, 10);
|
||||
document.getElementById('addAccountModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeAddAccount() {
|
||||
document.getElementById('addAccountModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async function submitAddAccount(e) {
|
||||
e.preventDefault();
|
||||
const body = {
|
||||
username: document.getElementById('addUsername').value.trim(),
|
||||
password: document.getElementById('addPassword').value,
|
||||
name: document.getElementById('addName').value.trim(),
|
||||
account_expires_at: document.getElementById('addExpiresAt').value || null
|
||||
};
|
||||
if (!body.username || !body.password || !body.name) {
|
||||
showToast('필수 항목을 입력하세요', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api('/partners/' + selectedCompanyId + '/accounts', { method: 'POST', body: JSON.stringify(body) });
|
||||
showToast('계정이 추가되었습니다');
|
||||
closeAddAccount();
|
||||
selectCompanyForAccounts(selectedCompanyId);
|
||||
} catch(e) {
|
||||
showToast(e.message || '계정 추가 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Edit Account ===== */
|
||||
function openEditAccount(id, name, expiresAt) {
|
||||
document.getElementById('editAccountId').value = id;
|
||||
document.getElementById('editName').value = name;
|
||||
document.getElementById('editExpiresAt').value = expiresAt;
|
||||
document.getElementById('editAccountModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeEditAccount() {
|
||||
document.getElementById('editAccountModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async function submitEditAccount(e) {
|
||||
e.preventDefault();
|
||||
const id = document.getElementById('editAccountId').value;
|
||||
const body = {
|
||||
name: document.getElementById('editName').value.trim(),
|
||||
account_expires_at: document.getElementById('editExpiresAt').value || null
|
||||
};
|
||||
|
||||
try {
|
||||
await api('/partners/' + selectedCompanyId + '/accounts/' + id, { method: 'PUT', body: JSON.stringify(body) });
|
||||
showToast('계정이 수정되었습니다');
|
||||
closeEditAccount();
|
||||
selectCompanyForAccounts(selectedCompanyId);
|
||||
} catch(e) {
|
||||
showToast(e.message || '수정 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Deactivate Account ===== */
|
||||
async function deactivateAccount(id) {
|
||||
if (!confirm('이 계정을 비활성화하시겠습니까?')) return;
|
||||
try {
|
||||
await api('/partners/' + selectedCompanyId + '/accounts/' + id + '/deactivate', { method: 'PUT' });
|
||||
showToast('계정이 비활성화되었습니다');
|
||||
selectCompanyForAccounts(selectedCompanyId);
|
||||
} catch(e) {
|
||||
showToast(e.message || '비활성화 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Init ===== */
|
||||
function initAccountsPage() {
|
||||
if (!initAuth()) return;
|
||||
loadCompaniesForAccounts();
|
||||
}
|
||||
@@ -70,6 +70,9 @@ function statusBadge(s) {
|
||||
const [cls, label] = m[s] || ['badge-gray', s];
|
||||
return `<span class="badge ${cls}">${label}</span>`;
|
||||
}
|
||||
function debounce(fn, ms) {
|
||||
let t; return function(...args) { clearTimeout(t); t = setTimeout(() => fn.apply(this, args), ms); };
|
||||
}
|
||||
|
||||
/* ===== Logout ===== */
|
||||
function doLogout() {
|
||||
@@ -83,8 +86,11 @@ function doLogout() {
|
||||
function renderNavbar() {
|
||||
const currentPage = location.pathname.replace(/\//g, '') || 'index.html';
|
||||
const links = [
|
||||
{ href: '/', icon: 'fa-door-open', label: '방문 관리', match: ['', 'index.html'] },
|
||||
{ href: '/partner.html', icon: 'fa-building', label: '협력업체', match: ['partner.html'] },
|
||||
{ href: '/', icon: 'fa-chart-line', label: '대시보드', match: ['', 'index.html'] },
|
||||
{ href: '/daylabor.html', icon: 'fa-hard-hat', label: '일용공 신청', match: ['daylabor.html'] },
|
||||
{ href: '/schedule.html', icon: 'fa-calendar-alt', label: '작업일정', match: ['schedule.html'] },
|
||||
{ href: '/workreport.html', icon: 'fa-clipboard-list', label: '업무현황', match: ['workreport.html'] },
|
||||
{ href: '/accounts.html', icon: 'fa-user-shield', label: '계정 관리', match: ['accounts.html'] },
|
||||
];
|
||||
const nav = document.getElementById('sideNav');
|
||||
if (!nav) return;
|
||||
@@ -110,8 +116,16 @@ function initAuth() {
|
||||
id: decoded.user_id || decoded.id,
|
||||
username: decoded.username || decoded.sub,
|
||||
name: decoded.name || decoded.full_name,
|
||||
role: (decoded.role || decoded.access_level || '').toLowerCase()
|
||||
role: (decoded.role || decoded.access_level || '').toLowerCase(),
|
||||
partner_company_id: decoded.partner_company_id || null,
|
||||
department_id: decoded.department_id || null
|
||||
};
|
||||
// 협력업체 계정 → partner-portal로 분기
|
||||
if (currentUser.partner_company_id && !location.pathname.includes('partner-portal')) {
|
||||
location.href = '/partner-portal.html';
|
||||
return false;
|
||||
}
|
||||
|
||||
const dn = currentUser.name || currentUser.username;
|
||||
const nameEl = document.getElementById('headerUserName');
|
||||
const avatarEl = document.getElementById('headerUserAvatar');
|
||||
|
||||
81
tkpurchase/web/static/js/tkpurchase-dashboard.js
Normal file
81
tkpurchase/web/static/js/tkpurchase-dashboard.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/* tkpurchase-dashboard.js - Dashboard logic */
|
||||
|
||||
async function loadDashboardStats() {
|
||||
try {
|
||||
const [dlStats, schedules, reports] = await Promise.all([
|
||||
api('/day-labor/stats'),
|
||||
api('/schedules?date_from=' + todayStr() + '&date_to=' + todayStr()),
|
||||
api('/work-reports?confirmed=false&page=1&limit=5')
|
||||
]);
|
||||
// Update stat cards
|
||||
const pending = (dlStats.data || []).find(s => s.status === 'pending');
|
||||
document.getElementById('statPending').textContent = pending ? pending.cnt : 0;
|
||||
document.getElementById('statSchedules').textContent = (schedules.data || []).length;
|
||||
document.getElementById('statUnconfirmed').textContent = (reports.data || []).length;
|
||||
} catch(e) { console.warn('Dashboard stats error:', e); }
|
||||
|
||||
// Load active checkins count separately
|
||||
try {
|
||||
const checkins = await api('/checkins?status=checked_in&page=1&limit=1');
|
||||
document.getElementById('statCheckins').textContent = checkins.total || 0;
|
||||
} catch(e) { console.warn('Checkins stat error:', e); }
|
||||
}
|
||||
|
||||
async function loadRecentDayLabor() {
|
||||
try {
|
||||
const r = await api('/day-labor?page=1&limit=5');
|
||||
const list = r.data || [];
|
||||
const c = document.getElementById('recentDayLabor');
|
||||
if (!list.length) { c.innerHTML = '<p class="text-gray-400 text-center py-4 text-sm">신청 내역이 없습니다</p>'; return; }
|
||||
const statusMap = { pending: ['bg-amber-50 text-amber-600', '대기'], approved: ['bg-emerald-50 text-emerald-600', '승인'], rejected: ['bg-red-50 text-red-600', '거절'], completed: ['bg-gray-100 text-gray-500', '완료'] };
|
||||
c.innerHTML = list.map(d => {
|
||||
const [cls, label] = statusMap[d.status] || ['bg-gray-100 text-gray-500', d.status];
|
||||
return `<div class="p-3 bg-gray-50 rounded-lg">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm font-medium">${formatDate(d.work_date)}</span>
|
||||
<span class="px-2 py-0.5 rounded text-xs ${cls}">${label}</span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-1">${escapeHtml(d.requester_name || '')} · ${d.worker_count}명 · ${escapeHtml(d.workplace_name || '')}</div>
|
||||
${d.work_description ? `<div class="text-xs text-gray-400 mt-0.5 truncate">${escapeHtml(d.work_description)}</div>` : ''}
|
||||
</div>`;
|
||||
}).join('');
|
||||
} catch(e) { console.warn(e); }
|
||||
}
|
||||
|
||||
async function loadTodaySchedules() {
|
||||
try {
|
||||
const today = todayStr();
|
||||
const r = await api('/schedules?date_from=' + today + '&date_to=' + today);
|
||||
const list = r.data || [];
|
||||
const c = document.getElementById('todaySchedules');
|
||||
if (!list.length) { c.innerHTML = '<p class="text-gray-400 text-center py-4 text-sm">오늘 일정이 없습니다</p>'; return; }
|
||||
const statusMap = { scheduled: ['badge-amber', '예정'], in_progress: ['badge-green', '진행중'], completed: ['badge-blue', '완료'], cancelled: ['badge-gray', '취소'] };
|
||||
c.innerHTML = list.map(s => {
|
||||
const [cls, label] = statusMap[s.status] || ['badge-gray', s.status];
|
||||
return `<div class="p-3 bg-gray-50 rounded-lg">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm font-medium">${escapeHtml(s.company_name || '')}</span>
|
||||
<span class="badge ${cls}">${label}</span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-1">${escapeHtml(s.workplace_name || '')} · ${s.expected_workers || 0}명</div>
|
||||
${s.work_description ? `<div class="text-xs text-gray-400 mt-0.5 truncate">${escapeHtml(s.work_description)}</div>` : ''}
|
||||
</div>`;
|
||||
}).join('');
|
||||
} catch(e) { console.warn(e); }
|
||||
}
|
||||
|
||||
function todayStr() { return new Date().toISOString().substring(0, 10); }
|
||||
|
||||
function initDashboard() {
|
||||
if (!initAuth()) return;
|
||||
// If partner account, redirect to portal
|
||||
const token = getToken();
|
||||
const decoded = decodeToken(token);
|
||||
if (decoded && decoded.partner_company_id) {
|
||||
location.href = '/partner-portal.html';
|
||||
return;
|
||||
}
|
||||
loadDashboardStats();
|
||||
loadRecentDayLabor();
|
||||
loadTodaySchedules();
|
||||
}
|
||||
173
tkpurchase/web/static/js/tkpurchase-daylabor.js
Normal file
173
tkpurchase/web/static/js/tkpurchase-daylabor.js
Normal file
@@ -0,0 +1,173 @@
|
||||
/* tkpurchase-daylabor.js - Day labor management */
|
||||
|
||||
let dayLaborPage = 1;
|
||||
const dayLaborLimit = 20;
|
||||
|
||||
async function loadDayLabor() {
|
||||
const dateFrom = document.getElementById('filterDateFrom').value;
|
||||
const dateTo = document.getElementById('filterDateTo').value;
|
||||
const status = document.getElementById('filterStatus').value;
|
||||
const department = document.getElementById('filterDepartment').value;
|
||||
|
||||
let query = `?page=${dayLaborPage}&limit=${dayLaborLimit}`;
|
||||
if (dateFrom) query += '&date_from=' + dateFrom;
|
||||
if (dateTo) query += '&date_to=' + dateTo;
|
||||
if (status) query += '&status=' + status;
|
||||
if (department) query += '&department=' + encodeURIComponent(department);
|
||||
|
||||
try {
|
||||
const r = await api('/day-labor' + query);
|
||||
renderDayLaborTable(r.data || [], r.total || 0);
|
||||
} catch(e) {
|
||||
console.warn('Day labor load error:', e);
|
||||
document.getElementById('dayLaborTableBody').innerHTML = '<tr><td colspan="8" class="text-center text-red-400 py-8">로딩 실패</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
function renderDayLaborTable(list, total) {
|
||||
const tbody = document.getElementById('dayLaborTableBody');
|
||||
if (!list.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="8" class="text-center text-gray-400 py-8">신청 내역이 없습니다</td></tr>';
|
||||
document.getElementById('dayLaborPagination').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const statusMap = {
|
||||
pending: ['badge-amber', '대기'],
|
||||
approved: ['badge-green', '승인'],
|
||||
rejected: ['badge-red', '거절'],
|
||||
completed: ['badge-gray', '완료']
|
||||
};
|
||||
|
||||
tbody.innerHTML = list.map(d => {
|
||||
const [cls, label] = statusMap[d.status] || ['badge-gray', d.status];
|
||||
let actions = '';
|
||||
if (d.status === 'pending') {
|
||||
actions = `
|
||||
<button onclick="approveDayLabor(${d.id})" class="text-emerald-600 hover:text-emerald-800 text-xs mr-1" title="승인"><i class="fas fa-check"></i></button>
|
||||
<button onclick="rejectDayLabor(${d.id})" class="text-red-500 hover:text-red-700 text-xs" title="거절"><i class="fas fa-times"></i></button>`;
|
||||
} else if (d.status === 'approved') {
|
||||
actions = `<button onclick="completeDayLabor(${d.id})" class="text-blue-600 hover:text-blue-800 text-xs" title="완료"><i class="fas fa-check-double"></i></button>`;
|
||||
}
|
||||
return `<tr>
|
||||
<td>${formatDate(d.created_at)}</td>
|
||||
<td class="font-medium">${formatDate(d.work_date)}</td>
|
||||
<td>${escapeHtml(d.requester_name || '')}</td>
|
||||
<td class="hide-mobile">${escapeHtml(d.department || '')}</td>
|
||||
<td class="text-center">${d.worker_count || 0}명</td>
|
||||
<td>${escapeHtml(d.workplace_name || '')}</td>
|
||||
<td><span class="badge ${cls}">${label}</span></td>
|
||||
<td class="text-right">${actions}</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
|
||||
// Pagination
|
||||
const totalPages = Math.ceil(total / dayLaborLimit);
|
||||
renderDayLaborPagination(totalPages);
|
||||
}
|
||||
|
||||
function renderDayLaborPagination(totalPages) {
|
||||
const container = document.getElementById('dayLaborPagination');
|
||||
if (totalPages <= 1) { container.innerHTML = ''; return; }
|
||||
|
||||
let html = '';
|
||||
if (dayLaborPage > 1) {
|
||||
html += `<button onclick="goToDayLaborPage(${dayLaborPage - 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">«</button>`;
|
||||
}
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i === dayLaborPage) {
|
||||
html += `<button class="px-3 py-1 bg-emerald-600 text-white rounded text-sm">${i}</button>`;
|
||||
} else if (Math.abs(i - dayLaborPage) <= 2 || i === 1 || i === totalPages) {
|
||||
html += `<button onclick="goToDayLaborPage(${i})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">${i}</button>`;
|
||||
} else if (Math.abs(i - dayLaborPage) === 3) {
|
||||
html += '<span class="text-gray-400">...</span>';
|
||||
}
|
||||
}
|
||||
if (dayLaborPage < totalPages) {
|
||||
html += `<button onclick="goToDayLaborPage(${dayLaborPage + 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">»</button>`;
|
||||
}
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function goToDayLaborPage(p) {
|
||||
dayLaborPage = p;
|
||||
loadDayLabor();
|
||||
}
|
||||
|
||||
function openAddDayLabor() {
|
||||
document.getElementById('addDayLaborForm').reset();
|
||||
// Default to tomorrow
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
document.getElementById('addWorkDate').value = tomorrow.toISOString().substring(0, 10);
|
||||
document.getElementById('addDayLaborModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeAddDayLabor() {
|
||||
document.getElementById('addDayLaborModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async function submitAddDayLabor(e) {
|
||||
e.preventDefault();
|
||||
const body = {
|
||||
work_date: document.getElementById('addWorkDate').value,
|
||||
worker_count: parseInt(document.getElementById('addWorkerCount').value) || 1,
|
||||
work_description: document.getElementById('addWorkDescription').value.trim(),
|
||||
workplace_name: document.getElementById('addWorkplaceName').value.trim(),
|
||||
notes: document.getElementById('addNotes').value.trim()
|
||||
};
|
||||
if (!body.work_date) { showToast('작업일을 선택하세요', 'error'); return; }
|
||||
|
||||
try {
|
||||
await api('/day-labor', { method: 'POST', body: JSON.stringify(body) });
|
||||
showToast('일용공 신청이 등록되었습니다');
|
||||
closeAddDayLabor();
|
||||
loadDayLabor();
|
||||
} catch(e) {
|
||||
showToast(e.message || '등록 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function approveDayLabor(id) {
|
||||
if (!confirm('이 신청을 승인하시겠습니까?')) return;
|
||||
try {
|
||||
await api('/day-labor/' + id + '/approve', { method: 'PUT' });
|
||||
showToast('승인되었습니다');
|
||||
loadDayLabor();
|
||||
} catch(e) {
|
||||
showToast(e.message || '승인 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function rejectDayLabor(id) {
|
||||
const reason = prompt('거절 사유를 입력하세요:');
|
||||
if (reason === null) return;
|
||||
try {
|
||||
await api('/day-labor/' + id + '/reject', { method: 'PUT', body: JSON.stringify({ reason }) });
|
||||
showToast('거절되었습니다');
|
||||
loadDayLabor();
|
||||
} catch(e) {
|
||||
showToast(e.message || '거절 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function completeDayLabor(id) {
|
||||
if (!confirm('이 신청을 완료 처리하시겠습니까?')) return;
|
||||
try {
|
||||
await api('/day-labor/' + id + '/complete', { method: 'PUT' });
|
||||
showToast('완료 처리되었습니다');
|
||||
loadDayLabor();
|
||||
} catch(e) {
|
||||
showToast(e.message || '완료 처리 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function initDayLaborPage() {
|
||||
if (!initAuth()) return;
|
||||
// Set default date range to this month
|
||||
const now = new Date();
|
||||
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
document.getElementById('filterDateFrom').value = firstDay.toISOString().substring(0, 10);
|
||||
document.getElementById('filterDateTo').value = now.toISOString().substring(0, 10);
|
||||
loadDayLabor();
|
||||
}
|
||||
241
tkpurchase/web/static/js/tkpurchase-partner-portal.js
Normal file
241
tkpurchase/web/static/js/tkpurchase-partner-portal.js
Normal file
@@ -0,0 +1,241 @@
|
||||
/* tkpurchase-partner-portal.js - Partner portal logic */
|
||||
|
||||
let portalSchedules = [];
|
||||
let portalCheckins = {};
|
||||
let partnerCompanyId = null;
|
||||
|
||||
async function loadMySchedules() {
|
||||
try {
|
||||
const r = await api('/schedules/my');
|
||||
portalSchedules = r.data || [];
|
||||
} catch(e) {
|
||||
console.warn('Load schedules error:', e);
|
||||
portalSchedules = [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMyCheckins() {
|
||||
try {
|
||||
const r = await api('/checkins/my');
|
||||
const list = r.data || [];
|
||||
portalCheckins = {};
|
||||
list.forEach(c => {
|
||||
if (c.schedule_id) portalCheckins[c.schedule_id] = c;
|
||||
});
|
||||
} catch(e) {
|
||||
console.warn('Load checkins error:', e);
|
||||
portalCheckins = {};
|
||||
}
|
||||
}
|
||||
|
||||
async function renderScheduleCards() {
|
||||
await Promise.all([loadMySchedules(), loadMyCheckins()]);
|
||||
|
||||
const container = document.getElementById('scheduleCards');
|
||||
const noMsg = document.getElementById('noScheduleMessage');
|
||||
|
||||
if (!portalSchedules.length) {
|
||||
container.innerHTML = '';
|
||||
noMsg.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
noMsg.classList.add('hidden');
|
||||
|
||||
container.innerHTML = portalSchedules.map(s => {
|
||||
const checkin = portalCheckins[s.id];
|
||||
const isCheckedIn = checkin && !checkin.check_out_at;
|
||||
const isCheckedOut = checkin && checkin.check_out_at;
|
||||
const hasReport = checkin && checkin.has_work_report;
|
||||
|
||||
// Step indicators
|
||||
const step1Class = checkin ? 'text-emerald-600' : 'text-gray-400';
|
||||
const step2Class = isCheckedIn || isCheckedOut ? 'text-emerald-600' : 'text-gray-400';
|
||||
const step3Class = isCheckedOut ? 'text-emerald-600' : 'text-gray-400';
|
||||
|
||||
return `<div class="bg-white rounded-xl shadow-sm overflow-hidden">
|
||||
<!-- 일정 정보 -->
|
||||
<div class="p-5 border-b">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<h3 class="text-base font-semibold text-gray-800">${escapeHtml(s.workplace_name || '작업장 미지정')}</h3>
|
||||
<span class="text-xs text-gray-500">${formatDate(s.work_date)}</span>
|
||||
</div>
|
||||
${s.work_description ? `<p class="text-sm text-gray-600 mb-2">${escapeHtml(s.work_description)}</p>` : ''}
|
||||
<div class="flex gap-4 text-xs text-gray-500">
|
||||
<span><i class="fas fa-users mr-1"></i>예상 ${s.expected_workers || 0}명</span>
|
||||
${s.notes ? `<span><i class="fas fa-sticky-note mr-1"></i>${escapeHtml(s.notes)}</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3-step 진행 표시 -->
|
||||
<div class="px-5 py-3 bg-gray-50 border-b">
|
||||
<div class="flex items-center justify-between text-xs">
|
||||
<div class="flex items-center gap-1 ${step1Class}">
|
||||
<i class="fas ${checkin ? 'fa-check-circle' : 'fa-circle'}"></i>
|
||||
<span>1. 작업 시작</span>
|
||||
</div>
|
||||
<div class="flex-1 border-t border-gray-300 mx-2"></div>
|
||||
<div class="flex items-center gap-1 ${step2Class}">
|
||||
<i class="fas ${(isCheckedIn || isCheckedOut) ? 'fa-check-circle' : 'fa-circle'}"></i>
|
||||
<span>2. 업무현황</span>
|
||||
</div>
|
||||
<div class="flex-1 border-t border-gray-300 mx-2"></div>
|
||||
<div class="flex items-center gap-1 ${step3Class}">
|
||||
<i class="fas ${isCheckedOut ? 'fa-check-circle' : 'fa-circle'}"></i>
|
||||
<span>3. 작업 종료</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: 작업 시작 (체크인) -->
|
||||
<div class="p-5 ${checkin ? 'bg-gray-50' : ''}">
|
||||
${!checkin ? `
|
||||
<div id="checkinForm_${s.id}">
|
||||
<h4 class="text-sm font-semibold text-gray-700 mb-3"><i class="fas fa-play-circle text-emerald-500 mr-1"></i>작업 시작</h4>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">실투입 인원 <span class="text-red-400">*</span></label>
|
||||
<input type="number" id="checkinWorkers_${s.id}" min="1" value="${s.expected_workers || 1}" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업자 명단</label>
|
||||
<input type="text" id="checkinNames_${s.id}" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="홍길동, 김철수">
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="doCheckIn(${s.id})" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">
|
||||
<i class="fas fa-play mr-1"></i>작업 시작
|
||||
</button>
|
||||
</div>
|
||||
` : `
|
||||
<div class="text-sm text-emerald-600 mb-1">
|
||||
<i class="fas fa-check-circle mr-1"></i>체크인 완료 (${formatTime(checkin.check_in_at)})
|
||||
· ${checkin.actual_worker_count || 0}명
|
||||
</div>
|
||||
`}
|
||||
</div>
|
||||
|
||||
<!-- Step 2: 업무현황 입력 (체크인 후 표시) -->
|
||||
${isCheckedIn ? `
|
||||
<div class="p-5 border-t">
|
||||
<h4 class="text-sm font-semibold text-gray-700 mb-3"><i class="fas fa-clipboard-list text-blue-500 mr-1"></i>업무현황 입력</h4>
|
||||
<div class="space-y-3">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">실투입 인원</label>
|
||||
<input type="number" id="reportWorkers_${checkin.id}" min="0" value="${checkin.actual_worker_count || 0}" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">진행률 (%)</label>
|
||||
<input type="number" id="reportProgress_${checkin.id}" min="0" max="100" value="0" class="input-field w-full px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">작업내용 <span class="text-red-400">*</span></label>
|
||||
<textarea id="reportContent_${checkin.id}" rows="3" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="오늘 수행한 작업 내용"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">이슈사항</label>
|
||||
<textarea id="reportIssues_${checkin.id}" rows="2" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="문제점이나 특이사항"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">향후 계획</label>
|
||||
<textarea id="reportNextPlan_${checkin.id}" rows="2" class="input-field w-full px-3 py-2 rounded-lg text-sm" placeholder="다음 작업 계획"></textarea>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button onclick="submitWorkReport(${checkin.id}, ${s.id})" class="px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700">
|
||||
<i class="fas fa-save mr-1"></i>업무현황 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: 작업 종료 -->
|
||||
<div class="p-5 border-t">
|
||||
<button onclick="doCheckOut(${checkin.id})" class="w-full px-4 py-3 bg-gray-800 text-white rounded-lg text-sm hover:bg-gray-900 font-medium">
|
||||
<i class="fas fa-stop-circle mr-1"></i>작업 종료 (체크아웃)
|
||||
</button>
|
||||
<p class="text-xs text-gray-400 text-center mt-2">업무현황을 먼저 저장한 후 작업을 종료하세요.</p>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
${isCheckedOut ? `
|
||||
<div class="p-5 border-t bg-gray-50">
|
||||
<div class="text-sm text-blue-600">
|
||||
<i class="fas fa-check-double mr-1"></i>작업 종료 완료 (${formatTime(checkin.check_out_at)})
|
||||
</div>
|
||||
${hasReport ? '<div class="text-xs text-emerald-600 mt-1"><i class="fas fa-clipboard-check mr-1"></i>업무현황 제출 완료</div>' : ''}
|
||||
</div>
|
||||
` : ''}
|
||||
</div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
async function doCheckIn(scheduleId) {
|
||||
const workerCount = parseInt(document.getElementById('checkinWorkers_' + scheduleId).value) || 1;
|
||||
const workerNames = document.getElementById('checkinNames_' + scheduleId).value.trim();
|
||||
|
||||
const body = {
|
||||
schedule_id: scheduleId,
|
||||
actual_worker_count: workerCount,
|
||||
worker_names: workerNames || null
|
||||
};
|
||||
|
||||
try {
|
||||
await api('/checkins', { method: 'POST', body: JSON.stringify(body) });
|
||||
showToast('체크인 완료');
|
||||
renderScheduleCards();
|
||||
} catch(e) {
|
||||
showToast(e.message || '체크인 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function submitWorkReport(checkinId, scheduleId) {
|
||||
const workContent = document.getElementById('reportContent_' + checkinId).value.trim();
|
||||
if (!workContent) { showToast('작업내용을 입력하세요', 'error'); return; }
|
||||
|
||||
const body = {
|
||||
checkin_id: checkinId,
|
||||
schedule_id: scheduleId,
|
||||
actual_workers: parseInt(document.getElementById('reportWorkers_' + checkinId).value) || 0,
|
||||
work_content: workContent,
|
||||
progress_rate: parseInt(document.getElementById('reportProgress_' + checkinId).value) || 0,
|
||||
issues: document.getElementById('reportIssues_' + checkinId).value.trim() || null,
|
||||
next_plan: document.getElementById('reportNextPlan_' + checkinId).value.trim() || null
|
||||
};
|
||||
|
||||
try {
|
||||
await api('/work-reports', { method: 'POST', body: JSON.stringify(body) });
|
||||
showToast('업무현황이 저장되었습니다');
|
||||
renderScheduleCards();
|
||||
} catch(e) {
|
||||
showToast(e.message || '저장 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function doCheckOut(checkinId) {
|
||||
if (!confirm('작업을 종료하시겠습니까? 업무현황을 먼저 저장했는지 확인하세요.')) return;
|
||||
try {
|
||||
await api('/checkins/' + checkinId + '/checkout', { method: 'PUT' });
|
||||
showToast('작업 종료 (체크아웃) 완료');
|
||||
renderScheduleCards();
|
||||
} catch(e) {
|
||||
showToast(e.message || '체크아웃 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function initPartnerPortal() {
|
||||
if (!initAuth()) return;
|
||||
|
||||
// Check if partner account
|
||||
const token = getToken();
|
||||
const decoded = decodeToken(token);
|
||||
if (!decoded || !decoded.partner_company_id) {
|
||||
location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
partnerCompanyId = decoded.partner_company_id;
|
||||
document.getElementById('welcomeCompanyName').textContent = decoded.partner_company_name || decoded.name || '협력업체';
|
||||
|
||||
renderScheduleCards();
|
||||
}
|
||||
250
tkpurchase/web/static/js/tkpurchase-schedule.js
Normal file
250
tkpurchase/web/static/js/tkpurchase-schedule.js
Normal file
@@ -0,0 +1,250 @@
|
||||
/* tkpurchase-schedule.js - Schedule management */
|
||||
|
||||
let schedulePage = 1;
|
||||
const scheduleLimit = 20;
|
||||
let companySearchTimer = null;
|
||||
|
||||
async function loadSchedules() {
|
||||
const company = document.getElementById('filterCompany').value.trim();
|
||||
const dateFrom = document.getElementById('filterDateFrom').value;
|
||||
const dateTo = document.getElementById('filterDateTo').value;
|
||||
const status = document.getElementById('filterStatus').value;
|
||||
|
||||
let query = `?page=${schedulePage}&limit=${scheduleLimit}`;
|
||||
if (company) query += '&company=' + encodeURIComponent(company);
|
||||
if (dateFrom) query += '&date_from=' + dateFrom;
|
||||
if (dateTo) query += '&date_to=' + dateTo;
|
||||
if (status) query += '&status=' + status;
|
||||
|
||||
try {
|
||||
const r = await api('/schedules' + query);
|
||||
renderScheduleTable(r.data || [], r.total || 0);
|
||||
} catch(e) {
|
||||
console.warn('Schedule load error:', e);
|
||||
document.getElementById('scheduleTableBody').innerHTML = '<tr><td colspan="7" class="text-center text-red-400 py-8">로딩 실패</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
function renderScheduleTable(list, total) {
|
||||
const tbody = document.getElementById('scheduleTableBody');
|
||||
if (!list.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="7" class="text-center text-gray-400 py-8">일정이 없습니다</td></tr>';
|
||||
document.getElementById('schedulePagination').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const statusMap = {
|
||||
scheduled: ['badge-amber', '예정'],
|
||||
in_progress: ['badge-green', '진행중'],
|
||||
completed: ['badge-blue', '완료'],
|
||||
cancelled: ['badge-gray', '취소']
|
||||
};
|
||||
|
||||
tbody.innerHTML = list.map(s => {
|
||||
const [cls, label] = statusMap[s.status] || ['badge-gray', s.status];
|
||||
const canEdit = s.status === 'scheduled';
|
||||
return `<tr>
|
||||
<td class="font-medium">${escapeHtml(s.company_name || '')}</td>
|
||||
<td>${formatDate(s.work_date)}</td>
|
||||
<td class="max-w-xs truncate">${escapeHtml(s.work_description || '')}</td>
|
||||
<td class="hide-mobile">${escapeHtml(s.workplace_name || '')}</td>
|
||||
<td class="text-center">${s.expected_workers || 0}명</td>
|
||||
<td><span class="badge ${cls}">${label}</span></td>
|
||||
<td class="text-right">
|
||||
${canEdit ? `<button onclick="openEditSchedule(${s.id})" class="text-blue-600 hover:text-blue-800 text-xs mr-1" title="수정"><i class="fas fa-edit"></i></button>
|
||||
<button onclick="deleteSchedule(${s.id})" class="text-red-500 hover:text-red-700 text-xs" title="삭제"><i class="fas fa-trash"></i></button>` : ''}
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
|
||||
// Pagination
|
||||
const totalPages = Math.ceil(total / scheduleLimit);
|
||||
renderSchedulePagination(totalPages);
|
||||
}
|
||||
|
||||
function renderSchedulePagination(totalPages) {
|
||||
const container = document.getElementById('schedulePagination');
|
||||
if (totalPages <= 1) { container.innerHTML = ''; return; }
|
||||
|
||||
let html = '';
|
||||
if (schedulePage > 1) {
|
||||
html += `<button onclick="goToSchedulePage(${schedulePage - 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">«</button>`;
|
||||
}
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i === schedulePage) {
|
||||
html += `<button class="px-3 py-1 bg-emerald-600 text-white rounded text-sm">${i}</button>`;
|
||||
} else if (Math.abs(i - schedulePage) <= 2 || i === 1 || i === totalPages) {
|
||||
html += `<button onclick="goToSchedulePage(${i})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">${i}</button>`;
|
||||
} else if (Math.abs(i - schedulePage) === 3) {
|
||||
html += '<span class="text-gray-400">...</span>';
|
||||
}
|
||||
}
|
||||
if (schedulePage < totalPages) {
|
||||
html += `<button onclick="goToSchedulePage(${schedulePage + 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">»</button>`;
|
||||
}
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function goToSchedulePage(p) {
|
||||
schedulePage = p;
|
||||
loadSchedules();
|
||||
}
|
||||
|
||||
/* ===== Company Autocomplete ===== */
|
||||
function setupCompanyAutocomplete(inputId, dropdownId, hiddenId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const dropdown = document.getElementById(dropdownId);
|
||||
const hidden = document.getElementById(hiddenId);
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
hidden.value = '';
|
||||
clearTimeout(companySearchTimer);
|
||||
const q = this.value.trim();
|
||||
if (q.length < 1) { dropdown.classList.add('hidden'); return; }
|
||||
companySearchTimer = setTimeout(async () => {
|
||||
try {
|
||||
const r = await api('/partners/search?q=' + encodeURIComponent(q));
|
||||
const list = r.data || [];
|
||||
if (!list.length) {
|
||||
dropdown.innerHTML = '<div class="px-3 py-2 text-sm text-gray-400">결과 없음</div>';
|
||||
} else {
|
||||
dropdown.innerHTML = list.map(c =>
|
||||
`<div class="px-3 py-2 text-sm hover:bg-emerald-50 cursor-pointer" onclick="selectCompany('${inputId}','${hiddenId}','${dropdownId}',${c.id},'${escapeHtml(c.name)}')">${escapeHtml(c.name)}</div>`
|
||||
).join('');
|
||||
}
|
||||
dropdown.classList.remove('hidden');
|
||||
} catch(e) {
|
||||
dropdown.classList.add('hidden');
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
input.addEventListener('blur', function() {
|
||||
setTimeout(() => dropdown.classList.add('hidden'), 200);
|
||||
});
|
||||
}
|
||||
|
||||
function selectCompany(inputId, hiddenId, dropdownId, id, name) {
|
||||
document.getElementById(inputId).value = name;
|
||||
document.getElementById(hiddenId).value = id;
|
||||
document.getElementById(dropdownId).classList.add('hidden');
|
||||
}
|
||||
|
||||
/* ===== Add Schedule ===== */
|
||||
function openAddSchedule() {
|
||||
document.getElementById('addScheduleForm').reset();
|
||||
document.getElementById('addCompanyId').value = '';
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
document.getElementById('addWorkDate').value = tomorrow.toISOString().substring(0, 10);
|
||||
document.getElementById('addScheduleModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeAddSchedule() {
|
||||
document.getElementById('addScheduleModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async function submitAddSchedule(e) {
|
||||
e.preventDefault();
|
||||
const companyId = document.getElementById('addCompanyId').value;
|
||||
if (!companyId) { showToast('업체를 선택하세요', 'error'); return; }
|
||||
|
||||
const body = {
|
||||
partner_company_id: parseInt(companyId),
|
||||
work_date: document.getElementById('addWorkDate').value,
|
||||
work_description: document.getElementById('addWorkDescription').value.trim(),
|
||||
workplace_name: document.getElementById('addWorkplaceName').value.trim(),
|
||||
expected_workers: parseInt(document.getElementById('addExpectedWorkers').value) || 0,
|
||||
notes: document.getElementById('addNotes').value.trim()
|
||||
};
|
||||
|
||||
try {
|
||||
await api('/schedules', { method: 'POST', body: JSON.stringify(body) });
|
||||
showToast('일정이 등록되었습니다');
|
||||
closeAddSchedule();
|
||||
loadSchedules();
|
||||
} catch(e) {
|
||||
showToast(e.message || '등록 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Edit Schedule ===== */
|
||||
let scheduleCache = {};
|
||||
|
||||
async function openEditSchedule(id) {
|
||||
try {
|
||||
const r = await api('/schedules/' + id);
|
||||
const s = r.data || r;
|
||||
scheduleCache[id] = s;
|
||||
|
||||
document.getElementById('editScheduleId').value = id;
|
||||
document.getElementById('editCompanySearch').value = s.company_name || '';
|
||||
document.getElementById('editCompanyId').value = s.partner_company_id || '';
|
||||
document.getElementById('editWorkDate').value = formatDate(s.work_date);
|
||||
document.getElementById('editWorkDescription').value = s.work_description || '';
|
||||
document.getElementById('editWorkplaceName').value = s.workplace_name || '';
|
||||
document.getElementById('editExpectedWorkers').value = s.expected_workers || 0;
|
||||
document.getElementById('editNotes').value = s.notes || '';
|
||||
document.getElementById('editScheduleModal').classList.remove('hidden');
|
||||
} catch(e) {
|
||||
showToast('일정 정보를 불러올 수 없습니다', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditSchedule() {
|
||||
document.getElementById('editScheduleModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async function submitEditSchedule(e) {
|
||||
e.preventDefault();
|
||||
const id = document.getElementById('editScheduleId').value;
|
||||
const companyId = document.getElementById('editCompanyId').value;
|
||||
if (!companyId) { showToast('업체를 선택하세요', 'error'); return; }
|
||||
|
||||
const body = {
|
||||
partner_company_id: parseInt(companyId),
|
||||
work_date: document.getElementById('editWorkDate').value,
|
||||
work_description: document.getElementById('editWorkDescription').value.trim(),
|
||||
workplace_name: document.getElementById('editWorkplaceName').value.trim(),
|
||||
expected_workers: parseInt(document.getElementById('editExpectedWorkers').value) || 0,
|
||||
notes: document.getElementById('editNotes').value.trim()
|
||||
};
|
||||
|
||||
try {
|
||||
await api('/schedules/' + id, { method: 'PUT', body: JSON.stringify(body) });
|
||||
showToast('일정이 수정되었습니다');
|
||||
closeEditSchedule();
|
||||
loadSchedules();
|
||||
} catch(e) {
|
||||
showToast(e.message || '수정 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Delete Schedule ===== */
|
||||
async function deleteSchedule(id) {
|
||||
if (!confirm('이 일정을 삭제하시겠습니까?')) return;
|
||||
try {
|
||||
await api('/schedules/' + id, { method: 'DELETE' });
|
||||
showToast('일정이 삭제되었습니다');
|
||||
loadSchedules();
|
||||
} catch(e) {
|
||||
showToast(e.message || '삭제 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Init ===== */
|
||||
function initSchedulePage() {
|
||||
if (!initAuth()) return;
|
||||
// Set default date range
|
||||
const now = new Date();
|
||||
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
||||
document.getElementById('filterDateFrom').value = firstDay.toISOString().substring(0, 10);
|
||||
document.getElementById('filterDateTo').value = lastDay.toISOString().substring(0, 10);
|
||||
|
||||
// Setup autocomplete for both modals
|
||||
setupCompanyAutocomplete('addCompanySearch', 'addCompanyDropdown', 'addCompanyId');
|
||||
setupCompanyAutocomplete('editCompanySearch', 'editCompanyDropdown', 'editCompanyId');
|
||||
|
||||
loadSchedules();
|
||||
}
|
||||
199
tkpurchase/web/static/js/tkpurchase-workreport.js
Normal file
199
tkpurchase/web/static/js/tkpurchase-workreport.js
Normal file
@@ -0,0 +1,199 @@
|
||||
/* tkpurchase-workreport.js - Work report monitoring */
|
||||
|
||||
let reportPage = 1;
|
||||
const reportLimit = 20;
|
||||
|
||||
async function loadCompaniesForFilter() {
|
||||
try {
|
||||
const r = await api('/partners?limit=100');
|
||||
const list = r.data || [];
|
||||
const sel = document.getElementById('filterCompany');
|
||||
list.forEach(c => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = c.name;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
} catch(e) { console.warn('Load companies error:', e); }
|
||||
}
|
||||
|
||||
async function loadReports() {
|
||||
const companyId = document.getElementById('filterCompany').value;
|
||||
const dateFrom = document.getElementById('filterDateFrom').value;
|
||||
const dateTo = document.getElementById('filterDateTo').value;
|
||||
const confirmed = document.getElementById('filterConfirmed').value;
|
||||
|
||||
let query = `?page=${reportPage}&limit=${reportLimit}`;
|
||||
if (companyId) query += '&company_id=' + companyId;
|
||||
if (dateFrom) query += '&date_from=' + dateFrom;
|
||||
if (dateTo) query += '&date_to=' + dateTo;
|
||||
if (confirmed) query += '&confirmed=' + confirmed;
|
||||
|
||||
try {
|
||||
const r = await api('/work-reports' + query);
|
||||
renderReportTable(r.data || [], r.total || 0);
|
||||
} catch(e) {
|
||||
console.warn('Report load error:', e);
|
||||
document.getElementById('reportTableBody').innerHTML = '<tr><td colspan="8" class="text-center text-red-400 py-8">로딩 실패</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
function renderReportTable(list, total) {
|
||||
const tbody = document.getElementById('reportTableBody');
|
||||
if (!list.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="8" class="text-center text-gray-400 py-8">업무현황이 없습니다</td></tr>';
|
||||
document.getElementById('reportPagination').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = list.map(r => {
|
||||
const progressColor = r.progress_rate >= 80 ? 'bg-emerald-500' : r.progress_rate >= 50 ? 'bg-blue-500' : r.progress_rate >= 20 ? 'bg-amber-500' : 'bg-red-500';
|
||||
const confirmedBadge = r.confirmed_at
|
||||
? '<span class="badge badge-green">확인</span>'
|
||||
: '<button onclick="confirmReport(' + r.id + ')" class="badge badge-amber cursor-pointer hover:opacity-80">미확인</button>';
|
||||
|
||||
return `<tr class="cursor-pointer hover:bg-gray-50" onclick="viewReportDetail(${r.id})">
|
||||
<td>${formatDate(r.report_date || r.created_at)}</td>
|
||||
<td class="font-medium">${escapeHtml(r.company_name || '')}</td>
|
||||
<td class="max-w-xs truncate">${escapeHtml(r.work_content || '')}</td>
|
||||
<td class="text-center">${r.actual_workers || 0}명</td>
|
||||
<td class="text-center">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex-1 bg-gray-200 rounded-full h-2 min-w-[3rem]">
|
||||
<div class="${progressColor} rounded-full h-2" style="width: ${r.progress_rate || 0}%"></div>
|
||||
</div>
|
||||
<span class="text-xs text-gray-500 whitespace-nowrap">${r.progress_rate || 0}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="hide-mobile max-w-[8rem] truncate text-xs">${escapeHtml(r.issues || '')}</td>
|
||||
<td class="text-center" onclick="event.stopPropagation()">${confirmedBadge}</td>
|
||||
<td class="text-right" onclick="event.stopPropagation()">
|
||||
<button onclick="viewReportDetail(${r.id})" class="text-blue-600 hover:text-blue-800 text-xs" title="상세보기"><i class="fas fa-eye"></i></button>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
|
||||
// Pagination
|
||||
const totalPages = Math.ceil(total / reportLimit);
|
||||
renderReportPagination(totalPages);
|
||||
}
|
||||
|
||||
function renderReportPagination(totalPages) {
|
||||
const container = document.getElementById('reportPagination');
|
||||
if (totalPages <= 1) { container.innerHTML = ''; return; }
|
||||
|
||||
let html = '';
|
||||
if (reportPage > 1) {
|
||||
html += `<button onclick="goToReportPage(${reportPage - 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">«</button>`;
|
||||
}
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i === reportPage) {
|
||||
html += `<button class="px-3 py-1 bg-emerald-600 text-white rounded text-sm">${i}</button>`;
|
||||
} else if (Math.abs(i - reportPage) <= 2 || i === 1 || i === totalPages) {
|
||||
html += `<button onclick="goToReportPage(${i})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">${i}</button>`;
|
||||
} else if (Math.abs(i - reportPage) === 3) {
|
||||
html += '<span class="text-gray-400">...</span>';
|
||||
}
|
||||
}
|
||||
if (reportPage < totalPages) {
|
||||
html += `<button onclick="goToReportPage(${reportPage + 1})" class="px-3 py-1 border rounded text-sm hover:bg-gray-50">»</button>`;
|
||||
}
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function goToReportPage(p) {
|
||||
reportPage = p;
|
||||
loadReports();
|
||||
}
|
||||
|
||||
async function confirmReport(id) {
|
||||
if (!confirm('이 업무현황을 확인 처리하시겠습니까?')) return;
|
||||
try {
|
||||
await api('/work-reports/' + id + '/confirm', { method: 'PUT' });
|
||||
showToast('확인 처리되었습니다');
|
||||
loadReports();
|
||||
} catch(e) {
|
||||
showToast(e.message || '확인 처리 실패', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function viewReportDetail(id) {
|
||||
try {
|
||||
const r = await api('/work-reports/' + id);
|
||||
const d = r.data || r;
|
||||
|
||||
const progressColor = d.progress_rate >= 80 ? 'bg-emerald-500' : d.progress_rate >= 50 ? 'bg-blue-500' : d.progress_rate >= 20 ? 'bg-amber-500' : 'bg-red-500';
|
||||
|
||||
const html = `
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<div class="text-xs text-gray-500 mb-1">업체</div>
|
||||
<div class="text-sm font-medium">${escapeHtml(d.company_name || '')}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-gray-500 mb-1">보고일</div>
|
||||
<div class="text-sm">${formatDateTime(d.report_date || d.created_at)}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-gray-500 mb-1">실투입 인원</div>
|
||||
<div class="text-sm">${d.actual_workers || 0}명</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-gray-500 mb-1">진행률</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex-1 bg-gray-200 rounded-full h-3">
|
||||
<div class="${progressColor} rounded-full h-3" style="width: ${d.progress_rate || 0}%"></div>
|
||||
</div>
|
||||
<span class="text-sm font-medium">${d.progress_rate || 0}%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<div class="text-xs text-gray-500 mb-1">작업내용</div>
|
||||
<div class="text-sm whitespace-pre-wrap bg-gray-50 rounded-lg p-3">${escapeHtml(d.work_content || '-')}</div>
|
||||
</div>
|
||||
${d.issues ? `<div class="sm:col-span-2">
|
||||
<div class="text-xs text-gray-500 mb-1">이슈사항</div>
|
||||
<div class="text-sm whitespace-pre-wrap bg-red-50 rounded-lg p-3 text-red-700">${escapeHtml(d.issues)}</div>
|
||||
</div>` : ''}
|
||||
${d.next_plan ? `<div class="sm:col-span-2">
|
||||
<div class="text-xs text-gray-500 mb-1">향후 계획</div>
|
||||
<div class="text-sm whitespace-pre-wrap bg-blue-50 rounded-lg p-3 text-blue-700">${escapeHtml(d.next_plan)}</div>
|
||||
</div>` : ''}
|
||||
<div>
|
||||
<div class="text-xs text-gray-500 mb-1">확인 상태</div>
|
||||
<div class="text-sm">${d.confirmed_at ? '<span class="badge badge-green">확인완료</span> ' + formatDateTime(d.confirmed_at) : '<span class="badge badge-amber">미확인</span>'}</div>
|
||||
</div>
|
||||
${d.confirmed_by_name ? `<div>
|
||||
<div class="text-xs text-gray-500 mb-1">확인자</div>
|
||||
<div class="text-sm">${escapeHtml(d.confirmed_by_name)}</div>
|
||||
</div>` : ''}
|
||||
</div>
|
||||
${!d.confirmed_at ? `<div class="mt-4 flex justify-end">
|
||||
<button onclick="confirmReport(${d.id})" class="px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700">
|
||||
<i class="fas fa-check mr-1"></i>확인 처리
|
||||
</button>
|
||||
</div>` : ''}`;
|
||||
|
||||
document.getElementById('reportDetailContent').innerHTML = html;
|
||||
document.getElementById('reportDetailPanel').classList.remove('hidden');
|
||||
document.getElementById('reportDetailPanel').scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
} catch(e) {
|
||||
showToast('상세 정보를 불러올 수 없습니다', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function closeReportDetail() {
|
||||
document.getElementById('reportDetailPanel').classList.add('hidden');
|
||||
}
|
||||
|
||||
function initWorkReportPage() {
|
||||
if (!initAuth()) return;
|
||||
// Set default date range to this month
|
||||
const now = new Date();
|
||||
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
document.getElementById('filterDateFrom').value = firstDay.toISOString().substring(0, 10);
|
||||
document.getElementById('filterDateTo').value = now.toISOString().substring(0, 10);
|
||||
|
||||
loadCompaniesForFilter();
|
||||
loadReports();
|
||||
}
|
||||
112
tkpurchase/web/workreport.html
Normal file
112
tkpurchase/web/workreport.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>업무현황 - TK 구매관리</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tkpurchase.css?v=20260312">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="bg-emerald-700 text-white sticky top-0 z-50">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between items-center h-14">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-truck text-xl text-emerald-200"></i>
|
||||
<h1 class="text-lg font-semibold">TK 구매관리</h1>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div id="headerUserName" class="text-sm font-medium hidden sm:block">-</div>
|
||||
<div id="headerUserAvatar" class="w-8 h-8 bg-emerald-600 rounded-full flex items-center justify-center text-sm font-semibold">-</div>
|
||||
<button onclick="doLogout()" class="text-emerald-200 hover:text-white" title="로그아웃"><i class="fas fa-sign-out-alt"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 fade-in">
|
||||
<div class="flex gap-6">
|
||||
<!-- Sidebar Nav -->
|
||||
<nav id="sideNav" class="hidden lg:flex flex-col gap-1 w-48 flex-shrink-0 pt-2"></nav>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<!-- 필터 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-4 mb-5">
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">업체</label>
|
||||
<select id="filterCompany" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">전체</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">시작일</label>
|
||||
<input type="date" id="filterDateFrom" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">종료일</label>
|
||||
<input type="date" id="filterDateTo" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">확인 상태</label>
|
||||
<select id="filterConfirmed" class="input-field px-3 py-2 rounded-lg text-sm">
|
||||
<option value="">전체</option>
|
||||
<option value="false">미확인</option>
|
||||
<option value="true">확인완료</option>
|
||||
</select>
|
||||
</div>
|
||||
<button onclick="loadReports()" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg text-sm hover:bg-gray-200">
|
||||
<i class="fas fa-search mr-1"></i>조회
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 테이블 -->
|
||||
<div class="bg-white rounded-xl shadow-sm p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">
|
||||
<i class="fas fa-clipboard-list text-purple-500 mr-2"></i>업무현황 목록
|
||||
</h2>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="visit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>보고일</th>
|
||||
<th>업체</th>
|
||||
<th>작업내용</th>
|
||||
<th class="text-center">실투입</th>
|
||||
<th class="text-center">진행률</th>
|
||||
<th class="hide-mobile">이슈</th>
|
||||
<th class="text-center">확인</th>
|
||||
<th class="text-right">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="reportTableBody">
|
||||
<tr><td colspan="8" class="text-center text-gray-400 py-8">로딩 중...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="reportPagination" class="flex justify-center items-center gap-2 mt-4"></div>
|
||||
</div>
|
||||
|
||||
<!-- 상세보기 패널 -->
|
||||
<div id="reportDetailPanel" class="hidden bg-white rounded-xl shadow-sm p-5 mt-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-base font-semibold text-gray-800">
|
||||
<i class="fas fa-file-alt text-purple-500 mr-2"></i>업무현황 상세
|
||||
</h2>
|
||||
<button onclick="closeReportDetail()" class="text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<div id="reportDetailContent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/tkpurchase-core.js?v=20260312"></script>
|
||||
<script src="/static/js/tkpurchase-workreport.js?v=20260312"></script>
|
||||
<script>initWorkReportPage();</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user