feat: [hr] 연봉이력 삭제 버튼 추가
- 이력 테이블에 삭제 컬럼/버튼 추가 - Alpine.js deleteHistory() 메서드 추가 (confirm 확인 후 API 호출) - reverse 표시 인덱스를 원본 인덱스로 변환하여 API 전달
This commit is contained in:
@@ -99,7 +99,8 @@ class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-
|
||||
<th class="text-left py-2 pr-3 font-medium">적용일</th>
|
||||
<th class="text-left py-2 pr-3 font-medium">비고</th>
|
||||
<th class="text-left py-2 pr-3 font-medium">기록일</th>
|
||||
<th class="text-left py-2 font-medium">기록자</th>
|
||||
<th class="text-left py-2 pr-3 font-medium">기록자</th>
|
||||
<th class="text-center py-2 font-medium" style="width: 60px;">삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@@ -109,7 +110,17 @@ class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-
|
||||
<td class="py-2 pr-3" x-text="item.effective_date || '-'"></td>
|
||||
<td class="py-2 pr-3" x-text="item.notes || '-'"></td>
|
||||
<td class="py-2 pr-3 text-gray-500" x-text="item.recorded_at || '-'"></td>
|
||||
<td class="py-2 text-gray-500" x-text="item.recorded_by || '-'"></td>
|
||||
<td class="py-2 pr-3 text-gray-500" x-text="item.recorded_by || '-'"></td>
|
||||
<td class="py-2 text-center">
|
||||
<button type="button"
|
||||
@click="deleteHistory(salaryData.history.length - 1 - idx)"
|
||||
class="inline-flex items-center justify-center w-7 h-7 rounded text-red-400 hover:text-red-600 hover:bg-red-50 transition-colors"
|
||||
title="이력 삭제">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
@@ -143,6 +154,29 @@ function salaryManager() {
|
||||
return isNaN(num) ? '' : num;
|
||||
},
|
||||
|
||||
async deleteHistory(originalIndex) {
|
||||
if (!confirm('이 연봉 이력을 삭제하시겠습니까?')) return;
|
||||
try {
|
||||
const res = await fetch(`/api/admin/hr/employees/{{ $employee->id }}/salary/history/${originalIndex}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.success) {
|
||||
this.salaryData = json.data;
|
||||
showToast(json.message, 'success');
|
||||
} else {
|
||||
showToast(json.message || '삭제에 실패했습니다.', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
showToast('이력 삭제 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
async saveSalary() {
|
||||
this.saving = true;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user