Browse Source

报告归档调整

xy 5 hours ago
parent
commit
dcd2857bf6

+ 6 - 1
yudao-ui-admin-vue3/src/api/pressure2/pipeInput/index.ts

@@ -9,5 +9,10 @@ export const PipeInputApi = {
   // 打印项目 - 返回 PDF blob
   handlePrint: async (data: any) => {
     return request.download2({url: `/pressure2/pipe-task-order-input/print`, data})
-  }
+  },
+
+  // 下载项目
+  handleDownloadPdf: async (data: any) => {
+    return request.download2({url: `/pressure2/pipe-task-order-input/downloadPdf`, data})
+  },
 }

+ 51 - 46
yudao-ui-admin-vue3/src/views/pressure2/reportArchivingBoiler/detail.vue

@@ -206,7 +206,7 @@ const detailTableSchema = reactive<TableItem[]>([
               <el-button
                 type="primary"
                 link
-                onClick={() => handleReportDownload(row, 'projectName')}
+                onClick={() => handleReportDownload(row, row.projectName)}
               >
                 下载
               </el-button>
@@ -327,7 +327,7 @@ const detailTableSchema = reactive<TableItem[]>([
               <el-button type="primary" link onClick={() => handleViewPdf(row)}>
                 预览
               </el-button>
-              <el-button type="primary" link onClick={() => handleReportDownload(row, 'fileName')}>
+              <el-button type="primary" link onClick={() => handleReportDownload(row, row.fileName)}>
                 下载
               </el-button>
             </>
@@ -638,7 +638,7 @@ const recordPdfSource = ref('')
 const reportPdfSource = ref('')
 const reportAndRecordPdfDialogRef = ref<InstanceType<typeof ReportAndRecordPdfDialog>>()
 
-const getPdfSource = async (type: number, data: any) => {
+const getPdfSource = async (type: number, data: any,fileName: string) => {
 
   if (!type) throw new Error('缺少参数type')
   if (!data) throw new Error('缺少参数')
@@ -650,7 +650,7 @@ const getPdfSource = async (type: number, data: any) => {
 
   try {
     // 调用 API 获取 ZIP blob
-    const zipBlob = await PipeInputApi.handleDownload(data)
+    const zipBlob = await PipeInputApi.handleDownloadPdf(data)
 
     if (zipBlob) {
       // 创建临时 URL
@@ -659,7 +659,7 @@ const getPdfSource = async (type: number, data: any) => {
       // 创建隐藏的 a 标签触发下载
       const link = document.createElement('a')
       link.href = zipUrl
-      link.download = '锅炉检测录入报告.zip'
+      link.download = fileName + '.pdf'
       document.body.appendChild(link)
       link.click()
 
@@ -685,40 +685,46 @@ const pdfPreviewVisible = ref(false)
 const currentPdfBlob = ref<Blob | null>(null)
 const handleViewPdf = async (row) => {
 
-  let data: any[] = []
-  data.push({
-    taskStatus: row.taskStatus,
-    resultTemplateId: '',
-    templateId: row.templateId,
-    reportTemplateId: row.reportTemplateId,
-    reportUrl: '',
-    id: row.reportId,
-  })
-
-  const loadingInstance = ElLoading.service({
-    fullscreen: true,
-    text: '正在生成...'
-  })
-
-  try {
-    // 调用 API 获取 ZIP blob
-    const pdfBlob = await PipeInputApi.handlePrint(data)
-
-    if (pdfBlob) {
-
-      currentPdfBlob.value = pdfBlob
-      pdfPreviewVisible.value = true
-
-    } else {
-      ElMessage.error('获取文件失败')
-    }
-  } catch (error) {
-    console.error('预览失败:', error)
-    ElMessage.error('预览失败')
-  } finally {
-    loadingInstance.close()
+  if (row.filePdf) {
+    docPdfUrls.value = ([row.filePdf] || []).map((url) => buildFileUrl(url))
+    showDocPdfDialog.value = true
+    return
   }
 
+  // let data: any[] = []
+  // data.push({
+  //   taskStatus: row.taskStatus,
+  //   resultTemplateId: '',
+  //   templateId: row.templateId,
+  //   reportTemplateId: row.reportTemplateId,
+  //   reportUrl: '',
+  //   id: row.reportId,
+  // })
+  //
+  // const loadingInstance = ElLoading.service({
+  //   fullscreen: true,
+  //   text: '正在生成...'
+  // })
+  //
+  // try {
+  //   // 调用 API 获取 ZIP blob
+  //   const pdfBlob = await PipeInputApi.handlePrint(data)
+  //
+  //   if (pdfBlob) {
+  //
+  //     currentPdfBlob.value = pdfBlob
+  //     pdfPreviewVisible.value = true
+  //
+  //   } else {
+  //     ElMessage.error('获取文件失败')
+  //   }
+  // } catch (error) {
+  //   console.error('预览失败:', error)
+  //   ElMessage.error('预览失败')
+  // } finally {
+  //   loadingInstance.close()
+  // }
+
 }
 
 // PDF预览关闭处理
@@ -738,23 +744,22 @@ function downloadFunc(href, filename) {
   }
 }
 
-const handleReportDownload = async (row) => {
-  await handlePdfUrl(row)
+const handleReportDownload = async (row,fileName) => {
+  await handlePdfUrl(row,fileName)
 }
 
-const handlePdfUrl = async (row) => {
+const handlePdfUrl = async (row,fileName) => {
   recordPdfSource.value = ''
   reportPdfSource.value = ''
   const { reportType } = row
-  let data: any[] = []
-  data.push({
+  let data: any = {
     taskStatus: row.taskStatus,
     resultTemplateId: '',
     templateId: row.templateId,
     reportTemplateId: row.reportTemplateId,
     reportUrl: '',
     id: row.reportId,
-  })
+  }
 
   // 操作指导书/检验方案/有限空间检验 只显示记录
   const onlyRecordType = [
@@ -765,11 +770,11 @@ const handlePdfUrl = async (row) => {
   ]
   const onlyReportType = [PressureReportType.SUBCONTRACT]
   if (onlyRecordType.includes(reportType)) {
-    await getPdfSource(100, data)
+    await getPdfSource(100, data, fileName)
   } else if (onlyReportType.includes(reportType)) {
-    await getPdfSource(300, data)
+    await getPdfSource(300, data, fileName)
   } else {
-    await getPdfSource(100, data)
+    await getPdfSource(100, data,  fileName)
   }
 
 }

+ 52 - 46
yudao-ui-admin-vue3/src/views/pressure2/reportArchivingPipe/detail.vue

@@ -206,7 +206,7 @@ const detailTableSchema = reactive<TableItem[]>([
               <el-button
                 type="primary"
                 link
-                onClick={() => handleReportDownload(row, 'projectName')}
+                onClick={() => handleReportDownload(row, row.projectName)}
               >
                 下载
               </el-button>
@@ -327,7 +327,7 @@ const detailTableSchema = reactive<TableItem[]>([
               <el-button type="primary" link onClick={() => handleViewPdf(row)}>
                 预览
               </el-button>
-              <el-button type="primary" link onClick={() => handleReportDownload(row, 'fileName')}>
+              <el-button type="primary" link onClick={() => handleReportDownload(row, row.fileName)}>
                 下载
               </el-button>
             </>
@@ -638,7 +638,7 @@ const recordPdfSource = ref('')
 const reportPdfSource = ref('')
 const reportAndRecordPdfDialogRef = ref<InstanceType<typeof ReportAndRecordPdfDialog>>()
 
-const getPdfSource = async (type: number, data: any) => {
+const getPdfSource = async (type: number, data: any, fileName: string) => {
 
   if (!type) throw new Error('缺少参数type')
   if (!data) throw new Error('缺少参数')
@@ -650,7 +650,7 @@ const getPdfSource = async (type: number, data: any) => {
 
   try {
     // 调用 API 获取 ZIP blob
-    const zipBlob = await PipeInputApi.handleDownload(data)
+    const zipBlob = await PipeInputApi.handleDownloadPdf(data)
 
     if (zipBlob) {
       // 创建临时 URL
@@ -659,7 +659,7 @@ const getPdfSource = async (type: number, data: any) => {
       // 创建隐藏的 a 标签触发下载
       const link = document.createElement('a')
       link.href = zipUrl
-      link.download = '锅炉检测录入报告.zip'
+      link.download = fileName + '.pdf'
       document.body.appendChild(link)
       link.click()
 
@@ -685,39 +685,45 @@ const pdfPreviewVisible = ref(false)
 const currentPdfBlob = ref<Blob | null>(null)
 const handleViewPdf = async (row) => {
 
-  let data: any[] = []
-  data.push({
-    taskStatus: row.taskStatus,
-    resultTemplateId: '',
-    templateId: row.templateId,
-    reportTemplateId: row.reportTemplateId,
-    reportUrl: '',
-    id: row.reportId,
-  })
-
-  const loadingInstance = ElLoading.service({
-    fullscreen: true,
-    text: '正在生成...'
-  })
-
-  try {
-    // 调用 API 获取 ZIP blob
-    const pdfBlob = await PipeInputApi.handlePrint(data)
-
-    if (pdfBlob) {
-
-      currentPdfBlob.value = pdfBlob
-      pdfPreviewVisible.value = true
-
-    } else {
-      ElMessage.error('获取文件失败')
-    }
-  } catch (error) {
-    console.error('预览失败:', error)
-    ElMessage.error('预览失败')
-  } finally {
-    loadingInstance.close()
+  if (row.filePdf) {
+    docPdfUrls.value = ([row.filePdf] || []).map((url) => buildFileUrl(url))
+    showDocPdfDialog.value = true
+    return
   }
+  //
+  // let data: any[] = []
+  // data.push({
+  //   taskStatus: row.taskStatus,
+  //   resultTemplateId: '',
+  //   templateId: row.templateId,
+  //   reportTemplateId: row.reportTemplateId,
+  //   reportUrl: '',
+  //   id: row.reportId,
+  // })
+  //
+  // const loadingInstance = ElLoading.service({
+  //   fullscreen: true,
+  //   text: '正在生成...'
+  // })
+  //
+  // try {
+  //   // 调用 API 获取 ZIP blob
+  //   const pdfBlob = await PipeInputApi.handlePrint(data)
+  //
+  //   if (pdfBlob) {
+  //
+  //     currentPdfBlob.value = pdfBlob
+  //     pdfPreviewVisible.value = true
+  //
+  //   } else {
+  //     ElMessage.error('获取文件失败')
+  //   }
+  // } catch (error) {
+  //   console.error('预览失败:', error)
+  //   ElMessage.error('预览失败')
+  // } finally {
+  //   loadingInstance.close()
+  // }
 
 }
 
@@ -738,23 +744,23 @@ function downloadFunc(href, filename) {
   }
 }
 
-const handleReportDownload = async (row) => {
-  await handlePdfUrl(row)
+const handleReportDownload = async (row,fileName) => {
+  await handlePdfUrl(row,fileName)
 }
 
-const handlePdfUrl = async (row) => {
+const handlePdfUrl = async (row,fileName) => {
+
   recordPdfSource.value = ''
   reportPdfSource.value = ''
   const { reportType } = row
-  let data: any[] = []
-  data.push({
+  let data: any = {
     taskStatus: row.taskStatus,
     resultTemplateId: '',
     templateId: row.templateId,
     reportTemplateId: row.reportTemplateId,
     reportUrl: '',
     id: row.reportId,
-  })
+  }
 
   // 操作指导书/检验方案/有限空间检验 只显示记录
   const onlyRecordType = [
@@ -765,11 +771,11 @@ const handlePdfUrl = async (row) => {
   ]
   const onlyReportType = [PressureReportType.SUBCONTRACT]
   if (onlyRecordType.includes(reportType)) {
-    await getPdfSource(100, data)
+    await getPdfSource(100, data, fileName)
   } else if (onlyReportType.includes(reportType)) {
-    await getPdfSource(300, data)
+    await getPdfSource(300, data, fileName)
   } else {
-    await getPdfSource(100, data)
+    await getPdfSource(100, data,  fileName)
   }
 
 }