Quellcode durchsuchen

fix: 修改办结监审查询详情

shiyanyu vor 2 Wochen
Ursprung
Commit
b11b73452d

+ 47 - 4
src/views/costAudit/auditInfo/completedSupervisionQuery/index.vue

@@ -148,11 +148,20 @@
     <taskInfo ref="taskInfo" />
     <cbjs-info
       :id="cbjsInfoData && cbjsInfoData.id"
+      :selected-project="cbjsInfoData"
       :visible.sync="cbjsInfoVisible"
       :current-node="cbjsInfoData && cbjsInfoData.currentNode"
       :current-status="cbjsInfoData && cbjsInfoData.status"
     />
     <taskDetail ref="taskDetail" />
+    <!-- 成本监审任务制定弹窗(用于“任务详情”只读查看) -->
+    <task-customized-release-dialog
+      :visible.sync="taskReleaseDialogVisible"
+      :project="project"
+      :is-view="true"
+      @backToList="taskReleaseDialogVisible = false"
+      @close="taskReleaseDialogVisible = false"
+    />
   </div>
 </template>
 
@@ -162,12 +171,15 @@
   import taskInfo from '@/components/task/taskInfo.vue'
   import cbjsInfo from '@/components/task/cbjsInfo.vue'
   import taskDetail from '@/components/task/taskDetail.vue'
+  import TaskCustomizedReleaseDialog from '@/components/task/TaskCustomizedReleaseDialog.vue'
+  import { getCostProjectDetail } from '@/api/taskCustomizedRelease.js'
   export default {
     name: 'CompletedSupervisionQuery',
     components: {
       taskDetail,
       taskInfo,
       cbjsInfo,
+      TaskCustomizedReleaseDialog,
     },
     data() {
       return {
@@ -195,6 +207,8 @@
         // cbjsInfo弹窗相关
         cbjsInfoVisible: false,
         cbjsInfoData: null,
+        // 任务详情(项目)弹窗
+        taskReleaseDialogVisible: false,
       }
     },
     created() {
@@ -330,12 +344,41 @@
         }
       },
 
+      // // 查看任务详情
+      // handleViewTaskDetail(row) {
+      //   // this.selectedTask = row
+      //   // this.activeTab = 'detail'
+      //   // this.showTaskDetail = true
+      //   this.$refs.taskDetail.open(row, 'chengben')
+      // },
+
       // 查看任务详情
       handleViewTaskDetail(row) {
-        // this.selectedTask = row
-        // this.activeTab = 'detail'
-        // this.showTaskDetail = true
-        this.$refs.taskDetail.open(row, 'chengben')
+        // 使用成本监审任务制定弹窗(只读)
+        this.openTaskReleaseDialog(row)
+      },
+      // 打开成本监审任务制定弹窗(只读查看)
+      openTaskReleaseDialog(row) {
+        if (!row) return
+        const projectId =
+          row.projectId || row.projectID || row.id || row.taskId || ''
+        if (!projectId) {
+          this.$message &&
+            this.$message.warning &&
+            this.$message.warning('缺少项目ID,无法查看详情')
+          return
+        }
+        this.isView = true
+        getCostProjectDetail({ id: projectId })
+          .then((res) => {
+            this.project = (res && res.value) || {}
+            this.taskReleaseDialogVisible = true
+          })
+          .catch(() => {
+            // 回退:接口失败时至少展示当前行数据
+            this.project = row || {}
+            this.taskReleaseDialogVisible = true
+          })
       },
 
       // 切换视图

+ 127 - 184
src/views/costAudit/baseInfo/catalogManage/surveyDialog.vue

@@ -67,52 +67,50 @@
               style="width: 100%"
               :row-class-name="getFixedPreviewRowClass"
             >
-              <el-table-column label="序号" width="80" align="center">
+              <!-- <el-table-column label="序号" width="80" align="center">
                 <template slot-scope="scope">
                   {{ scope.row._displaySeq || '-' }}
                 </template>
-              </el-table-column>
-              <!-- <el-table-column label="项目" min-width="200" align="left">
-                <template slot-scope="scope">
-                  <span
-                    :class="[
-                      'table-item-text',
-                      scope.row._isCategory ? 'category-name' : '',
-                    ]"
-                    :style="{ paddingLeft: `${scope.row._indentLevel * 20}px` }"
-                  >
-                    {{ scope.row._displayName || '-' }}
-                  </span>
-                </template>
-              </el-table-column>
-              <el-table-column label="单位" width="100" align="center">
-                <template slot-scope="scope">
-                  <span v-if="!scope.row._isCategory">
-                    {{ scope.row._displayUnit || '-' }}
-                  </span>
-                </template>
               </el-table-column> -->
