From 6eeb82e56306d645a290a0f5ba202efe3ef2385d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 27 十月 2026 17:49:09 +0800
Subject: [PATCH] feat(report): 新增PDF报告预览功能并重构报告下载流程
---
src/views/business/reportPreparation/index.vue | 183 +++++++++++++++++++++++++--------------------
1 files changed, 100 insertions(+), 83 deletions(-)
diff --git a/src/views/business/reportPreparation/index.vue b/src/views/business/reportPreparation/index.vue
index 2cb25ad..09de219 100644
--- a/src/views/business/reportPreparation/index.vue
+++ b/src/views/business/reportPreparation/index.vue
@@ -48,7 +48,8 @@
:isSelection="true" :handleSelectionChange="handleChange" :height="'calc(100vh - 290px)'"
@pagination="pagination" key="valueTableData">
<template #action="scope"><div>
- <!-- <el-button size="small" type="text" @click="viewIssued(scope.row)">鏌ョ湅鎶ュ憡</el-button>-->
+ <el-button link type="primary" size="small" :disabled="!scope.row.url && !scope.row.urlS"
+ @click="previewReport(scope.row)">棰勮</el-button>
<el-upload ref='upload1' style="display: inline;margin: 0 6px" :action="fileAction1 + '?id=' + scope.row.id"
:auto-upload="true" :before-upload="fileBeforeUpload1" :headers="uploadHeader" :on-error="onError1"
:on-success="handleSuccessUp1" :show-file-list="false" accept='.doc,.docx'>
@@ -59,7 +60,8 @@
<el-button v-if="scope.row.urlS && !isBrowserEditedReportUrl(scope.row.urlS)" link type="primary" size="small"
:disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName || !scope.row.url"
@click="handleRestore(scope.row)">杩樺師绯荤粺鎶ュ憡</el-button>
- <el-button link type="primary" size="small" @click="sendBackTask(scope.row)">閫�鍥炰换鍔�</el-button>
+ <el-button v-if="scope.row.state == 1" link type="primary" size="small"
+ @click="openSendBack(scope.row)">閫�鍥炰换鍔�</el-button>
<el-button link type="primary" size="small" :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName"
@click="handle(scope.row)">鎻愪氦
</el-button>
@@ -68,7 +70,7 @@
@click="handleIssued(scope.row)">瀹℃牳
</el-button>
<el-button link type="primary" size="small"
- :disabled="scope.row.state == null || scope.row.state == 0 || scope.row.isExamine == 0 || scope.row.isExamine == null || scope.row.isRatify == 1 || nickName !== scope.row.ratifyUser"
+ :disabled="scope.row.state == null || scope.row.state == 0 || scope.row.isExamine != 1 || scope.row.isRatify == 1 || nickName !== scope.row.ratifyUser"
@click="handleApprove(scope.row)">鎵瑰噯
</el-button>
<el-button style="margin-left: 10px" link type="primary" size="small"
@@ -84,6 +86,25 @@
</div></template>
</lims-table>
</div>
+ <el-dialog v-model="sendBackVisible" title="閫�鍥炰换鍔�" width="460px" :close-on-click-modal="false">
+ <el-form label-width="90px">
+ <el-form-item label="閫�鍥炰綅缃�">
+ <el-radio-group v-if="sendBackRow && sendBackRow.isRatify == 1" v-model="sendBackForm.target">
+ <el-radio value="INSPECTION_TASK">閫�鍥炲埌妫�楠屼换鍔�</el-radio>
+ <el-radio value="REPORT_REVIEW">閫�鍥炲埌鎶ュ憡瀹℃牳</el-radio>
+ </el-radio-group>
+ <span v-else>閫�鍥炲埌妫�楠屼换鍔�</span>
+ </el-form-item>
+ <el-form-item label="閫�鍥炲師鍥�">
+ <el-input v-model="sendBackForm.reason" type="textarea" :rows="4" maxlength="1000"
+ show-word-limit placeholder="璇疯緭鍏ラ��鍥炲師鍥�" />
+ </el-form-item>
+ </el-form>
+ <template #footer><span class="dialog-footer">
+ <el-button :disabled="sendBackLoading" @click="sendBackVisible = false">鍙栨秷</el-button>
+ <el-button type="primary" :loading="sendBackLoading" @click="submitSendBack">纭畾閫�鍥�</el-button>
+ </span></template>
+ </el-dialog>
<el-dialog :fullscreen="fullscreen" :modal-append-to-body="false" v-model="claimVisible" title="鍦ㄧ嚎缂栧埗"
width="22cm">
<div class="full-screen">
@@ -160,7 +181,7 @@
<img v-else alt="" src="@/assets/images/no-full.svg" style="cursor: pointer;" @click="fullscreen = false;">
</div>
<div v-if="approveVisible" class="approve-preview">
- <onlyoffice ref="onlyoffice" :options="option" style="width: 100%;height: 100%;"/>
+ <pdf-viewer :key="currentInfo.id" :load="loadApprovalPdf" />
</div>
<div class="seal-select-block" v-loading="sealLoading">
<div class="seal-select-title">
@@ -247,18 +268,7 @@
</el-dialog>
<!--浜т笟閾句俊鎭煡鐪�-->
<!-- <ShowInfo v-if="showInfoDialog" ref="showInfoDialog" :showInfoDialog="showInfoDialog"></ShowInfo>-->
- <!--鎶ュ憡鏌ョ湅-->
- <el-dialog :fullscreen="fullscreen" :modal-append-to-body="false" v-model="viewIssuedVisible" title="鎶ュ憡鏌ョ湅"
- width="80vw">
- <div class="full-screen">
- <lims-icon name="el-icon-full-screen" v-if="!fullscreen" style="cursor: pointer;font-size: 18px"
- @click="fullscreen = true;"></lims-icon>
- <img v-else alt="" src="@/assets/images/no-full.svg" style="cursor: pointer;" @click="fullscreen = false;">
- </div>
- <div v-if="viewIssuedVisible" style="height: 80vh;">
- <onlyoffice ref="onlyoffice" :options="option" style="width: 100%;height: 100%;"/>
- </div>
- </el-dialog>
+ <report-preview ref="reportPreview" />
<!--闄勪欢鏌ョ湅-->
<el-dialog v-model="filesDialogVisible" title="闄勪欢鏌ョ湅" width="80%" @closed="closeFilesLook">
<div style="margin-bottom: 10px">
@@ -285,6 +295,7 @@
</el-form>
<template #footer><span class="dialog-footer">
<el-button @click="downloadDialogVisible = false">鍙� 娑�</el-button>
+ <el-button :disabled="!downloadRow" @click="previewReport(downloadRow, selectedReportType)">棰� 瑙�</el-button>
<el-button type="primary" :loading="downloadingReportType !== null"
:disabled="selectedReportType === null || downloadingReportType !== null"
@click="downloadSelectedReport(selectedReportType)">涓� 杞�</el-button>
@@ -294,12 +305,15 @@
</template>
<script>
-import onlyoffice from "@/components/Onlyoffice/onlyoffice.vue";
+import PdfViewer from '@/components/ReportPreview/PdfViewer.vue'
import ReportWordEditor from "@/components/ReportWordEditor/index.vue";
+import ReportPreview from '@/components/ReportPreview/index.vue'
+import { reportFilename } from '@/utils/reportPreview'
// import ShowInfo from "../do/b1-material-ins-order/showInfo.vue";
import {
downAll,
downloadReport,
+ previewReportPdf,
examineReport,
getReportEditDocument,
saveReportEditDocument,
@@ -321,10 +335,11 @@
export default {
name: 'ReportPreparation',
- components: {limsTable, onlyoffice, ReportWordEditor},
+ components: {limsTable, PdfViewer, ReportWordEditor, ReportPreview},
dicts: ['material_prop_type'],
data() {
return {
+ hasActivated: false,
entity: {
queryStatus: null,
code: null,
@@ -345,6 +360,13 @@
issuedReasonVisible: false,
approveVisible: false,
approveReasonVisible: false,
+ sendBackVisible: false,
+ sendBackLoading: false,
+ sendBackRow: null,
+ sendBackForm: {
+ target: null,
+ reason: ''
+ },
sealOptions: [],
sealPositions: [
{ key: 'maSealId', label: 'MA鏍囧織绔�', description: 'PDF 绗�1椤靛乏涓婅' },
@@ -418,11 +440,11 @@
customsInspection: {},
currentId: null,
examine: null,
- viewIssuedVisible: false,
queryStatusList: [
{label: '寰呮彁浜�', value: 0},
{label: '寰呭鏍�', value: 1},
{label: '寰呮壒鍑�', value: 2},
+ {label: '宸查��鍥�', value: 3},
],
state: 0,
orderId: 0,
@@ -580,6 +602,8 @@
return "涓嶉�氳繃";
} else if (params == 1) {
return "閫氳繃";
+ } else if (params == 2) {
+ return "宸查��鍥�";
} else {
return null
}
@@ -589,6 +613,8 @@
return "danger";
} else if (params == 1) {
return "success";
+ } else if (params == 2) {
+ return "warning";
} else {
return undefined
}
@@ -607,6 +633,8 @@
return "涓嶆壒鍑�";
} else if (params == 1) {
return "鎵瑰噯";
+ } else if (params == 2) {
+ return "宸查��鍥�";
} else {
return null
}
@@ -616,6 +644,8 @@
return "danger";
} else if (params == 1) {
return "success";
+ } else if (params == 2) {
+ return "warning";
} else {
return undefined
}
@@ -647,6 +677,13 @@
},
mounted() {
this.refreshTable()
+ },
+ activated() {
+ // 棣栨杩涘叆鐢� mounted 鍔犺浇锛岀紦瀛橀〉闈㈠啀娆℃縺娲绘椂鍒锋柊鍒楄〃銆�
+ if (this.hasActivated) {
+ this.refreshTable()
+ }
+ this.hasActivated = true
},
methods: {
refreshTable() {
@@ -1103,52 +1140,47 @@
this.auditDocument = null
done()
},
- // 鏌ョ湅鎶ュ憡
- viewIssued(row) {
- console.log('this.javaApi', this.javaApi)
- this.currentInfo = row;
- let fileName = (row.urlS === null || row.urlS === '') ? row.url : row.urlS
- let fileType = "docx"
- if (row.tempUrlPdf != null || row.tempUrlPdf === '') {
- fileName = row.tempUrlPdf
- fileType = "pdf"
- }
- fileName = fileName.replace('/word/', '')
- const userName = this.nickName
- this.option = {
- url: this.javaApi + "/word/" + fileName,
- isEdit: false,
- fileType: fileType,
- title: fileName,
- lang: 'zh-CN',
- isPrint: false,
- user_id: 1,
- user_name: userName,
- editUrl: this.javaApi + "/insReport/onlyOffice/save?fileName=" + fileName
- }
- this.viewIssuedVisible = true;
+ // 浣跨敤鏈嶅姟绔寜 Word 鐗堝紡鐢熸垚鐨� PDF锛屽鏉傝〃鏍间笉鍦ㄦ祻瑙堝櫒涓噸鏂版帓鐗堛��
+ previewReport(row, reportType = 0) {
+ const variants = [{ key: 0, label: '妫�娴嬫姤鍛�' }]
+ if (row.inspectionUrl) variants.push({ key: 1, label: '妫�楠屾姤鍛�' })
+ this.$refs.reportPreview.open(variants.map(item => ({
+ ...item, format: 'pdf',
+ filename: reportFilename((row.code || '鎶ュ憡') + (row.inspectionUrl ? '-' + item.label : ''), 'docx'),
+ load: signal => previewReportPdf(row.id, item.key, signal),
+ download: signal => downloadReport(row.id, item.key, signal), downloadFormat: 'docx'
+ })), reportType)
},
- // 閫�鍥炲埌浠诲姟
- sendBackTask(row) {
- this.$confirm('纭閫�鍥炲埌妫�楠屼换鍔�?閫�鍥炲悗闇�閲嶆柊鎻愪氦澶嶆牳', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
- type: 'warning'
+ openSendBack(row) {
+ this.sendBackRow = row
+ this.sendBackForm = {
+ target: row.isRatify == 1 ? null : 'INSPECTION_TASK',
+ reason: ''
+ }
+ this.sendBackVisible = true
+ },
+ submitSendBack() {
+ if (!this.sendBackForm.target) {
+ return this.$message.error('璇烽�夋嫨閫�鍥炰綅缃�')
+ }
+ if (!this.sendBackForm.reason || !this.sendBackForm.reason.trim()) {
+ return this.$message.error('璇疯緭鍏ラ��鍥炲師鍥�')
+ }
+ if (this.sendBackLoading || !this.sendBackRow) return
+ this.sendBackLoading = true
+ const targetName = this.sendBackForm.target === 'REPORT_REVIEW' ? '鎶ュ憡瀹℃牳' : '妫�楠屼换鍔�'
+ sendBackTask({
+ id: this.sendBackRow.id,
+ target: this.sendBackForm.target,
+ reason: this.sendBackForm.reason.trim()
}).then(() => {
- this.upLoad = true
- sendBackTask({id: row.id}).then(res => {
- this.upLoad = false
- this.$message.success('閫�鍥炴垚鍔燂紒')
- this.refreshTable('page')
- }).catch(err => {
- this.upLoad = false
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '宸插彇娑堝垹闄�'
- });
- });
+ this.$message.success(`宸查��鍥炲埌${targetName}`)
+ this.sendBackVisible = false
+ this.sendBackRow = null
+ this.refreshTable('page')
+ }).finally(() => {
+ this.sendBackLoading = false
+ })
},
// 瀹℃牳閫氳繃
async submitAddApprover() {
@@ -1228,26 +1260,11 @@
handleApprove(row) {
this.currentInfo = row;
this.loadEnabledSeals(row);
- let fileName = (row.urlS === null || row.urlS === '') ? row.url : row.urlS
- let fileType = "docx"
- if (row.tempUrlPdf != null || row.tempUrlPdf === '') {
- fileName = row.tempUrlPdf
- fileType = "pdf"
- }
- fileName = fileName.replace('/word/', '')
- const userName = this.nickName
- this.option = {
- url: this.javaApi + "/word/" + fileName,
- isEdit: false,
- fileType: fileType,
- title: fileName,
- lang: 'zh-CN',
- isPrint: false,
- user_id: 1,
- user_name: userName,
- editUrl: this.javaApi + "/insReport/onlyOffice/save?fileName=" + fileName
- }
+ this.fullscreen = false;
this.approveVisible = true;
+ },
+ loadApprovalPdf(signal) {
+ return previewReportPdf(this.currentInfo.id, 0, signal)
},
// 鎵瑰噯閫氳繃
subApprove() {
@@ -1368,7 +1385,7 @@
ratifyTell: this.reason
}).then(res => {
this.loadingApproveReason = false
- this.$message.success('鎿嶄綔鎴愬姛')
+ this.$message.success('宸查��鍥炴姤鍛婂鏍�')
this.refreshTable('page')
this.currentInfo = null;
this.reason = '';
--
Gitblit v1.9.3