feat: [org-chart] 부서 숨기기 상태 DB 저장
- departments.options JSON 컬럼에 orgchart_hidden 플래그 저장 - 숨기기/복원 시 API 호출하여 영구 저장 - 페이지 로드 시 DB에서 숨김 상태 복원
This commit is contained in:
@@ -177,6 +177,33 @@ public function orgChartReorderDepts(Request $request): JsonResponse
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조직도 - 부서 숨기기/표시 토글
|
||||
*/
|
||||
public function orgChartToggleHide(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'department_id' => 'required|integer',
|
||||
'hidden' => 'required|boolean',
|
||||
]);
|
||||
|
||||
$tenantId = session('selected_tenant_id');
|
||||
$dept = Department::where('tenant_id', $tenantId)
|
||||
->where('id', $request->department_id)
|
||||
->first();
|
||||
|
||||
if (! $dept) {
|
||||
return response()->json(['success' => false, 'message' => '부서를 찾을 수 없습니다.'], 404);
|
||||
}
|
||||
|
||||
$options = $dept->options ?? [];
|
||||
$options['orgchart_hidden'] = $request->hidden;
|
||||
$dept->options = $options;
|
||||
$dept->save();
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중대재해처벌법 실무 점검
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,7 @@ class Department extends Model
|
||||
'parent_id' => 'int',
|
||||
'is_active' => 'bool',
|
||||
'sort_order' => 'int',
|
||||
'options' => 'array',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
@@ -127,7 +127,7 @@ function orgChart() {
|
||||
deptSortables: [],
|
||||
empSortables: [],
|
||||
unassignedSortable: null,
|
||||
hiddenDepts: new Set(),
|
||||
hiddenDepts: new Set(@json($departments->filter(fn($d) => ($d->options['orgchart_hidden'] ?? false))->pluck('id')->values())),
|
||||
dblClickDept: null,
|
||||
execTitles: ['대표이사', '사장', '부사장', '회장', '부회장'],
|
||||
|
||||
@@ -414,11 +414,25 @@ function orgChart() {
|
||||
this.hiddenDepts.add(deptId);
|
||||
this.dblClickDept = null;
|
||||
this.renderTree();
|
||||
this.saveHideState(deptId, true);
|
||||
},
|
||||
|
||||
restoreDept(deptId) {
|
||||
this.hiddenDepts.delete(deptId);
|
||||
this.renderTree();
|
||||
this.saveHideState(deptId, false);
|
||||
},
|
||||
|
||||
async saveHideState(deptId, hidden) {
|
||||
this.saving = true;
|
||||
try {
|
||||
await fetch('{{ route("rd.org-chart.toggle-hide") }}', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, 'Accept': 'application/json' },
|
||||
body: JSON.stringify({ department_id: deptId, hidden }),
|
||||
});
|
||||
} catch (e) { console.error('숨기기 저장 실패:', e); }
|
||||
finally { this.saving = false; }
|
||||
},
|
||||
|
||||
get hiddenDeptList() {
|
||||
|
||||
@@ -393,6 +393,7 @@
|
||||
Route::post('/org-chart/unassign', [RdController::class, 'orgChartUnassign'])->name('org-chart.unassign');
|
||||
Route::post('/org-chart/reorder', [RdController::class, 'orgChartReorder'])->name('org-chart.reorder');
|
||||
Route::post('/org-chart/reorder-depts', [RdController::class, 'orgChartReorderDepts'])->name('org-chart.reorder-depts');
|
||||
Route::post('/org-chart/toggle-hide', [RdController::class, 'orgChartToggleHide'])->name('org-chart.toggle-hide');
|
||||
|
||||
// 중대재해처벌법 실무 점검
|
||||
Route::get('/safety-audit', [RdController::class, 'safetyAudit'])->name('safety-audit');
|
||||
|
||||
Reference in New Issue
Block a user