+
+              <!-- 动态生成 fixedFields 中的列 -->
               <el-table-column
-                v-for="column in fixedTableValueColumns"
-                :key="column.key"
-                :label="column.label"
-                min-width="120"
+                v-for="field in contentEditForm.fixedTable.fixedTablesTitle"
+                :key="field.rkey"
+                :label="field.rkey"
+                min-width="150"
                 align="center"
+                :prop="field.rkey"
               >
                 <template slot-scope="scope">
-                  <el-input
-                    v-if="!scope.row._isCategory"
-                    :value="scope.row._displayValues[column.key] || ''"
-                    :placeholder="column.placeholder"
-                    disabled
-                  />
+                  <!-- 显示内容 -->
+                  <span v-if="scope.row[field.rkey] !== undefined">
+                    {{ scope.row[field.rkey] || '-' }}
+                  </span>
+                  <span
+                    v-else-if="
+                      scope.row.fixedValues &&
+                      scope.row.fixedValues[field.rkey] !== undefined
+                    "
+                  >
+                    {{ scope.row.fixedValues[field.rkey] || '-' }}
+                  </span>
+                  <span
+                    v-else-if="
+                      scope.row._displayValues &&
+                      scope.row._displayValues[field.rkey] !== undefined
+                    "
+                  >
+                    {{ scope.row._displayValues[field.rkey] || '-' }}
+                  </span>
+                  <span v-else>
+                    {{ '-' }}
+                  </span>
                 </template>
               </el-table-column>
-              <el-table-column label="备注" min-width="160" align="left">
+
+              <!-- <el-table-column label="备注" min-width="160" align="left">
                 <template slot-scope="scope">
-                  <!-- <span v-if="!scope.row._isCategory">
-                    {{ scope.row._displayRemark || '-' }}
-                  </span> -->
                   <el-input
                     v-if="!scope.row._isCategory"
                     :value="scope.row._displayRemark || ''"
@@ -120,7 +118,7 @@
                     disabled
                   />
                 </template>
-              </el-table-column>
+              </el-table-column> -->
               <!-- <el-table-column label="指标编号" width="120" align="center">
                 <template slot-scope="scope">
                   <span v-if="!scope.row._isCategory">
@@ -415,92 +413,26 @@
         }
         return Array.from(labels)
       },
