summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pos/download-pos-file.ts7
-rw-r--r--lib/rfq-last/table/rfq-attachments-dialog.tsx65
2 files changed, 51 insertions, 21 deletions
diff --git a/lib/pos/download-pos-file.ts b/lib/pos/download-pos-file.ts
index d876c673..bd18f059 100644
--- a/lib/pos/download-pos-file.ts
+++ b/lib/pos/download-pos-file.ts
@@ -178,3 +178,10 @@ export async function createDownloadUrl(relativePath: string): Promise<string> {
const encodedPath = encodeURIComponent(relativePath);
return `/api/pos/download?path=${encodedPath}`;
}
+
+/**
+ * POS 파일의 리비전 ID를 사용하여 다운로드 URL을 생성하는 헬퍼 함수
+ */
+export async function createDownloadUrlByRevisionId(revisionId: number): Promise<string> {
+ return `/api/pos/download?revisionId=${revisionId}`;
+}
diff --git a/lib/rfq-last/table/rfq-attachments-dialog.tsx b/lib/rfq-last/table/rfq-attachments-dialog.tsx
index 161e446a..103617b3 100644
--- a/lib/rfq-last/table/rfq-attachments-dialog.tsx
+++ b/lib/rfq-last/table/rfq-attachments-dialog.tsx
@@ -94,24 +94,38 @@ export function RfqAttachmentsDialog({ isOpen, onClose, rfqData }: RfqAttachment
setDownloadingFiles(prev => new Set([...prev, attachmentId]))
try {
- const result = await downloadFile(
- attachment.filePath,
- attachment.originalFileName,
- {
- action: 'download',
- showToast: true,
- showSuccessToast: true,
- onSuccess: (fileName, fileSize) => {
- console.log(`다운로드 완료: ${fileName} (${formatFileSize(fileSize || 0)})`)
- },
- onError: (error) => {
- console.error(`다운로드 실패: ${error}`)
+ // POS 파일(설계 문서)은 별도 API 사용
+ if (attachment.attachmentType === '설계') {
+ const downloadUrl = `/api/pos/download?revisionId=${attachment.attachmentId}`
+ const link = document.createElement('a')
+ link.href = downloadUrl
+ link.download = attachment.originalFileName
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+
+ toast.success(`${attachment.originalFileName} 다운로드가 시작되었습니다.`)
+ } else {
+ // 일반 파일은 기존 downloadFile 함수 사용
+ const result = await downloadFile(
+ attachment.filePath,
+ attachment.originalFileName,
+ {
+ action: 'download',
+ showToast: true,
+ showSuccessToast: true,
+ onSuccess: (fileName, fileSize) => {
+ console.log(`다운로드 완료: ${fileName} (${formatFileSize(fileSize || 0)})`)
+ },
+ onError: (error) => {
+ console.error(`다운로드 실패: ${error}`)
+ }
}
- }
- )
+ )
- if (!result.success) {
- console.error("다운로드 결과:", result)
+ if (!result.success) {
+ console.error("다운로드 결과:", result)
+ }
}
} catch (error) {
console.error("파일 다운로드 오류:", error)
@@ -128,15 +142,19 @@ export function RfqAttachmentsDialog({ isOpen, onClose, rfqData }: RfqAttachment
// 파일 미리보기 핸들러
const handlePreview = async (attachment: RfqAttachment) => {
const fileInfo = getFileInfo(attachment.originalFileName)
-
- if (!fileInfo.canPreview) {
- toast.info("이 파일 형식은 미리보기를 지원하지 않습니다. 다운로드를 진행합니다.")
+
+ // POS 파일(설계 문서)은 미리보기를 지원하지 않음
+ if (attachment.attachmentType === '설계' || !fileInfo.canPreview) {
+ const message = attachment.attachmentType === '설계'
+ ? "POS 파일은 미리보기를 지원하지 않습니다. 다운로드를 진행합니다."
+ : "이 파일 형식은 미리보기를 지원하지 않습니다. 다운로드를 진행합니다."
+ toast.info(message)
return handleDownload(attachment)
}
try {
const result = await quickPreview(attachment.filePath, attachment.originalFileName)
-
+
if (!result.success) {
console.error("미리보기 결과:", result)
}
@@ -150,7 +168,12 @@ export function RfqAttachmentsDialog({ isOpen, onClose, rfqData }: RfqAttachment
const handleSmartAction = async (attachment: RfqAttachment) => {
const attachmentId = attachment.attachmentId
const fileInfo = getFileInfo(attachment.originalFileName)
-
+
+ // POS 파일(설계 문서)은 미리보기를 지원하지 않으므로 바로 다운로드
+ if (attachment.attachmentType === '설계') {
+ return handleDownload(attachment)
+ }
+
if (fileInfo.canPreview) {
return handlePreview(attachment)
} else {