오류수정, 암호화 추가
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
<div class="file-upload-wrapper">
|
||||
<FileUpload
|
||||
ref="fileUploadRef"
|
||||
name="file"
|
||||
:url="uploadUrl"
|
||||
@upload="onUpload"
|
||||
@@ -68,7 +69,14 @@
|
||||
</template>
|
||||
</FileUpload>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 시트 선택 UI -->
|
||||
<div v-if="sheetNames.length > 0" class="mt-3">
|
||||
<label for="sheet-select" class="field-label">엑셀 시트 선택</label>
|
||||
<Select id="sheet-select" v-model="selectedSheetName" :options="sheetNames" placeholder="시트 선택" class="p-inputtext" />
|
||||
<Button label="시트 데이터 불러오기" class="ml-2" @click="parseFile" :disabled="!selectedSheetName || loading" />
|
||||
</div>
|
||||
|
||||
<div v-if="uploadError" class="error-message">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
{{ uploadError }}
|
||||
@@ -498,7 +506,7 @@
|
||||
|
||||
<div class="field col-6 mb-3">
|
||||
<label for="newMemberType" class="mb-1">회원 유형</label>
|
||||
<Select id="newMemberType" v-model="newMember.memberType" :options="MEMBER_TYPE_OPTIONS" optionLabel="name" optionValue="code" placeholder="회원 유형 선택" class="w-full" :disabled="newMemberMode === 'guest'" />
|
||||
<Select id="newMemberType" v-model="newMember.memberType" :options="MEMBER_TYPE_OPTIONS" optionLabel="name" optionValue="value" placeholder="회원 유형 선택" class="w-full" :disabled="newMemberMode === 'guest'" />
|
||||
</div>
|
||||
|
||||
<div class="field col-6 mb-3">
|
||||
@@ -518,7 +526,7 @@
|
||||
|
||||
<div class="field col-6 mb-3">
|
||||
<label for="newMemberStatus" class="mb-1">상태</label>
|
||||
<Select id="newMemberStatus" v-model="newMember.status" :options="STATUS_OPTIONS" optionLabel="label" optionValue="value" placeholder="상태 선택" class="w-full" />
|
||||
<Select id="newMemberStatus" v-model="newMember.status" :options="STATUS_OPTIONS" optionLabel="name" optionValue="value" placeholder="상태 선택" class="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -548,6 +556,7 @@ import dayjs from 'dayjs';
|
||||
import { useClubStore } from '@/stores/clubStore';
|
||||
import eventService from '@/services/eventService';
|
||||
import clubService from '@/services/clubService';
|
||||
import * as XLSX from 'xlsx';
|
||||
|
||||
// 기존 이벤트 선택 관련 상태
|
||||
const selectedEventId = ref(null);
|
||||
@@ -591,9 +600,7 @@ const loadSelectedEvent = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadEventOptions();
|
||||
});
|
||||
// onMounted 훅은 아래에서 한 번만 사용
|
||||
|
||||
// PrimeVue 컴포넌트 임포트
|
||||
|
||||
@@ -626,9 +633,13 @@ const steps = ref([
|
||||
{ label: '최종 확인' }
|
||||
]);
|
||||
|
||||
// FileUpload 컴포넌트 참조
|
||||
const fileUploadRef = ref(null);
|
||||
|
||||
const uploadedFile = ref(null);
|
||||
const uploadError = ref('');
|
||||
const loading = ref(false);
|
||||
const uploading = ref(false);
|
||||
const saving = ref(false);
|
||||
const submitted = ref(false);
|
||||
|
||||
@@ -638,6 +649,10 @@ const parsedData = ref({
|
||||
gameCount: 0
|
||||
});
|
||||
|
||||
// 엑셀 시트 관련 상태
|
||||
const sheetNames = ref([]);
|
||||
const selectedSheetName = ref('');
|
||||
|
||||
// 이벤트 데이터
|
||||
const eventData = ref({
|
||||
title: '',
|
||||
@@ -684,8 +699,9 @@ const uploadUrl = computed(() => {
|
||||
return `${import.meta.env.VITE_API_URL}${eventService.getFileUploadUrl(props.clubId)}`;
|
||||
});
|
||||
|
||||
// 컴포넌트 마운트 시 클럽 회원 목록 로드
|
||||
// 컴포넌트 마운트 시 초기화 작업 수행
|
||||
onMounted(async () => {
|
||||
loadEventOptions();
|
||||
await loadClubMembers();
|
||||
});
|
||||
|
||||
@@ -716,9 +732,6 @@ const loadClubMembers = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 업로드 상태 변수 추가
|
||||
const uploading = ref(false);
|
||||
|
||||
// 이미지 파일 여부 체크
|
||||
const isImageFile = (file) => {
|
||||
const ext = file.name.split('.').pop().toLowerCase();
|
||||
@@ -760,21 +773,31 @@ const uploadFile = async (event) => {
|
||||
uploadError.value = '업로드할 파일을 선택해주세요.';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 프론트에서 시트명 추출
|
||||
const file = event.files[0];
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const data = new Uint8Array(e.target.result);
|
||||
const workbook = XLSX.read(data, { type: 'array' });
|
||||
sheetNames.value = workbook.SheetNames;
|
||||
// 기본값: 첫 번째 시트 선택
|
||||
selectedSheetName.value = workbook.SheetNames[0] || '';
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', event.files[0]);
|
||||
formData.append('file', file);
|
||||
formData.append('clubId', props.clubId);
|
||||
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
uploading.value = true;
|
||||
const data = await eventService.uploadFile(event.files[0], props.clubId);
|
||||
const data = await eventService.uploadFile(file, props.clubId);
|
||||
uploadedFile.value = data.file;
|
||||
uploadError.value = '';
|
||||
|
||||
// 파일 파싱 요청
|
||||
parseFile();
|
||||
|
||||
// 파일 파싱은 시트 선택 후 별도로 진행
|
||||
// parseFile();
|
||||
// 업로드 완료 후 파일 목록 초기화
|
||||
if (event.clear) {
|
||||
event.clear();
|
||||
@@ -808,40 +831,41 @@ const parseFile = async () => {
|
||||
if (!uploadedFile.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selectedSheetName.value) {
|
||||
uploadError.value = '시트를 선택해주세요.';
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const response = await eventService.parseEventFile({
|
||||
filename: uploadedFile.value.filename,
|
||||
clubId: props.clubId
|
||||
clubId: props.clubId,
|
||||
sheetName: selectedSheetName.value
|
||||
});
|
||||
|
||||
parsedData.value = response.data;
|
||||
eventData.value.gameCount = parsedData.value.gameCount || 3;
|
||||
|
||||
// 추론된 이벤트 정보가 있는 경우 이를 활용
|
||||
if (parsedData.value.inferredEventInfo) {
|
||||
const inferredInfo = parsedData.value.inferredEventInfo;
|
||||
|
||||
// 제목이 추론되었다면 적용
|
||||
if (inferredInfo.title) {
|
||||
eventData.value.title = inferredInfo.title;
|
||||
}
|
||||
|
||||
// 시작일이 추론되었다면 적용
|
||||
if (inferredInfo.startDate) {
|
||||
eventData.value.startDate = new Date(inferredInfo.startDate);
|
||||
}
|
||||
|
||||
// 장소가 추론되었다면 적용
|
||||
if (inferredInfo.location) {
|
||||
eventData.value.location = inferredInfo.location;
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 단계로 이동
|
||||
activeStep.value = 1;
|
||||
|
||||
// 파일 파싱이 완료되면 파일 업로드 컴포넌트 초기화
|
||||
if (fileUploadRef.value && fileUploadRef.value.clear) {
|
||||
fileUploadRef.value.clear();
|
||||
}
|
||||
|
||||
// 업로드 파일 정보는 유지 (파일명은 백엔드에서 사용하기 때문)
|
||||
} catch (error) {
|
||||
console.error('파일 파싱 오류:', error);
|
||||
uploadError.value = error.message || '파일 파싱 중 오류가 발생했습니다.';
|
||||
@@ -1231,6 +1255,8 @@ watch(() => props.visible, (newValue) => {
|
||||
status: '활성'
|
||||
};
|
||||
submitted.value = false;
|
||||
sheetNames.value = [];
|
||||
selectedSheetName.value = '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user