Просмотр исходного кода

fix: 报送资料固定表在线填报监审期间修改,添加审核按钮

shiyanyu 2 недель назад
Родитель
Сommit
59002ad4a5

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

@@ -40,6 +40,7 @@
       :audit-periods="auditPeriods"
       :project-audit-periods="auditPeriods"
       :project-audit-period="auditPeriod"
+      :project-id="projectId"
       :is-view-mode="viewModeForDialog"
       :request-type="2"
       :audited-unit-id="auditedUnitId"
@@ -322,6 +323,7 @@
       :visible.sync="fixedDialogVisible"
       :is-view-mode="true"
       :request-type="2"
+      :project-id="projectId"
       :audited-unit-id="auditedUnitId"
       :audit-periods="auditPeriods"
       :project-audit-periods="auditPeriods"
@@ -408,6 +410,11 @@
         type: [String, Number],
         default: '',
       },
+      // 立项信息ID(用于 FixedTableDialog 优先用接口 auditPeriod 渲染年份)
+      projectId: {
+        type: [String, Number],
+        default: '',
+      },
     },
     data() {
       return {

+ 90 - 25
src/views/EntDeclaration/auditTaskManagement/components/FixedTableDialog.vue

@@ -201,6 +201,7 @@
   import { saveSingleRecordSurvey, getSurveyDetail } from '@/api/audit/survey'
   import { getByTypeKey } from '@/api/dictionaryManage'
   import { dictMixin } from '@/mixins/useDict'
+  import { getProjectInformationInfo } from '@/api/auditTaskProcessing'
 
   export default {
     name: 'FixedTableDialog',
@@ -298,6 +299,11 @@
         type: [String, Number],
         default: '',
       },
+      // 立项信息ID(用于在缺少年份来源时自动获取监审期间)
+      projectId: {
+        type: [String, Number],
+        default: '',
+      },
       // 从父组件传入的固定表头(逗号分隔)
       fixedFields: {
         type: String,
@@ -340,6 +346,8 @@
             console.log('FixedTableDialog fixedFields:', this.fixedFields)
             // 打印父组件传入的 surveyData
             console.log('FixedTableDialog surveyData:', this.surveyData)
+            // 优先初始化年份列(确保表头渲染)
+            await this.initYearColumns()
             // 先初始化表格数据
             this.initTableData()
             // 等待 DOM 更新后,如果有 uploadId,调用接口获取详情数据并回显
@@ -386,6 +394,13 @@
           this.initTableData()
         }
       },
+      // projectId 变化时在弹窗开启状态下重新初始化年份
+      projectId(newVal) {
+        if (this.dialogVisible) {
+          this.initYearColumns()
+          this.initTableData()
+        }
+      },
       // 预加载字典选项:扫描元数据中的 dictCode 等字段(优先 surveyData.fixedHeaders)
       columnsMeta: {
         handler() {
@@ -505,9 +520,9 @@
             extras.push(label)
           }
         })
-        const base = labels.concat(extras)
+        let base = labels.concat(extras)
         // 基于元数据控制显示:showVisible==='1' 强制显示;否则当 isAuditPeriod==='false' 隐藏
-        const filtered = base.filter((label) => {
+        let filtered = base.filter((label) => {
           const m = this.getFieldMeta(label)
           if (!m) return true
           // 强制显示优先
@@ -518,8 +533,12 @@
           const str = String(v).trim().toLowerCase()
           return !(str === 'false' || str === '0' || str === 'no')
         })
+        // 移除纯年份表头(如“2023”或“2023年”),年份列统一由 yearColumns 渲染
+        filtered = filtered.filter((label) => !/^\d{4}(年)?$/.test(label))
         // 若全部被过滤导致空表头,则回退为全部显示,避免页面空白
-        return filtered.length > 0 ? filtered : base
+        return filtered.length > 0
+          ? filtered
+          : base.filter((label) => !/^\d{4}(年)?$/.test(label))
       },
       // ====== fixedFields 渲染辅助(基于 columnsMeta)======
       getFieldMeta(label) {
@@ -719,9 +738,19 @@
         }
         this.$set(row, label, s)
       },
