Pārlūkot izejas kodu

fix: 填报任务报送资料查看、在线填报完刷新,查看报送资料、成本调查表查看详情

shiyanyu 1 mēnesi atpakaļ
vecāks
revīzija
84be7830a0

+ 427 - 0
src/components/task/taskInfo.vue

@@ -9,6 +9,57 @@
     class="task-info-dialog"
   >
     <div class="task-info-container">
+      <!-- 报送资料预置模版查看弹窗:复用 SurveyFormDialog / FixedTableDialog / DynamicTableDialog,只读模式 -->
+      <survey-form-dialog
+        :visible.sync="surveyFormDialogVisible"
+        :survey-data="{ ...(currentTemplateRow || {}), ...surveyDetailData }"
+        :form-fields="formFields"
+        :is-view-mode="true"
+        :audited-unit-id="auditedUnitId"
+        :request-type="2"
+        :upload-id="
+          (currentTemplateRow &&
+            (currentTemplateRow.uploadId || currentTemplateRow.id)) ||
+          ''
+        "
+        :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+        :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+      />
+
+      <fixed-table-dialog
+        :visible.sync="fixedTableDialogVisible"
+        :survey-data="{ ...(currentTemplateRow || {}), fixedHeaders }"
+        :table-items="tableItems"
+        :audit-periods="auditPeriods"
+        :is-view-mode="true"
+        :request-type="2"
+        :audited-unit-id="auditedUnitId"
+        :upload-id="
+          (currentTemplateRow &&
+            (currentTemplateRow.uploadId || currentTemplateRow.id)) ||
+          ''
+        "
+        :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+        :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+      />
+
+      <dynamic-table-dialog
+        :key="dynamicDialogKey"
+        :visible.sync="dynamicTableDialogVisible"
+        :survey-data="currentTemplateRow || {}"
+        :table-data="dynamicTableData"
+        :table-items="tableItems"
+        :is-view-mode="true"
+        :request-type="2"
+        :audited-unit-id="auditedUnitId"
+        :upload-id="
+          (currentTemplateRow &&
+            (currentTemplateRow.uploadId || currentTemplateRow.id)) ||
+          ''
+        "
+        :survey-template-id="getSurveyTemplateId(currentTemplateRow)"
+        :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+      />
       <!-- 标签页容器 -->
       <el-tabs
         v-model="activeTab"
@@ -507,6 +558,16 @@
                     <template v-if="scope.row.formatRequired == '3'">
                       <el-button
                         v-if="
+                          scope.row.isUpload === 1 || scope.row.isUpload === '1'
+                        "
+                        type="text"
+                        size="small"
+                        @click="handleViewTemplate(scope.row)"
+                      >
+                        查看
+                      </el-button>
+                      <el-button
+                        v-if="
                           (scope.row.isUpload === 1 ||
                             scope.row.isUpload === '1') &&
                           scope.row.templateType !== '1'
@@ -576,6 +637,7 @@
                 width="100"
                 align="center"
               ></el-table-column>
+
               <el-table-column label="是否上传" width="100" align="center">
                 <template slot-scope="scope">
                   <span
@@ -588,6 +650,18 @@
                   </span>
                 </template>
               </el-table-column>
+              <!-- 操作列:查看单记录/固定表/动态表 -->
+              <el-table-column label="操作" width="120" align="center">
+                <template slot-scope="scope">
+                  <el-button
+                    type="text"
+                    size="small"
+                    @click="handleCostSurveyView(scope.row)"
+                  >
+                    查看
+                  </el-button>
+                </template>
+              </el-table-column>
             </el-table>
             <el-pagination
               background
@@ -909,6 +983,15 @@
   import TemplatePreviewEdit from '@/components/costAudit/TemplatePreviewEdit.vue'
   import MultiAttachmentDialog from '@/components/costAudit/MultiAttachmentDialog'
   import { uploadFile } from '@/api/file'