-      fixedTableValueColumns() {
-        const auditYears = this.auditPeriodYears
-        const candidateLabels = this.fixedTableColumnCandidates
-        const usedLabels = new Set()
-        const resultColumns = []
-        const extractYear = (label) => {
-          if (!label) return ''
-          const match = String(label).match(/(19|20)\d{2}/)
-          return match ? match[0] : ''
-        }
-        const buildColumn = ({ key, label, placeholder, candidates }) => ({
-          key,
-          label,
-          placeholder,
-          candidates,
-        })
-
-        auditYears.forEach((year) => {
-          const matchLabel =
-            candidateLabels.find((label) => {
-              const normalized = extractYear(label)
-              return normalized && normalized === String(year)
-            }) || ''
-          const displayLabel = matchLabel || `${year}年`
-          const columnKey = `year-${year}`
-          usedLabels.add(matchLabel)
-          resultColumns.push(
-            buildColumn({
-              key: columnKey,
-              label: displayLabel,
-              placeholder: `请输入${displayLabel}数据`,
-              candidates: [
-                matchLabel,
-                displayLabel,
-                `${year}年`,
-                `${year}年度`,
-                `${year}`,
-                `year_${year}`,
-              ].filter(Boolean),
-            })
-          )
-        })
-
-        candidateLabels.forEach((label) => {
-          if (!label || usedLabels.has(label)) {
-            return
-          }
-          if (
-            ['序号', '项目', '指标编号', '计算公式', '单位', '备注'].includes(
-              label
-            )
-          ) {
-            return
-          }
-          resultColumns.push(
-            buildColumn({
-              key: `col-${label}`,
-              label,
-              placeholder: `请输入${label}`,
-              candidates: [label],
-            })
-          )
-          usedLabels.add(label)
-        })
-
-        return resultColumns
-      },
       fixedTableDisplayData() {
         const rows =
-          (this.contentEditForm &&
-            this.contentEditForm.fixedTable &&
+          (this.contentEditForm.fixedTable &&
             this.contentEditForm.fixedTable.fixedTables) ||
           []
-        if (!Array.isArray(rows) || rows.length === 0) {
-          return []
-        }
+        if (!rows.length) return []
 
-        const normalizeId = (val) => {
-          if (val === undefined || val === null) return ''
-          return String(val)
+        const normalizeId = (id) => {
+          if (id === undefined || id === null) return ''
+          return String(id).trim()
         }
 
+        // 创建行ID到父ID的映射
         const parentMap = {}
+        const childMap = {}
+
         rows.forEach((row, index) => {
           const rowId = normalizeId(row.rowid || row.itemId || index)
           const parentId = row.parentid
+
           if (
             parentId !== undefined &&
             parentId !== null &&
@@ -514,7 +446,7 @@
           }
         })
 
-        const childMap = {}
+        // 创建子项映射
         Object.keys(parentMap).forEach((rowId) => {
           const parentId = parentMap[rowId]
           if (parentId) {
@@ -525,27 +457,24 @@
           }
         })
 
+        // 计算缩进级别
         const computedLevels = {}
         const getLevel = (rowId, depth = 0) => {
           if (!rowId) return 0
-          if (computedLevels[rowId] !== undefined) {
-            return computedLevels[rowId]
-          }
-          if (depth > rows.length) {
-            return 0
-          }
+          if (computedLevels[rowId] !== undefined) return computedLevels[rowId]
+          if (depth > rows.length) return 0
+
           const parentId = parentMap[rowId]
           if (!parentId) {
             computedLevels[rowId] = 0
             return 0
           }
+
           const level = 1 + getLevel(parentId, depth + 1)
           computedLevels[rowId] = level
           return level
         }
 
-        const columnDefs = this.fixedTableValueColumns || []
-
         return rows.map((row, index) => {
           const rowId = normalizeId(row.rowid || row.itemId || index)
           const fixedValues = row.fixedValues || {}
@@ -555,14 +484,29 @@
             row.orderNum ||
             row.seq ||
             ''
-          const displayName =
-            fixedValues['项目'] ||
-            fixedValues['项目名称'] ||
-            row.itemName ||
-            row.projectName ||
-            ''
-          const displayUnit = fixedValues['单位'] || row.unit || ''
-          const displayRemark = fixedValues['备注'] || row.remark || ''
+
+          // 获取所有字段的显示值
+          const displayValues = { ...fixedValues }
+
+          // 确保所有fixedFields中的字段都有值
+          const fixedFields =
+            this.contentEditForm.fixedTable.fixedTablesTitle || []
+          fixedFields.forEach((field) => {
+            const fieldName = field.rkey
+            if (displayValues[fieldName] === undefined) {
+              displayValues[fieldName] = ''
+            }
+          })
+
+          // 设置默认显示名称(使用第一个非序号字段)
+          let displayName = ''
+          const nonSeqField = fixedFields.find((f) => f.rkey !== '序号')
+          if (nonSeqField) {
+            displayName = displayValues[nonSeqField.rkey] || ''
+          }
+
+          const displayUnit = displayValues['单位'] || row.unit || ''
+          const displayRemark = displayValues['备注'] || row.remark || ''
           const hasChildren = !!childMap[rowId]
           const isChild =
             row.isChild ||
@@ -572,62 +516,21 @@
               row.parentid !== '' &&
               row.parentid !== '-1' &&
               row.parentid !== -1)
-          const isCategory =
-            row.isCategory === true || (!isChild && hasChildren)
-
-          const displayValues = {}
-          columnDefs.forEach((column) => {
-            let value = ''
-            const candidates = column.candidates || []
-            for (let i = 0; i < candidates.length; i += 1) {
-              const candidate = candidates[i]
-              if (!candidate) continue
-              if (
-                fixedValues[candidate] !== undefined &&
-                fixedValues[candidate] !== null &&
-                fixedValues[candidate] !== ''
-              ) {
-                value = fixedValues[candidate]
-                break
-              }
-              if (
-                row[candidate] !== undefined &&
-                row[candidate] !== null &&
-                row[candidate] !== ''
-              ) {
-                value = row[candidate]
-                break
-              }
-              const altKey = String(candidate).replace(/年|年度/g, '')
-              if (
-                altKey &&
-                fixedValues[altKey] !== undefined &&
-                fixedValues[altKey] !== null &&
-                fixedValues[altKey] !== ''
-              ) {
-                value = fixedValues[altKey]
-                break
-              }
-            }
-            displayValues[column.key] = value
-          })
-
-          const remarkValue =
-            fixedValues['备注'] !== undefined && fixedValues['备注'] !== null
-              ? fixedValues['备注']
-              : displayRemark
+          const level = getLevel(rowId)
+          const indentLevel = Math.min(level, 5)
+          const isCategory = hasChildren || isChild
 
           return {
             ...row,
-            _rowId: rowId,
             _displaySeq: displaySeq,
             _displayName: displayName,
             _displayUnit: displayUnit,
-            _displayRemark: remarkValue,
+            _displayRemark: displayRemark,
+            _displayValues: displayValues,
             _hasChildren: hasChildren,
             _isCategory: isCategory,
-            _indentLevel: getLevel(rowId),
-            _displayValues: displayValues,
+            _indentLevel: indentLevel,
+            _rowId: rowId,
           }
         })
       },
@@ -692,6 +595,7 @@
        * @param {Object} responseData - listByCurrentTemplateId接口返回的数据
        */
       parseAndDisplayFixedTableData(responseData) {
+        // 解析fixedFields
         if (responseData.value.fixedFields) {
           this.contentEditForm.fixedTable.fixedTablesTitle =
             this.stringToObjects(responseData.value.fixedFields || '')
@@ -702,10 +606,11 @@
           this.contentEditForm.fixedTable.fixedTablesTitle =
             this.stringToObjects(fixedFields || '')
         }
+
         const fixedTitles = this.contentEditForm.fixedTable.fixedTablesTitle
-        this.contentEditForm.fixedTable.fixedTableHeaders = fixedTitles.filter(
-          (title) => title.rkey !== '序号'
-        )
+        // 保留所有字段,包括序号
+        this.contentEditForm.fixedTable.fixedTableHeaders = [...fixedTitles]
+
         if (
           !responseData ||
           !responseData.value ||
@@ -721,12 +626,14 @@
         this.contentEditForm.fixedTable.fixedTables = []
 
         // 遍历itemList,为每个项目创建一行数据
-        itemList.forEach((item, index) => {
+        itemList.forEach((item) => {
           // 判断是否为子项(parentid不为-1且不为"-1")
           const isSubItem =
             item.parentid && item.parentid !== -1 && item.parentid !== '-1'
 
+          // 创建新行数据
           const newRow = {
+            ...item, // 首先展开所有原始字段
             orderText: item.orderNum || '', // 显示用序号
             orderNum: item.orderNum || '', // 保留原始序号用于发送后端
             surveyTemplateId: item.surveyTemplateId,
@@ -741,6 +648,7 @@
             isSubItem: isSubItem,
             rowid: item.rowid || this.generateUUID(),
             jsonstr: item.jsonstr || null,
+            remark: item.remark || '', // 添加备注字段
           }
 
           // 确保orderNum是数字类型
@@ -750,7 +658,17 @@
 
           // 初始化fixedValues并填充实际值
           fixedTitles.forEach((title) => {
-            newRow.fixedValues[title.rkey] = item[title.rkey] || ''
+            // 优先从item中获取值,如果没有则从其他可能的位置获取
+            const fieldValue =
+              item[title.rkey] !== undefined
+                ? item[title.rkey]
+                : item.fixedValues && item.fixedValues[title.rkey] !== undefined
+                ? item.fixedValues[title.rkey]
+                : ''
+
+            // 处理可能的null或undefined值
+            newRow.fixedValues[title.rkey] =
+              fieldValue !== undefined && fieldValue !== null ? fieldValue : ''
           })
 
           allRows.push(newRow)
@@ -865,20 +783,45 @@
       flattenHierarchy(rows) {
         const sortedRows = []
         const parentMap = {}
+        const rowMap = {}
+
+        // 首先将所有行添加到rowMap中,方便后续查找
         rows.forEach((row) => {
+          rowMap[row.rowid] = row
           parentMap[row.parentid] = parentMap[row.parentid] || []
           parentMap[row.parentid].push(row)
         })
-        function addRows(parentId) {
+
+        // 递归添加行,并设置层级信息
+        function addRows(parentId, level = 0) {
           if (parentMap[parentId]) {
             parentMap[parentId].forEach((row) => {
+              // 设置层级信息
+              row._level = level
+              row._isCategory = true // 标记为分类(父级)
+
+              // 确保子项的父级也被标记为分类
+              if (row.parentid && row.parentid !== -1 && rowMap[row.parentid]) {
+                rowMap[row.parentid]._isCategory = true
+              }
+
               sortedRows.push(row)
-              addRows(row.rowid)
+              // 递归添加子项
+              addRows(row.rowid, level + 1)
             })
           }
         }
+
+        // 从顶级(parentid为-1或undefined)开始添加
         addRows(-1)
-        return sortedRows
+
+        // 确保所有行都有必要的属性
+        return sortedRows.map((row) => ({
+          ...row,
+          _isCategory: row._isCategory || false,
+          _level: row._level || 0,
+          _hasChildren: parentMap[row.rowid] && parentMap[row.rowid].length > 0,
+        }))
       },
       // 字符串转对象数组
       stringToObjects(str) {