Browse Source

fix: 调用saveSingleRecordSurvey这个接口的时候需要传taskId

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

+ 2 - 0
src/views/EntDeclaration/auditTaskManagement/components/CostSurveyTab.vue

@@ -17,6 +17,7 @@
           : surveyTemplateId
       "
       :catalog-id="catalogId"
+      :task-id="taskId"
       @save="handleSurveyFormSave"
       @refresh="handleRefresh"
     />
@@ -41,6 +42,7 @@
           : surveyTemplateId
       "
       :catalog-id="catalogId"
+      :task-id="taskId"
       @save="handleFixedTableSave"
       @refresh="handleRefresh"
     />

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

@@ -204,6 +204,7 @@
             ''
           "
           :period-record-id="currentRow ? currentRow.id : ''"
+          :task-id="taskId || (surveyData && surveyData.taskId) || ''"
         />
       </div>
       <div slot="footer" class="dialog-footer">

+ 7 - 0
src/views/EntDeclaration/auditTaskManagement/components/FixedAssetsTable.vue

@@ -165,6 +165,11 @@
         type: String,
         default: '',
       },
+      // 任务ID(按接口字段名 taskkId 传递)
+      taskId: {
+        type: [String, Number],
+        default: '',
+      },
     },
     data() {
       return {
@@ -1246,6 +1251,8 @@
               auditedUnitId: this.auditedUnitId || '',
               surveyTemplateId: this.surveyTemplateId || '',
               catalogId: this.catalogId || '',
+              // 接口字段名为 taskkId,这里从 prop taskId 映射
+              taskkId: this.taskId || '',
               type: 1,
             }
 

+ 6 - 0
src/views/EntDeclaration/auditTaskManagement/components/FixedTableDialog.vue

@@ -179,6 +179,11 @@
         type: [String, Number],
         default: 1,
       },
+      // 任务ID
+      taskId: {
+        type: [String, Number],
+        default: '',
+      },
     },
     data() {
       return {
@@ -879,6 +884,7 @@
               surveyTemplateId:
                 this.surveyTemplateId || this.surveyData.surveyTemplateId || '',
               catalogId: this.catalogId || this.surveyData.catalogId || '',
+              taskId: this.taskId || this.surveyData.taskId || '',
               type: this.requestType,
             }
 

+ 6 - 0
src/views/EntDeclaration/auditTaskManagement/components/SurveyFormDialog.vue

@@ -198,6 +198,11 @@
         type: String,
         default: '',
       },
+      // 任务ID
+      taskId: {
+        type: [String, Number],
+        default: '',
+      },
       // 统一控制接口 type(1=成本调查表,2=报送资料)
       requestType: {
         type: [String, Number],
@@ -912,6 +917,7 @@
                     this.surveyData.surveyTemplateId ||
                     '',
                   catalogId: this.catalogId || this.surveyData.catalogId || '',
+                  taskId: this.taskId || this.surveyData.taskId || '',
                   rowid: field.prop, // 字段ID(对应 fixedFieldids)
                   rkey: field.label, // 字段名称(对应 fixedFields,即 label)
                   rvalue: this.form[field.prop] || '', // 字段值(表单输入的值)

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

@@ -178,7 +178,7 @@
   } from '@/api/costVerifyManage'
   import { getDetail } from '@/api/auditInitiation'
   import { catalogMixin } from '@/mixins/useDict'
-  import { saveSingleRecordSurvey } from '@/api/audit/survey'
+  import { saveSingleRecordSurvey, getSurveyDetail } from '@/api/audit/survey'
 
   export default {
     name: 'CostAudit',
@@ -416,6 +416,7 @@
           if (tableHeadersRes.code == 200) {
             this.parseAndDisplayTableHeaders(tableHeadersRes)
             this.parseAndDisplayTableData(tableDataRes)
+            await this.tryEchoUploadData()
           }
         }
       },
@@ -438,6 +439,57 @@
         // 处理表格数据
         if (tableDataRes.code == 200) {
           this.parseAndDisplayTableData(tableDataRes)
+          await this.tryEchoUploadData()
+        }
+      },
+      // 根据已存在的上传数据进行回显(若有)
+      async tryEchoUploadData() {
+        try {
+          const uploadId = (this.auditForm && this.auditForm.uploadId) || ''
+          const auditedUnitId = this.auditedUnitId || ''
+          if (!uploadId || !auditedUnitId) return
+          const params = {
+            uploadId,
+            auditedUnitId,
+            type: 1,
+          }
+          const res = await getSurveyDetail(params)
+          if (res && res.code === 200 && res.value) {
+            const triplets = Array.isArray(res.value)
+              ? res.value
+              : res.value.items || res.value.records || []
+            if (!Array.isArray(triplets) || triplets.length === 0) return
+            // 建立字段名映射:rkey(中文列名) -> fieldEname(表格prop)
+            const headerMap = {}
+            ;(this.tableHeadersRes || []).forEach((h) => {
+              if (h && h.fieldName && h.fieldEname)
+                headerMap[h.fieldName] = h.fieldEname
+            })
+            // 行索引:rowid -> 行对象
+            const rowMap = new Map()
+            ;(this.costAuditData || []).forEach((row) => {
+              if (row && row.rowid !== undefined && row.rowid !== null) {
+                rowMap.set(String(row.rowid), row)
+              }
+            })
+            // 应用回显
+            triplets.forEach((item) => {
+              const rowid = item.rowid || item.rowId || item.ROWID
+              const rkey = item.rkey || item.rKey || item.RKEY
+              const rvalue = item.rvalue || item.rValue || item.RVALUE
+              if (!rowid || !rkey) return
+              const row = rowMap.get(String(rowid))
+              const prop = headerMap[rkey]
+              if (row && prop) {
+                row[prop] = rvalue != null ? String(rvalue) : ''
+              }
+            })
+            // 强制刷新
+            this.costAuditData = [...this.costAuditData]
+          }
+        } catch (e) {
+          // 静默失败即可
+          console.warn('回显上传数据失败: ', e)
         }
       },
       parseAndDisplayTableHeaders(res) {
@@ -725,6 +777,8 @@
             this.auditForm.surveyTemplateId || this.auditForm.dataTable || ''
           const catalogId = this.auditForm.catalogId || ''
           const hasData = !!(this.auditForm && this.auditForm.uploadId)
+          const taskId =
+            (this.selectedProject && this.selectedProject.taskId) || ''
 
           const finalSaveData = rawItems.map((it) => {
             const base = {
@@ -734,6 +788,7 @@
               auditedUnitId,
               surveyTemplateId,
               catalogId,
+              taskId,
             }
             if (hasData) base.uploadId = this.auditForm.uploadId
             return base
@@ -744,6 +799,7 @@
           if (res && res.code === 200) {
             this.$message.success('保存成功')
             this.loadTemplateData && this.loadTemplateData()
+            await this.tryEchoUploadData()
           } else {
             this.$message.error((res && res.message) || '保存失败')
           }