+  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'
+  import {
+    getSingleRecordSurveyList,
+    getSurveyDetail,
+    getDynamicTableData,
+  } from '@/api/audit/survey'
+  import { getListBySurveyFdTemplateIdAndVersion } from '@/api/costSurveyTemplateHeaders'
   export default {
     name: 'TaskInfo',
     components: {
@@ -917,6 +1000,9 @@
       CostAuditDialog,
       TemplatePreviewEdit,
       MultiAttachmentDialog,
+      SurveyFormDialog,
+      FixedTableDialog,
+      DynamicTableDialog,
     },
     mixins: [dictMixin],
     props: {
@@ -1025,6 +1111,18 @@
         activeDocTab: 'preview', // 当前标签页,preview:预览,edit:修改
         dialogMultiVisible: false,
         attachments: [],
+        // 报送资料预置模版查看相关
+        currentTemplateRow: null,
+        surveyFormDialogVisible: false,
+        fixedTableDialogVisible: false,
+        dynamicTableDialogVisible: false,
+        formFields: [],
+        surveyDetailData: {},
+        tableItems: [],
+        auditPeriods: [],
+        dynamicTableData: [],
+        dynamicDialogKey: 0,
+        fixedHeaders: null,
       }
     },
     computed: {
@@ -1448,6 +1546,334 @@
           this.loading = false
         }
       },
