feat: [esign] 근로계약서 사원 불러오기 시 주소, 생년월일, 계약일 자동 반영

- 주민등록번호에서 출생년도/월/일 분리 (세기 자동 판별)
- 입사일 기반 계약일, 근로계약시작일, 연봉계약시작일 자동 반영
- 연봉계약종료일은 입사일 + 1년으로 계산
- 사원 주소, 계약자 이름 자동 매핑 추가
This commit is contained in:
김보곤
2026-03-11 16:18:37 +09:00
parent 3e8b730242
commit 4bb03fffcb
2 changed files with 66 additions and 12 deletions

View File

@@ -98,18 +98,35 @@ public function searchEmployees(Request $request): JsonResponse
$employees = $query->limit(20)->get();
$data = $employees->map(fn ($emp) => [
'id' => $emp->id,
'name' => $emp->user?->name,
'phone' => $emp->user?->phone,
'email' => $emp->user?->email,
'department' => $emp->department?->name,
'position' => $emp->position_label,
'job_title' => $emp->job_title_label,
'address' => $emp->address,
'hire_date' => $emp->hire_date,
'birth_year' => $emp->resident_number ? ('19'.substr($emp->resident_number, 0, 2)) : null,
]);
$data = $employees->map(function ($emp) {
$rn = $emp->resident_number;
$birthYear = null;
$birthMonth = null;
$birthDay = null;
if ($rn && strlen($rn) >= 7) {
$genderDigit = substr($rn, 6, 1);
$prefix = in_array($genderDigit, ['3', '4', '7', '8']) ? '20' : '19';
$birthYear = $prefix.substr($rn, 0, 2);
$birthMonth = substr($rn, 2, 2);
$birthDay = substr($rn, 4, 2);
}
return [
'id' => $emp->id,
'name' => $emp->user?->name,
'phone' => $emp->user?->phone,
'email' => $emp->user?->email,
'department' => $emp->department?->name,
'position' => $emp->position_label,
'job_title' => $emp->job_title_label,
'address' => $emp->address,
'hire_date' => $emp->hire_date,
'birth_year' => $birthYear,
'birth_month' => $birthMonth,
'birth_day' => $birthDay,
];
});
return response()->json(['success' => true, 'data' => $data]);
}

View File

@@ -950,9 +950,30 @@ className={`w-full text-left px-3 py-2.5 rounded-lg mb-1 transition-colors ${i =
// 사원 선택 시 근로계약서 변수 자동 채우기
const handleEmployeeSelect = (emp) => {
// 입사일에서 년/월/일 분리
let hireYear = '', hireMonth = '', hireDay = '';
let endYear = '', endMonth = '', endDay = '';
if (emp.hire_date) {
const hd = emp.hire_date.replace(/-/g, '');
if (hd.length >= 8) {
hireYear = hd.substring(0, 4);
hireMonth = hd.substring(4, 6);
hireDay = hd.substring(6, 8);
// 1년 후 계산
const endDate = new Date(parseInt(hireYear), parseInt(hireMonth) - 1, parseInt(hireDay));
endDate.setFullYear(endDate.getFullYear() + 1);
endYear = String(endDate.getFullYear());
endMonth = String(endDate.getMonth() + 1).padStart(2, '0');
endDay = String(endDate.getDate()).padStart(2, '0');
}
}
const labelMap = {
'직원.*주소': emp.address,
'주소': emp.address,
'출생.*년도': emp.birth_year,
'출생.*월$': emp.birth_month,
'출생.*일$': emp.birth_day,
'부서': emp.department,
'직책': emp.position,
'직위': emp.job_title || emp.position,
@@ -964,6 +985,22 @@ className={`w-full text-left px-3 py-2.5 rounded-lg mb-1 transition-colors ${i =
'근로자.*이름': emp.name,
'근로자.*성명': emp.name,
'입사.*일': emp.hire_date,
// 계약일 = 입사일
'계약.*연도': hireYear,
'계약.*월$': hireMonth,
'계약.*일$': hireDay,
// 근로계약 시작일 = 입사일
'근로계약.*시작.*년도': hireYear,
'근로계약.*시작.*월$': hireMonth,
'근로계약.*시작.*일$': hireDay,
// 연봉계약 시작일 = 입사일
'연봉계약.*시작.*년도': hireYear,
'연봉계약.*시작.*월$': hireMonth,
'연봉계약.*시작.*일$': hireDay,
// 연봉계약 종료일 = 입사일 + 1년
'연봉계약.*종료.*년도': endYear,
'연봉계약.*종료.*월$': endMonth,
'연봉계약.*종료.*일$': endDay,
};
setMetadata(prev => {