Sfoglia il codice sorgente

fix: 成本审核保存核定数据换接口

shiyanyu 1 mese fa
parent
commit
bfe32fad6f

+ 53 - 6
src/views/costAudit/auditInfo/auditManage/costAudit.vue

@@ -109,7 +109,7 @@
       <el-button type="primary" size="small" @click="handleImportData">
         导入数据
       </el-button>
-      <el-button type="primary" size="small" @click="handleSaveTemplate">
+      <el-button type="primary" size="small" @click="handleSaveData">
         保存核定数据
       </el-button>
     </div>
@@ -178,7 +178,8 @@
   } from '@/api/costVerifyManage'
   import { getDetail } from '@/api/auditInitiation'
   import { catalogMixin } from '@/mixins/useDict'
-  import { saveAs } from 'file-saver'
+  import { saveSingleRecordSurvey } from '@/api/audit/survey'
+
   export default {
     name: 'CostAudit',
     mixins: [catalogMixin],
@@ -201,6 +202,7 @@
         type: String,
         default: '',
       },
+      auditedUnitId: { type: String, default: '' },
     },
     data() {
       return {
@@ -705,7 +707,52 @@
             this.$loading().close()
             console.log(err)
           })
-        // this.$message({ type: 'success', message: '保存成功' })
+      },
+      async handleSaveData() {
+        const loading = this.$loading({
+          lock: true,
+          text: '保存数据中...',
+          spinner: 'el-icon-loading',
+          background: 'rgba(0, 0, 0, 0.7)',
+        })
+        try {
+          // 1) 基于当前表格数据生成保存明细
+          const rawItems =
+            this.splitFixedTableDataForSave(this.costAuditData) || []
+          const auditedUnitId =
+            this.auditedUnitId || this.auditForm.auditedUnitId || ''
+          const surveyTemplateId =
+            this.auditForm.surveyTemplateId || this.auditForm.dataTable || ''
+          const catalogId = this.auditForm.catalogId || ''
+          const hasData = !!(this.auditForm && this.auditForm.uploadId)
+
+          const finalSaveData = rawItems.map((it) => {
+            const base = {
+              rowid: it.rowid,
+              rkey: it.rkey,
+              rvalue: it.rvalue != null ? String(it.rvalue) : '',
+              auditedUnitId,
+              surveyTemplateId,
+              catalogId,
+            }
+            if (hasData) base.uploadId = this.auditForm.uploadId
+            return base
+          })
+
+          // 2) 调用保存接口
+          const res = await saveSingleRecordSurvey(finalSaveData)
+          if (res && res.code === 200) {
+            this.$message.success('保存成功')
+            this.loadTemplateData && this.loadTemplateData()
+          } else {
+            this.$message.error((res && res.message) || '保存失败')
+          }
+        } catch (err) {
+          console.error(err)
+          // this.$message.error('保存失败')
+        } finally {
+          loading.close()
+        }
       },
       //分割字符串
       stringToObjects(str) {
@@ -982,9 +1029,9 @@
         this.$message({ type: 'info', message: '导出数据' })
       },
 
-      handleSaveData() {
-        this.$message({ type: 'success', message: '成本审核数据已保存' })
-      },
+      // handleSaveData() {
+      //   this.$message({ type: 'success', message: '成本审核数据已保存' })
+      // },
 
       handleRemark(row, field) {
         this.$prompt('请输入说明', '提示', {

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

@@ -57,6 +57,7 @@
             :selected-project="selectedProject"
             :current-node="currentNode"
             :current-status="currentStatus"
+            :audited-unit-id="auditedUnitId"
           />
         </el-tab-pane>
         <el-tab-pane