1061 lines
No EOL
63 KiB
PHP
1061 lines
No EOL
63 KiB
PHP
<?php require_once 'auth_check.php'; ?>
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>직원 마스터 리스트 | FKI ASSET</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
<link href="https://fonts.googleapis.com/css2?family=Pretendard:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/style.css">
|
|
<style>
|
|
body {
|
|
font-family: 'Pretendard', sans-serif;
|
|
}
|
|
|
|
[x-cloak] {
|
|
display: none !important;
|
|
}
|
|
|
|
.modal-bg {
|
|
background-color: rgba(15, 23, 42, 0.7);
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
|
|
.sort-icon {
|
|
transition: transform 0.2s;
|
|
}
|
|
|
|
.sort-active {
|
|
color: #2563eb;
|
|
}
|
|
|
|
.no-scrollbar::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="bg-[#f8fafc] text-slate-800" x-data="userManagement()">
|
|
|
|
<?php include 'nav.php'; ?>
|
|
|
|
<!-- Main Content -->
|
|
<main class="max-w-[1600px] mx-auto p-8 pt-10">
|
|
<header class="mb-6 flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
<div>
|
|
<div class="flex items-center gap-3">
|
|
<h2 class="text-3xl font-extrabold text-slate-900 tracking-tight">직원 마스터</h2>
|
|
<div
|
|
class="flex items-baseline gap-1 bg-white px-4 py-1.5 rounded-2xl border border-slate-200 shadow-sm">
|
|
<span class="text-lg font-black text-blue-600" x-text="visibleCount"></span>
|
|
<span class="text-xs font-bold text-slate-400">/</span>
|
|
<span class="text-sm font-bold text-slate-500" x-text="users.length"></span>
|
|
<span class="text-[10px] font-bold text-slate-400 ml-1 uppercase">명 (목록인원/전체)</span>
|
|
</div>
|
|
</div>
|
|
<p class="text-slate-500 mt-1">임직원 기본 정보 및 부서 체계 관리</p>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<div class="relative">
|
|
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-slate-400">
|
|
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
</svg>
|
|
</span>
|
|
<input type="text" x-model="searchQuery"
|
|
class="block w-64 pl-10 pr-3 py-2.5 border border-slate-200 rounded-xl leading-5 bg-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all text-sm"
|
|
placeholder="이름, 사번, 이메일 검색...">
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<button @click="openAddModal()"
|
|
class="bg-blue-600 text-white px-5 py-2.5 rounded-xl font-bold shadow-lg shadow-blue-200 hover:bg-blue-700 transition-all flex items-center shrink-0">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
|
</svg>
|
|
신규 등록
|
|
</button>
|
|
<button @click="openRestoreModal()"
|
|
class="bg-slate-800 text-white px-5 py-2.5 rounded-xl font-bold shadow-lg shadow-slate-200 hover:bg-slate-900 transition-all flex items-center shrink-0">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
|
|
</svg>
|
|
불러오기
|
|
</button>
|
|
<button @click="openExportModal()"
|
|
class="bg-emerald-600 text-white px-5 py-2.5 rounded-xl font-bold shadow-lg shadow-emerald-200 hover:bg-emerald-700 transition-all flex items-center shrink-0">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
|
</svg>
|
|
CSV 내보내기
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Filters & Bulk Actions -->
|
|
<div class="mb-6 flex flex-wrap items-center justify-between gap-4">
|
|
<div class="flex items-center gap-2">
|
|
<button @click="filterRetired = !filterRetired"
|
|
:class="filterRetired ? 'bg-rose-600 text-white border-rose-600 shadow-md shadow-rose-100' : 'bg-white text-slate-500 border-slate-200 hover:border-rose-300 hover:text-rose-500'"
|
|
class="px-4 py-2 rounded-xl text-xs font-bold border transition-all flex items-center">
|
|
<div class="w-2 h-2 rounded-full mr-2" :class="filterRetired ? 'bg-white' : 'bg-rose-500'"></div>
|
|
퇴사자 포함
|
|
</button>
|
|
<button @click="filterOnLeave = !filterOnLeave"
|
|
:class="filterOnLeave ? 'bg-amber-500 text-white border-amber-500 shadow-md shadow-amber-100' : 'bg-white text-slate-500 border-slate-200 hover:border-amber-300 hover:text-amber-500'"
|
|
class="px-4 py-2 rounded-xl text-xs font-bold border transition-all flex items-center">
|
|
<div class="w-2 h-2 rounded-full mr-2" :class="filterOnLeave ? 'bg-white' : 'bg-amber-500'"></div>
|
|
휴직자 표시
|
|
</button>
|
|
<button @click="filterClassification = !filterClassification"
|
|
:class="filterClassification ? 'bg-indigo-600 text-white border-indigo-600 shadow-md shadow-indigo-100' : 'bg-white text-slate-500 border-slate-200 hover:border-indigo-300 hover:text-indigo-500'"
|
|
class="px-4 py-2 rounded-xl text-xs font-bold border transition-all flex items-center">
|
|
<div class="w-2 h-2 rounded-full mr-2" :class="filterClassification ? 'bg-white' : 'bg-indigo-500'">
|
|
</div>
|
|
분류 대상 표시
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Bulk Command Center (Fixed Floating Bar) -->
|
|
<div x-show="selectedIds.length > 0" x-transition x-cloak
|
|
class="fixed bottom-10 left-10 z-[200] bg-slate-900 text-white px-6 py-4 rounded-3xl flex items-center gap-6 shadow-2xl border border-white/10 animate-in fade-in slide-in-from-left-4 duration-300">
|
|
<div class="flex items-center gap-2">
|
|
<div class="w-10 h-10 bg-blue-600 rounded-full flex items-center justify-center font-black text-sm shadow-lg shadow-blue-500/30"
|
|
x-text="selectedIds.length"></div>
|
|
<div class="flex flex-col">
|
|
<span class="text-[10px] font-black text-slate-400 uppercase tracking-tighter">Selected</span>
|
|
<span class="text-xs font-bold">인원 선택됨</span>
|
|
</div>
|
|
</div>
|
|
<div class="h-8 w-px bg-white/10 mx-2"></div>
|
|
<div class="flex items-center gap-3">
|
|
<select x-model="bulkStatus"
|
|
class="bg-slate-800 border-none rounded-xl text-xs font-bold px-4 py-2 focus:ring-2 focus:ring-blue-500 appearance-none shadow-inner min-w-[120px]">
|
|
<option value="">상태 변경...</option>
|
|
<option value="active">재직</option>
|
|
<option value="retired">퇴사</option>
|
|
<option value="on_leave">휴직</option>
|
|
<option value="classification">분류</option>
|
|
</select>
|
|
<select x-model="bulkDeptId"
|
|
class="bg-slate-800 border-none rounded-xl text-xs font-bold px-4 py-2 focus:ring-2 focus:ring-blue-500 appearance-none shadow-inner min-w-[150px]">
|
|
<option value="">부서 이동...</option>
|
|
<template x-for="dept in depts" :key="dept.id">
|
|
<option :value="dept.id" x-text="dept.name"></option>
|
|
</template>
|
|
</select>
|
|
<input type="text" x-model="bulkPosition" placeholder="직위 변경..."
|
|
class="bg-slate-800 border-none rounded-xl text-xs font-bold px-4 py-2 focus:ring-2 focus:ring-blue-500 shadow-inner w-32">
|
|
<button @click="applyBulkUpdate"
|
|
class="bg-blue-600 hover:bg-blue-700 px-6 py-2 rounded-xl text-xs font-black transition-all shadow-lg shadow-blue-500/20 active:scale-95">일괄
|
|
적용</button>
|
|
|
|
<div class="h-8 w-px bg-white/10 mx-1"></div>
|
|
|
|
<button @click="openExportModal"
|
|
class="bg-emerald-600 hover:bg-emerald-700 px-6 py-2 rounded-xl text-xs font-black transition-all shadow-lg shadow-emerald-500/20 active:scale-95 flex items-center gap-2">
|
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
|
</svg>
|
|
CSV 다운로드
|
|
</button>
|
|
<button @click="bulkDelete"
|
|
class="bg-rose-600 hover:bg-rose-700 px-6 py-2 rounded-xl text-xs font-black transition-all shadow-lg shadow-rose-500/20 active:scale-95 flex items-center gap-2">
|
|
<svg class="w-3.5 h-3.5" 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>
|
|
|
|
<button @click="selectedIds = []"
|
|
class="ml-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-white/10 text-slate-400 hover:text-white transition-all">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- User Table -->
|
|
<div class="bg-white rounded-3xl shadow-sm border border-slate-200 overflow-hidden">
|
|
<table class="min-w-full divide-y divide-slate-100">
|
|
<thead class="bg-slate-50/50">
|
|
<tr>
|
|
<th class="px-6 py-4 text-left">
|
|
<input type="checkbox" @change="toggleSelectAll($event.target.checked)"
|
|
class="w-4 h-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500">
|
|
</th>
|
|
<th @click="toggleSort('name')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
이름 / 사번
|
|
<span class="ml-1" x-show="sortKey === 'name'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th @click="toggleSort('dept_name')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
부서 / 직위
|
|
<span class="ml-1" x-show="sortKey === 'dept_name'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">
|
|
<div class="flex items-center gap-1">
|
|
<span class="mr-1">노트북</span>
|
|
<span class="text-slate-300 font-normal">(</span>
|
|
<button @click="toggleSort('laptop_purchase_date')"
|
|
class="hover:text-blue-600 transition-colors flex items-center">
|
|
취득년도
|
|
<span class="ml-0.5 text-[10px]" x-show="sortKey === 'laptop_purchase_date'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</button>
|
|
<span class="text-slate-300 font-normal">/</span>
|
|
<button @click="toggleSort('laptop_model_name')"
|
|
class="hover:text-blue-600 transition-colors flex items-center">
|
|
모델명
|
|
<span class="ml-0.5 text-[10px]" x-show="sortKey === 'laptop_model_name'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</button>
|
|
<span class="text-slate-300 font-normal">)</span>
|
|
</div>
|
|
</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">연락처 /
|
|
사내전화</th>
|
|
<th @click="toggleSort('accounting_type')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
회계구분
|
|
<span class="ml-1" x-show="sortKey === 'accounting_type'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th @click="toggleSort('status')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
상태
|
|
<span class="ml-1" x-show="sortKey === 'status'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-emerald-500 uppercase tracking-wider">단기임대
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-50">
|
|
<template x-for="user in filteredUsers" :key="user.id">
|
|
<tr class="hover:shadow-md transition-all group relative overflow-hidden"
|
|
:class="getPositionInfo(user.position).bgClass" :style="getRowStyle(user)">
|
|
<td class="px-6 py-4 relative z-10">
|
|
<input type="checkbox" :value="user.id" x-model="selectedIds"
|
|
class="w-4 h-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500">
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap cursor-pointer relative z-10"
|
|
@click="editUser(user)">
|
|
<div class="flex items-center">
|
|
<div class="h-11 w-11 flex-shrink-0 rounded-2xl flex items-center justify-center font-black text-lg shadow-sm transform group-hover:scale-110 transition-transform duration-300"
|
|
:class="getPositionInfo(user.position).iconClass" x-text="user.name.charAt(0)">
|
|
</div>
|
|
<div class="ml-4">
|
|
<div class="flex items-center gap-2">
|
|
<div class="text-sm font-black text-slate-900 group-hover:text-blue-700 transition-colors"
|
|
x-text="user.name"></div>
|
|
<template x-if="getPositionInfo(user.position).isVIP">
|
|
<span
|
|
class="text-[9px] px-1.5 py-0.5 rounded-md font-black uppercase tracking-tighter"
|
|
:class="getPositionInfo(user.position).tagClass"
|
|
x-text="'VIP Member'"></span>
|
|
</template>
|
|
</div>
|
|
<div class="text-[11px] font-bold text-slate-400" x-text="user.emp_id"></div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap cursor-pointer relative z-10"
|
|
@click="editUser(user)">
|
|
<div class="text-sm font-bold text-slate-700"
|
|
x-text="user.dept_name ? user.dept_name.split(' > ').pop() : '미소속'">
|
|
</div>
|
|
<div class="text-xs font-black text-slate-900 mt-0.5 flex items-center gap-1.5"
|
|
:class="getPositionInfo(user.position).isVIP ? getPositionInfo(user.position).textClass : ''">
|
|
<template x-if="getPositionInfo(user.position).isVIP">
|
|
<div class="w-1.5 h-1.5 rounded-full"
|
|
:class="getPositionInfo(user.position).tagClass"></div>
|
|
</template>
|
|
<span x-text="user.position || '-'"></span>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap cursor-pointer relative z-10"
|
|
@click="editUser(user)">
|
|
<template x-if="user.laptop_tag">
|
|
<div>
|
|
<div class="text-[11px] font-black text-blue-600 bg-blue-50 px-2 py-0.5 rounded inline-block mb-1"
|
|
x-text="user.laptop_tag"></div>
|
|
<div class="text-[10px] text-slate-500 font-bold">
|
|
<span
|
|
x-text="user.laptop_purchase_date ? user.laptop_purchase_date.substring(0,4) : ''"></span>
|
|
<span x-show="user.laptop_purchase_date && user.laptop_model_name"> /
|
|
</span>
|
|
<span x-text="user.laptop_model_name || ''"></span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<template x-if="!user.laptop_tag">
|
|
<span class="text-[10px] text-slate-300 italic">미배정</span>
|
|
</template>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="text-sm text-slate-600 font-medium" x-text="user.email || '-'"></div>
|
|
<div class="flex flex-col gap-0.5 mt-1">
|
|
<div class="text-[10px] text-slate-400 flex items-center">
|
|
<span class="w-12 font-bold uppercase tracking-tighter">Mobile</span>
|
|
<span class="text-slate-600 font-semibold" x-text="user.mobile || '-'"></span>
|
|
</div>
|
|
<div class="text-[10px] text-slate-400 flex items-center">
|
|
<span class="w-12 font-bold uppercase tracking-tighter">사내전화</span>
|
|
<span class="text-slate-600 font-semibold" x-text="user.phone || '-'"></span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<span
|
|
class="px-3 py-1.5 text-[10px] font-black rounded-lg border shadow-sm transition-all"
|
|
:class="getAccountingInfo(user.accounting_type).badgeClass"
|
|
x-text="user.accounting_type"></span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<template x-if="user.status === 'active'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-emerald-50 text-emerald-600 border border-emerald-100">재직
|
|
중</span>
|
|
</template>
|
|
<template x-if="user.status === 'retired'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-rose-50 text-rose-600 border border-rose-100">퇴사</span>
|
|
</template>
|
|
<template x-if="user.status === 'on_leave'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-amber-50 text-amber-600 border border-amber-100">휴직</span>
|
|
</template>
|
|
<template x-if="user.status === 'classification'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-indigo-50 text-indigo-600 border border-indigo-100">분류</span>
|
|
</template>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-center">
|
|
<template x-if="user.rental_count > 0">
|
|
<button @click="showUserRentals(user)"
|
|
class="w-8 h-8 rounded-full bg-emerald-100 text-emerald-600 font-black text-sm hover:bg-emerald-600 hover:text-white transition-all shadow-sm border border-emerald-200"
|
|
x-text="user.rental_count"></button>
|
|
</template>
|
|
<template x-if="!user.rental_count || user.rental_count == 0">
|
|
<span class="text-slate-200 text-xs">-</span>
|
|
</template>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
</tbody>
|
|
</table>
|
|
<div x-show="filteredUsers.length === 0" class="py-20 text-center bg-white">
|
|
<div class="text-slate-300 mb-2">
|
|
<svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
|
|
</svg>
|
|
</div>
|
|
<p class="text-slate-400 font-medium">검색 결과가 없습니다.</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Rental List Modal -->
|
|
<div x-show="showRentalListModal" x-cloak class="fixed inset-0 z-[120] flex items-center justify-center p-4">
|
|
<div class="fixed inset-0 modal-bg" @click="showRentalListModal = false"></div>
|
|
<div
|
|
class="bg-white rounded-[2rem] p-8 max-w-2xl w-full relative z-[121] shadow-2xl overflow-hidden flex flex-col max-h-[85vh]">
|
|
<div class="flex justify-between items-start mb-6">
|
|
<div class="flex items-center gap-4">
|
|
<div class="w-12 h-12 bg-emerald-100 rounded-2xl flex items-center justify-center">
|
|
<svg class="w-6 h-6 text-emerald-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7" />
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-2xl font-black text-slate-900" x-text="selectedUser?.name + '님의 단기 임대 목록'"></h3>
|
|
<p class="text-xs font-bold text-slate-400 uppercase tracking-widest"
|
|
x-text="(selectedUser?.dept_name || '미소속') + ' / ' + (selectedUser?.position || '-')"></p>
|
|
</div>
|
|
</div>
|
|
<button @click="showRentalListModal = false"
|
|
class="text-slate-300 hover:text-slate-900 transition-colors">
|
|
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="flex-1 overflow-y-auto pr-2 no-scrollbar">
|
|
<div class="grid grid-cols-1 gap-4">
|
|
<template x-for="rental in userRentals" :key="rental.id">
|
|
<div
|
|
class="bg-slate-50 rounded-2xl p-5 border border-slate-100 items-center justify-between flex">
|
|
<div>
|
|
<div class="flex items-center gap-2 mb-1">
|
|
<span class="text-xs font-black text-blue-600 bg-blue-100 px-2 py-0.5 rounded-lg"
|
|
x-text="rental.asset_tag"></span>
|
|
<span class="text-sm font-bold text-slate-800" x-text="rental.model_name"></span>
|
|
</div>
|
|
<div class="text-[10px] text-slate-400 font-bold uppercase tracking-wider"
|
|
x-text="rental.manufacturer"></div>
|
|
<template x-if="rental.rental_peripherals">
|
|
<div class="flex flex-wrap gap-1 mt-2">
|
|
<template x-for="p in rental.rental_peripherals.split(',')">
|
|
<span
|
|
class="px-1.5 py-0.5 bg-emerald-50 text-emerald-600 text-[9px] font-black rounded border border-emerald-100"
|
|
x-text="p"></span>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
<div class="text-right">
|
|
<div class="text-[11px] font-black text-slate-400 uppercase mb-1">임대 현황</div>
|
|
<div class="space-y-1">
|
|
<div class="text-xs font-bold text-slate-700">시작: <span
|
|
x-text="rental.rental_start_date"></span></div>
|
|
<div class="text-xs font-bold text-rose-500" x-show="rental.rental_end_scheduled">
|
|
예정: <span x-text="rental.rental_end_scheduled"></span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-8">
|
|
<button @click="showRentalListModal = false"
|
|
class="w-full py-4 bg-slate-900 text-white rounded-2xl font-bold hover:bg-slate-800 transition-all shadow-lg shadow-slate-200">
|
|
확인완료
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- User Registration/Edit Modal -->
|
|
<div x-show="showModal" x-cloak class="fixed inset-0 z-[110] flex items-center justify-center p-4">
|
|
<div class="fixed inset-0 modal-bg" @click="showModal = false"></div>
|
|
<div class="bg-white rounded-3xl p-8 max-w-xl w-full relative z-[111] shadow-2xl overflow-hidden">
|
|
<h3 class="text-2xl font-black text-slate-900 mb-8" x-text="isEdit ? '직원 정보 수정' : '신규 직원 등록'"></h3>
|
|
<form @submit.prevent="submitUser" class="space-y-6">
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">이름</label>
|
|
<input type="text" x-model="formData.name" required
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">사번</label>
|
|
<input type="text" x-model="formData.emp_id" required
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">부서</label>
|
|
<select x-model="formData.department_id"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="">부서 선택</option>
|
|
<template x-for="dept in depts" :key="dept.id">
|
|
<option :value="dept.id" x-text="dept.path"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">직위</label>
|
|
<input type="text" x-model="formData.position"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">이메일</label>
|
|
<input type="email" x-model="formData.email"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">회계구분</label>
|
|
<select x-model="formData.accounting_type"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="일반회계">일반회계</option>
|
|
<option value="특별회계">특별회계</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">휴대폰</label>
|
|
<input type="text" x-model="formData.mobile"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">사내전화</label>
|
|
<input type="text" x-model="formData.phone"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">상태</label>
|
|
<select x-model="formData.status"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="active">재직</option>
|
|
<option value="retired">퇴사</option>
|
|
<option value="on_leave">휴직</option>
|
|
<option value="classification">분류</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Laptop Info Section (Read-only) -->
|
|
<template x-if="isEdit && formData.laptop_tag">
|
|
<div class="bg-blue-50/50 p-6 rounded-[2rem] border border-blue-100/50 space-y-4 mt-6">
|
|
<div class="flex items-center gap-2 mb-2">
|
|
<div class="w-1.5 h-1.5 rounded-full bg-blue-500"></div>
|
|
<h4 class="text-xs font-black text-blue-600 uppercase tracking-widest">사용 중인 노트북 정보</h4>
|
|
</div>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label
|
|
class="block text-[10px] font-black text-slate-400 uppercase mb-2 ml-1">자산번호</label>
|
|
<div class="px-4 py-3 bg-white border border-slate-200 rounded-xl text-sm font-bold text-blue-600"
|
|
x-text="formData.laptop_tag"></div>
|
|
</div>
|
|
<div>
|
|
<label
|
|
class="block text-[10px] font-black text-slate-400 uppercase mb-2 ml-1">모델명</label>
|
|
<div class="px-4 py-3 bg-white border border-slate-200 rounded-xl text-sm font-bold text-slate-700"
|
|
x-text="formData.laptop_model_name || '-'"></div>
|
|
</div>
|
|
<div>
|
|
<label
|
|
class="block text-[10px] font-black text-slate-400 uppercase mb-2 ml-1">취득일</label>
|
|
<div class="px-4 py-3 bg-white border border-slate-200 rounded-xl text-sm font-bold text-slate-700"
|
|
x-text="formData.laptop_purchase_date || '-'"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<div class="pt-6 flex gap-4">
|
|
<button type="button" @click="showModal = false"
|
|
class="flex-1 py-4 bg-slate-100 text-slate-600 rounded-2xl font-bold hover:bg-slate-200 transition-all">취소</button>
|
|
<button type="submit"
|
|
class="flex-1 py-4 bg-blue-600 text-white rounded-2xl font-bold shadow-lg shadow-blue-200 hover:bg-blue-700 transition-all"
|
|
x-text="isEdit ? '수정 완료' : '직원 추가'"></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Restore (Import) Modal -->
|
|
<div x-show="showRestoreModal" x-cloak class="fixed inset-0 z-[120] flex items-center justify-center p-4">
|
|
<div class="fixed inset-0 modal-bg" @click="showRestoreModal = false"></div>
|
|
<div
|
|
class="bg-white rounded-[2.5rem] p-8 max-w-2xl w-full relative z-[121] shadow-2xl overflow-hidden flex flex-col max-h-[85vh]">
|
|
<div class="flex justify-between items-start mb-6">
|
|
<div>
|
|
<h3 class="text-2xl font-black text-slate-900">아카이브에서 불러오기</h3>
|
|
<p class="text-xs font-bold text-slate-400 uppercase tracking-widest mt-1">Select Archived Employees
|
|
to Restore</p>
|
|
</div>
|
|
<button @click="showRestoreModal = false" class="text-slate-300 hover:text-slate-900 transition-colors">
|
|
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="flex-1 overflow-y-auto pr-2 no-scrollbar">
|
|
<template x-if="archivedUsers.length === 0">
|
|
<div class="text-center py-20">
|
|
<div class="w-16 h-16 bg-slate-50 rounded-2xl flex items-center justify-center mx-auto mb-4">
|
|
<svg class="w-8 h-8 text-slate-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />
|
|
</svg>
|
|
</div>
|
|
<p class="text-slate-400 font-bold">내보내기된 직원이 없습니다.</p>
|
|
</div>
|
|
</template>
|
|
|
|
<div class="grid grid-cols-1 gap-3">
|
|
<template x-for="user in archivedUsers" :key="user.id">
|
|
<div
|
|
class="p-4 bg-slate-50 border border-slate-100 rounded-2xl flex items-center justify-between group hover:bg-white hover:shadow-lg hover:border-blue-200 transition-all">
|
|
<div class="flex items-center gap-4">
|
|
<div
|
|
class="w-10 h-10 bg-white rounded-xl flex items-center justify-center shadow-sm text-slate-400 group-hover:text-blue-500 transition-colors">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<div class="text-sm font-black text-slate-900" x-text="user.name"></div>
|
|
<div class="text-[10px] font-bold text-slate-400"
|
|
x-text="user.dept_name + ' / ' + user.position"></div>
|
|
</div>
|
|
</div>
|
|
<button @click="restoreUser(user.id)"
|
|
class="px-4 py-2 bg-slate-900 text-white text-[11px] font-black rounded-xl hover:bg-blue-600 transition-all active:scale-95">
|
|
불러오기
|
|
</button>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CSV Export Modal -->
|
|
<div x-show="showExportModal" x-cloak class="fixed inset-0 z-[130] flex items-center justify-center p-4">
|
|
<div class="fixed inset-0 modal-bg" @click="showExportModal = false"></div>
|
|
<div class="bg-white rounded-[2.5rem] p-8 max-w-lg w-full relative z-[131] shadow-2xl overflow-hidden">
|
|
<div class="flex justify-between items-start mb-6">
|
|
<div>
|
|
<h3 class="text-2xl font-black text-slate-900">CSV 내보내기 설정</h3>
|
|
<p class="text-xs font-bold text-slate-400 uppercase tracking-widest mt-1">Select Columns to Export
|
|
</p>
|
|
</div>
|
|
<button @click="showExportModal = false" class="text-slate-300 hover:text-slate-900 transition-colors">
|
|
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="mb-6">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<span class="text-sm font-bold text-slate-600">내보낼 항목 선택</span>
|
|
<button @click="toggleAllColumns" class="text-xs font-bold text-blue-600 hover:underline">전체
|
|
선택/해제</button>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-3">
|
|
<template x-for="(label, key) in columnOptions" :key="key">
|
|
<label
|
|
class="flex items-center p-3 bg-slate-50 rounded-xl cursor-pointer hover:bg-blue-50 transition-colors border border-transparent"
|
|
:class="selectedColumns.includes(key) ? 'border-blue-200 bg-blue-50/50' : ''">
|
|
<input type="checkbox" :value="key" x-model="selectedColumns"
|
|
class="w-4 h-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500 mr-3">
|
|
<span class="text-sm font-medium text-slate-700" x-text="label"></span>
|
|
</label>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-3">
|
|
<div class="p-4 bg-amber-50 rounded-2xl border border-amber-100 mb-2">
|
|
<div class="flex gap-3">
|
|
<svg class="w-5 h-5 text-amber-500 shrink-0" fill="none" stroke="currentColor"
|
|
viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
<p class="text-[11px] font-bold text-amber-700 leading-normal">
|
|
<span x-show="selectedIds.length > 0"><span class="text-rose-600"
|
|
x-text="selectedIds.length"></span>명의 선택된 직원 정보를 내보냅니다.</span>
|
|
<span x-show="selectedIds.length === 0">전체 <span class="text-blue-600"
|
|
x-text="users.length"></span>명의 직원 정보를 내보냅니다.</span>
|
|
<br>UTF-8 BOM이 포함되어 엑셀에서 바로 열어도 한글이 깨지지 않습니다.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<button @click="downloadCSV" :disabled="selectedColumns.length === 0"
|
|
class="w-full py-4 bg-blue-600 text-white rounded-2xl font-black hover:bg-blue-700 transition-all shadow-lg shadow-blue-200 disabled:opacity-50 disabled:shadow-none flex items-center justify-center gap-2">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
|
</svg>
|
|
CSV 다운로드 시작
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function userManagement() {
|
|
return {
|
|
users: [],
|
|
depts: [],
|
|
loading: true,
|
|
showModal: false,
|
|
isEdit: false,
|
|
searchQuery: '',
|
|
filterRetired: false,
|
|
filterOnLeave: true,
|
|
filterClassification: true,
|
|
sortKey: 'name',
|
|
sortOrder: 'asc',
|
|
selectedIds: [],
|
|
bulkStatus: '',
|
|
bulkDeptId: '',
|
|
bulkPosition: '',
|
|
showRentalListModal: false,
|
|
showRestoreModal: false,
|
|
showExportModal: false,
|
|
userRentals: [],
|
|
archivedUsers: [],
|
|
selectedColumns: ['name', 'emp_id', 'dept_name', 'position', 'email', 'mobile', 'status', 'laptop_tag'],
|
|
columnOptions: {
|
|
'name': '이름',
|
|
'emp_id': '사번',
|
|
'dept_name': '부서',
|
|
'position': '직위',
|
|
'email': '이메일',
|
|
'mobile': '휴대폰',
|
|
'phone': '사내전화',
|
|
'accounting_type': '회계구분',
|
|
'status': '상태',
|
|
'laptop_tag': '노트북 자산번호'
|
|
},
|
|
formData: { id: '', name: '', emp_id: '', department_id: '', position: '', email: '', mobile: '', accounting_type: '일반회계', status: 'active', phone: '' },
|
|
|
|
init() {
|
|
this.fetchUsers();
|
|
this.fetchDepts();
|
|
},
|
|
|
|
get visibleCount() {
|
|
return this.filteredUsers.length;
|
|
},
|
|
|
|
get filteredUsers() {
|
|
let result = [...this.users];
|
|
if (this.searchQuery) {
|
|
const q = this.searchQuery.toLowerCase();
|
|
result = result.filter(u => u.name.toLowerCase().includes(q) || u.emp_id.toLowerCase().includes(q) || (u.email && u.email.toLowerCase().includes(q)));
|
|
}
|
|
if (!this.filterRetired) result = result.filter(u => u.status !== 'retired');
|
|
if (!this.filterOnLeave) result = result.filter(u => u.status !== 'on_leave');
|
|
if (!this.filterClassification) result = result.filter(u => u.status !== 'classification');
|
|
|
|
// 직위 랭킹 함수
|
|
const getRank = (pos) => {
|
|
if (!pos) return 99;
|
|
if (pos.includes('부회장')) return 1;
|
|
if (pos.includes('총괄')) return 2;
|
|
if (pos.includes('원장')) return 3;
|
|
if (pos.includes('센터장')) return 4;
|
|
if (pos.includes('본부장')) return 5;
|
|
if (pos.includes('실장')) return 6;
|
|
if (pos.includes('부문장')) return 7;
|
|
if (pos.includes('팀장')) return 8;
|
|
return 90;
|
|
};
|
|
|
|
result.sort((a, b) => {
|
|
if (this.sortKey) {
|
|
let valA = a[this.sortKey] || '';
|
|
let valB = b[this.sortKey] || '';
|
|
if (typeof valA === 'string') valA = valA.toLowerCase();
|
|
if (typeof valB === 'string') valB = valB.toLowerCase();
|
|
if (valA !== valB) {
|
|
if (valA < valB) return this.sortOrder === 'asc' ? -1 : 1;
|
|
if (valA > valB) return this.sortOrder === 'asc' ? 1 : -1;
|
|
}
|
|
}
|
|
|
|
// 2순위: 직위 랭킹 (정렬 기준이 같을 때만 적용)
|
|
return getRank(a.position) - getRank(b.position);
|
|
});
|
|
return result;
|
|
},
|
|
|
|
getPositionInfo(pos) {
|
|
if (!pos) return { bgClass: 'bg-white', iconClass: 'bg-slate-100 text-slate-500', isVIP: false };
|
|
|
|
const configs = [
|
|
{ key: '부회장', from: '#fbbf24', to: '#d97706', text: 'text-amber-700', icon: 'bg-amber-100 text-amber-600', tag: 'bg-amber-500 text-white' },
|
|
{ key: '총괄', from: '#3b82f6', to: '#1d4ed8', text: 'text-blue-700', icon: 'bg-blue-100 text-blue-600', tag: 'bg-blue-600 text-white' },
|
|
{ key: '원장', from: '#10b981', to: '#059669', text: 'text-emerald-700', icon: 'bg-emerald-100 text-emerald-600', tag: 'bg-emerald-600 text-white' },
|
|
{ key: '센터장', from: '#06b6d4', to: '#0891b2', text: 'text-cyan-700', icon: 'bg-cyan-100 text-cyan-600', tag: 'bg-cyan-600 text-white' },
|
|
{ key: '본부장', from: '#8b5cf6', to: '#7c3aed', text: 'text-purple-700', icon: 'bg-purple-100 text-purple-600', tag: 'bg-purple-600 text-white' },
|
|
{ key: '실장', from: '#64748b', to: '#475569', text: 'text-slate-700', icon: 'bg-slate-100 text-slate-600', tag: 'bg-slate-600 text-white' },
|
|
{ key: '부문장', from: '#f43f5e', to: '#e11d48', text: 'text-rose-700', icon: 'bg-rose-100 text-rose-600', tag: 'bg-rose-600 text-white' },
|
|
{ key: '팀장', from: '#6366f1', to: '#4f46e5', text: 'text-indigo-700', icon: 'bg-indigo-100 text-indigo-600', tag: 'bg-indigo-600 text-white' }
|
|
];
|
|
|
|
const config = configs.find(c => pos.includes(c.key));
|
|
if (config) {
|
|
return {
|
|
isVIP: true,
|
|
from: config.from,
|
|
bgClass: 'hover:bg-opacity-50 transition-all cursor-pointer',
|
|
iconClass: config.icon,
|
|
tagClass: config.tag,
|
|
textClass: config.text
|
|
};
|
|
}
|
|
return { bgClass: 'bg-white', iconClass: 'bg-slate-100 text-slate-500', isVIP: false };
|
|
},
|
|
|
|
getAccountingInfo(type) {
|
|
if (type === '특별회계') {
|
|
return {
|
|
isSpecial: true,
|
|
badgeClass: 'bg-amber-100 text-amber-700 border-amber-200',
|
|
rowGradient: 'linear-gradient(to left, rgba(251, 191, 36, 0.1) 0%, transparent 40%)'
|
|
};
|
|
}
|
|
return {
|
|
isSpecial: false,
|
|
badgeClass: 'bg-blue-50 text-blue-600 border-blue-100',
|
|
rowGradient: ''
|
|
};
|
|
},
|
|
|
|
getRowStyle(user) {
|
|
const vip = this.getPositionInfo(user.position);
|
|
const acc = this.getAccountingInfo(user.accounting_type);
|
|
let gradients = [];
|
|
|
|
if (vip.isVIP) {
|
|
gradients.push(`linear-gradient(to right, ${vip.from}08 0%, transparent 60%)`);
|
|
}
|
|
if (acc.isSpecial) {
|
|
gradients.push(acc.rowGradient);
|
|
}
|
|
|
|
return gradients.length > 0 ? `background: ${gradients.join(', ')}` : 'background: white';
|
|
},
|
|
|
|
fetchUsers() {
|
|
const scrollPos = window.scrollY;
|
|
this.loading = true;
|
|
fetch('api.php?action=get_users')
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
this.users = data;
|
|
this.loading = false;
|
|
this.$nextTick(() => window.scrollTo(0, scrollPos));
|
|
});
|
|
},
|
|
|
|
fetchDepts() {
|
|
fetch('api.php?action=get_departments').then(res => res.json()).then(data => { this.depts = data; });
|
|
},
|
|
|
|
toggleSort(key) {
|
|
if (this.sortKey === key) {
|
|
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
|
} else {
|
|
this.sortKey = key;
|
|
this.sortOrder = 'asc';
|
|
}
|
|
},
|
|
|
|
toggleSelectAll(checked) {
|
|
this.selectedIds = checked ? this.filteredUsers.map(u => u.id) : [];
|
|
},
|
|
|
|
showUserRentals(user) {
|
|
this.selectedUser = user;
|
|
fetch(`api.php?action=get_user_rentals&user_id=${user.id}`)
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
this.userRentals = data;
|
|
this.showRentalListModal = true;
|
|
});
|
|
},
|
|
|
|
openAddModal() {
|
|
this.resetForm();
|
|
this.showModal = true;
|
|
},
|
|
|
|
editUser(user) {
|
|
this.isEdit = true;
|
|
this.formData = { ...user };
|
|
this.showModal = true;
|
|
},
|
|
|
|
submitUser() {
|
|
if (!this.formData.department_id) {
|
|
window.showAlert('부서를 선택해주세요.', '입력 확인', 'error');
|
|
return;
|
|
}
|
|
const action = this.isEdit ? 'update_user' : 'add_user';
|
|
fetch(`api.php?action=${action}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(this.formData)
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
window.showAlert(this.isEdit ? '정보가 수정되었습니다.' : '새 직원이 등록되었습니다.', '성공', 'success');
|
|
this.showModal = false;
|
|
this.fetchUsers();
|
|
} else {
|
|
window.showAlert(data.error || '처리 중 오류가 발생했습니다.', '오류', 'error');
|
|
}
|
|
}).catch(err => {
|
|
console.error(err);
|
|
window.showAlert('서버와 통신 중 문제가 발생했습니다.', '시스템 오류', 'error');
|
|
});
|
|
},
|
|
|
|
applyBulkUpdate() {
|
|
if (this.selectedIds.length === 0) return;
|
|
fetch('api.php?action=bulk_update_users', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
user_ids: this.selectedIds,
|
|
status: this.bulkStatus,
|
|
department_id: this.bulkDeptId,
|
|
position: this.bulkPosition
|
|
})
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
window.showAlert(`${this.selectedIds.length}명의 직원 정보가 일괄 변경되었습니다.`, '변경 성공', 'success');
|
|
this.selectedIds = [];
|
|
this.bulkStatus = '';
|
|
this.bulkDeptId = '';
|
|
this.bulkPosition = '';
|
|
this.fetchUsers();
|
|
} else {
|
|
window.showAlert('직원 정보 일괄 변경에 실패했습니다.', '변경 실패', 'error');
|
|
}
|
|
});
|
|
},
|
|
|
|
resetForm() {
|
|
this.isEdit = false;
|
|
this.formData = { id: '', name: '', emp_id: '', department_id: '', position: '', email: '', mobile: '', accounting_type: '일반회계', status: 'active', phone: '' };
|
|
},
|
|
|
|
archiveUsers() {
|
|
window.showConfirm(`선택한 ${this.selectedIds.length}명의 직원을 내보내기 하시겠습니까?\n내보내기된 정보는 '불러오기' 메뉴에서 확인 가능합니다.`, () => {
|
|
fetch('api.php?action=archive_users', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ user_ids: this.selectedIds })
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
window.showAlert('선택한 인원이 아카이브로 내보내기 되었습니다.', '내보내기 완료', 'success');
|
|
this.selectedIds = [];
|
|
this.fetchUsers();
|
|
}
|
|
});
|
|
}, '내보내기 확인');
|
|
},
|
|
|
|
bulkDelete() {
|
|
window.showConfirm(`선택한 ${this.selectedIds.length}명의 직원을 영구 삭제하시겠습니까?\n이 작업은 되돌릴 수 없습니다.`, () => {
|
|
fetch('api.php?action=bulk_delete_users', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ user_ids: this.selectedIds })
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
window.showAlert('영구 삭제되었습니다.', '삭제 완료', 'success');
|
|
this.selectedIds = [];
|
|
this.fetchUsers();
|
|
}
|
|
});
|
|
}, '영구 삭제 확인');
|
|
},
|
|
|
|
openRestoreModal() {
|
|
this.fetchArchivedUsers();
|
|
},
|
|
|
|
fetchArchivedUsers() {
|
|
fetch('api.php?action=get_archived_users')
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
this.archivedUsers = data;
|
|
this.showRestoreModal = true;
|
|
});
|
|
},
|
|
|
|
restoreUser(id) {
|
|
fetch('api.php?action=restore_users', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ user_ids: [id] })
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
window.showAlert('직원 정보가 복구되었습니다.', '불러오기 성공', 'success');
|
|
this.fetchArchivedUsers();
|
|
this.fetchUsers();
|
|
}
|
|
});
|
|
},
|
|
|
|
openExportModal() {
|
|
this.showExportModal = true;
|
|
},
|
|
|
|
toggleAllColumns() {
|
|
if (this.selectedColumns.length === Object.keys(this.columnOptions).length) {
|
|
this.selectedColumns = [];
|
|
} else {
|
|
this.selectedColumns = Object.keys(this.columnOptions);
|
|
}
|
|
},
|
|
|
|
async downloadCSV() {
|
|
const columns = {};
|
|
this.selectedColumns.forEach(key => {
|
|
columns[key] = this.columnOptions[key];
|
|
});
|
|
|
|
try {
|
|
const response = await fetch('api.php?action=export_users_csv', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
user_ids: this.selectedIds,
|
|
columns: columns
|
|
})
|
|
});
|
|
|
|
if (!response.ok) throw new Error('Download failed');
|
|
|
|
const blob = await response.blob();
|
|
const url = window.URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = `직원목록_${new Date().toISOString().slice(0, 10)}.csv`;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
this.showExportModal = false;
|
|
|
|
window.showAlert('CSV 파일 다운로드가 시작되었습니다.', '다운로드 성공', 'success');
|
|
} catch (err) {
|
|
console.error(err);
|
|
window.showAlert('다운로드 중 오류가 발생했습니다.', '오류', 'error');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|