|
|
@@ -19,6 +19,17 @@
|
|
|
{{ team.name }}
|
|
|
</option>
|
|
|
</select>
|
|
|
+
|
|
|
+ <label class="admin--filter-label">직책</label>
|
|
|
+ <select v-model="filters.position" class="admin--form-select">
|
|
|
+ <option value="">전체</option>
|
|
|
+ <option value="10">팀장</option>
|
|
|
+ <option value="15">마스터</option>
|
|
|
+ <option value="20">차장</option>
|
|
|
+ <option value="30">과장</option>
|
|
|
+ <option value="40">대리</option>
|
|
|
+ <option value="60">사원</option>
|
|
|
+ </select>
|
|
|
</div>
|
|
|
|
|
|
<div class="admin--filter-row">
|
|
|
@@ -30,23 +41,23 @@
|
|
|
placeholder="이름으로 검색"
|
|
|
@keyup.enter="handleSearch"
|
|
|
/>
|
|
|
- <button class="admin--btn admin--btn-primary" @click="handleSearch">
|
|
|
+ <button class="admin--btn-small admin--btn-small-primary" @click="handleSearch">
|
|
|
검색
|
|
|
</button>
|
|
|
- <button class="admin--btn admin--btn-secondary" @click="handleReset">
|
|
|
+ <button class="admin--btn-small admin--btn-small-secondary" @click="handleReset">
|
|
|
초기화
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="admin--search-actions">
|
|
|
- <button class="admin--btn admin--btn-secondary" @click="handleExcelDownload">
|
|
|
+ <button class="admin--btn-small admin--btn-small-excel" @click="handleExcelDownload">
|
|
|
엑셀 다운로드
|
|
|
</button>
|
|
|
- <button class="admin--btn admin--btn-secondary" @click="handleA2Print">
|
|
|
+ <button class="admin--btn-small admin--btn-small-secondary" @click="handleA2Print">
|
|
|
A2 출력하기
|
|
|
</button>
|
|
|
- <button class="admin--btn admin--btn-primary" @click="goToCreate">
|
|
|
+ <button class="admin--btn-small admin--btn-small-primary" @click="goToCreate">
|
|
|
+ 사원 등록
|
|
|
</button>
|
|
|
</div>
|
|
|
@@ -70,10 +81,7 @@
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
- <tr v-if="isLoading">
|
|
|
- <td colspan="10" class="admin--table-loading">데이터를 불러오는 중...</td>
|
|
|
- </tr>
|
|
|
- <tr v-else-if="!salesList || salesList.length === 0">
|
|
|
+ <tr v-if="!salesList || salesList.length === 0">
|
|
|
<td colspan="10" class="admin--table-empty">등록된 영업사원이 없습니다.</td>
|
|
|
</tr>
|
|
|
<tr v-else v-for="(sales, index) in salesList" :key="sales.id">
|
|
|
@@ -84,12 +92,12 @@
|
|
|
<div v-else class="admin--table-photo-empty">사진없음</div>
|
|
|
</div>
|
|
|
</td>
|
|
|
- <td>{{ sales.showroom_name }}</td>
|
|
|
- <td>{{ sales.team_name }}</td>
|
|
|
+ <td>{{ getShowroomName(sales.showroom) }}</td>
|
|
|
+ <td>{{ getTeamName(sales.team) }}</td>
|
|
|
<td class="admin--table-title">{{ sales.name }}</td>
|
|
|
- <td>{{ sales.position }}</td>
|
|
|
+ <td>{{ getPositionName(sales.position) }}</td>
|
|
|
<td>{{ sales.main_phone }}</td>
|
|
|
- <td>{{ sales.mobile }}</td>
|
|
|
+ <td>{{ sales.direct_phone }}</td>
|
|
|
<td>{{ sales.email }}</td>
|
|
|
<td>
|
|
|
<div class="admin--table-actions admin--table-actions-col">
|
|
|
@@ -112,7 +120,7 @@
|
|
|
프린트
|
|
|
</button>
|
|
|
<button
|
|
|
- class="admin--btn-small admin--btn-small-secondary"
|
|
|
+ class="admin--btn-small admin--btn-small-excel"
|
|
|
@click="handleExcelExport(sales.id)"
|
|
|
>
|
|
|
엑셀출력
|
|
|
@@ -165,8 +173,6 @@
|
|
|
const router = useRouter();
|
|
|
const { get, del } = useApi();
|
|
|
const { getImageUrl } = useImage();
|
|
|
-
|
|
|
- const isLoading = ref(false);
|
|
|
const salesList = ref([]);
|
|
|
const showrooms = ref([]);
|
|
|
|
|
|
@@ -188,6 +194,7 @@
|
|
|
const filters = ref({
|
|
|
showroom: "",
|
|
|
team: "",
|
|
|
+ position: "",
|
|
|
keyword: "",
|
|
|
});
|
|
|
|
|
|
@@ -229,8 +236,6 @@
|
|
|
|
|
|
// 데이터 로드
|
|
|
const loadSales = async () => {
|
|
|
- isLoading.value = true;
|
|
|
-
|
|
|
const params = {
|
|
|
page: currentPage.value,
|
|
|
per_page: perPage.value,
|
|
|
@@ -246,8 +251,6 @@
|
|
|
totalPages.value = Math.ceil(totalCount.value / perPage.value);
|
|
|
console.log("[SalesList] 영업사원 목록 로드 성공");
|
|
|
}
|
|
|
-
|
|
|
- isLoading.value = false;
|
|
|
};
|
|
|
|
|
|
// 검색
|
|
|
@@ -261,12 +264,40 @@
|
|
|
filters.value = {
|
|
|
showroom: "",
|
|
|
team: "",
|
|
|
+ position: "",
|
|
|
keyword: "",
|
|
|
};
|
|
|
currentPage.value = 1;
|
|
|
loadSales();
|
|
|
};
|
|
|
|
|
|
+ // 전시장 이름 가져오기
|
|
|
+ const getShowroomName = (showroomId) => {
|
|
|
+ const showroom = showrooms.value.find(s => s.id === showroomId);
|
|
|
+ return showroom ? showroom.name : '-';
|
|
|
+ };
|
|
|
+
|
|
|
+ // 팀 이름 가져오기
|
|
|
+ const getTeamName = (teamId) => {
|
|
|
+ if (teamId === 0 || teamId === '0') {
|
|
|
+ return '마스터팀';
|
|
|
+ }
|
|
|
+ return teamId ? `${teamId}팀` : '-';
|
|
|
+ };
|
|
|
+
|
|
|
+ // 직책 이름 가져오기
|
|
|
+ const getPositionName = (positionCode) => {
|
|
|
+ const positions = {
|
|
|
+ 10: '팀장',
|
|
|
+ 15: '마스터',
|
|
|
+ 20: '차장',
|
|
|
+ 30: '과장',
|
|
|
+ 40: '대리',
|
|
|
+ 60: '사원'
|
|
|
+ };
|
|
|
+ return positions[positionCode] || '-';
|
|
|
+ };
|
|
|
+
|
|
|
// 페이지 변경
|
|
|
const changePage = (page) => {
|
|
|
if (page < 1 || page > totalPages.value) return;
|
|
|
@@ -276,24 +307,290 @@
|
|
|
|
|
|
// 엑셀 다운로드 (전체)
|
|
|
const handleExcelDownload = async () => {
|
|
|
- const params = { ...filters.value };
|
|
|
- window.open(`/api/staff/sales/excel?${new URLSearchParams(params)}`, "_blank");
|
|
|
+ // 전체 데이터 가져오기 (페이지네이션 없이)
|
|
|
+ const params = {
|
|
|
+ ...filters.value,
|
|
|
+ per_page: 10000 // 충분히 큰 값으로 전체 가져오기
|
|
|
+ };
|
|
|
+
|
|
|
+ const { data } = await get("/staff/sales", params);
|
|
|
+ if (!data?.success || !data?.data) {
|
|
|
+ alert('데이터를 가져올 수 없습니다.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const allStaff = data.data.items || [];
|
|
|
+
|
|
|
+ if (allStaff.length === 0) {
|
|
|
+ alert('다운로드할 데이터가 없습니다.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // HTML 테이블 생성
|
|
|
+ let tableRows = '';
|
|
|
+ allStaff.forEach((staff, index) => {
|
|
|
+ const showroomName = getShowroomName(staff.showroom);
|
|
|
+ const teamName = getTeamName(staff.team);
|
|
|
+ const positionName = getPositionName(staff.position);
|
|
|
+ const photoUrl = staff.photo_url ? getImageUrl(staff.photo_url) : '';
|
|
|
+
|
|
|
+ tableRows += `
|
|
|
+ <tr style="height: 110px;">
|
|
|
+ <td style="text-align: center; vertical-align: middle;">${index + 1}</td>
|
|
|
+ <td style="text-align: center; padding: 5px; vertical-align: middle;">
|
|
|
+ ${photoUrl ? `<img src="${photoUrl}" height="100" style="display: block; margin: 0 auto; max-width: 100%;" />` : '사진없음'}
|
|
|
+ </td>
|
|
|
+ <td style="vertical-align: middle;">${showroomName}</td>
|
|
|
+ <td style="vertical-align: middle;">${teamName}</td>
|
|
|
+ <td style="vertical-align: middle;">${staff.name}</td>
|
|
|
+ <td style="vertical-align: middle;">${positionName}</td>
|
|
|
+ <td style="vertical-align: middle;">${staff.main_phone || ''}</td>
|
|
|
+ <td style="vertical-align: middle;">${staff.direct_phone || ''}</td>
|
|
|
+ <td style="vertical-align: middle;">${staff.email || ''}</td>
|
|
|
+ </tr>
|
|
|
+ `;
|
|
|
+ });
|
|
|
+
|
|
|
+ const html = `
|
|
|
+<html xmlns:x="urn:schemas-microsoft-com:office:excel">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <style>
|
|
|
+ body {
|
|
|
+ font-family: "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
|
|
|
+ }
|
|
|
+ table {
|
|
|
+ border-collapse: collapse;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ th, td {
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ padding: 10px;
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ th {
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ font-weight: bold;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ .title {
|
|
|
+ font-size: 18pt;
|
|
|
+ font-weight: bold;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="title">영업사원 목록</div>
|
|
|
+ <table>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>NO</th>
|
|
|
+ <th>사진</th>
|
|
|
+ <th>전시장</th>
|
|
|
+ <th>팀</th>
|
|
|
+ <th>이름</th>
|
|
|
+ <th>직책</th>
|
|
|
+ <th>대표번호</th>
|
|
|
+ <th>핸드폰</th>
|
|
|
+ <th>이메일</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ ${tableRows}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+</body>
|
|
|
+</html>`;
|
|
|
+
|
|
|
+ // Blob 생성 및 다운로드
|
|
|
+ const blob = new Blob(['\ufeff' + html], { type: 'application/vnd.ms-excel;charset=utf-8;' });
|
|
|
+ const link = document.createElement('a');
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
+ link.setAttribute('href', url);
|
|
|
+ link.setAttribute('download', `sales_staff_list_${new Date().toISOString().split('T')[0]}.xls`);
|
|
|
+ link.style.visibility = 'hidden';
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
};
|
|
|
|
|
|
// A2 출력
|
|
|
const handleA2Print = () => {
|
|
|
- const params = { ...filters.value };
|
|
|
- window.open(`/api/staff/sales/print-a2?${new URLSearchParams(params)}`, "_blank");
|
|
|
+ window.open('/admin/staff/sales/print-a2', '_blank');
|
|
|
};
|
|
|
|
|
|
// 개별 프린트
|
|
|
const handlePrint = (id) => {
|
|
|
- window.open(`/api/staff/sales/${id}/print`, "_blank");
|
|
|
+ window.open(`/admin/staff/sales/print/${id}`, "_blank");
|
|
|
};
|
|
|
|
|
|
// 개별 엑셀 출력
|
|
|
- const handleExcelExport = (id) => {
|
|
|
- window.open(`/api/staff/sales/${id}/excel`, "_blank");
|
|
|
+ const handleExcelExport = async (id) => {
|
|
|
+ // 해당 사원 데이터 가져오기
|
|
|
+ const { data } = await get(`/staff/sales/${id}`);
|
|
|
+ if (!data?.success || !data?.data) {
|
|
|
+ alert('데이터를 가져올 수 없습니다.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const staff = data.data;
|
|
|
+
|
|
|
+ // 전시장 이름
|
|
|
+ const showroomName = getShowroomName(staff.showroom);
|
|
|
+ // 팀 이름
|
|
|
+ const teamName = getTeamName(staff.team);
|
|
|
+ // 직책 이름
|
|
|
+ const positionName = getPositionName(staff.position);
|
|
|
+
|
|
|
+ // 사진 URL
|
|
|
+ const photoUrl = staff.photo_url ? getImageUrl(staff.photo_url) : '';
|
|
|
+
|
|
|
+ // HTML 생성 (엑셀 호환 테이블 레이아웃)
|
|
|
+ const html = `
|
|
|
+<html xmlns:x="urn:schemas-microsoft-com:office:excel">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <style>
|
|
|
+ body {
|
|
|
+ font-family: "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
|
|
|
+ }
|
|
|
+ table {
|
|
|
+ border-collapse: collapse;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ .header-table {
|
|
|
+ width: 100%;
|
|
|
+ margin-bottom: 40px;
|
|
|
+ border-bottom: 2px solid #000;
|
|
|
+ padding-bottom: 10px;
|
|
|
+ }
|
|
|
+ .header-table td {
|
|
|
+ border: none;
|
|
|
+ padding: 10px;
|
|
|
+ }
|
|
|
+ .header-title {
|
|
|
+ font-size: 20pt;
|
|
|
+ font-weight: bold;
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ .header-logo {
|
|
|
+ text-align: right;
|
|
|
+ font-size: 10pt;
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+ .content-table {
|
|
|
+ width: 100%;
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+ .content-table td {
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ vertical-align: top;
|
|
|
+ padding: 10px;
|
|
|
+ }
|
|
|
+ .info-wrapper {
|
|
|
+ padding-top: 0px;
|
|
|
+ }
|
|
|
+ .photo-cell {
|
|
|
+ width: 200px;
|
|
|
+ text-align: center;
|
|
|
+ vertical-align: top;
|
|
|
+ }
|
|
|
+ .photo-cell img {
|
|
|
+ width: 200px;
|
|
|
+ height: auto;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ .photo-placeholder {
|
|
|
+ width: 200px;
|
|
|
+ height: 300px;
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ background-color: #f9f9f9;
|
|
|
+ display: inline-block;
|
|
|
+ line-height: 300px;
|
|
|
+ text-align: center;
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ .info-table {
|
|
|
+ width: 100%;
|
|
|
+ border-collapse: collapse;
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+ .info-table tr {
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+ .info-table td {
|
|
|
+ padding: 10px;
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ }
|
|
|
+ .info-label {
|
|
|
+ width: 100px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #333;
|
|
|
+ font-size: 13pt;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ }
|
|
|
+ .info-value {
|
|
|
+ color: #555;
|
|
|
+ font-size: 13pt;
|
|
|
+ }
|
|
|
+ .info-value-name {
|
|
|
+ color: #000;
|
|
|
+ font-size: 16pt;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <table class="content-table" style="table-layout: fixed;">
|
|
|
+ <colgroup>
|
|
|
+ <col style="width: 200px;">
|
|
|
+ <col style="width: 100px;">
|
|
|
+ <col style="width: auto;">
|
|
|
+ </colgroup>
|
|
|
+ <tr>
|
|
|
+ <td class="photo-cell" rowspan="6" style="padding: 0;">
|
|
|
+ ${photoUrl ? `<img src="${photoUrl}" width="200" style="display: block;" />` : '<div class="photo-placeholder">사진없음</div>'}
|
|
|
+ </td>
|
|
|
+ <td class="info-label" style="height: 44.5px;">전시장</td>
|
|
|
+ <td class="info-value">${showroomName}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td class="info-label" style="height: 44.5px;">팀</td>
|
|
|
+ <td class="info-value">${teamName}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td class="info-label" style="height: 44.5px;">이름</td>
|
|
|
+ <td class="info-value-name">${staff.name}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td class="info-label" style="height: 44.5px;">직책</td>
|
|
|
+ <td class="info-value">${positionName}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td class="info-label" style="height: 44.5px;">핸드폰</td>
|
|
|
+ <td class="info-value">${staff.direct_phone || ''}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td class="info-label" style="height: 44.5px;">이메일</td>
|
|
|
+ <td class="info-value">${staff.email || ''}</td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+</body>
|
|
|
+</html>`;
|
|
|
+
|
|
|
+ // Blob 생성 및 다운로드
|
|
|
+ const blob = new Blob(['\ufeff' + html], { type: 'application/vnd.ms-excel;charset=utf-8;' });
|
|
|
+ const link = document.createElement('a');
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
+ link.setAttribute('href', url);
|
|
|
+ link.setAttribute('download', `sales_staff_${staff.name}_${new Date().toISOString().split('T')[0]}.xls`);
|
|
|
+ link.style.visibility = 'hidden';
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
};
|
|
|
|
|
|
// 등록 페이지로 이동
|
|
|
@@ -325,3 +622,31 @@
|
|
|
loadSales();
|
|
|
});
|
|
|
</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ /* 필터 영역 input/select 테두리 스타일 */
|
|
|
+ .admin--filter-row .admin--form-input,
|
|
|
+ .admin--filter-row .admin--form-select {
|
|
|
+ border: 1px solid var(--admin-border-color);
|
|
|
+ border-radius: 4px;
|
|
|
+ height: 33px;
|
|
|
+ padding: 6px 14px;
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 버튼 영역 간격 조정 */
|
|
|
+ .admin--search-actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 12px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 상단 버튼들 세로 크기 */
|
|
|
+ .admin--search-actions .admin--btn-small {
|
|
|
+ height: 78px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
+</style>
|