Browse Source

Merge remote-tracking branch 'origin/master'

zzw 1 tháng trước cách đây
mục cha
commit
2178e3d975

+ 9 - 0
src/api/audit/survey.js

@@ -63,3 +63,12 @@ export function deleteDynamicTableData(data) {
     method: 'post',
   })
 }
+
+// 审核(资料/调查表审核保存)
+export function reviewCastTaskInfo(data) {
+  return request({
+    url: url + '/api/enterprise/castTaskInfo/review',
+    method: 'post',
+    data: data,
+  })
+}

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

@@ -13,7 +13,12 @@
           <submit-data :id="id" :disabled="true" />
         </el-tab-pane>
         <el-tab-pane label="成本调查表" name="costSurvey">
-          <cost-survey :id="id" :disabled="true" />
+          <cost-survey
+            :id="id"
+            :disabled="true"
+            :audited-unit-id="auditedUnitId"
+            :catalog-id="catalogId"
+          />
         </el-tab-pane>
         <el-tab-pane
           v-if="currentNode !== 'clcs'"
@@ -127,6 +132,23 @@
         }
         return '成本审核详情'
       },
+      // 从 selectedProject 中派生 auditedUnitId / catalogId,供子组件查询接口使用
+      auditedUnitId() {
+        return (
+          (this.selectedProject &&
+            (this.selectedProject.auditedUnitId ||
+              this.selectedProject.auditedunitid)) ||
+          ''
+        )
+      },
+      catalogId() {
+        return (
+          (this.selectedProject &&
+            (this.selectedProject.catalogId ||
+              this.selectedProject.catalogid)) ||
+          ''
+        )
+      },
     },
     watch: {
       visible(newVal) {

+ 149 - 8
src/components/task/components/costSurvey.vue

@@ -1,14 +1,14 @@
 <template>
   <div>
-    <!-- 成本调查表内容 -->
-    <el-table border :data="surveyData.list" style="width: 100%">
+    <!-- 成本调查表(只读) -->
+    <el-table border :data="rows" style="width: 100%">
       <el-table-column
         prop="index"
         label="序号"
         width="80"
         align="center"
         header-align="center"
-      ></el-table-column>
+      />
       <el-table-column
         prop="name"
         label="成本调查表"
@@ -16,21 +16,21 @@
         align="left"
         header-align="center"
         show-overflow-tooltip
-      ></el-table-column>
+      />
       <el-table-column
-        prop="type"
+        prop="dataType"
         label="资料类型"
         width="120"
         align="center"
         header-align="center"
-      ></el-table-column>
+      />
       <el-table-column
-        prop="required"
+        prop="isRequired"
         label="是否必填"
         width="100"
         align="center"
         header-align="center"
-      ></el-table-column>
+      />
       <el-table-column
         label="操作"
         width="120"
@@ -44,11 +44,152 @@
         </template>
       </el-table-column>
     </el-table>
+
+    <!-- 单记录弹窗(查看) -->
+    <survey-form-dialog
+      :visible.sync="singleDialogVisible"
+      :survey-data="{}"
+      :is-view-mode="true"
+      :audited-unit-id="
+        (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
+      "
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="
+        (currentTemplateRow &&
+          (currentTemplateRow.templateId ||
+            currentTemplateRow.surveyTemplateId)) ||
+        ''
+      "
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
+
+    <!-- 固定表弹窗(查看) -->
+    <fixed-table-dialog
+      :visible.sync="fixedDialogVisible"
+      :is-view-mode="true"
+      :audited-unit-id="
+        (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
+      "
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="
+        (currentTemplateRow &&
+          (currentTemplateRow.templateId ||
+            currentTemplateRow.surveyTemplateId)) ||
+        ''
+      "
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
+
+    <!-- 动态表弹窗(查看) -->
+    <dynamic-table-dialog
+      :visible.sync="dynamicDialogVisible"
+      :is-view-mode="true"
+      :audited-unit-id="
+        (currentTemplateRow && currentTemplateRow.auditedUnitId) || ''
+      "
+      :upload-id="(currentTemplateRow && currentTemplateRow.uploadId) || ''"
+      :survey-template-id="
+        (currentTemplateRow &&
+          (currentTemplateRow.templateId ||
+            currentTemplateRow.surveyTemplateId)) ||
+        ''
+      "
+      :catalog-id="(currentTemplateRow && currentTemplateRow.catalogId) || ''"
+    />
   </div>
 </template>
 <script>
   import taskMixins from './taskMixins.js'
+  import { getSurveyList } 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'
   export default {
+    components: { SurveyFormDialog, FixedTableDialog, DynamicTableDialog },
     mixins: [taskMixins],
+    props: {
+      auditedUnitId: { type: String, default: '' },
+      catalogId: { type: String, default: '' },
+    },
+    data() {
+      return {
+        loading: false,
+        rows: [],
+        currentTemplateRow: null,
+        singleDialogVisible: false,
+        fixedDialogVisible: false,
+        dynamicDialogVisible: false,
+      }
+    },
+    created() {
+      this.loadList()
+    },
+    methods: {
+      async loadList() {
+        try {
+          const params = {
+            catalogId: this.catalogId,
+            pageNum: 1,
+            pageSize: 100,
+          }
+
+          if (this.auditedUnitId) params.auditedUnitId = this.auditedUnitId
+          const resp = await getSurveyList(params)
+          console.log(resp, 'resp')
+          const raw =
+            (resp &&
+              ((resp.value && (resp.value.records || resp.value)) ||
+                resp.data ||
+                resp)) ||
+            []
+          const list = Array.isArray(raw)
+            ? raw
+            : Array.isArray(raw.records)
+            ? raw.records
+            : []
+          this.rows = list.map((it, idx) => {
+            const t = String(it.templateType || it.templatetype || '')
+            const tableType =
+              t === '1'
+                ? '单记录'
+                : t === '2'
+                ? '固定表'
+                : t === '3'
+                ? '动态表'
+                : ''
+            return {
+              index: idx + 1,
+              id: it.uploadId || it.id || '',
+              name:
+                it.surveyTemplateName || it.informationName || it.name || '',
+              dataType: it.dataType || '预置模板',
+              tableType,
+              isRequired: String(it.isRequired) === '1' ? '是' : '否',
+              isUpload: String(it.isUpload) === '1' || it.isUpload === true,
+              uploadId: it.uploadId || it.id || '',
+              surveyTemplateId: it.templateId || it.surveyTemplateId || '',
+              catalogId: it.catalogId || this.catalogId || '',
+              auditedUnitId: it.auditedUnitId || this.auditedUnitId || '',
+              templateType: t,
+            }
+          })
+        } catch (e) {
+          this.rows = []
+        }
+      },
+      handleViewTemplate(row) {
+        this.currentTemplateRow = 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
+          this.$message &&
+            this.$message.warning &&
+            this.$message.warning('未知的模板类型,无法打开预置模板')
+      },
+    },
   }
 </script>

+ 105 - 18
src/components/task/taskInfo.vue

@@ -496,7 +496,7 @@
           <div v-loading="loading" element-loading-text="加载中...">
             <el-table
               style="width: 100%"
-              :data="paginatedCostSurveyData"
+              :data="formData.costSurveyData"
               border
               size="small"
             >
@@ -717,6 +717,7 @@
     getTaskRequirementList,
     sendMessage,
   } from '@/api/auditTaskProcessing'
+  import { getSurveyList } from '@/api/audit/survey'
 
   export default {
     name: 'TaskInfo',
@@ -820,6 +821,25 @@
       }
     },
     computed: {
+      // 从传入 taskData/formData 中派生 catalogId/auditedUnitId,供成本调查表接口使用
+      catalogId() {
+        return (
+          (this.taskData &&
+            (this.taskData.catalogId || this.taskData.catalogid)) ||
+          (this.formData &&
+            this.formData.basicInfo &&
+            (this.formData.basicInfo.catalogId ||
+              this.formData.basicInfo.catalogid)) ||
+          ''
+        )
+      },
+      auditedUnitId() {
+        return (
+          (this.taskData &&
+            (this.taskData.auditedUnitId || this.taskData.auditedunitid)) ||
+          ''
+        )
+      },
       groupedDataRequirements() {
         if (
           !this.formData.dataRequirements ||
@@ -883,6 +903,13 @@
           this.dialogVisible = val
           if (val) {
             this.loadData()
+            // 若默认即在成本调查表页且尚未加载,则加载
+            if (
+              this.activeTab === 'costSurvey' &&
+              !this.tabLoadedStatus.costSurvey
+            ) {
+              this.loadCostSurvey()
+            }
           }
         },
         immediate: true,
@@ -1151,24 +1178,86 @@
       },
       // 加载成本调查表
       async loadCostSurvey() {
+        console.log(1111111)
+        // if (!this.catalogId) {
+        //   this.formData.costSurveyData = []
+        //   this.costSurveyPagination.total = 0
+        //   this.tabLoadedStatus.costSurvey = true
+        //   return
+        // }
         try {
           this.loading = true
-          // TODO: 调用成本调查表接口
-          // const res = await getCostSurveyList(this.currentTaskInfo.taskId)
-          // if (res && res.code === 200) {
-          //   this.formData.costSurveyData = res.value || []
-          //   this.costSurveyPagination.total = this.formData.costSurveyData.length
-          // }
-
-          // 暂时使用mock数据
-          this.formData.costSurveyData = []
-          this.costSurveyPagination.total = this.formData.costSurveyData.length
+          const params = {
+            catalogId: this.catalogId,
+            pageNum: this.costSurveyPagination.currentPage,
+            pageSize: this.costSurveyPagination.pageSize,
+          }
+          if (this.auditedUnitId) params.auditedUnitId = this.auditedUnitId
+          const res = await getSurveyList(params)
+          console.log(res, 'res')
+          // 兼容不同返回结构
+          const raw =
+            (res &&
+              ((res.value && (res.value.records || res.value)) ||
+                res.data ||
+                res)) ||
+            []
+          const list = Array.isArray(raw)
+            ? raw
+            : Array.isArray(raw.records)
+            ? raw.records
+            : []
+          const rows = list.map((it, idx) => {
+            const t = String(it.templateType || it.templatetype || '')
+            const tableType =
+              t === '1'
+                ? '单记录'
+                : t === '2'
+                ? '固定表'
+                : t === '3'
+                ? '动态表'
+                : ''
+            return {
+              index:
+                (this.costSurveyPagination.currentPage - 1) *
+                  this.costSurveyPagination.pageSize +
+                idx +
+                1,
+              id: it.uploadId || it.id || '',
+              name:
+                it.surveyTemplateName || it.informationName || it.name || '',
+              dataType: it.dataType || '预置模板',
+              tableType,
+              isRequired: String(it.isRequired) === '1' ? '是' : '否',
+              isUpload: String(it.isUpload) === '1' || it.isUpload === true,
+              uploadId: it.uploadId || it.id || '',
+              surveyTemplateId: it.templateId || it.surveyTemplateId || '',
+              catalogId: it.catalogId || this.catalogId || '',
+              auditedUnitId: it.auditedUnitId || this.auditedUnitId || '',
+            }
+          })
+          this.formData.costSurveyData = rows
+          // 设置总数
+          const total =
+            (res &&
+              res.value &&
+              (res.value.total ||
+                (Array.isArray(res.value.records)
+                  ? res.value.records.length
+                  : Array.isArray(res.value)
+                  ? res.value.length
+                  : 0))) ||
+            (Array.isArray(raw) ? raw.length : raw.total || 0)
+          this.costSurveyPagination.total = total
           this.tabLoadedStatus.costSurvey = true
-        } catch (error) {
-          console.error('加载成本调查表失败:', error)
-          this.$message.error('加载成本调查表失败')
+        } catch (err) {
+          console.error('加载成本调查表失败:', err)
+          this.$message &&
+            this.$message.error &&
+            this.$message.error('加载成本调查表失败')
           this.formData.costSurveyData = []
           this.costSurveyPagination.total = 0
+          this.tabLoadedStatus.costSurvey = true
         } finally {
           this.loading = false
         }
@@ -1277,16 +1366,14 @@
       // 成本调查表分页 - 页码改变
       handleCostSurveyPageChange(page) {
         this.costSurveyPagination.currentPage = page
-        // 如果成本调查表数据来自API,可以在这里调用API
-        // this.loadCostSurvey()
+        this.loadCostSurvey()
       },
 
       // 成本调查表分页 - 每页条数改变
       handleCostSurveySizeChange(size) {
         this.costSurveyPagination.pageSize = size
         this.costSurveyPagination.currentPage = 1
-        // 如果成本调查表数据来自API,可以在这里调用API
-        // this.loadCostSurvey()
+        this.loadCostSurvey()
       },
 
       // 消息通知分页 - 页码改变

+ 130 - 0
src/views/costAudit/auditInfo/auditManage/costSurvey.vue

@@ -139,11 +139,43 @@
           </span>
         </template>
       </el-table-column>
+      <el-table-column label="初审结果" width="100" align="center">
+        <template slot-scope="scope">
+          <span
+            :class="{
+              'result-pending':
+                !scope.row.auditedStatus || scope.row.auditedStatus === '0',
+              'result-pass': scope.row.auditedStatus === '1',
+              'result-fail': scope.row.auditedStatus === '2',
+            }"
+          >
+            {{
+              !scope.row.auditedStatus || scope.row.auditedStatus === '0'
+                ? '未审核'
+                : scope.row.auditedStatus === '1'
+                ? '通过'
+                : '不通过'
+            }}
+          </span>
+        </template>
+      </el-table-column>
 
       <!-- 操作列(只保留查看) -->
       <el-table-column label="操作" width="160" align="center">
         <template slot-scope="scope">
           <el-button
+            v-if="
+              scope.row.auditedStatus === '0' &&
+              (currentStatusLocal === 200 || currentStatusLocal === '200') &&
+              (currentNodeLocal === 'clcs' || currentNodeLocal === 'sdsh')
+            "
+            type="text"
+            size="small"
+            @click="handleAuditMaterial(scope.row)"
+          >
+            审核
+          </el-button>
+          <el-button
             type="text"
             size="small"
             @click="handleOnlineFillClick(scope.row)"
@@ -165,6 +197,40 @@
       @current-change="handlePageChange"
       @size-change="handleSizeChange"
     />
+
+    <!-- 资料审核弹窗 -->
+    <el-dialog
+      title="资料审核"
+      :visible.sync="showAuditDialog"
+      width="400px"
+      center
+      :modal="false"
+      append-to-body
+    >
+      <div class="audit-material-info">
+        <p>
+          <strong>资料名称:</strong>
+          {{
+            (currentAuditMaterial &&
+              (currentAuditMaterial.name ||
+                currentAuditMaterial.informationName)) ||
+            ''
+          }}
+        </p>
+      </div>
+      <el-form ref="auditForm" :model="auditForm" label-width="80px">
+        <el-form-item label="审核结果" prop="auditedStatus">
+          <el-radio-group v-model="auditForm.auditedStatus">
+            <el-radio label="1">审核通过</el-radio>
+            <el-radio label="2">不通过</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="showAuditDialog = false">取消</el-button>
+        <el-button type="primary" @click="handleAuditSubmit">提交</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -176,6 +242,7 @@
     getSingleRecordSurveyList,
     getSurveyDetail,
     getDynamicTableData,
+    reviewCastTaskInfo,
   } from '@/api/audit/survey'
   import { getListBySurveyTemplateIdAndVersion } from '@/api/costSurveyTemplateHeaders'
 
@@ -192,6 +259,14 @@
       uploadId: { type: String, default: '' },
       surveyTemplateId: { type: String, default: '' },
       catalogId: { type: String, default: '' },
+      currentNode: {
+        type: String,
+        default: '',
+      },
+      currentStatus: {
+        type: String,
+        default: '',
+      },
     },
     data() {
       return {
@@ -207,8 +282,24 @@
         dynamicDialogKey: 0,
         dynamicTableLoading: false,
         fixedHeaders: null,
+        currentStatusLocal: '',
+        currentNodeLocal: '',
+        showAuditDialog: false,
+        currentAuditMaterial: null,
+        auditForm: {
+          auditedStatus: '1',
+          auditOpinion: '',
+        },
       }
     },
+    watch: {
+      currentNode(newVal) {
+        this.currentNodeLocal = newVal
+      },
+      currentStatus(newVal) {
+        this.currentStatusLocal = newVal
+      },
+    },
     methods: {
       // 查看(只读)
       async handleOnlineFillClick(row) {
@@ -244,6 +335,45 @@
           await this.initDynamicTableData()
         }
       },
+      // 处理审核点击
+      handleAuditMaterial(row) {
+        this.currentAuditMaterial = { ...row }
+        this.auditForm = {
+          auditedStatus:
+            this.currentAuditMaterial && this.currentAuditMaterial.auditedStatus
+              ? String(this.currentAuditMaterial.auditedStatus)
+              : '1',
+          auditOpinion: '',
+        }
+        this.showAuditDialog = true
+      },
+      // 提交审核
+      async handleAuditSubmit() {
+        try {
+          const payload = {
+            ...this.currentAuditMaterial,
+            auditedStatus: this.auditForm.auditedStatus,
+            auditResult: this.auditForm.auditedStatus,
+            auditOpinion: this.auditForm.auditOpinion,
+          }
+          const res = await reviewCastTaskInfo(payload)
+          if (res && res.code === 200) {
+            this.$message({
+              type: 'success',
+              message: res.value || '审核已提交',
+            })
+            this.$emit('refresh')
+            this.showAuditDialog = false
+          } else {
+            this.$message({
+              type: 'error',
+              message: (res && res.message) || '提交失败',
+            })
+          }
+        } catch (e) {
+          this.$message.error('提交失败')
+        }
+      },
       handlePageChange(page) {
         this.$emit('handle-page-change', page)
       },

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

@@ -34,6 +34,8 @@
         </el-tab-pane>
         <el-tab-pane label="成本调查表" name="costSurvey">
           <cost-survey
+            :current-node="currentNode"
+            :current-status="currentStatus"
             :paginated-data="costSurveyPaginated"
             :pagination="costSurveyPagination"
             :audited-unit-id="auditedUnitId"
@@ -42,6 +44,7 @@
             :catalog-id="catalogId"
             @handle-page-change="handleCostSurveyPageChange"
             @handle-size-change="handleCostSurveySizeChange"
+            @refresh="handleCostSurveyRefresh"
           />
         </el-tab-pane>
         <el-tab-pane
@@ -286,6 +289,28 @@
         }
         return '成本审核详情'
       },
