Selaa lähdekoodia

fix: 详情中显示成本审核表格

shiyanyu 1 kuukausi sitten
vanhempi
commit
4836f3cd75

+ 1 - 1
src/api/audit/survey.js

@@ -5,7 +5,7 @@ const url = window.context.form
 // 成本调查列表
 export function getSurveyList(data) {
   return request({
-    url: url + '/api/enterprise/castTaskInfo/listUploadByCatalogId',
+    url: url + '/api/enterprise/castTaskInfo/listByTaskId',
     method: 'get',
     params: data,
   })

+ 30 - 1
src/components/task/cbjsInfo.vue

@@ -8,16 +8,23 @@
       @close="handleClose"
     >
       <!-- 标签页面 - 移除了操作按钮区域 -->
-      <el-tabs v-model="activeTab" type="card" class="audit-tabs">
+      <el-tabs
+        v-model="activeTab"
+        type="card"
+        class="audit-tabs"
+        @tab-click="handleTabClick"
+      >
         <el-tab-pane label="报送资料" name="submitData">
           <submit-data :id="id" :disabled="true" />
         </el-tab-pane>
         <el-tab-pane label="成本调查表" name="costSurvey">
           <cost-survey
             :id="id"
+            ref="costSurveyRef"
             :disabled="true"
             :audited-unit-id="auditedUnitId"
             :catalog-id="catalogId"
+            :task-id="taskId"
           />
         </el-tab-pane>
         <el-tab-pane
@@ -149,6 +156,13 @@
           ''
         )
       },
+      taskId() {
+        return (
+          (this.selectedProject &&
+            (this.selectedProject.taskId || this.selectedProject.taskid)) ||
+          ''
+        )
+      },
     },
     watch: {
       visible(newVal) {
@@ -212,6 +226,21 @@
           this.activeTab = 'submitData'
         }
       },
