Browse Source

fix: 企业报送资料增加查看按钮实现功能

shiyanyu 1 tháng trước cách đây
mục cha
commit
f708b38897

+ 70 - 0
src/views/EntDeclaration/auditTaskManagement/components/DataRequirementsTab.vue

@@ -148,6 +148,14 @@
             <template v-else>
               <!-- v-if="scope.row.isUpload === 1 || scope.row.isUpload === '1'" -->
               <el-button
+                v-if="scope.row.isUpload === 1 || scope.row.isUpload === '1'"
+                type="text"
+                size="small"
+                @click="handleViewTemplate(scope.row)"
+              >
+                查看
+              </el-button>
+              <el-button
                 type="text"
                 size="small"
                 @click="handleTemplateDownload(scope.row)"
@@ -178,6 +186,37 @@
       style="display: none"
       @change="handleDataFileChange"
     />
+
+    <!-- 单记录弹窗(查看模式) -->
+    <survey-form-dialog
+      :visible.sync="singleDialogVisible"
+      :survey-data="{}"
+      :is-view-mode="true"
+      :audited-unit-id="auditedUnitId"
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
+
+    <!-- 固定表弹窗(查看模式) -->
+    <fixed-table-dialog
+      :visible.sync="fixedDialogVisible"
+      :is-view-mode="true"
+      :audited-unit-id="auditedUnitId"
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
+
+    <!-- 动态表弹窗(查看模式) -->
+    <dynamic-table-dialog
+      :visible.sync="dynamicDialogVisible"
+      :is-view-mode="true"
+      :audited-unit-id="auditedUnitId"
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
   </div>
 </template>
 
@@ -186,8 +225,16 @@
     downloadPresetTemplate,
     uploadPresetTemplate,
   } from '@/api/auditTaskProcessing'
+  import SurveyFormDialog from '@/views/EntDeclaration/auditTaskManagement/components/SurveyFormDialog.vue'
+  import FixedTableDialog from '@/views/EntDeclaration/auditTaskManagement/components/FixedTableDialog.vue'
+  import DynamicTableDialog from '@/views/EntDeclaration/auditTaskManagement/components/DynamicTableDialog.vue'
   export default {
     name: 'DataRequirementsTab',
+    components: {
+      SurveyFormDialog,
+      FixedTableDialog,
+      DynamicTableDialog,
+    },
     props: {
       dataRequirements: {
         type: Array,
@@ -218,6 +265,11 @@
       return {
         pendingUploadRow: null,
         dataUploadAccept: '.xls,.xlsx',
+        // 模板查看相关
+        currentTemplateRow: null,
+        singleDialogVisible: false,
+        fixedDialogVisible: false,
+        dynamicDialogVisible: false,
       }
     },
     computed: {},
@@ -256,6 +308,24 @@
             this.$message.error('文件预览失败')
         }
       },
+      // 模版查看:与 submitData.vue 的 handleViewTemplate 保持一致
+      handleViewTemplate(row) {
+        this.currentTemplateRow = row || null
+        const t = String(
+          (row && (row.templateType || row.templatetype)) || ''
+        ).trim()
+        if (t === '1') {
+          this.singleDialogVisible = true
+        } else if (t === '2') {
+          this.fixedDialogVisible = true
+        } else if (t === '3') {
+          this.dynamicDialogVisible = true
+        } else {
+          this.$message &&
+            this.$message.warning &&
+            this.$message.warning('未知的模板类型,无法打开预置模板')
+        }
+      },
       // 根据资料类型返回上传accept白名单
       getUploadAccept(row) {
         const fmt = row && row.formatRequired

+ 34 - 1
src/views/costAudit/auditInfo/auditManage/submitData.vue

@@ -416,7 +416,40 @@
       handleViewDownload(row) {
         // this.$message.info(`查看下载文件:${row.name}`)
         // 这里可以添加查看下载文件的逻辑
-        this.handleViewTemplate(row)
+        if (row.fileUrl !== null) {
+          this.handleFileView(row)
+        } else {
+          this.handleViewTemplate(row)
+        }
+      },
+      handleFileView(row) {
+        console.log(row, '这一行数据')
+        try {
+          const filePath =
+            row?.filePath ||
+            row?.filepath ||
+            row?.fileUrl ||
+            row?.url ||
+            row?.path ||
+            ''
+          if (!filePath) {
+            this.$message &&
+              this.$message.warning &&
+              this.$message.warning('未找到可预览的文件路径')
+            return
+          }
+          const encodedUrl = encodeURIComponent(
+            Base64.encode((window.context && window.context.form) + filePath)
+          )
+          window.open(`${host}:8012/onlinePreview?url=${encodedUrl}`)
+          // 兼容保留:通知父组件
+          this.$emit('handleFileView', row)
+        } catch (e) {
+          console.error('文件预览失败: ', e)
+          // this.$message &&
+          //   this.$message.error &&
+          //   this.$message.error('文件预览失败')
+        }
       },
       // 查看预置模板,按模板类型打开不同弹窗
       handleViewTemplate(row) {