Ver código fonte

fix: 详情添加成本调查表

shiyanyu 1 mês atrás
pai
commit
c3c91545bf

+ 186 - 9
src/components/task/components/costSurvey.vue

@@ -24,6 +24,13 @@
         align="center"
         header-align="center"
       />
+      <!-- 表格类型 -->
+      <el-table-column
+        prop="tableType"
+        label="表格类型"
+        width="120"
+        align="center"
+      />
       <el-table-column
         prop="isRequired"
         label="是否必填"
@@ -31,6 +38,18 @@
         align="center"
         header-align="center"
       />
+      <!-- 是否上传(只读显示) -->
+      <el-table-column label="是否上传" width="100" align="center">
+        <template slot-scope="scope">
+          <span
+            :style="{
+              color: scope.row.isUploaded === true ? '#67c23a' : '#f56c6c',
+            }"
+          >
+            {{ scope.row.isUploaded === true ? '已上传' : '未上传' }}
+          </span>
+        </template>
+      </el-table-column>
       <el-table-column
         label="操作"
         width="120"
@@ -48,7 +67,7 @@
     <!-- 单记录弹窗(查看) -->
     <survey-form-dialog
       :visible.sync="singleDialogVisible"
-      :survey-data="{}"
+      :survey-data="{ ...currentSurveyRow, ...surveyDetailData }"
       :is-view-mode="true"
       :audited-unit-id="
         (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
@@ -66,6 +85,7 @@
     <!-- 固定表弹窗(查看) -->
     <fixed-table-dialog
       :visible.sync="fixedDialogVisible"
+      :survey-data="surveyDetailData"
       :is-view-mode="true"
       :audited-unit-id="
         (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
@@ -78,11 +98,14 @@
         ''
       "
       :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+      :table-items="tableItems"
+      :audit-periods="auditPeriods"
     />
 
     <!-- 动态表弹窗(查看) -->
     <dynamic-table-dialog
       :visible.sync="dynamicDialogVisible"
+      :table-data="dynamicTableData"
       :is-view-mode="true"
       :audited-unit-id="
         (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
@@ -100,7 +123,12 @@
 </template>
 <script>
   import taskMixins from './taskMixins.js'
-  import { getSurveyList } from '@/api/audit/survey'
+  import {
+    getSurveyList,
+    getSurveyDetail,
+    getSingleRecordSurveyList,
+    getDynamicTableData,
+  } from '@/api/audit/survey'
   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'
@@ -116,15 +144,64 @@
         loading: false,
         rows: [],
         currentTemplateRow: null,
+        currentSurveyRow: null,
+        surveyDetailData: {},
+        tableItems: [],
+        auditPeriods: [],
+        dynamicTableData: [],
         singleDialogVisible: false,
         fixedDialogVisible: false,
         dynamicDialogVisible: false,
       }
     },
+    watch: {
+      catalogId(newVal, oldVal) {
+        if (newVal && newVal !== oldVal) {
+          this.loadList()
+        }
+      },
+      auditedUnitId(newVal, oldVal) {
+        if (this.catalogId && newVal !== oldVal) {
+          this.loadList()
+        }
+      },
+    },
     created() {
-      this.loadList()
+      console.log('auditedUnitId', this.auditedUnitId)
+      console.log('catalogId', this.catalogId)
+      if (this.catalogId) {
+        this.loadList()
+      }
     },
     methods: {
+      // 预取单记录详情作为回显
+      async loadSingleRecordDetail() {
+        this.surveyDetailData = {}
+        const row = this.currentTemplateRow || {}
+        const uploadId = row.uploadId || row.id || ''
+        const auditedUnitId = row.auditedUnitId || this.auditedUnitId || ''
+        if (!uploadId || !auditedUnitId) return
+        try {
+          const params = { uploadId, auditedUnitId }
+          const res = await getSurveyDetail(params)
+          if (res && res.code === 200 && res.value) {
+            const detail = {}
+            if (Array.isArray(res.value)) {
+              res.value.forEach((item) => {
+                if (item && item.rowid !== undefined) {
+                  detail[item.rowid] = item.rvalue
+                }
+              })
+            } else if (res.value && typeof res.value === 'object') {
+              // 兼容对象结构
+              Object.assign(detail, res.value)
+            }
+            this.surveyDetailData = detail
+          }
+        } catch (e) {
+          this.surveyDetailData = {}
+        }
+      },
       async loadList() {
         try {
           const params = {
@@ -165,7 +242,7 @@
               dataType: it.dataType || '预置模板',
               tableType,
               isRequired: String(it.isRequired) === '1' ? '是' : '否',
-              isUpload: String(it.isUpload) === '1' || it.isUpload === true,
+              isUploaded: String(it.isUpload) === '1' || it.isUpload === true,
               uploadId: it.uploadId || it.id || '',
               surveyTemplateId: it.templateId || it.surveyTemplateId || '',
               catalogId: it.catalogId || this.catalogId || '',
@@ -177,18 +254,118 @@
           this.rows = []
         }
       },
-      handleViewTemplate(row) {
+      async handleViewTemplate(row) {
         this.currentTemplateRow = row || null
+        this.currentSurveyRow = 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
+        if (t === '1') {
+          // 单记录:清理并预取详情
+          this.surveyDetailData = {}
+          await this.loadSingleRecordDetail()
+          this.singleDialogVisible = true
+        } else if (t === '2') {
+          // 预加载固定表配置(tableItems)并推断监审期间
+          this.tableItems = []
+          this.auditPeriods = []
+          await this.initFixedTableData()
+          this.fixedDialogVisible = true
+        } else if (t === '3') {
+          // 预加载动态表列表数据
+          this.dynamicTableData = []
+          await this.initDynamicTableData()
+          this.dynamicDialogVisible = true
+        } else {
           this.$message &&
             this.$message.warning &&
             this.$message.warning('未知的模板类型,无法打开预置模板')
+        }
+      },
+      async initFixedTableData() {
+        this.tableItems = []
+        this.auditPeriods = []
+        const row = this.currentTemplateRow || {}
+        const surveyTemplateId = row.templateId || row.surveyTemplateId || ''
+        if (!surveyTemplateId) return
+        try {
+          const params = { surveyTemplateId }
+          const res = await getSingleRecordSurveyList(params)
+          if (res && res.code === 200 && res.value) {
+            const { itemlist } = res.value || {}
+            if (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.项目 || item.itemName || '',
+                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,
+              }))
+            }
+            // 尝试从当前行或配置中解析监审期间
+            const periodStr =
+              row.auditPeriod || (res.value && res.value.auditPeriod) || ''
+            this.auditPeriods = this.parseAuditPeriod(periodStr)
+          }
+        } catch (e) {
+          this.tableItems = []
+          this.auditPeriods = []
+        }
+      },
+      parseAuditPeriod(periodStr) {
+        if (!periodStr) return []
+        const str = String(periodStr)
+        if (str.includes(',')) {
+          return str.split(',').map((p) => String(p).trim())
+        }
+        if (str.includes('-')) {
+          const parts = str.split('-')
+          if (parts.length === 2) {
+            const start = parseInt(parts[0].trim())
+            const end = parseInt(parts[1].trim())
+            const years = []
+            for (let y = start; y <= end; y++) years.push(String(y))
+            return years
+          }
+        }
+        return [String(str)]
+      },
+      async initDynamicTableData() {
+        this.dynamicTableData = []
+        const row = this.currentTemplateRow || {}
+        const uploadId = row.uploadId || row.id || ''
+        const auditedUnitId = row.auditedUnitId || this.auditedUnitId || ''
+        const catalogId = row.catalogId || this.catalogId || ''
+        const surveyTemplateId = row.templateId || row.surveyTemplateId || ''
+        if (!uploadId || !auditedUnitId) return
+        try {
+          const params = {
+            uploadId,
+            auditedUnitId,
+            catalogId,
+            surveyTemplateId,
+          }
+          const res = await getDynamicTableData(params)
+          if (res && res.code === 200) {
+            const records = res.value?.records || res.value || []
+            this.dynamicTableData = Array.isArray(records) ? records : []
+          }
+        } catch (e) {
+          this.dynamicTableData = []
+        }
       },
     },
   }

+ 0 - 1
src/views/EntDeclaration/auditTaskManagement/components/DynamicTableDialog.vue

@@ -84,7 +84,6 @@
           <el-button
             type="text"
             size="small"
-            :disabled="isViewMode"
             @click="handleViewDetail(scope.row)"
           >
             详情

+ 1 - 1
src/views/costAudit/auditInfo/auditManage/index.vue

@@ -194,7 +194,7 @@
     <!-- 成本监审信息弹窗 -->
     <cbjs-info
       :id="cbjsInfoData && cbjsInfoData.id"
-      :selected-project="selectedProject"
+      :selected-project="cbjsInfoData"
       :visible.sync="cbjsInfoVisible"
       :current-node="cbjsInfoData && cbjsInfoData.currentNode"
       :current-status="cbjsInfoData && cbjsInfoData.status"