+      // 标签切换时回调
+      handleTabClick(tab) {
+        if (tab && tab.name === 'costSurvey') {
+          // 切到成本调查表时,调用子组件刷新
+          this.$nextTick(() => {
+            if (
+              this.$refs &&
+              this.$refs.costSurveyRef &&
+              this.$refs.costSurveyRef.loadList
+            ) {
+              this.$refs.costSurveyRef.loadList()
+            }
+          })
+        }
+      },
       handleClose() {
         // 关闭弹窗时触发事件
         this.$emit('update:visible', false)

+ 6 - 5
src/components/task/components/costSurvey.vue

@@ -138,6 +138,7 @@
     props: {
       auditedUnitId: { type: String, default: '' },
       catalogId: { type: String, default: '' },
+      taskId: { type: String, default: '' },
     },
     data() {
       return {
@@ -155,21 +156,21 @@
       }
     },
     watch: {
-      catalogId(newVal, oldVal) {
+      taskId(newVal, oldVal) {
         if (newVal && newVal !== oldVal) {
           this.loadList()
         }
       },
       auditedUnitId(newVal, oldVal) {
-        if (this.catalogId && newVal !== oldVal) {
+        if (this.taskId && newVal !== oldVal) {
           this.loadList()
         }
       },
     },
     created() {
       console.log('auditedUnitId', this.auditedUnitId)
-      console.log('catalogId', this.catalogId)
-      if (this.catalogId) {
+      console.log('taskId', this.taskId)
+      if (this.taskId) {
         this.loadList()
       }
     },
@@ -205,7 +206,7 @@
       async loadList() {
         try {
           const params = {
-            catalogId: this.catalogId,
+            taskId: this.taskId,
             pageNum: 1,
             pageSize: 100,
           }

+ 25 - 11
src/components/task/taskComponents/surveyTab.vue

@@ -66,13 +66,13 @@
     watch: {
       project: {
         handler(newVal) {
-          const catalogId = this.getCatalogId(newVal)
-          if (catalogId) {
-            // 如果 catalogId 没有变化,不重复加载
-            if (this.projectIdCache === catalogId) {
+          const taskId = this.getTaskId(newVal)
+          if (taskId) {
+            // 如果 taskId 没有变化,不重复加载
+            if (this.projectIdCache === taskId) {
               return
             }
-            this.projectIdCache = catalogId
+            this.projectIdCache = taskId
             // 调用接口加载数据
             this.loadSurveyData()
           }
@@ -83,13 +83,27 @@
     },
     mounted() {
       console.log('project', this.project)
-      // 如果已有 catalogId,立即加载
-      const catalogId = this.getCatalogId(this.project)
-      if (catalogId) {
+      // 如果已有 taskId,立即加载
+      const taskId = this.getTaskId(this.project)
+      if (taskId) {
         this.loadSurveyData()
       }
     },
     methods: {
+      // 从任务信息中获取 taskId
+      getTaskId(project) {
+        if (!project) return null
+        if (project.taskId) return project.taskId
+        if (project.basicInfo && project.basicInfo.taskId)
+          return project.basicInfo.taskId
+        if (
+          project.data &&
+          project.data.basicInfo &&
+          project.data.basicInfo.taskId
+        )
+          return project.data.basicInfo.taskId
+        return null
+      },
       // 从立项信息中获取 catalogId
       getCatalogId(project) {
         if (!project) {
@@ -115,15 +129,15 @@
       },
       // 加载成本调查表数据
       async loadSurveyData() {
-        const catalogId = this.getCatalogId(this.project)
-        if (!catalogId) {
+        const taskId = this.getTaskId(this.project)
+        if (!taskId) {
           return
         }
 
         try {
           this.loading = true
           const params = {
-            catalogId: catalogId,
+            taskId: taskId,
           }
           const res = await getSurveyList(params)
 

+ 9 - 1
src/components/task/taskInfo.vue

@@ -1187,8 +1187,16 @@
         // }
         try {
           this.loading = true
+          // getSurveyList 现在按 taskId 查询
+          if (!this.currentTaskInfo || !this.currentTaskInfo.taskId) {
+            this.formData.costSurveyData = []
+            this.costSurveyPagination.total = 0
+            this.tabLoadedStatus.costSurvey = true
+            this.loading = false
+            return
+          }
           const params = {
-            catalogId: this.catalogId,
+            taskId: this.currentTaskInfo.taskId,
             pageNum: this.costSurveyPagination.currentPage,
             pageSize: this.costSurveyPagination.pageSize,
           }

+ 15 - 2
src/views/EntDeclaration/auditTaskManagement/components/DynamicTableDialog.vue

@@ -265,6 +265,15 @@
         type: String,
         default: '',
       },
+      // 任务ID(用于新增动态表数据)
+      taskId: {
+        type: String,
+        default: '',
+      },
+      projectId: {
+        type: String,
+        default: '',
+      },
       // 表格数据
       tableData: {
         type: Array,
@@ -736,6 +745,8 @@
             const catalogId = this.catalogId || sd.catalogId || ''
             const surveyTemplateId =
               this.surveyTemplateId || sd.surveyTemplateId || ''
+            const taskId = this.taskId || sd.taskId || ''
+            const projectId = this.projectId || sd.projectId || ''
             // if (!uploadId || !auditedUnitId) {
             //   Message.error('缺少必要参数:uploadId 或 auditedUnitId')
             //   this.adding = false
@@ -747,6 +758,8 @@
               auditedUnitId,
               catalogId,
               surveyTemplateId,
+              taskId,
+              projectId,
               auditPeriod: this.addForm.auditPeriod,
               reportingTime: this.addForm.reportingTime || now,
             }
@@ -758,11 +771,11 @@
               // 触发刷新事件,通知父组件刷新列表
               this.$emit('refresh')
             } else {
-              Message.error(res?.message || '新增失败')
+              Message.error(res?.message)
             }
           } catch (e) {
             console.error('新增失败:', e)
-            Message.error('新增失败')
+            // Message.error('新增失败')
           } finally {
             this.adding = false
           }

+ 4 - 1
src/views/EntDeclaration/auditTaskManagement/taskFillIn.vue

@@ -104,6 +104,8 @@
               :is-view-mode="isViewMode"
               :audited-unit-id="auditedUnitId"
               :catalog-id="taskInfo.catalogId"
+              :task-id="taskInfo.taskId"
+              :project-id="taskInfo.projectId"
               :audit-period="getAuditPeriodArray()"
               @handle-modify="handleModify"
               @handle-data-download="handleDataDownload"
@@ -1210,10 +1212,11 @@
       getCostSurveyList() {
         this.tabLoading.costSurvey = true
         const params = {
-          catalogId: this.taskInfo.catalogId,
+          taskId: this.taskId || (this.taskInfo && this.taskInfo.taskId) || '',
           pageNum: this.costSurveyPagination.currentPage,
           pageSize: this.costSurveyPagination.pageSize,
         }
+        if (this.auditedUnitId) params.auditedUnitId = this.auditedUnitId
         getSurveyList(params)
           .then((res) => {
             console.log('成本调查表列表', res)

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

@@ -464,7 +464,7 @@
         console.log(this.taskInfo, '这行数据')
         try {
           const params = {
-            catalogId: this.catalogId,
+            taskId: this.taskInfo.taskId,
             pageNum: this.costSurveyPagination.currentPage,
             pageSize: this.costSurveyPagination.pageSize,
           }