-      // 初始化年份列
-      initYearColumns() {
-        // 1) 优先使用立项信息中的监审期间(数组)
+      // 初始化年份列(当提供 projectId 时,仅使用接口返回的 auditPeriod)
+      async initYearColumns() {
+        // 0) 若提供了 projectId,则仅通过接口获取 auditPeriod,不再混用其他来源
+        this.yearColumns = []
+        if (this.projectId) {
+          console.log('initYearColumns start, projectId:', this.projectId)
+          await this.fetchProjectPeriodsFromApi()
+          // 无论是否获取到,都直接返回,避免被其他来源覆盖
+          console.log('initYearColumns using API years:', this.yearColumns)
+          return
+        }
+
+        // 1) 立项信息中的监审期间(数组)
         if (this.projectAuditPeriods && this.projectAuditPeriods.length > 0) {
           this.yearColumns = this.projectAuditPeriods.map((period) => {
             if (typeof period === 'string' && period.includes('-')) {
@@ -757,34 +786,70 @@
           const periods = this.parseAuditPeriod(this.surveyData.auditPeriod)
           this.yearColumns = periods
         } else {
-          // 默认使用最近3年
-          const currentYear = new Date().getFullYear()
-          this.yearColumns = [
-            String(currentYear - 2),
-            String(currentYear - 1),
-            String(currentYear),
-          ]
+          // 不再默认使用最近3年,保持为空
+          this.yearColumns = []
+        }
+        console.log('initYearColumns fallback years:', this.yearColumns)
+      },
+      // 通过接口自动获取立项信息监审期间
+      async fetchProjectPeriodsFromApi() {
+        try {
+          const pid = this.projectId
+          if (!pid) return
+          const res = await getProjectInformationInfo(pid)
+          console.log('fetchProjectPeriodsFromApi raw response:', res)
+          const periodStr =
+            (res &&
+              res.value &&
+              (res.value.auditPeriod || res.value.auditperiod)) ||
+            ''
+          const periods = this.parseAuditPeriod(periodStr)
+          console.log(
+            'fetchProjectPeriodsFromApi projectId:',
+            pid,
+            '\n value:',
+            res && res.value,
+            '\n auditPeriod string:',
+            periodStr,
+            '\n parsed years:',
+            periods
+          )
+          if (Array.isArray(periods) && periods.length > 0) {
+            this.yearColumns = periods
+          }
+        } catch (e) {
+          // 忽略错误,保持为空
         }
       },
       // 解析监审期间字符串(如 "2022,2023,2024" 或 "2022-2024")
       parseAuditPeriod(periodStr) {
         if (!periodStr) return []
-        if (periodStr.includes(',')) {
-          return periodStr.split(',').map((p) => p.trim())
-        }
-        if (periodStr.includes('-')) {
-          const parts = periodStr.split('-')
+        let s = String(periodStr).trim()
+        // 规范化:去除“年”和空格,将中文逗号替换为英文逗号
+        s = s.replace(/年/g, '').replace(/\s+/g, '').replace(/,/g, ',')
+        // 若是形如 2022-2024 或 2022年-2024年
+        if (s.includes('-')) {
+          const parts = s.split('-')
           if (parts.length === 2) {
-            const start = parseInt(parts[0].trim())
-            const end = parseInt(parts[1].trim())
-            const years = []
-            for (let year = start; year <= end; year++) {
-              years.push(String(year))
+            const start = parseInt(parts[0])
+            const end = parseInt(parts[1])
+            if (!isNaN(start) && !isNaN(end) && end >= start) {
+              const years = []
+              for (let y = start; y <= end; y++) years.push(String(y))
+              return years
             }
-            return years
           }
         }
-        return [String(periodStr)]
+        // 多年以逗号分隔
+        if (s.includes(',')) {
+          return s
+            .split(',')
+            .map((p) => p.trim())
+            .filter((p) => /^\d{4}$/.test(p))
+        }
+        // 单一年份
+        if (/^\d{4}$/.test(s)) return [s]
+        return []
       },
       // 初始化表格数据
       initTableData() {

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

@@ -90,6 +90,7 @@
               :current-node="currentNode"
               :audited-unit-id="auditedUnitId"
               :task-id="taskId"
+              :project-id="taskInfo.projectId"
               @handleAddMaterial="handleAddMaterial"
               @handleFileView="handleFileView"
               @handleFileDownload="handleFileDownload"

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

@@ -144,7 +144,10 @@
               </el-button>
               <el-button
                 v-if="
-                  scope.row.currentNode === 'yjfk' && scope.row.status === '260'
+                  (scope.row.currentNode === 'yjfk' &&
+                    scope.row.status === '260') ||
+                  (scope.row.currentNode === 'jtsy' &&
+                    scope.row.status === '200')
                 "
                 type="text"
                 @click="handleOpenDetails(scope.row)"

+ 6 - 3
src/views/costAudit/auditInfo/auditManage/submitData.vue

@@ -96,9 +96,11 @@
           <template slot-scope="scope">
             <el-button
               v-if="
-                scope.row.auditedStatus === '0' &&
-                (currentStatus === 200 || currentStatus === '200') &&
-                (currentNode === 'clcs' || currentNode === 'sdsh')
+                (scope.row.auditedStatus === '0' &&
+                  (currentStatus === 200 || currentStatus === '200') &&
+                  (currentNode === 'clcs' || currentNode === 'sdsh')) ||
+                (scope.row.taskNode === 'jtsy' &&
+                  scope.row.auditedStatus === '0')
               "
               type="text"
               size="small"
@@ -178,6 +180,7 @@
       :visible.sync="fixedDialogVisible"
       :is-view-mode="true"
       :request-type="2"
+      :project-id="projectId"
       :audited-unit-id="
         auditedUnitId ||
         (currentTemplateRow && currentTemplateRow.auditedUnitId) ||