|
|
@@ -11,87 +11,150 @@
|
|
|
<template>
|
|
|
<view class="preview-container">
|
|
|
<!-- 导航栏 -->
|
|
|
- <NavBar title="报告审批预览" />
|
|
|
-
|
|
|
- <!-- 头部视图 -->
|
|
|
- <HeadView
|
|
|
- v-if="reportList.length > 0"
|
|
|
- :report-list="reportList"
|
|
|
- :select-report="selectReport"
|
|
|
- @update:select-report="handleReportSelect"
|
|
|
- />
|
|
|
+ <ReportNavBar>
|
|
|
+ <template #right>
|
|
|
+ <picker
|
|
|
+ class="report-picker"
|
|
|
+ @change="handleReportChange"
|
|
|
+ :value="selectedReportIndex"
|
|
|
+ :range="reportDOList"
|
|
|
+ range-key="name"
|
|
|
+ >
|
|
|
+ <view class="picker-content">
|
|
|
+ <text class="picker-text">{{ reportDOList[selectedReportIndex]?.name || '选择报告' }}</text>
|
|
|
+ <text class="picker-arrow">▼</text>
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ <button class="nav-btn btn-grey">查看附件</button>
|
|
|
+ <button class="nav-btn btn-grey">查看档案</button>
|
|
|
+ <button class="nav-btn btn-orange">查看记录</button>
|
|
|
+ <button class="nav-btn btn-red">退回</button>
|
|
|
+ <button class="nav-btn btn-blue" @click="handleApprove">通过</button>
|
|
|
+ </template>
|
|
|
+ </ReportNavBar>
|
|
|
|
|
|
<!-- PDF 预览区域 -->
|
|
|
- <view class="pdf-container">
|
|
|
- <text class="preview-tip">报告预览功能待完善</text>
|
|
|
- <text class="preview-info">当前报告:{{ selectReport?.reportName || '-' }}</text>
|
|
|
- <text class="preview-info">报告类型:{{ getReportTypeName(selectReport?.reportType) }}</text>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 操作按钮 -->
|
|
|
- <view class="action-buttons">
|
|
|
- <view class="button-row">
|
|
|
- <button class="action-btn reject-btn" @click="handleReject">
|
|
|
- <text class="action-btn-text">退回</text>
|
|
|
- </button>
|
|
|
- <button class="action-btn approve-btn" @click="handleApprove">
|
|
|
- <text class="action-btn-text">通过审批</text>
|
|
|
- </button>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ <SpreadPDFViewer
|
|
|
+ ref="spreadPdfViewerRef"
|
|
|
+ :businessConfig="businessConfig"
|
|
|
+ :templateData="templateData"
|
|
|
+ :templateBlob="templateBlob"
|
|
|
+ />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
+import { onLoad } from '@dcloudio/uni-app'
|
|
|
import { finishApi, rollbackApi } from '@/api/pendingRatify'
|
|
|
-import HeadView from '@/pages/pendingVerification/preViewReport/HeadView.vue'
|
|
|
-import NavBar from '@/components/NavBar/NavBar.vue'
|
|
|
+import ReportNavBar from '@/components/NavBar/ReportNavBar.vue'
|
|
|
+import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
|
|
|
+import { buildFileUrl } from '@/utils/index'
|
|
|
+import { getDynamicTbVal } from '@/api/task'
|
|
|
+import { getStandardTemplate } from '@/api/index'
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'PendingRatifyPreview',
|
|
|
})
|
|
|
|
|
|
-// 从路由参数获取数据
|
|
|
-const pages = getCurrentPages()
|
|
|
-const currentPage = pages[pages.length - 1] as any
|
|
|
-const options = currentPage.options || {}
|
|
|
-
|
|
|
-const id = ref(options.id || '')
|
|
|
-const orderId = ref(options.orderId || '')
|
|
|
+const id = ref('')
|
|
|
+const orderId = ref('')
|
|
|
+const equipCode = ref('')
|
|
|
const reportDOList = ref<any[]>([])
|
|
|
-const equipCode = ref(options.equipCode || '')
|
|
|
|
|
|
-// 解析报告列表
|
|
|
-try {
|
|
|
- if (options.reportDOList) {
|
|
|
- reportDOList.value = JSON.parse(decodeURIComponent(options.reportDOList))
|
|
|
+const reportList = ref<any[]>([])
|
|
|
+
|
|
|
+const selectedReport = ref<any>(null)
|
|
|
+watch(selectedReport, (newVal) => {
|
|
|
+ if (newVal) {
|
|
|
+ previewReport(newVal)
|
|
|
}
|
|
|
-} catch (error) {
|
|
|
- console.error('解析报告列表失败:', error)
|
|
|
-}
|
|
|
+})
|
|
|
|
|
|
-const reportList = ref<any[]>(reportDOList.value)
|
|
|
-const selectReport = ref<any>(reportList.value?.[0] || null)
|
|
|
+onLoad((options) => {
|
|
|
+ id.value = options?.id || ''
|
|
|
+ orderId.value = options?.orderId || ''
|
|
|
+ equipCode.value = options?.equipCode || ''
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (options?.reportDOList) {
|
|
|
+ reportDOList.value = JSON.parse(decodeURIComponent(options.reportDOList)) || []
|
|
|
+ console.log('报告列表:', reportDOList.value)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('解析报告列表失败:', error)
|
|
|
+ }
|
|
|
+
|
|
|
+ reportList.value = reportDOList.value
|
|
|
+ selectedReport.value = reportList.value?.[0] || null
|
|
|
+})
|
|
|
+
|
|
|
+const spreadPdfViewerRef = ref<any>(null)
|
|
|
+const templateBlob = ref<any>(null)
|
|
|
+const businessConfig = ref<any>({
|
|
|
+ businessType: 'JLJH',
|
|
|
+ title: '记录审批',
|
|
|
+ disableNavigate: true,
|
|
|
+
|
|
|
+ ui: {
|
|
|
+ title: '记录审批',
|
|
|
+ saveButtonText: '保存',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ showAdditionalToolbar: true,
|
|
|
+ customButtons: [],
|
|
|
+ },
|
|
|
+})
|
|
|
+const templateData = ref<any>({})
|
|
|
+const selectedReportIndex = ref(0)
|
|
|
|
|
|
// 处理报告选择
|
|
|
-const handleReportSelect = (report: any) => {
|
|
|
- selectReport.value = report
|
|
|
- console.log('选择报告:', report)
|
|
|
+const handleReportChange = (e) => {
|
|
|
+ const index = e.detail.value
|
|
|
+ selectedReportIndex.value = index
|
|
|
+ selectedReport.value = reportList.value?.[index] || null
|
|
|
}
|
|
|
|
|
|
-// 获取报告类型名称
|
|
|
-const getReportTypeName = (reportType: string) => {
|
|
|
- const typeMap: Record<string, string> = {
|
|
|
- '100': '主报告',
|
|
|
- '200': '附件报告',
|
|
|
+const previewReport = async (selectedReport: any) => {
|
|
|
+ if (!selectedReport) {
|
|
|
+ return uni.showToast({ title: '请选择报告', icon: 'error' })
|
|
|
}
|
|
|
- return typeMap[reportType] || reportType
|
|
|
+ const refId = selectedReport.id
|
|
|
+ const reportTemplateId = selectedReport.reportTemplateId
|
|
|
+ const inputRecordTemplateId = selectedReport.templateId
|
|
|
+
|
|
|
+ const res = await getStandardTemplate({ id: reportTemplateId })
|
|
|
+ const resData = (res as any).data
|
|
|
+ const dataMap: any = {}
|
|
|
+ const dynamicTbResp = await getDynamicTbVal({
|
|
|
+ refId,
|
|
|
+ })
|
|
|
+ const dynamicTb: any = dynamicTbResp.data
|
|
|
+ for (let i = 0; i < dynamicTb.dynamicTbValRespVOList.length; i++) {
|
|
|
+ const item = dynamicTb.dynamicTbValRespVOList[i]
|
|
|
+ dataMap[item.colCode] = item.valValue
|
|
|
+ }
|
|
|
+ templateData.value = {
|
|
|
+ schema: resData.bindingPathSchema ? JSON.parse(resData.bindingPathSchema) : {},
|
|
|
+ data: {
|
|
|
+ ...dataMap,
|
|
|
+ reportTemplateId,
|
|
|
+ templateUrl: resData.fileUrl,
|
|
|
+ },
|
|
|
+ pathNameMapping: JSON.parse(resData.bindingPathNameJson),
|
|
|
+ template: reportTemplateId,
|
|
|
+ templateUrl: resData.fileUrl,
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(templateData.value)
|
|
|
+ const fileUri = resData.fileUrl
|
|
|
+ const fileUrl = buildFileUrl(fileUri)
|
|
|
+ const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
|
|
|
+ templateBlob.value = fileBase64
|
|
|
}
|
|
|
|
|
|
// 退回
|
|
|
const handleReject = async () => {
|
|
|
- if (!selectReport.value) {
|
|
|
+ if (!selectedReport.value) {
|
|
|
return uni.showToast({ title: '请选择报告', icon: 'error' })
|
|
|
}
|
|
|
|
|
|
@@ -104,7 +167,7 @@ const handleReject = async () => {
|
|
|
|
|
|
try {
|
|
|
const result: any = await rollbackApi({
|
|
|
- id: selectReport.value.reportId,
|
|
|
+ id: selectedReport.value.id,
|
|
|
reason: '审批退回',
|
|
|
})
|
|
|
|
|
|
@@ -112,6 +175,7 @@ const handleReject = async () => {
|
|
|
|
|
|
if (result?.code === 0) {
|
|
|
uni.showToast({ title: '退回成功', icon: 'success' })
|
|
|
+ uni.$emit('RefreshRatifyListApi')
|
|
|
setTimeout(() => {
|
|
|
uni.navigateBack()
|
|
|
}, 1000)
|
|
|
@@ -130,7 +194,7 @@ const handleReject = async () => {
|
|
|
|
|
|
// 通过审批
|
|
|
const handleApprove = async () => {
|
|
|
- if (!selectReport.value) {
|
|
|
+ if (!selectedReport.value) {
|
|
|
return uni.showToast({ title: '请选择报告', icon: 'error' })
|
|
|
}
|
|
|
|
|
|
@@ -143,13 +207,14 @@ const handleApprove = async () => {
|
|
|
|
|
|
try {
|
|
|
const result: any = await finishApi({
|
|
|
- id: selectReport.value.reportId,
|
|
|
+ id: selectedReport.value.id,
|
|
|
})
|
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
|
if (result?.code === 0) {
|
|
|
uni.showToast({ title: '审批通过', icon: 'success' })
|
|
|
+ uni.$emit('RefreshRatifyListApi')
|
|
|
setTimeout(() => {
|
|
|
uni.navigateBack()
|
|
|
}, 1000)
|
|
|
@@ -165,11 +230,6 @@ const handleApprove = async () => {
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- console.log('报告列表:', reportList.value)
|
|
|
- console.log('当前选择:', selectReport.value)
|
|
|
-})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -195,28 +255,56 @@ onMounted(() => {
|
|
|
color: #333;
|
|
|
}
|
|
|
|
|
|
-.pdf-container {
|
|
|
- flex: 1;
|
|
|
+.report-picker {
|
|
|
display: flex;
|
|
|
- flex-direction: column;
|
|
|
- justify-content: center;
|
|
|
align-items: center;
|
|
|
- padding: 20px;
|
|
|
- background-color: #fff;
|
|
|
- margin: 10px;
|
|
|
- border-radius: 5px;
|
|
|
+ margin-right: 4px;
|
|
|
}
|
|
|
|
|
|
-.preview-tip {
|
|
|
- font-size: 18px;
|
|
|
- color: #666;
|
|
|
- margin-bottom: 20px;
|
|
|
+.picker-content {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 4px 8px;
|
|
|
+ background-color: #c3c2c2;
|
|
|
+ border-radius: 3px;
|
|
|
}
|
|
|
|
|
|
-.preview-info {
|
|
|
- font-size: 14px;
|
|
|
- color: #999;
|
|
|
- margin: 5px 0;
|
|
|
+.picker-text {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #fff;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+.picker-arrow {
|
|
|
+ margin-left: 4px;
|
|
|
+ font-size: 10px;
|
|
|
+ color: #fff;
|
|
|
+}
|
|
|
+
|
|
|
+.nav-btn {
|
|
|
+ padding: 4px 8px;
|
|
|
+ margin: 0 0 0 4px !important;
|
|
|
+ font-size: 12px;
|
|
|
+ line-height: 1.4;
|
|
|
+ color: #fff;
|
|
|
+ border: none;
|
|
|
+ border-radius: 3px;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-grey {
|
|
|
+ background-color: #999;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-orange {
|
|
|
+ background-color: #f5a623;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-red {
|
|
|
+ background-color: #ff4d4f;
|
|
|
+}
|
|
|
+
|
|
|
+.btn-blue {
|
|
|
+ background-color: #2f8eff;
|
|
|
}
|
|
|
|
|
|
.action-buttons {
|
|
|
@@ -224,15 +312,7 @@ onMounted(() => {
|
|
|
background-color: #fff;
|
|
|
}
|
|
|
|
|
|
-.button-row {
|
|
|
- display: flex;
|
|
|
- flex-direction: row;
|
|
|
- justify-content: space-between;
|
|
|
- gap: 15px;
|
|
|
-}
|
|
|
-
|
|
|
.action-btn {
|
|
|
- flex: 1;
|
|
|
height: 44px;
|
|
|
border-radius: 5px;
|
|
|
display: flex;
|
|
|
@@ -242,12 +322,7 @@ onMounted(() => {
|
|
|
font-size: 16px;
|
|
|
}
|
|
|
|
|
|
-.reject-btn {
|
|
|
- background-color: #FF4445;
|
|
|
- color: #fff;
|
|
|
-}
|
|
|
-
|
|
|
-.approve-btn {
|
|
|
+.submit-btn {
|
|
|
background-color: #2f8eff;
|
|
|
color: #fff;
|
|
|
}
|