|
|
@@ -20,7 +20,7 @@
|
|
|
<script>
|
|
|
import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
|
|
|
import SurveyDialog from '@/views/costAudit/baseInfo/catalogManage/surveyDialog.vue'
|
|
|
- import { getCostProjectSurveyDetail } from '@/api/taskCustomizedRelease'
|
|
|
+ import { getSurveyList } from '@/api/audit/survey'
|
|
|
export default {
|
|
|
components: {
|
|
|
CostAuditTable,
|
|
|
@@ -66,12 +66,13 @@
|
|
|
watch: {
|
|
|
project: {
|
|
|
handler(newVal) {
|
|
|
- if (newVal && newVal.projectId) {
|
|
|
- // 如果 projectId 没有变化,不重复加载
|
|
|
- if (this.projectIdCache === newVal.projectId) {
|
|
|
+ const catalogId = this.getCatalogId(newVal)
|
|
|
+ if (catalogId) {
|
|
|
+ // 如果 catalogId 没有变化,不重复加载
|
|
|
+ if (this.projectIdCache === catalogId) {
|
|
|
return
|
|
|
}
|
|
|
- this.projectIdCache = newVal.projectId
|
|
|
+ this.projectIdCache = catalogId
|
|
|
// 调用接口加载数据
|
|
|
this.loadSurveyData()
|
|
|
}
|
|
|
@@ -81,31 +82,94 @@
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
- // 如果已有 projectId,立即加载
|
|
|
- if (this.project && this.project.projectId) {
|
|
|
+ console.log('project', this.project)
|
|
|
+ // 如果已有 catalogId,立即加载
|
|
|
+ const catalogId = this.getCatalogId(this.project)
|
|
|
+ if (catalogId) {
|
|
|
this.loadSurveyData()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 从立项信息中获取 catalogId
|
|
|
+ getCatalogId(project) {
|
|
|
+ if (!project) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ // 优先从 project.catalogId 获取
|
|
|
+ if (project.catalogId) {
|
|
|
+ return project.catalogId
|
|
|
+ }
|
|
|
+ // 其次从 project.basicInfo.catalogId 获取(立项信息)
|
|
|
+ if (project.basicInfo && project.basicInfo.catalogId) {
|
|
|
+ return project.basicInfo.catalogId
|
|
|
+ }
|
|
|
+ // 最后从 project.data.basicInfo.catalogId 获取
|
|
|
+ if (
|
|
|
+ project.data &&
|
|
|
+ project.data.basicInfo &&
|
|
|
+ project.data.basicInfo.catalogId
|
|
|
+ ) {
|
|
|
+ return project.data.basicInfo.catalogId
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ },
|
|
|
// 加载成本调查表数据
|
|
|
async loadSurveyData() {
|
|
|
- if (!this.project || !this.project.projectId) {
|
|
|
+ const catalogId = this.getCatalogId(this.project)
|
|
|
+ if (!catalogId) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
this.loading = true
|
|
|
- const res = await getCostProjectSurveyDetail(this.project.projectId)
|
|
|
+ const params = {
|
|
|
+ catalogId: catalogId,
|
|
|
+ }
|
|
|
+ const res = await getSurveyList(params)
|
|
|
|
|
|
- if (res && res.value) {
|
|
|
- // 接口返回的数据格式可能是数组或对象
|
|
|
- if (Array.isArray(res.value)) {
|
|
|
- this.internalSurveyData.list = res.value
|
|
|
- } else if (res.value.records) {
|
|
|
- this.internalSurveyData.list = res.value.records || []
|
|
|
- } else {
|
|
|
- this.internalSurveyData.list = []
|
|
|
- }
|
|
|
+ console.log('成本调查表列表', res)
|
|
|
+ if (res && res.code === 200 && res.value) {
|
|
|
+ // 处理返回的数据
|
|
|
+ const records = res.value.records || res.value || []
|
|
|
+ // 映射数据格式,转换为组件需要的格式
|
|
|
+ const mappedData = records.map((item, index) => {
|
|
|
+ // 转换表格类型:1=单记录,2=固定表,3=动态表
|
|
|
+ let tableType = ''
|
|
|
+ if (item.templateType === 1 || item.templateType === '1') {
|
|
|
+ tableType = '单记录'
|
|
|
+ } else if (item.templateType === 2 || item.templateType === '2') {
|
|
|
+ tableType = '固定表'
|
|
|
+ } else if (item.templateType === 3 || item.templateType === '3') {
|
|
|
+ tableType = '动态表'
|
|
|
+ } else if (item.tableType) {
|
|
|
+ tableType = item.tableType
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换是否必填:0=否,1=是
|
|
|
+ const isRequired =
|
|
|
+ item.isRequired === 1 || item.isRequired === '1' ? '是' : '否'
|
|
|
+
|
|
|
+ // 转换是否上传:0=未上传,1=已上传
|
|
|
+ const isUploaded = item.isUpload === 1 || item.isUpload === '1'
|
|
|
+
|
|
|
+ return {
|
|
|
+ index: index + 1,
|
|
|
+ id: item.id,
|
|
|
+ surveyTemplateId: item.surveyTemplateId || '',
|
|
|
+ surveyTemplateName:
|
|
|
+ item.surveyTemplateName || item.name || item.surveyName || '',
|
|
|
+ dataType: item.dataType || '',
|
|
|
+ tableType: tableType,
|
|
|
+ isRequired: isRequired,
|
|
|
+ isUploaded: isUploaded,
|
|
|
+ isDisabled: item.isDisabled || false,
|
|
|
+ fileUrl: item.fileUrl || '',
|
|
|
+ dataUrl: item.dataUrl || '',
|
|
|
+ templateUrl: item.templateUrl || '',
|
|
|
+ ...item, // 保留其他字段
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.internalSurveyData.list = mappedData
|
|
|
} else {
|
|
|
this.internalSurveyData.list = []
|
|
|
}
|