+      // 从 selectedProject / taskInfo 中派生 auditedUnitId,供模板和子组件使用
+      auditedUnitId() {
+        return (
+          (this.selectedProject &&
+            (this.selectedProject.auditedUnitId ||
+              this.selectedProject.auditedunitid)) ||
+          (this.taskInfo &&
+            (this.taskInfo.auditedUnitId || this.taskInfo.auditedunitid)) ||
+          ''
+        )
+      },
+      // 从 selectedProject / taskInfo 中派生 catalogId,供模板和查询使用
+      catalogId() {
+        return (
+          (this.selectedProject &&
+            (this.selectedProject.catalogId ||
+              this.selectedProject.catalogid)) ||
+          (this.taskInfo &&
+            (this.taskInfo.catalogId || this.taskInfo.catalogid)) ||
+          ''
+        )
+      },
     },
     watch: {
       visible(newVal) {
@@ -411,6 +436,10 @@
         // 打开弹窗方法,供父组件通过ref调用
         this.$emit('update:visible', true)
       },
+      // 成本调查表审核成功后刷新列表
+      handleCostSurveyRefresh() {
+        this.loadCostSurveyList()
+      },
       handleTabClick(tab) {
         if (tab && tab.name === 'submitData' && this.id) {
           this.loadSubmitMaterials()
@@ -435,7 +464,7 @@
         console.log(this.taskInfo, '这行数据')
         try {
           const params = {
-            catalogId: this.taskInfo.catalogId,
+            catalogId: this.catalogId,
             pageNum: this.costSurveyPagination.currentPage,
             pageSize: this.costSurveyPagination.pageSize,
           }
@@ -477,6 +506,7 @@
               auditedUnitId: it.auditedUnitId || this.auditedUnitId || '',
               tableItems: it.tableItems || [],
               dynamicTableData: it.dynamicTableData || [],
+              auditedStatus: it.auditedStatus,
             }
           })
           console.log(