+      // 成本调查表-查看:复用报送资料预置模版查看的三种弹窗(只读)
+      handleCostSurveyView(row) {
+        if (!row) return
+        // 将成本调查表行映射为 currentTemplateRow 结构
+        const templateRow = {
+          uploadId: row.uploadId || row.id,
+          id: row.id,
+          surveyTemplateId: row.surveyTemplateId,
+          templateType:
+            row.templateType ||
+            (row.tableType === '单记录'
+              ? '1'
+              : row.tableType === '固定表'
+              ? '2'
+              : row.tableType === '动态表'
+              ? '3'
+              : ''),
+          catalogId: row.catalogId || this.catalogId || '',
+          auditedUnitId: row.auditedUnitId || this.auditedUnitId || '',
+          informationName: row.name,
+        }
+        this.handleViewTemplate(templateRow)
+      },
+      // 报送资料预置模版-查看:单记录/固定表/动态表只读查看并回显
+      async handleOnlineSubmission(row) {
+        if (!row) return
+        this.currentTemplateRow = row
+        this.surveyDetailData = {}
+
+        const t = String(row.templateType || row.templatetype || '').trim()
+        if (t === '1') {
+          if (row.uploadId || row.id) {
+            try {
+              const params = {
+                uploadId: row.uploadId || row.id,
+                auditedUnitId: this.auditedUnitId,
+                type: 2,
+              }
+              const res = await getSurveyDetail(params)
+              if (res && res.code === 200 && res.value) {
+                const detailData = {}
+                if (Array.isArray(res.value)) {
+                  res.value.forEach((item) => {
+                    if (item.rowid && item.rvalue !== undefined) {
+                      detailData[item.rowid] = item.rvalue
+                    }
+                  })
+                } else if (res.value && typeof res.value === 'object') {
+                  Object.assign(detailData, res.value)
+                }
+                this.surveyDetailData = detailData
+              }
+            } catch (err) {
+              console.error('获取单记录详情失败', err)
+            }
+          }
+          await this.initFormFields()
+        } else if (t === '2') {
+          await this.initFixedTableData()
+        } else if (t === '3') {
+          await this.initDynamicTableData()
+        }
+      },
+      handleViewTemplate(row) {
+        this.currentTemplateRow = row || null
+        const t = String(
+          (row && (row.templateType || row.templatetype)) || ''
+        ).trim()
+        if (t === '1' || t === '2' || t === '3') {
+          this.handleOnlineSubmission(row)
+        } else {
+          this.$message &&
+            this.$message.warning &&
+            this.$message.warning('未知的模板类型,无法打开预置模板')
+        }
+      },
+      async initDynamicTableData() {
+        try {
+          const uploadId =
+            (this.currentTemplateRow &&
+              (this.currentTemplateRow.uploadId ||
+                this.currentTemplateRow.id)) ||
+            ''
+          const auditedUnitId = this.auditedUnitId || ''
+          const catalogId =
+            (this.currentTemplateRow && this.currentTemplateRow.catalogId) || ''
+          const surveyTemplateId = this.getSurveyTemplateId(
+            this.currentTemplateRow
+          )
+
+          const params = {
+            uploadId,
+            auditedUnitId,
+            catalogId,
+            surveyTemplateId,
+            type: 2,
+          }
+          const res = await getDynamicTableData(params)
+          if (res && res.code === 200) {
+            const records = res.value?.records || res.value || []
+            this.dynamicTableData = Array.isArray(records) ? records : []
+          } else {
+            this.dynamicTableData =
+              this.currentTemplateRow?.dynamicTableData || []
+          }
+
+          if (
+            this.currentTemplateRow &&
+            this.currentTemplateRow.tableItems &&
+            this.currentTemplateRow.tableItems.length > 0
+          ) {
+            this.tableItems = this.currentTemplateRow.tableItems
+          } else {
+            this.tableItems = this.getMockTableItems()
+          }
+          this.dynamicTableDialogVisible = true
+        } catch (error) {
+          console.error('获取动态表数据失败', error)
+          this.dynamicTableData =
+            this.currentTemplateRow?.dynamicTableData || []
+          this.tableItems =
+            this.currentTemplateRow?.tableItems || this.getMockTableItems()
+          this.dynamicTableDialogVisible = true
+        }
+      },
+      async initFormFields() {
+        if (
+          this.currentTemplateRow &&
+          this.getSurveyTemplateId(this.currentTemplateRow)
+        ) {
+          try {
+            const params = {
+              surveyTemplateId: this.getSurveyTemplateId(
+                this.currentTemplateRow
+              ),
+              type: 2,
+            }
+            const res = await getListBySurveyFdTemplateIdAndVersion(params)
+            if (res && res.code === 200) {
+              let mapped = []
+              if (Array.isArray(res.value)) {
+                mapped = res.value
+                  .map((item, index) =>
+                    this.mapApiFieldToFormField(item, index)
+                  )
+                  .filter(Boolean)
+              } else if (res.value && typeof res.value === 'object') {
+                const { fixedFields, fixedFieldids } = res.value
+                if (fixedFields && fixedFieldids) {
+                  const labels = fixedFields.split(',').map((i) => i.trim())
+                  const ids = fixedFieldids.split(',').map((i) => i.trim())
+                  mapped = labels.map((label, index) => ({
+                    prop: ids[index] || `field_${index}`,
+                    label,
+                    type: 'input',
+                    colSpan: 12,
+                    placeholder: `请输入${label}`,
+                    rules: [],
+                    defaultValue: '',
+                    disabled: false,
+                    clearable: true,
+                    multiple: false,
+                    required: false,
+                  }))
+                }
+              }
+              this.formFields =
+                mapped.length > 0 ? mapped : this.getMockFormFields()
+            } else {
+              this.formFields = this.getMockFormFields()
+            }
+            this.surveyFormDialogVisible = true
+          } catch (err) {
+            console.error('获取单记录表单字段配置失败', err)
+            this.formFields = this.getMockFormFields()
+            this.surveyFormDialogVisible = true
+          }
+        } else {
+          this.formFields = this.getMockFormFields()
+          this.surveyFormDialogVisible = true
+        }
+      },
+      async initFixedTableData() {
+        if (
+          this.currentTemplateRow &&
+          this.getSurveyTemplateId(this.currentTemplateRow)
+        ) {
+          try {
+            const params = {
+              surveyTemplateId: this.getSurveyTemplateId(
+                this.currentTemplateRow
+              ),
+              type: 2,
+            }
+            const res = await getSingleRecordSurveyList(params)
+            if (res && res.code === 200 && res.value) {
+              const { itemlist } = res.value
+              if (itemlist && Array.isArray(itemlist) && itemlist.length > 0) {
+                this.tableItems = itemlist.map((item) => ({
+                  id: item.id || item.itemId || '',
+                  rowid: item.rowid || item.id || item.itemId || '',
+                  seq: item.序号,
+                  itemName: item.项目 || '',
+                  unit: item.unit || '',
+                  isCategory: item.isCategory || false,
+                  categorySeq: item.categorySeq || '',
+                  categoryId: item.categoryId || '',
+                  parentid:
+                    item.parentid !== undefined
+                      ? item.parentid
+                      : item.parentId !== undefined
+                      ? item.parentId
+                      : '-1',
+                  validateRules: item.validateRules || {},
+                  linkageRules: item.linkageRules || {},
+                  children: item.children || [],
+                  ...item,
+                }))
+              } else {
+                this.tableItems = this.getMockTableItems()
+              }
+            } else {
+              this.tableItems = this.getMockTableItems()
+            }
+          } catch (err) {
+            console.error('获取固定表配置失败', err)
+            this.tableItems = this.getMockTableItems()
+          }
+        } else if (
+          this.currentTemplateRow &&
+          this.currentTemplateRow.tableItems
+        ) {
+          this.tableItems = this.currentTemplateRow.tableItems
+        } else {
+          this.tableItems = this.getMockTableItems()
+        }
+
+        const currentYear = new Date().getFullYear()
+        this.auditPeriods = [
+          String(currentYear - 2),
+          String(currentYear - 1),
+          String(currentYear),
+        ]
+
+        try {
+          const headerRes = await getListBySurveyFdTemplateIdAndVersion({
+            surveyTemplateId: this.getSurveyTemplateId(this.currentTemplateRow),
+            type: 2,
+          })
+          if (headerRes && headerRes.code === 200) {
+            this.fixedHeaders = headerRes.value || null
+          } else {
+            this.fixedHeaders = null
+          }
+        } catch (err) {
+          console.error('获取固定表表头配置失败', err)
+          this.fixedHeaders = null
+        }
+
+        this.fixedTableDialogVisible = true
+      },
+      getSurveyTemplateId(row) {
+        return (
+          row?.surveyTemplateId ||
+          row?.templateId ||
+          row?.surveyTemplateID ||
+          row?.templateID ||
+          ''
+        )
+      },
+      getMockFormFields() {
+        return []
+      },
+      getMockTableItems() {
+        return []
+      },
+      mapApiFieldToFormField(item, index = 0) {
+        if (!item) return null
+        const getVal = (keys, fallback) => {
+          for (const key of keys) {
+            if (
+              key &&
+              item[key] !== undefined &&
+              item[key] !== null &&
+              item[key] !== ''
+            ) {
+              return item[key]
+            }
+          }
+          return fallback
+        }
+        const prop =
+          getVal(
+            [
+              'fieldName',
+              'field_name',
+              'columnName',
+              'column_name',
+              'fieldCode',
+            ],
+            undefined
+          ) || `field_${index}`
+        const label =
+          getVal(
+            [
+              'columnComment',
+              'column_comment',
+              'fieldCname',
+              'field_cname',
+              'fieldLabel',
+              'field_label',
+            ],
+            prop
+          ) || prop
+        return {
+          prop,
+          label,
+          type: 'input',
+          colSpan: 12,
+          placeholder: `请输入${label}`,
+          rules: [],
+          defaultValue: '',
+          disabled: false,
+          clearable: true,
+          multiple: false,
+          required: false,
+        }
+      },
       // 加载监审文书
       async loadAuditDocument() {
         try {
@@ -1795,6 +2221,7 @@
               surveyTemplateId: it.templateId || it.surveyTemplateId || '',
               catalogId: it.catalogId || this.catalogId || '',
               auditedUnitId: it.auditedUnitId || this.auditedUnitId || '',
+              templateType: t,
             }
           })
           this.formData.costSurveyData = rows

