init
This commit is contained in:
@@ -0,0 +1,718 @@
|
||||
<template>
|
||||
<div class="club-management">
|
||||
<div class="header">
|
||||
<h2>클럽 관리</h2>
|
||||
<Button label="새 클럽 추가" icon="pi pi-plus" @click="openNewClubDialog" />
|
||||
</div>
|
||||
|
||||
<DataTable :value="clubs" :paginator="true" :rows="10"
|
||||
:rowsPerPageOptions="[5, 10, 20]"
|
||||
stripedRows responsiveLayout="scroll"
|
||||
:loading="loading">
|
||||
<Column field="id" header="ID" sortable style="width: 5%"></Column>
|
||||
<Column field="name" header="클럽명" sortable style="width: 20%">
|
||||
<template #body="slotProps">
|
||||
<div>
|
||||
<div class="club-name">{{ slotProps.data.name }}</div>
|
||||
<div class="club-location">{{ slotProps.data.location }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="owner.name" header="모임장" sortable style="width: 15%">
|
||||
<template #body="slotProps">
|
||||
{{ slotProps.data.owner?.name || '-' }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="memberCount" header="회원 수" sortable style="width: 10%"></Column>
|
||||
<Column field="createdAt" header="생성일" sortable style="width: 15%">
|
||||
<template #body="slotProps">
|
||||
{{ formatDate(slotProps.data.createdAt) }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column header="관리" style="width: 20%">
|
||||
<template #body="slotProps">
|
||||
<Button icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2"
|
||||
@click="editClub(slotProps.data)" />
|
||||
<Button icon="pi pi-cog" class="p-button-rounded p-button-info mr-2"
|
||||
@click="manageFeatures(slotProps.data)" />
|
||||
<Button icon="pi pi-users" class="p-button-rounded p-button-warning mr-2"
|
||||
@click="manageMembers(slotProps.data)" />
|
||||
<Button icon="pi pi-trash" class="p-button-rounded p-button-danger"
|
||||
@click="confirmDeleteClub(slotProps.data)" />
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
|
||||
<!-- 새 클럽 추가/수정 다이얼로그 -->
|
||||
<Dialog v-model:visible="clubDialog" :style="{width: '450px'}"
|
||||
:header="dialogMode === 'new' ? '새 클럽 추가' : '클럽 수정'"
|
||||
:modal="true" class="p-fluid">
|
||||
<div class="field">
|
||||
<label for="name">클럽명</label>
|
||||
<InputText id="name" v-model="club.name" required autofocus :class="{'p-invalid': submitted && !club.name}" />
|
||||
<small class="p-error" v-if="submitted && !club.name">클럽명은 필수입니다.</small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="description">클럽 설명</label>
|
||||
<Textarea id="description" v-model="club.description" rows="3" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ownerEmail">모임장 이메일</label>
|
||||
<InputText id="ownerEmail" v-model="club.ownerEmail" required :class="{'p-invalid': submitted && !club.ownerEmail}" />
|
||||
<small class="p-error" v-if="submitted && !club.ownerEmail">모임장 이메일은 필수입니다.</small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="location">볼링장</label>
|
||||
<InputText id="location" v-model="club.location" />
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<Button label="취소" icon="pi pi-times" class="p-button-text" @click="hideDialog" />
|
||||
<Button label="저장" icon="pi pi-check" class="p-button-text" @click="saveClub" :loading="saving" />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 기능 관리 다이얼로그 -->
|
||||
<Dialog v-model:visible="featureDialog" :style="{width: '500px'}"
|
||||
header="클럽 기능 관리" :modal="true">
|
||||
<div v-if="selectedClub">
|
||||
<h3>{{ selectedClub.name }} - 기능 관리</h3>
|
||||
|
||||
<div v-for="feature in clubFeatures" :key="feature.id" class="feature-item">
|
||||
<div class="feature-header">
|
||||
<h4>{{ feature.name }}</h4>
|
||||
<div class="feature-toggle">
|
||||
<span>{{ feature.enabled ? '활성화됨' : '비활성화됨' }}</span>
|
||||
<Button :icon="feature.enabled ? 'pi pi-check' : 'pi pi-times'"
|
||||
:class="feature.enabled ? 'p-button-success' : 'p-button-secondary'"
|
||||
@click="toggleFeature(feature)" />
|
||||
</div>
|
||||
</div>
|
||||
<p>{{ feature.description }}</p>
|
||||
<p class="feature-price">월 {{ feature.price.toLocaleString() }}원</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<Button label="닫기" icon="pi pi-times" class="p-button-text" @click="featureDialog = false" />
|
||||
<Button label="저장" icon="pi pi-check" @click="saveFeatures" :loading="savingFeatures" />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 회원 관리 다이얼로그 -->
|
||||
<Dialog v-model:visible="memberDialog" :style="{width: '800px'}"
|
||||
header="회원 관리" :modal="true">
|
||||
<div v-if="selectedClub">
|
||||
<h3>{{ selectedClub.name }} - 회원 관리</h3>
|
||||
|
||||
<div class="mb-3">
|
||||
<Button label="새 회원 추가" icon="pi pi-plus" @click="openNewMemberDialog" />
|
||||
</div>
|
||||
|
||||
<DataTable :value="clubMembers" :paginator="true" :rows="10"
|
||||
:rowsPerPageOptions="[5, 10, 20]"
|
||||
stripedRows
|
||||
scrollable scrollHeight="400px"
|
||||
:loading="loadingMembers">
|
||||
<Column field="name" header="이름" sortable style="min-width: 12rem">
|
||||
<template #body="slotProps">
|
||||
<div>
|
||||
<div class="member-name">{{ slotProps.data.name }}</div>
|
||||
<div class="member-contact">
|
||||
<div>{{ slotProps.data.phone }}</div>
|
||||
<div>{{ slotProps.data.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="gender" header="성별" sortable style="min-width: 6rem"></Column>
|
||||
<Column field="memberType" header="회원 유형" sortable style="min-width: 8rem">
|
||||
<template #body="slotProps">
|
||||
<Dropdown v-model="slotProps.data.memberType"
|
||||
:options="memberTypes"
|
||||
@change="updateMemberType(slotProps.data)"
|
||||
:disabled="slotProps.data.memberType === '모임장' && !canChangeOwner" />
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="handicap" header="핸디캡" sortable style="min-width: 6rem"></Column>
|
||||
<Column field="average" header="평균" sortable style="min-width: 6rem">
|
||||
<template #body="slotProps">
|
||||
{{ slotProps.data.average.toFixed(1) }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column field="games" header="게임 수" sortable style="min-width: 6rem"></Column>
|
||||
<Column field="joinDate" header="가입일" sortable style="min-width: 8rem">
|
||||
<template #body="slotProps">
|
||||
{{ formatDate(slotProps.data.joinDate) }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column header="관리" style="min-width: 8rem">
|
||||
<template #body="slotProps">
|
||||
<Button icon="pi pi-pencil"
|
||||
class="p-button-rounded p-button-success mr-2"
|
||||
@click="editMember(slotProps.data)" />
|
||||
<Button icon="pi pi-trash"
|
||||
class="p-button-rounded p-button-danger"
|
||||
@click="confirmDeleteMember(slotProps.data)"
|
||||
:disabled="slotProps.data.memberType === '모임장'" />
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<!-- 회원 추가/수정 다이얼로그 -->
|
||||
<Dialog v-model:visible="memberFormDialog" :style="{width: '450px'}"
|
||||
:header="memberDialogMode === 'new' ? '새 회원 추가' : '회원 정보 수정'"
|
||||
:modal="true" class="p-fluid">
|
||||
<div class="field">
|
||||
<label for="name">이름</label>
|
||||
<InputText id="name" v-model="member.name" required autofocus :class="{'p-invalid': memberSubmitted && !member.name}" />
|
||||
<small class="p-error" v-if="memberSubmitted && !member.name">이름은 필수입니다.</small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="gender">성별</label>
|
||||
<Dropdown id="gender" v-model="member.gender"
|
||||
:options="['남성', '여성']" placeholder="성별 선택"
|
||||
:class="{'p-invalid': memberSubmitted && !member.gender}" />
|
||||
<small class="p-error" v-if="memberSubmitted && !member.gender">성별은 필수입니다.</small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="memberType">회원 유형</label>
|
||||
<Dropdown id="memberType" v-model="member.memberType"
|
||||
:options="memberTypes" placeholder="회원 유형 선택"
|
||||
:class="{'p-invalid': memberSubmitted && !member.memberType}" />
|
||||
<small class="p-error" v-if="memberSubmitted && !member.memberType">회원 유형은 필수입니다.</small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="handicap">핸디캡</label>
|
||||
<InputNumber id="handicap" v-model="member.handicap" :min="0" :max="300" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="phone">연락처</label>
|
||||
<InputText id="phone" v-model="member.phone" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="email">이메일</label>
|
||||
<InputText id="email" v-model="member.email" type="email" />
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<Button label="취소" icon="pi pi-times" class="p-button-text" @click="memberFormDialog = false" />
|
||||
<Button label="저장" icon="pi pi-check" class="p-button-text" @click="saveMember" :loading="savingMember" />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 삭제 확인 다이얼로그 -->
|
||||
<Dialog v-model:visible="deleteDialog" :style="{width: '450px'}"
|
||||
header="클럽 삭제" :modal="true">
|
||||
<div class="confirmation-content">
|
||||
<i class="pi pi-exclamation-triangle mr-3" style="font-size: 2rem" />
|
||||
<span v-if="selectedClub">정말로 <b>{{ selectedClub.name }}</b> 클럽을 삭제하시겠습니까?</span>
|
||||
</div>
|
||||
<template #footer>
|
||||
<Button label="아니오" icon="pi pi-times" class="p-button-text" @click="deleteDialog = false" />
|
||||
<Button label="예" icon="pi pi-check" class="p-button-text" @click="deleteClub" :loading="deleting" />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 회원 삭제 확인 다이얼로그 -->
|
||||
<Dialog v-model:visible="deleteMemberDialog" :style="{width: '450px'}"
|
||||
header="회원 삭제" :modal="true">
|
||||
<div class="confirmation-content">
|
||||
<i class="pi pi-exclamation-triangle mr-3" style="font-size: 2rem" />
|
||||
<span v-if="selectedMember">정말로 <b>{{ selectedMember.name }}</b> 회원을 삭제하시겠습니까?</span>
|
||||
</div>
|
||||
<template #footer>
|
||||
<Button label="아니오" icon="pi pi-times" class="p-button-text" @click="deleteMemberDialog = false" />
|
||||
<Button label="예" icon="pi pi-check" class="p-button-text" @click="deleteMember" :loading="deletingMember" />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<Toast />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import dayjs from 'dayjs';
|
||||
import adminService from '@/services/adminService';
|
||||
|
||||
const toast = useToast();
|
||||
|
||||
// 상태 변수
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const savingFeatures = ref(false);
|
||||
const deleting = ref(false);
|
||||
const loadingMembers = ref(false);
|
||||
const deletingMember = ref(false);
|
||||
const savingMember = ref(false);
|
||||
const submitted = ref(false);
|
||||
const memberSubmitted = ref(false);
|
||||
|
||||
// 클럽 목록
|
||||
const clubs = ref([]);
|
||||
const clubMembers = ref([]);
|
||||
|
||||
// 회원 유형 목록
|
||||
const memberTypes = ref(['모임장', '정회원', '준회원', '운영진']);
|
||||
|
||||
// 기능 목록
|
||||
const allFeatures = ref([
|
||||
{ id: 1, name: '회원 관리', description: '클럽 회원 목록 관리 및 회원 정보 수정', price: 5000 },
|
||||
{ id: 2, name: '정기 모임 관리', description: '정기 모임 일정 및 참석자 관리', price: 8000 },
|
||||
{ id: 3, name: '점수 관리', description: '게임별 점수 기록 및 통계', price: 10000 },
|
||||
{ id: 4, name: '팀 관리', description: '팀 구성 및 팀별 점수 관리', price: 7000 },
|
||||
{ id: 5, name: '통계 대시보드', description: '상세한 통계 및 분석 대시보드', price: 12000 }
|
||||
]);
|
||||
|
||||
// 현재 클럽의 기능 목록
|
||||
const clubFeatures = ref([]);
|
||||
|
||||
// 다이얼로그 상태
|
||||
const clubDialog = ref(false);
|
||||
const featureDialog = ref(false);
|
||||
const deleteDialog = ref(false);
|
||||
const memberDialog = ref(false);
|
||||
const memberFormDialog = ref(false);
|
||||
const deleteMemberDialog = ref(false);
|
||||
const dialogMode = ref('new');
|
||||
const memberDialogMode = ref('new');
|
||||
|
||||
// 선택된 클럽 및 편집중인 클럽 데이터
|
||||
const selectedClub = ref(null);
|
||||
const selectedMember = ref(null);
|
||||
const club = reactive({
|
||||
id: null,
|
||||
name: '',
|
||||
description: '',
|
||||
ownerEmail: '',
|
||||
location: '',
|
||||
memberCount: 0,
|
||||
createdAt: ''
|
||||
});
|
||||
|
||||
// 편집중인 회원 데이터
|
||||
const member = reactive({
|
||||
id: null,
|
||||
name: '',
|
||||
gender: null,
|
||||
memberType: null,
|
||||
handicap: 0,
|
||||
phone: '',
|
||||
email: ''
|
||||
});
|
||||
|
||||
// 모임장 변경 권한
|
||||
const canChangeOwner = ref(true);
|
||||
|
||||
// 페이지 로드 시 클럽 목록 가져오기
|
||||
onMounted(async () => {
|
||||
await fetchClubs();
|
||||
});
|
||||
|
||||
// 클럽 목록 가져오기
|
||||
const fetchClubs = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const response = await adminService.getAllClubs();
|
||||
clubs.value = response.data;
|
||||
} catch (error) {
|
||||
console.error('클럽 목록을 가져오는 중 오류 발생:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '클럽 목록을 가져오는 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 날짜 포맷팅
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '';
|
||||
return dayjs(date).format('YYYY-MM-DD');
|
||||
};
|
||||
|
||||
// 새 클럽 추가 다이얼로그 열기
|
||||
const openNewClubDialog = () => {
|
||||
club.id = null;
|
||||
club.name = '';
|
||||
club.description = '';
|
||||
club.ownerEmail = '';
|
||||
club.location = '';
|
||||
submitted.value = false;
|
||||
dialogMode.value = 'new';
|
||||
clubDialog.value = true;
|
||||
};
|
||||
|
||||
// 클럽 수정 다이얼로그 열기
|
||||
const editClub = async (data) => {
|
||||
dialogMode.value = 'edit';
|
||||
selectedClub.value = { ...data };
|
||||
|
||||
try {
|
||||
// 클럽 상세 정보 가져오기
|
||||
const response = await adminService.getClubById(data.id);
|
||||
const clubData = response.data;
|
||||
|
||||
club.id = clubData.id;
|
||||
club.name = clubData.name;
|
||||
club.description = clubData.description;
|
||||
club.ownerEmail = clubData.owner?.email; // owner 객체에서 이메일 가져오기
|
||||
club.location = clubData.location;
|
||||
club.memberCount = clubData.memberCount;
|
||||
club.createdAt = clubData.createdAt;
|
||||
|
||||
clubDialog.value = true;
|
||||
} catch (error) {
|
||||
console.error('클럽 정보를 가져오는 중 오류 발생:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '클럽 정보를 가져오는 중 오류가 발생했습니다.', life: 3000 });
|
||||
}
|
||||
};
|
||||
|
||||
// 다이얼로그 닫기
|
||||
const hideDialog = () => {
|
||||
clubDialog.value = false;
|
||||
submitted.value = false;
|
||||
};
|
||||
|
||||
// 클럽 저장
|
||||
const saveClub = async () => {
|
||||
submitted.value = true;
|
||||
|
||||
if (!club.name || !club.ownerEmail) {
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '필수 항목을 모두 입력해주세요.', life: 3000 });
|
||||
return;
|
||||
}
|
||||
|
||||
saving.value = true;
|
||||
|
||||
try {
|
||||
if (dialogMode.value === 'new') {
|
||||
// 새 클럽 추가
|
||||
const clubData = {
|
||||
name: club.name,
|
||||
description: club.description,
|
||||
ownerEmail: club.ownerEmail,
|
||||
location: club.location
|
||||
};
|
||||
|
||||
await adminService.createClub(clubData);
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '클럽이 추가되었습니다.', life: 3000 });
|
||||
} else {
|
||||
// 클럽 수정
|
||||
await adminService.updateClub(club.id, club);
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '클럽이 수정되었습니다.', life: 3000 });
|
||||
}
|
||||
|
||||
clubDialog.value = false;
|
||||
await fetchClubs();
|
||||
} catch (error) {
|
||||
console.error('클럽 저장 중 오류 발생:', error);
|
||||
let errorMessage = '클럽 저장 중 오류가 발생했습니다.';
|
||||
|
||||
if (error.response && error.response.data && error.response.data.message) {
|
||||
errorMessage = error.response.data.message;
|
||||
}
|
||||
|
||||
toast.add({ severity: 'error', summary: '오류', detail: errorMessage, life: 3000 });
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 기능 관리 다이얼로그 열기
|
||||
const manageFeatures = async (data) => {
|
||||
selectedClub.value = { ...data };
|
||||
|
||||
try {
|
||||
// 클럽의 현재 기능 목록 가져오기
|
||||
const response = await adminService.getClubById(data.id);
|
||||
const clubData = response.data;
|
||||
|
||||
// 모든 기능을 복사하고 활성화 상태 설정
|
||||
clubFeatures.value = allFeatures.value.map(feature => {
|
||||
const isEnabled = clubData.features && clubData.features.some(f => f.id === feature.id);
|
||||
return { ...feature, enabled: isEnabled };
|
||||
});
|
||||
|
||||
featureDialog.value = true;
|
||||
} catch (error) {
|
||||
console.error('클럽 기능 정보를 가져오는 중 오류 발생:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '클럽 기능 정보를 가져오는 중 오류가 발생했습니다.', life: 3000 });
|
||||
}
|
||||
};
|
||||
|
||||
// 기능 토글
|
||||
const toggleFeature = (feature) => {
|
||||
feature.enabled = !feature.enabled;
|
||||
};
|
||||
|
||||
// 기능 설정 저장
|
||||
const saveFeatures = async () => {
|
||||
if (!selectedClub.value) return;
|
||||
|
||||
savingFeatures.value = true;
|
||||
|
||||
try {
|
||||
// 활성화된 기능만 필터링
|
||||
const enabledFeatures = clubFeatures.value
|
||||
.filter(feature => feature.enabled)
|
||||
.map(feature => ({ id: feature.id, name: feature.name }));
|
||||
|
||||
// 기능 업데이트 API 호출
|
||||
await adminService.manageClubFeatures(selectedClub.value.id, enabledFeatures);
|
||||
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '클럽 기능이 업데이트되었습니다.', life: 3000 });
|
||||
featureDialog.value = false;
|
||||
|
||||
// 클럽 목록 새로고침
|
||||
await fetchClubs();
|
||||
} catch (error) {
|
||||
console.error('클럽 기능 저장 중 오류 발생:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '클럽 기능 저장 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
savingFeatures.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 회원 관리 다이얼로그 열기
|
||||
const manageMembers = async (data) => {
|
||||
selectedClub.value = data;
|
||||
loadingMembers.value = true;
|
||||
memberDialog.value = true;
|
||||
|
||||
try {
|
||||
const response = await adminService.getClubMembers(data.id);
|
||||
clubMembers.value = response.data;
|
||||
} catch (error) {
|
||||
console.error('회원 목록 조회 오류:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '회원 목록을 가져오는 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
loadingMembers.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 회원 유형 업데이트
|
||||
const updateMemberType = async (member) => {
|
||||
try {
|
||||
if (!selectedClub.value || !selectedClub.value.id) {
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '선택된 클럽 정보가 없습니다.', life: 3000 });
|
||||
return;
|
||||
}
|
||||
|
||||
const clubId = parseInt(selectedClub.value.id);
|
||||
const memberId = parseInt(member.id);
|
||||
|
||||
const response = await adminService.updateClubMember(clubId, memberId, {
|
||||
memberType: member.memberType
|
||||
});
|
||||
|
||||
// 응답 데이터로 회원 정보 업데이트
|
||||
const index = clubMembers.value.findIndex(m => m.id === memberId);
|
||||
if (index !== -1) {
|
||||
clubMembers.value[index] = response.data;
|
||||
}
|
||||
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '회원 유형이 업데이트되었습니다.', life: 3000 });
|
||||
} catch (error) {
|
||||
console.error('회원 유형 업데이트 오류:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '회원 유형을 업데이트하는 중 오류가 발생했습니다.', life: 3000 });
|
||||
}
|
||||
};
|
||||
|
||||
// 회원 삭제 확인
|
||||
const confirmDeleteMember = (member) => {
|
||||
selectedMember.value = member;
|
||||
deleteMemberDialog.value = true;
|
||||
};
|
||||
|
||||
// 회원 삭제
|
||||
const deleteMember = async () => {
|
||||
if (!selectedMember.value || !selectedClub.value) return;
|
||||
|
||||
deletingMember.value = true;
|
||||
try {
|
||||
await adminService.deleteClubMember(selectedClub.value.id, selectedMember.value.id);
|
||||
|
||||
// 회원 목록에서 삭제된 회원 제거
|
||||
clubMembers.value = clubMembers.value.filter(m => m.id !== selectedMember.value.id);
|
||||
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '회원이 삭제되었습니다.', life: 3000 });
|
||||
deleteMemberDialog.value = false;
|
||||
} catch (error) {
|
||||
console.error('회원 삭제 오류:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '회원을 삭제하는 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
deletingMember.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 클럽 삭제 확인 다이얼로그 열기
|
||||
const confirmDeleteClub = (data) => {
|
||||
selectedClub.value = data;
|
||||
deleteDialog.value = true;
|
||||
};
|
||||
|
||||
// 클럽 삭제
|
||||
const deleteClub = async () => {
|
||||
if (!selectedClub.value) return;
|
||||
|
||||
deleting.value = true;
|
||||
|
||||
try {
|
||||
// 클럽 삭제 API 호출
|
||||
await adminService.deleteClub(selectedClub.value.id);
|
||||
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '클럽이 삭제되었습니다.', life: 3000 });
|
||||
deleteDialog.value = false;
|
||||
|
||||
// 클럽 목록 새로고침
|
||||
await fetchClubs();
|
||||
} catch (error) {
|
||||
console.error('클럽 삭제 중 오류 발생:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '클럽 삭제 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 새 회원 추가 다이얼로그 열기
|
||||
const openNewMemberDialog = () => {
|
||||
memberDialogMode.value = 'new';
|
||||
memberSubmitted.value = false;
|
||||
Object.assign(member, {
|
||||
id: null,
|
||||
name: '',
|
||||
gender: null,
|
||||
memberType: '준회원',
|
||||
handicap: 0,
|
||||
phone: '',
|
||||
email: ''
|
||||
});
|
||||
memberFormDialog.value = true;
|
||||
};
|
||||
|
||||
// 회원 수정 다이얼로그 열기
|
||||
const editMember = (data) => {
|
||||
memberDialogMode.value = 'edit';
|
||||
memberSubmitted.value = false;
|
||||
Object.assign(member, {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
gender: data.gender,
|
||||
memberType: data.memberType,
|
||||
handicap: data.handicap,
|
||||
phone: data.phone,
|
||||
email: data.email
|
||||
});
|
||||
memberFormDialog.value = true;
|
||||
};
|
||||
|
||||
// 회원 저장
|
||||
const saveMember = async () => {
|
||||
memberSubmitted.value = true;
|
||||
|
||||
if (!member.name || !member.gender || !member.memberType) {
|
||||
return;
|
||||
}
|
||||
|
||||
savingMember.value = true;
|
||||
try {
|
||||
let response;
|
||||
if (memberDialogMode.value === 'new') {
|
||||
response = await adminService.addClubMember(selectedClub.value.id, member);
|
||||
clubMembers.value.push(response.data);
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '새 회원이 추가되었습니다.', life: 3000 });
|
||||
} else {
|
||||
response = await adminService.updateClubMember(selectedClub.value.id, member.id, member);
|
||||
const index = clubMembers.value.findIndex(m => m.id === member.id);
|
||||
if (index !== -1) {
|
||||
clubMembers.value[index] = response.data;
|
||||
}
|
||||
toast.add({ severity: 'success', summary: '성공', detail: '회원 정보가 수정되었습니다.', life: 3000 });
|
||||
}
|
||||
memberFormDialog.value = false;
|
||||
} catch (error) {
|
||||
console.error('회원 저장 오류:', error);
|
||||
toast.add({ severity: 'error', summary: '오류', detail: '회원 정보를 저장하는 중 오류가 발생했습니다.', life: 3000 });
|
||||
} finally {
|
||||
savingMember.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.club-management {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
margin-bottom: 1.5rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.feature-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.feature-header h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.feature-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.feature-price {
|
||||
font-weight: bold;
|
||||
color: #6366f1;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.confirmation-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.mr-2 {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.club-name {
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.club-location {
|
||||
font-size: 0.85rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.member-name {
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.member-contact {
|
||||
font-size: 0.75rem;
|
||||
color: #666;
|
||||
line-height: 1.2;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user