summaryrefslogtreecommitdiff
path: root/lib/rfq-last/vendor-response/editor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rfq-last/vendor-response/editor')
-rw-r--r--lib/rfq-last/vendor-response/editor/attachments-upload.tsx32
-rw-r--r--lib/rfq-last/vendor-response/editor/vendor-response-editor.tsx38
2 files changed, 54 insertions, 16 deletions
diff --git a/lib/rfq-last/vendor-response/editor/attachments-upload.tsx b/lib/rfq-last/vendor-response/editor/attachments-upload.tsx
index ea7bb9c9..b85407ff 100644
--- a/lib/rfq-last/vendor-response/editor/attachments-upload.tsx
+++ b/lib/rfq-last/vendor-response/editor/attachments-upload.tsx
@@ -97,10 +97,10 @@ export default function AttachmentsUpload({
// 파일 추가
const handleFileAdd = (files: FileList | null, type: "구매" | "설계") => {
if (!files) return
-
+
const newFiles: FileWithType[] = []
const errors: string[] = []
-
+
Array.from(files).forEach(file => {
const error = validateFile(file)
if (error) {
@@ -110,17 +110,31 @@ export default function AttachmentsUpload({
attachmentType: type,
description: ""
})
+ // 디버그 로그 추가
+ console.log(`파일 추가됨: ${file.name}, 타입: ${type}`)
newFiles.push(fileWithType)
}
})
-
+
if (errors.length > 0) {
setUploadErrors(errors)
setTimeout(() => setUploadErrors([]), 5000)
}
-
+
if (newFiles.length > 0) {
- onAttachmentsChange([...attachments, ...newFiles])
+ const updatedFiles = [...attachments, ...newFiles]
+ onAttachmentsChange(updatedFiles)
+
+ // 추가된 파일들의 타입 확인 로그
+ console.log('업데이트된 파일 목록:', updatedFiles.map(f => ({
+ name: f.name,
+ attachmentType: f.attachmentType
+ })))
+
+ // 각 파일의 타입이 제대로 설정되었는지 검증
+ newFiles.forEach(file => {
+ console.log(`새 파일 타입 검증: ${file.name} = ${file.attachmentType}`)
+ })
}
}
@@ -175,7 +189,15 @@ export default function AttachmentsUpload({
// 파일 타입 변경
const handleTypeChange = (index: number, newType: "구매" | "설계") => {
const newFiles = [...attachments]
+ const oldType = newFiles[index].attachmentType
newFiles[index].attachmentType = newType
+
+ console.log(`파일 타입 변경: ${newFiles[index].name} (${oldType} -> ${newType})`)
+ console.log('변경 후 파일 목록:', newFiles.map(f => ({
+ name: f.name,
+ attachmentType: f.attachmentType
+ })))
+
onAttachmentsChange(newFiles)
}
diff --git a/lib/rfq-last/vendor-response/editor/vendor-response-editor.tsx b/lib/rfq-last/vendor-response/editor/vendor-response-editor.tsx
index fec9a2b9..795431f6 100644
--- a/lib/rfq-last/vendor-response/editor/vendor-response-editor.tsx
+++ b/lib/rfq-last/vendor-response/editor/vendor-response-editor.tsx
@@ -249,28 +249,34 @@ export default function VendorResponseEditor({
}
const onSubmit = async (data: VendorResponseFormData, isSubmit: boolean = false) => {
- console.log('onSubmit called with:', { data, isSubmit }) // 디버깅용
-
+ console.log('onSubmit called with:', { data, isSubmit, attachmentsCount: attachments.length }) // 디버깅용
+
setLoading(true)
setUploadProgress(0)
try {
const formData = new FormData()
- const fileMetadata = attachments.map((file: FileWithType) => ({
- attachmentType: file.attachmentType || "기타",
- description: file.description || ""
- }))
+ // 첨부파일 메타데이터 생성 시 타입 확인
+ const fileMetadata = attachments.map((file: FileWithType) => {
+ const metadata = {
+ attachmentType: file.attachmentType || "기타",
+ description: file.description || ""
+ };
+ console.log(`파일 메타데이터 생성: ${file.name} -> 타입: ${metadata.attachmentType}`);
+ return metadata;
+ });
+
- // 삭제된 첨부파일 ID 목록
- const deletedAttachmentIds = deletedAttachments.map(file => file.id)
// 디버그: 첨부파일 attachmentType 확인
- console.log('Attachments with types:', attachments.map(f => ({
+ console.log('최종 첨부파일 목록:', attachments.map(f => ({
name: f.name,
attachmentType: f.attachmentType,
size: f.size
})))
+
+ console.log('파일 메타데이터:', fileMetadata)
// 기본 데이터 추가
@@ -285,15 +291,17 @@ export default function VendorResponseEditor({
totalAmount: data.quotationItems.reduce((sum, item) => sum + item.totalPrice, 0),
updatedBy: userId,
fileMetadata,
- deletedAttachmentIds
}
console.log('Submitting data:', submitData) // 디버깅용
formData.append('data', JSON.stringify(submitData))
- // 첨부파일 추가
+ // 첨부파일 추가 (메타데이터를 통해 타입 정보 전달)
attachments.forEach((file, index) => {
+ const metadata = fileMetadata[index];
+ console.log(`첨부파일 추가: ${file.name}, 타입: ${metadata?.attachmentType}`);
+
formData.append(`attachments`, file)
})
@@ -341,6 +349,14 @@ export default function VendorResponseEditor({
await uploadPromise
+ // 임시저장 성공 시 첨부파일 목록 초기화 (중복 저장 방지)
+ if (!isSubmit) {
+ console.log('임시저장 완료 - 첨부파일 목록 초기화');
+ setAttachments([]);
+ setExistingAttachments([]);
+ setDeletedAttachments([]);
+ }
+
toast.success(isSubmit ? "견적서가 제출되었습니다." : "견적서가 저장되었습니다.")
if (isSubmit) {
router.push('/partners/rfq-last')