+ 14 - 12
src/views/EntDeclaration/auditTaskManagement/components/DataRequirementsTab.vue

@@ -1,11 +1,11 @@
 <template>
   <div>
-    <!-- 在线填报弹窗(单记录类型,编辑模式) -->
+    <!-- 在线填报弹窗(单记录类型,可编辑/只读由 isViewMode/viewModeForDialog 控制) -->
     <survey-form-dialog
       :visible.sync="surveyFormDialogVisible"
       :survey-data="{ ...(currentTemplateRow || {}), ...surveyDetailData }"
       :form-fields="formFields"
-      :is-view-mode="isViewMode"
+      :is-view-mode="isViewMode || viewModeForDialog"
       :audited-unit-id="auditedUnitId"
       :request-type="2"
       :upload-id="
@@ -29,13 +29,13 @@
       "
     />
 
-    <!-- 固定表填报弹窗(编辑模式) -->
+    <!-- 固定表填报弹窗(可编辑/只读由 isViewMode/viewModeForDialog 控制) -->
     <fixed-table-dialog
       :visible.sync="fixedTableDialogVisible"
       :survey-data="{ ...(currentTemplateRow || {}), fixedHeaders }"
       :table-items="tableItems"
       :audit-periods="auditPeriods"
-      :is-view-mode="isViewMode"
+      :is-view-mode="isViewMode || viewModeForDialog"
       :request-type="2"
       :audited-unit-id="auditedUnitId"
       :upload-id="
