瀏覽代碼

将SpreadPDFViewer替换为使用BackendPDFViewer

yangguanjin 2 周之前
父節點
當前提交
ac370e9c39

+ 9 - 4
src/components/SpreadDesigner/SpreadPDFConverter.vue

@@ -339,8 +339,15 @@ function deepMergeSchemaValue(target, source) {
       } else if (sourceValue !== undefined && sourceValue !== '') {
         const trimmedSourceValue = sourceValue.trim()
         // JSON字符串需要解析为对象或数组
-        if (typeof trimmedSourceValue === 'string' && (trimmedSourceValue.startsWith("{") || trimmedSourceValue.startsWith("["))) {
-          result[key] = JSON.parse(trimmedSourceValue)
+        if (
+          typeof trimmedSourceValue === 'string' &&
+          (trimmedSourceValue.startsWith('{') || trimmedSourceValue.startsWith('['))
+        ) {
+          try {
+            result[key] = JSON.parse(trimmedSourceValue)
+          } catch (error) {
+            result[key] = trimmedSourceValue
+          }
         } else {
           result[key] = trimmedSourceValue
         }
@@ -912,7 +919,6 @@ function loadTemplateData(templateBlob, templateData) {
   spreadInstance.touchToolStrip.clear()
 
   if (templateBlob) {
-
     try {
       const blob = base64ToBlob(templateBlob, 'application/ssjson')
 
@@ -938,7 +944,6 @@ function loadTemplateData(templateBlob, templateData) {
       console.error('处理模板文件时发生错误:', error)
     }
   } else if (templateData.schema) {
-
     if (spreadInstance.getSheetCount() === 0) {
       const sheet = spreadInstance.addSheet(0)
       sheet.name('Sheet1')

+ 10 - 52
src/pages/inspectionPlanAudit/preViewReport/index.vue

@@ -18,11 +18,10 @@
       </template>
     </ReportNavBar>
 
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
 
     <wd-popup position="center" v-model="showGoBack">
@@ -56,13 +55,10 @@ import { ref, watch } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import ReportNavBar from '@/components/NavBar/ReportNavBar.vue'
 import { useToast } from 'wot-design-uni'
-import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 
 import { useConfigStore } from '@/store/config'
 
-import { buildFileUrl } from '@/utils/index'
-import { getDynamicTbVal } from '@/api/task'
-import { getStandardTemplate } from '@/api/index'
 import { requestFunc, ApprovalFuncName } from '@/api/ApiRouter/approval'
 
 defineOptions({
@@ -74,21 +70,9 @@ const templateIdFromRoute = ref('')
 
 const equipType = useConfigStore().getEquipType()
 
-const spreadPdfViewerRef = ref<any>(null)
-const templateBlob = ref<any>(null)
-const businessConfig = ref<any>({
-  businessType: 'JYFA',
-  title: '检验方案审核',
-  disableNavigate: true,
-  ui: {
-    title: '检验方案审核',
-    saveButtonText: '保存',
-    cancelButtonText: '取消',
-    showAdditionalToolbar: true,
-    customButtons: [],
-  },
-})
-const templateData = ref<any>({})
+const backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 
 onLoad((options: any) => {
   id.value = options?.id || ''
@@ -102,34 +86,8 @@ watch(id, (newVal) => {
 })
 
 const loadPreviewData = async () => {
-  const tmplId = templateIdFromRoute.value
-  const refId = id.value
-
-  const res = await getStandardTemplate({ id: tmplId })
-  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,
-      templateId: tmplId,
-      templateUrl: resData.fileUrl,
-    },
-    pathNameMapping: JSON.parse(resData.bindingPathNameJson),
-    template: tmplId,
-    templateUrl: resData.fileUrl,
-  }
-
-  const fileUri = resData.fileUrl
-  const fileUrl = buildFileUrl(fileUri)
-  const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
-  templateBlob.value = fileBase64
+  templateId.value = templateIdFromRoute.value
+  refId.value = id.value
 }
 
 const showGoBack = ref(false)

+ 10 - 57
src/pages/pendingApproval/preViewReport/index.vue

@@ -27,11 +27,10 @@
     </ReportNavBar>
 
     <!-- PDF 预览区域 -->
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
   </view>
 </template>
@@ -41,10 +40,7 @@ import { ref, watch, computed } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import { submitApi, rollbackApi } from '@/api/pendingApproval'
 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'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 
 defineOptions({
   name: 'PendingApprovalPreview',
@@ -82,22 +78,9 @@ onLoad((options) => {
   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 backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 const selectedReportIndex = ref(0)
 const reportDOColumn = computed(() => [
   reportDOList.value.map((item) => ({ label: item.name, value: item.id })),
@@ -113,38 +96,8 @@ const previewReport = async (selectedReport: any) => {
   if (!selectedReport) {
     return uni.showToast({ title: '请选择报告', icon: 'error' })
   }
-  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
+  refId.value = selectedReport.id
+  templateId.value = selectedReport.reportTemplateId
 }
 
 // 退回

+ 10 - 61
src/pages/pendingPreparation/preViewReport/index.vue

@@ -26,11 +26,10 @@
     </ReportNavBar>
 
     <!-- PDF 预览区域 -->
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
   </view>
 </template>
@@ -40,10 +39,7 @@ import { ref, watch, computed } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import { submitApi } from '@/api/pendingPreparation'
 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'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 
 defineOptions({
   name: 'PendingPreparationPreview',
@@ -81,22 +77,9 @@ onLoad((options) => {
   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 backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 const selectedReportIndex = ref(0)
 const reportDOColumn = computed(() => [
   reportDOList.value.map((item) => ({ label: item.name, value: item.id })),
@@ -112,42 +95,8 @@ const previewReport = async (selectedReport: any) => {
   if (!selectedReport) {
     return uni.showToast({ title: '请选择报告', icon: 'error' })
   }
-  const refId = selectedReport.id
-  const reportTemplateId = selectedReport.reportTemplateId
-  const inputRecordTemplateId = selectedReport.templateId
-
-  // 获取templateSchema
-  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
-  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)
-  // 获取 template 文件
-  const fileUri = resData.fileUrl
-  const fileUrl = buildFileUrl(fileUri)
-  const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
-  templateBlob.value = fileBase64
+  refId.value = selectedReport.id
+  templateId.value = selectedReport.reportTemplateId
 }
 
 // 提交报告

+ 11 - 57
src/pages/pendingRatify/preViewReport/index.vue

@@ -27,11 +27,10 @@
     </ReportNavBar>
 
     <!-- PDF 预览区域 -->
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
   </view>
 </template>
@@ -41,10 +40,8 @@ import { ref, watch, computed } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import { finishApi, rollbackApi } from '@/api/pendingRatify'
 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'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
+
 
 defineOptions({
   name: 'PendingRatifyPreview',
@@ -82,22 +79,9 @@ onLoad((options) => {
   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 backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 const selectedReportIndex = ref(0)
 const reportDOColumn = computed(() => [
   reportDOList.value.map((item) => ({ label: item.name, value: item.id })),
@@ -113,38 +97,8 @@ const previewReport = async (selectedReport: any) => {
   if (!selectedReport) {
     return uni.showToast({ title: '请选择报告', icon: 'error' })
   }
-  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
+  refId.value = selectedReport.id
+  templateId.value = selectedReport.reportTemplateId
 }
 
 // 退回

+ 1 - 1
src/pages/pendingVerification/list/PipeItem.vue

@@ -59,7 +59,7 @@
     </view>
 
     <view class="btn-group">
-      <button class="main-btn" @click="handleOperation">
+      <button v-show="item.recheckStatus == '100'" class="main-btn" @click="handleOperation">
           <text class="main-btn-text">{{ operateText }}</text>
       </button>
     </view>

+ 11 - 59
src/pages/pendingVerification/preViewReport/index.vue

@@ -20,11 +20,10 @@
       </template>
     </ReportNavBar>
 
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
 
     <wd-popup position="center" v-model="showGoBack">
@@ -69,12 +68,9 @@ import { onLoad } from '@dcloudio/uni-app'
 import { type ItemsProps } from './HeadView.vue'
 import ReportNavBar from '@/components/NavBar/ReportNavBar.vue'
 import { useConfigStore } from '@/store/config'
-import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 import { requestFunc, TaskOrderItemReportFuncName } from '@/api/ApiRouter/taskOrderItemReport'
 import { requestFunc as ApprovalRequestFunc, ApprovalFuncName } from '@/api/ApiRouter/approval'
-import { buildFileUrl } from '@/utils/index'
-import { getDynamicTbVal } from '@/api/task'
-import { getStandardTemplate } from '@/api/index'
 import { useToast } from 'wot-design-uni'
 
 interface StringAnyObj {
@@ -95,22 +91,9 @@ const equipCode = ref('')
 
 const equipType = useConfigStore().getEquipType()
 
-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 backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 
 onLoad((options: any) => {
   id.value = options?.id || ''
@@ -140,42 +123,11 @@ const loadPreviewData = async () => {
   const taskOrderItemReportReportResp = await requestFunc(
     TaskOrderItemReportFuncName.TaskOrderItemReport,
     equipType,
-    {
-      id: currentReportId.value,
-    },
+    { id: currentReportId.value },
   )
   const taskOrderItemReport = taskOrderItemReportReportResp.data
-  const templateId = taskOrderItemReport?.templateId || ''
-  const refId = currentReportId.value
-
-  const res = await getStandardTemplate({ id: templateId })
-  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,
-      templateId,
-      templateUrl: resData.fileUrl,
-    },
-    pathNameMapping: JSON.parse(resData.bindingPathNameJson),
-    template: templateId,
-    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
+  templateId.value = taskOrderItemReport?.templateId || ''
+  refId.value = currentReportId.value
 }
 
 

+ 1 - 1
src/pages/securityCheck/detail/index copy.vue

@@ -13,7 +13,7 @@
     <!-- 导航栏 -->
     <NavBar>
       <template #title>
-        <HeadView v-if="renderCenter" title="操作指导书批准详情" :btn-array="btnArray" />
+        <HeadView v-if="renderCenter" title="安全检查记录详情" :btn-array="btnArray" />
         <text v-else class="nav-title">安全检查记录详情</text>
       </template>
     </NavBar>

+ 38 - 29
src/pages/securityCheck/detail/index.vue

@@ -13,7 +13,7 @@
     <!-- 导航栏 -->
     <NavBar>
       <template #title>
-        <HeadView v-if="renderCenter" title="操作指导书批准详情" :btn-array="btnArray" />
+        <HeadView v-if="renderCenter" title="安全检查记录详情" :btn-array="btnArray" />
         <text v-else class="nav-title">安全检查记录详情</text>
       </template>
     </NavBar>
@@ -23,11 +23,16 @@
       <view v-if="loading" class="loading-container">
         <text class="loading-text">加载中...</text>
       </view>
-      <SpreadPDFViewer
+      <!-- <SpreadPDFViewer
         ref="spreadPdfViewerRef"
         :businessConfig="businessConfig"
         :templateData="templateData"
         :templateBlob="templateBlob"
+      /> -->
+      <BackendPDFViewer
+        ref="backendPdfViewerRef"
+        :refId="securityCheckId"
+        :templateId="templateId"
       />
     </view>
   </view>
@@ -39,6 +44,7 @@ import { onLoad } from '@dcloudio/uni-app'
 import HeadView from '../components/HeadView.vue'
 import NavBar from '@/components/NavBar/NavBar.vue'
 import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 
 import { useConfigStore } from '@/store/config'
 
@@ -57,6 +63,7 @@ const orderId = ref('')
 const unitContact = ref('')
 const unitPhone = ref('')
 const receiverEmail = ref('')
+const securityCheckId = ref('')
 const templateId = ref('')
 const spreadPdfViewerRef = ref<any>(null)
 
@@ -121,34 +128,36 @@ const init = async () => {
     const id = detailItem.value?.id || ''
     if (!id) return
     const defaultTemplateResp = await requestFunc(SecurityCheckFuncName.getTemplate, equipType, { orderId: orderId.value })
-    const res = await getStandardTemplate({ id: defaultTemplateResp.data?.templateId })
-    const resData = (res as any).data
-    const dataMap: any = {}
-    const dynamicTbValResp = await getDynamicTbVal({ refId: id })
-    const dynamicTb: any = dynamicTbValResp.data
-    for (let i = 0; i < dynamicTb.dynamicTbValRespVOList.length; i++) {
-      const item = dynamicTb.dynamicTbValRespVOList[i]
-      dataMap[item.colCode] = item.valValue
-    }
-    // 组装templateData
-    templateData.value = {
-      schema: resData.bindingPathSchema ? JSON.parse(resData.bindingPathSchema) : {},
-      data: {
-        ...dataMap,
-        templateId,
-        templateUrl: resData.fileUrl,
-      },
-      pathNameMapping: JSON.parse(resData.bindingPathNameJson),
-      template: templateId,
-      templateUrl: resData.fileUrl,
-    }
+    securityCheckId.value = id
+    templateId.value = defaultTemplateResp.data?.templateId || ''
+    // const res = await getStandardTemplate({ id: defaultTemplateResp.data?.templateId })
+    // const resData = (res as any).data
+    // const dataMap: any = {}
+    // const dynamicTbValResp = await getDynamicTbVal({ refId: id })
+    // const dynamicTb: any = dynamicTbValResp.data
+    // for (let i = 0; i < dynamicTb.dynamicTbValRespVOList.length; i++) {
+    //   const item = dynamicTb.dynamicTbValRespVOList[i]
+    //   dataMap[item.colCode] = item.valValue
+    // }
+    // // 组装templateData
+    // templateData.value = {
+    //   schema: resData.bindingPathSchema ? JSON.parse(resData.bindingPathSchema) : {},
+    //   data: {
+    //     ...dataMap,
+    //     templateId,
+    //     templateUrl: resData.fileUrl,
+    //   },
+    //   pathNameMapping: JSON.parse(resData.bindingPathNameJson),
+    //   template: templateId,
+    //   templateUrl: resData.fileUrl,
+    // }
 
-    console.log(templateData.value)
-    // 获取 template 文件
-    const fileUri = resData.fileUrl
-    const fileUrl = buildFileUrl(fileUri)
-    const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
-    templateBlob.value = fileBase64
+    // console.log(templateData.value)
+    // // 获取 template 文件
+    // const fileUri = resData.fileUrl
+    // const fileUrl = buildFileUrl(fileUri)
+    // const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
+    // templateBlob.value = fileBase64
   } catch (error) {
     console.error('[Page] 初始化失败:', error)
     uni.showToast({ title: 'PDF 加载失败', icon: 'none' })

+ 7 - 58
src/pages/sign/index.vue

@@ -20,12 +20,11 @@
     <!-- 内容区域 -->
     <scroll-view class="scroll-content" scroll-y>
       <!-- PDF 图片预览 -->
-      <SpreadPDFViewer
-        ref="spreadPdfViewerRef"
-        :businessConfig="businessConfig"
-        :templateData="templateData"
-        :templateBlob="templateBlob"
-        viewer-height="50vh"
+      <BackendPDFViewer
+        ref="backendPdfViewerRef"
+        :refId="refId"
+        :templateId="templateId"
+        viewerHeight="50vh"
       />
 
       <!-- 签名区域分割线 -->
@@ -166,17 +165,14 @@
 import { ref, computed, onMounted, nextTick } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import SignatureCanvas from '@/components/Signature/SignatureCanvas.vue'
-import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 import NavBar from '@/components/NavBar/NavBar.vue'
 
 import { useUserStore } from '@/store/user'
 import { useConfigStore } from '@/store/config'
 
 import { getGcConfig, getTaskOrderImg, pushPressure2TaskOrder, uploadSignImage } from '@/api/sign'
-import { getDynamicTbVal } from '@/api/task'
-import { getStandardTemplate } from '@/api/index'
 import { getTaskOrderReport } from '@/api/orderReport'
-import { buildFileUrl } from '@/utils/index'
 import { SignFuncName, requestFunc } from '@/api/ApiRouter/sign'
 import { TaskOrderFuncName, requestFunc as taskOrderRequestFunc } from '@/api/ApiRouter/taskOrder'
 import {
@@ -215,22 +211,7 @@ const inputPhone = ref('')
 const inputEmail = ref('')
 const gcConfig = ref<any>(null)
 
-const spreadPdfViewerRef = ref<any>(null)
-const templateBlob = ref<any>(null)
-const businessConfig = ref<any>({
-  businessType: 'AQJC',
-  title: '安全检查记录编辑',
-  disableNavigate: true, // 是否禁用跳转,默认不禁用
-
-  ui: {
-    title: '安全检查记录',
-    saveButtonText: '保存',
-    cancelButtonText: '取消',
-    showAdditionalToolbar: true,
-    customButtons: [],
-  },
-})
-const templateData = ref<any>({})
+const backendPdfViewerRef = ref<any>(null)
 
 // 签名区域状态:empty | signing | signed
 const signStatus = ref<'empty' | 'signing' | 'signed'>('empty')
@@ -363,38 +344,6 @@ const getPreviewData = async () => {
       uni.showToast({ title: '请选择正确的签字文件类型', icon: 'error' })
       break
   }
-
-  // 获取templateSchema
-  const res = await getStandardTemplate({ id: templateId.value })
-  const resData = (res as any).data
-  // 加载报表数据
-  const dataMap: any = {}
-  const dynamicTbResp = await getDynamicTbVal({
-    refId: refId.value,
-  })
-  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
-  templateData.value = {
-    schema: resData.bindingPathSchema ? JSON.parse(resData.bindingPathSchema) : {},
-    data: {
-      ...dataMap,
-      templateId: templateId.value,
-      templateUrl: resData.fileUrl,
-    },
-    pathNameMapping: JSON.parse(resData.bindingPathNameJson),
-    template: templateId.value,
-    templateUrl: resData.fileUrl,
-  }
-
-  // 获取 template 文件
-  const fileUri = resData.fileUrl
-  const fileUrl = buildFileUrl(fileUri)
-  const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
-  templateBlob.value = fileBase64
 }
 
 const handleToSign = () => {

+ 10 - 52
src/pages/workInstructionAudit/preViewReport/index.vue

@@ -18,11 +18,10 @@
       </template>
     </ReportNavBar>
 
-    <SpreadPDFViewer
-      ref="spreadPdfViewerRef"
-      :businessConfig="businessConfig"
-      :templateData="templateData"
-      :templateBlob="templateBlob"
+    <BackendPDFViewer
+      ref="backendPdfViewerRef"
+      :refId="refId"
+      :templateId="templateId"
     />
 
     <wd-popup position="center" v-model="showGoBack">
@@ -56,13 +55,10 @@ import { ref, watch } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import ReportNavBar from '@/components/NavBar/ReportNavBar.vue'
 import { useToast } from 'wot-design-uni'
-import SpreadPDFViewer from '@/components/SpreadDesigner/SpreadPDFViewer.vue'
+import BackendPDFViewer from '@/components/BackendPDFViewer/index.vue'
 
 import { useConfigStore } from '@/store/config'
 
-import { buildFileUrl } from '@/utils/index'
-import { getDynamicTbVal } from '@/api/task'
-import { getStandardTemplate } from '@/api/index'
 import { requestFunc, ApprovalFuncName } from '@/api/ApiRouter/approval'
 
 defineOptions({
@@ -74,21 +70,9 @@ const templateIdFromRoute = ref('')
 
 const equipType = useConfigStore().getEquipType()
 
-const spreadPdfViewerRef = ref<any>(null)
-const templateBlob = ref<any>(null)
-const businessConfig = ref<any>({
-  businessType: 'ZDS',
-  title: '操作指导书批准',
-  disableNavigate: true,
-  ui: {
-    title: '操作指导书批准',
-    saveButtonText: '保存',
-    cancelButtonText: '取消',
-    showAdditionalToolbar: true,
-    customButtons: [],
-  },
-})
-const templateData = ref<any>({})
+const backendPdfViewerRef = ref<any>(null)
+const templateId = ref('')
+const refId = ref('')
 
 onLoad((options: any) => {
   id.value = options?.id || ''
@@ -102,34 +86,8 @@ watch(id, (newVal) => {
 })
 
 const loadPreviewData = async () => {
-  const tmplId = templateIdFromRoute.value
-  const refId = id.value
-
-  const res = await getStandardTemplate({ id: tmplId })
-  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,
-      templateId: tmplId,
-      templateUrl: resData.fileUrl,
-    },
-    pathNameMapping: JSON.parse(resData.bindingPathNameJson),
-    template: tmplId,
-    templateUrl: resData.fileUrl,
-  }
-
-  const fileUri = resData.fileUrl
-  const fileUrl = buildFileUrl(fileUri)
-  const fileBase64 = await spreadPdfViewerRef.value.downloadFileAsBase64(fileUrl)
-  templateBlob.value = fileBase64
+  templateId.value = templateIdFromRoute.value
+  refId.value = id.value
 }
 
 const showGoBack = ref(false)

+ 3 - 1
vite.config.ts

@@ -172,7 +172,9 @@ export default ({ command, mode }) => {
         : undefined,
     },
     build: {
-      // 方便非h5端调试
+      outDir: UNI_PLATFORM === 'h5'
+        ? (mode === 'uat' ? 'dist/build/h5-uat' : 'dist/build/h5')
+        : undefined,
       sourcemap: VITE_SHOW_SOURCEMAP === 'true', // 默认是false
       target: 'es6',
       // 开发环境不用压缩