@@ -59,14 +59,14 @@
       "
     />
 
-    <!-- 动态表填报弹窗(编辑模式) -->
+    <!-- 动态表填报弹窗(可编辑/只读由 isViewMode/viewModeForDialog 控制) -->
     <dynamic-table-dialog
       :key="dynamicDialogKey"
       :visible.sync="dynamicTableDialogVisible"
       :survey-data="currentTemplateRow || {}"
       :table-data="dynamicTableData"
       :table-items="tableItems"
-      :is-view-mode="isViewMode"
+      :is-view-mode="isViewMode || viewModeForDialog"
       :request-type="2"
       :audited-unit-id="auditedUnitId"
       :upload-id="
@@ -384,6 +384,8 @@
         singleDialogVisible: false,
         fixedDialogVisible: false,
         dynamicDialogVisible: false,
+        // 在线填报/查看共用弹窗的只读控制
+        viewModeForDialog: false,
         // 在线填报(编辑)相关
         surveyFormDialogVisible: false,
         fixedTableDialogVisible: false,
@@ -408,6 +410,8 @@
         if (!row) return
         this.currentTemplateRow = row
         this.surveyDetailData = {}
+        // 在线填报时使用页面传入的 isViewMode,不强制只读
+        this.viewModeForDialog = false
 
         const t = String(row.templateType || row.templatetype || '').trim()
         // 1=单记录,2=固定表,3=动态表
@@ -483,12 +487,10 @@
         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
+        // 点击“查看”时,复用在线填报的弹窗和数据加载逻辑,但强制只读
+        this.viewModeForDialog = true
+        if (t === '1' || t === '2' || t === '3') {
+          this.handleOnlineSubmission(row)
         } else {
           this.$message &&
             this.$message.warning &&

+ 5 - 0
src/views/EntDeclaration/auditTaskManagement/taskFillIn.vue

@@ -84,6 +84,8 @@
               :is-view-mode="isViewMode"
               :dict-data="dictData"
               :current-node="currentNode"
+              :audited-unit-id="auditedUnitId"
+              :task-id="taskId"
               @handleAddMaterial="handleAddMaterial"
               @handleFileView="handleFileView"
               @handleFileDownload="handleFileDownload"
@@ -91,6 +93,9 @@
               @handleTemplateDownload="handleTemplateDownload"
               @data-upload-success="getTaskRequirementPage"
               @handleDataUpload="handleDataUpload"
+              @handle-survey-form-save="getTaskRequirementPage"
+              @handle-fixed-table-save="getTaskRequirementPage"
+              @handle-dynamic-table-save="getTaskRequirementPage"
             />
           </el-tab-pane>
           <!-- 成本调查表 -->