|
@@ -456,7 +456,11 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
|
|
|
|
- <el-table-column prop="showVisible" label="是否显示" width="120">
|
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ prop="showVisible"
|
|
|
|
|
+ label="是否在项目中显示"
|
|
|
|
|
+ width="140"
|
|
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="scope.row.showVisible"
|
|
v-model="scope.row.showVisible"
|
|
@@ -709,7 +713,11 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
|
|
|
|
- <el-table-column prop="showVisible" label="是否显示" width="120">
|
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ prop="showVisible"
|
|
|
|
|
+ label="是否在项目中显示"
|
|
|
|
|
+ width="140"
|
|
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="scope.row.showVisible"
|
|
v-model="scope.row.showVisible"
|
|
@@ -874,7 +882,7 @@
|
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="序号" width="120" align="center">
|
|
|
|
|
|
|
+ <!-- <el-table-column label="序号" width="120" align="center">
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
<el-input
|
|
|
:value="
|
|
:value="
|
|
@@ -889,7 +897,7 @@
|
|
|
@input="handleFixedValueChange(scope.row, '序号', $event)"
|
|
@input="handleFixedValueChange(scope.row, '序号', $event)"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</template>
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
|
|
|
|
+ </el-table-column> -->
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
v-for="(item, index) in contentEditForm.fixedTable
|
|
v-for="(item, index) in contentEditForm.fixedTable
|
|
|
.fixedTableHeaders"
|
|
.fixedTableHeaders"
|
|
@@ -1182,7 +1190,11 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
|
|
|
|
- <el-table-column prop="showVisible" label="是否显示" width="120">
|
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ prop="showVisible"
|
|
|
|
|
+ label="是否在项目中显示"
|
|
|
|
|
+ width="140"
|
|
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="scope.row.showVisible"
|
|
v-model="scope.row.showVisible"
|
|
@@ -1330,7 +1342,7 @@
|
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="序号" width="120" align="center">
|
|
|
|
|
|
|
+ <!-- <el-table-column label="序号" width="120" align="center">
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<div
|
|
<div
|
|
|
style="
|
|
style="
|
|
@@ -1355,7 +1367,7 @@
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
|
|
|
|
+ </el-table-column> -->
|
|
|
|
|
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
v-for="(item, index) in contentEditForm.dynamicTable
|
|
v-for="(item, index) in contentEditForm.dynamicTable
|
|
@@ -2570,11 +2582,11 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (const key in fixedValues) {
|
|
for (const key in fixedValues) {
|
|
|
- if (key == '序号') {
|
|
|
|
|
- fixedValues[key] = childOrderNum
|
|
|
|
|
- } else {
|
|
|
|
|
- fixedValues[key] = ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (key == '序号') {
|
|
|
|
|
+ // fixedValues[key] = childOrderNum
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ fixedValues[key] = ''
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const fixedNewRow = {
|
|
const fixedNewRow = {
|
|
@@ -2635,11 +2647,11 @@
|
|
|
.children.length + 1
|
|
.children.length + 1
|
|
|
let dynamicValues = { ...parentRow.dynamicValues }
|
|
let dynamicValues = { ...parentRow.dynamicValues }
|
|
|
for (const key in dynamicValues) {
|
|
for (const key in dynamicValues) {
|
|
|
- if (key == '序号') {
|
|
|
|
|
- dynamicValues[key] = dynamicChildOrderNum
|
|
|
|
|
- } else {
|
|
|
|
|
- dynamicValues[key] = ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (key == '序号') {
|
|
|
|
|
+ // dynamicValues[key] = dynamicChildOrderNum
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ dynamicValues[key] = ''
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const dynamicNewRow = {
|
|
const dynamicNewRow = {
|
|
@@ -2702,54 +2714,75 @@
|
|
|
})) || []
|
|
})) || []
|
|
|
|
|
|
|
|
// 检查并添加序号字段(固定表和动态表需要)
|
|
// 检查并添加序号字段(固定表和动态表需要)
|
|
|
- if (['2', '3'].includes(this.contentEditForm.templateType)) {
|
|
|
|
|
- const hasSerialNumber = this.contentEditForm.tableHeaders.some(
|
|
|
|
|
- (item) => item.fieldName === '序号'
|
|
|
|
|
- )
|
|
|
|
|
- if (!hasSerialNumber) {
|
|
|
|
|
- this.contentEditForm.tableHeaders.unshift({
|
|
|
|
|
- fieldName: '序号',
|
|
|
|
|
- fieldType: 'string',
|
|
|
|
|
- format: '255',
|
|
|
|
|
- fieldTypelen: '',
|
|
|
|
|
- fieldTypenointlen: '',
|
|
|
|
|
- isRequired: 'false',
|
|
|
|
|
- showVisible: '1',
|
|
|
|
|
- isAuditPeriod: 'false',
|
|
|
|
|
- tabtype: this.templateType,
|
|
|
|
|
- surveyTemplateId: this.surveyTemplateId,
|
|
|
|
|
- versionId: this.versionId,
|
|
|
|
|
- isDisabled: false,
|
|
|
|
|
- orderNum: 1,
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- // 如果已存在序号字段,确保其不可编辑
|
|
|
|
|
- const serialNumberIndex =
|
|
|
|
|
- this.contentEditForm.tableHeaders.findIndex(
|
|
|
|
|
- (item) => item.fieldName === '序号'
|
|
|
|
|
- )
|
|
|
|
|
- if (serialNumberIndex !== -1) {
|
|
|
|
|
- this.contentEditForm.tableHeaders[
|
|
|
|
|
- serialNumberIndex
|
|
|
|
|
- ].isDisabled = false
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (['2', '3'].includes(this.contentEditForm.templateType)) {
|
|
|
|
|
+ // const hasSerialNumber = this.contentEditForm.tableHeaders.some(
|
|
|
|
|
+ // (item) => item.fieldName === '序号'
|
|
|
|
|
+ // )
|
|
|
|
|
+ // if (!hasSerialNumber) {
|
|
|
|
|
+ // this.contentEditForm.tableHeaders.unshift({
|
|
|
|
|
+ // fieldName: '序号',
|
|
|
|
|
+ // fieldType: 'string',
|
|
|
|
|
+ // format: '255',
|
|
|
|
|
+ // fieldTypelen: '',
|
|
|
|
|
+ // fieldTypenointlen: '',
|
|
|
|
|
+ // isRequired: 'false',
|
|
|
|
|
+ // showVisible: '1',
|
|
|
|
|
+ // isAuditPeriod: 'false',
|
|
|
|
|
+ // tabtype: this.templateType,
|
|
|
|
|
+ // surveyTemplateId: this.surveyTemplateId,
|
|
|
|
|
+ // versionId: this.versionId,
|
|
|
|
|
+ // isDisabled: false,
|
|
|
|
|
+ // orderNum: 1,
|
|
|
|
|
+ // })
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // // 如果已存在序号字段,确保其不可编辑
|
|
|
|
|
+ // const serialNumberIndex =
|
|
|
|
|
+ // this.contentEditForm.tableHeaders.findIndex(
|
|
|
|
|
+ // (item) => item.fieldName === '序号'
|
|
|
|
|
+ // )
|
|
|
|
|
+ // if (serialNumberIndex !== -1) {
|
|
|
|
|
+ // this.contentEditForm.tableHeaders[
|
|
|
|
|
+ // serialNumberIndex
|
|
|
|
|
+ // ].isDisabled = false
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // 使用深拷贝避免引用问题,并根据模板类型更新对应的表头
|
|
|
|
|
+ const sortedHeaders = [...this.contentEditForm.tableHeaders].sort(
|
|
|
|
|
+ (a, b) => (a.orderNum || 0) - (b.orderNum || 0)
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ // 根据模板类型更新对应的表头,避免重复赋值
|
|
|
|
|
+ if (this.contentEditForm.templateType === '2') {
|
|
|
|
|
+ // 固定表:只在表头为空或需要更新时才赋值
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.contentEditForm.fixedTable.tableHeaders ||
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders.length === 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders =
|
|
|
|
|
+ sortedHeaders.map((item) => ({ ...item }))
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if (this.contentEditForm.templateType === '3') {
|
|
|
|
|
+ // 动态表:只在表头为空或需要更新时才赋值
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.contentEditForm.dynamicTable.tableHeaders ||
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders.length === 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders =
|
|
|
|
|
+ sortedHeaders.map((item) => ({ ...item }))
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 单记录类型:直接赋值
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders =
|
|
|
|
|
+ sortedHeaders.map((item) => ({ ...item }))
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders = sortedHeaders.map(
|
|
|
|
|
+ (item) => ({ ...item })
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.contentEditForm.dynamicTable.tableHeaders =
|
|
|
|
|
- this.contentEditForm.tableHeaders
|
|
|
|
|
- this.contentEditForm.fixedTable.tableHeaders =
|
|
|
|
|
- this.contentEditForm.tableHeaders
|
|
|
|
|
- // 表头按照orderNum重新排序
|
|
|
|
|
- this.contentEditForm.tableHeaders.sort(
|
|
|
|
|
- (a, b) => a.orderNum - b.orderNum
|
|
|
|
|
- )
|
|
|
|
|
- this.contentEditForm.dynamicTable.tableHeaders.sort(
|
|
|
|
|
- (a, b) => a.orderNum - b.orderNum
|
|
|
|
|
- )
|
|
|
|
|
- this.contentEditForm.fixedTable.tableHeaders.sort(
|
|
|
|
|
- (a, b) => a.orderNum - b.orderNum
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ // 更新主表头数据
|
|
|
|
|
+ this.contentEditForm.tableHeaders = sortedHeaders
|
|
|
// 同时获取表头标题信息
|
|
// 同时获取表头标题信息
|
|
|
listByTemplateIdAndVersion(surveyTemplateId, versionId)
|
|
listByTemplateIdAndVersion(surveyTemplateId, versionId)
|
|
|
.then((response) => {
|
|
.then((response) => {
|
|
@@ -3066,9 +3099,10 @@
|
|
|
this.contentEditForm.fixedTable.fixedTablesTitle =
|
|
this.contentEditForm.fixedTable.fixedTablesTitle =
|
|
|
this.stringToObjects(fixedFields || '')
|
|
this.stringToObjects(fixedFields || '')
|
|
|
this.contentEditForm.fixedTable.fixedTableHeaders =
|
|
this.contentEditForm.fixedTable.fixedTableHeaders =
|
|
|
- this.contentEditForm.fixedTable.fixedTablesTitle.filter(
|
|
|
|
|
- (title) => title.rkey !== '序号'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.contentEditForm.fixedTable.fixedTablesTitle
|
|
|
|
|
+ // this.contentEditForm.fixedTable.fixedTablesTitle.filter(
|
|
|
|
|
+ // (title) => title.rkey !== '序号'
|
|
|
|
|
+ // )
|
|
|
handleDelete()
|
|
handleDelete()
|
|
|
// 重新排序
|
|
// 重新排序
|
|
|
this.updateTableHeadersOrderNumbers()
|
|
this.updateTableHeadersOrderNumbers()
|
|
@@ -3184,9 +3218,10 @@
|
|
|
this.contentEditForm.dynamicTable.dynamicTablesTitle =
|
|
this.contentEditForm.dynamicTable.dynamicTablesTitle =
|
|
|
this.stringToObjects(dynamicFields || '')
|
|
this.stringToObjects(dynamicFields || '')
|
|
|
this.contentEditForm.dynamicTable.dynamicTableHeaders =
|
|
this.contentEditForm.dynamicTable.dynamicTableHeaders =
|
|
|
- this.contentEditForm.dynamicTable.dynamicTablesTitle.filter(
|
|
|
|
|
- (title) => title.rkey !== '序号'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTablesTitle
|
|
|
|
|
+ // this.contentEditForm.dynamicTable.dynamicTablesTitle.filter(
|
|
|
|
|
+ // (title) => title.rkey !== '序号'
|
|
|
|
|
+ // )
|
|
|
handleDelete()
|
|
handleDelete()
|
|
|
// 重新排序
|
|
// 重新排序
|
|
|
this.updateTableHeadersOrderNumbers()
|
|
this.updateTableHeadersOrderNumbers()
|
|
@@ -3441,27 +3476,28 @@
|
|
|
curr.orderNum = swam.orderNum
|
|
curr.orderNum = swam.orderNum
|
|
|
swam.orderNum = tempOrderNum
|
|
swam.orderNum = tempOrderNum
|
|
|
// row.isChild &&
|
|
// row.isChild &&
|
|
|
- if (!isHeader) {
|
|
|
|
|
- // 获取当前项的序号值
|
|
|
|
|
- let currIndex = curr.fixedValues
|
|
|
|
|
- ? curr.fixedValues['序号']
|
|
|
|
|
- : curr.dynamicValues['序号']
|
|
|
|
|
- // 获取交换项的序号值
|
|
|
|
|
- let swamIndex = swam.fixedValues
|
|
|
|
|
- ? swam.fixedValues['序号']
|
|
|
|
|
- : swam.dynamicValues['序号']
|
|
|
|
|
- // 先保存交换项的值,再进行赋值,避免值被覆盖
|
|
|
|
|
- if (curr.fixedValues) {
|
|
|
|
|
- curr.fixedValues['序号'] = swamIndex
|
|
|
|
|
- } else {
|
|
|
|
|
- curr.dynamicValues['序号'] = swamIndex
|
|
|
|
|
- }
|
|
|
|
|
- if (swam.fixedValues) {
|
|
|
|
|
- swam.fixedValues['序号'] = currIndex
|
|
|
|
|
- } else {
|
|
|
|
|
- swam.dynamicValues['序号'] = currIndex
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 获取当前项的序号值
|
|
|
|
|
+ // if (!isHeader) {
|
|
|
|
|
+ // // 获取当前项的序号值
|
|
|
|
|
+ // let currIndex = curr.fixedValues
|
|
|
|
|
+ // ? curr.fixedValues['序号']
|
|
|
|
|
+ // : curr.dynamicValues['序号']
|
|
|
|
|
+ // // 获取交换项的序号值
|
|
|
|
|
+ // let swamIndex = swam.fixedValues
|
|
|
|
|
+ // ? swam.fixedValues['序号']
|
|
|
|
|
+ // : swam.dynamicValues['序号']
|
|
|
|
|
+ // // 先保存交换项的值,再进行赋值,避免值被覆盖
|
|
|
|
|
+ // if (curr.fixedValues) {
|
|
|
|
|
+ // curr.fixedValues['序号'] = swamIndex
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // curr.dynamicValues['序号'] = swamIndex
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (swam.fixedValues) {
|
|
|
|
|
+ // swam.fixedValues['序号'] = currIndex
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // swam.dynamicValues['序号'] = currIndex
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
// 交换数组中的位置
|
|
// 交换数组中的位置
|
|
|
arr[rowIndex] = swam
|
|
arr[rowIndex] = swam
|
|
@@ -3596,8 +3632,17 @@
|
|
|
this.loading = false
|
|
this.loading = false
|
|
|
})
|
|
})
|
|
|
} else if (type === '固定表表头') {
|
|
} else if (type === '固定表表头') {
|
|
|
|
|
+ // 确保使用最新的表头数据,避免使用旧数据
|
|
|
|
|
+ const headersToSave =
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ }))
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '保存固定表表头,发送的数据:',
|
|
|
|
|
+ JSON.stringify(headersToSave, null, 2)
|
|
|
|
|
+ )
|
|
|
var data = {
|
|
var data = {
|
|
|
- headersList: this.contentEditForm.fixedTable.tableHeaders,
|
|
|
|
|
|
|
+ headersList: headersToSave,
|
|
|
}
|
|
}
|
|
|
getBatchSaveOrUpdate(data)
|
|
getBatchSaveOrUpdate(data)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
@@ -3607,17 +3652,49 @@
|
|
|
|
|
|
|
|
// 如果后端返回了保存后的数据,更新本地数据
|
|
// 如果后端返回了保存后的数据,更新本地数据
|
|
|
if (res.value && Array.isArray(res.value)) {
|
|
if (res.value && Array.isArray(res.value)) {
|
|
|
- this.contentEditForm.fixedTable.tableHeaders =
|
|
|
|
|
- res.value.map((item) => ({
|
|
|
|
|
- ...item,
|
|
|
|
|
- }))
|
|
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '保存成功,后端返回的数据:',
|
|
|
|
|
+ JSON.stringify(res.value, null, 2)
|
|
|
|
|
+ )
|
|
|
|
|
+ // 直接使用后端返回的数据,确保数据一致性,完全替换旧数据
|
|
|
|
|
+ const newHeaders = res.value.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ fieldKey: item.fieldEname
|
|
|
|
|
+ ? item.fieldEname.toLowerCase()
|
|
|
|
|
+ : `field_${Date.now()}_${Math.random()
|
|
|
|
|
+ .toString(36)
|
|
|
|
|
+ .substr(2, 9)}`,
|
|
|
|
|
+ }))
|
|
|
|
|
+ // 使用 Vue.set 或直接赋值确保响应式更新
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.contentEditForm.fixedTable,
|
|
|
|
|
+ 'tableHeaders',
|
|
|
|
|
+ newHeaders
|
|
|
|
|
+ )
|
|
|
// 确保保存后的数据也按正确顺序显示
|
|
// 确保保存后的数据也按正确顺序显示
|
|
|
this.updateTableHeadersOrderNumbers()
|
|
this.updateTableHeadersOrderNumbers()
|
|
|
|
|
+ // 同步更新主表头数据,使用深拷贝避免引用问题
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.contentEditForm,
|
|
|
|
|
+ 'tableHeaders',
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders.map(
|
|
|
|
|
+ (item) => ({ ...item })
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '更新后的表头数据:',
|
|
|
|
|
+ JSON.stringify(
|
|
|
|
|
+ this.contentEditForm.fixedTable.tableHeaders,
|
|
|
|
|
+ null,
|
|
|
|
|
+ 2
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果后端没有返回数据,说明可能有问题,但保持当前数据不变
|
|
|
|
|
+ console.warn('保存成功但后端未返回表头数据,保持当前数据')
|
|
|
}
|
|
}
|
|
|
- this.getListBySurveyTemplateIdAndVersion(
|
|
|
|
|
- this.surveyTemplateId,
|
|
|
|
|
- this.versionId
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ // 不再调用 getListBySurveyTemplateIdAndVersion,避免重复获取表头数据
|
|
|
|
|
+ // 只获取项目数据
|
|
|
listByTemplateIdAndVersion(
|
|
listByTemplateIdAndVersion(
|
|
|
this.surveyTemplateId,
|
|
this.surveyTemplateId,
|
|
|
this.versionId
|
|
this.versionId
|
|
@@ -3634,9 +3711,10 @@
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
this.contentEditForm.fixedTable.fixedTableHeaders =
|
|
this.contentEditForm.fixedTable.fixedTableHeaders =
|
|
|
- this.contentEditForm.fixedTable.fixedTablesTitle.filter(
|
|
|
|
|
- (title) => title.rkey !== '序号'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.contentEditForm.fixedTable.fixedTablesTitle
|
|
|
|
|
+ // this.contentEditForm.fixedTable.fixedTablesTitle.filter(
|
|
|
|
|
+ // (title) => title.rkey !== '序号'
|
|
|
|
|
+ // )
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
console.error('查询失败:', error)
|
|
console.error('查询失败:', error)
|
|
@@ -3656,8 +3734,17 @@
|
|
|
} else if (type === '固定表项目') {
|
|
} else if (type === '固定表项目') {
|
|
|
this.saveFixedTableData(action)
|
|
this.saveFixedTableData(action)
|
|
|
} else if (type === '动态表表头') {
|
|
} else if (type === '动态表表头') {
|
|
|
|
|
+ // 确保使用最新的表头数据,避免使用旧数据
|
|
|
|
|
+ const headersToSave =
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ }))
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '保存动态表表头,发送的数据:',
|
|
|
|
|
+ JSON.stringify(headersToSave, null, 2)
|
|
|
|
|
+ )
|
|
|
var data = {
|
|
var data = {
|
|
|
- headersList: this.contentEditForm.dynamicTable.tableHeaders,
|
|
|
|
|
|
|
+ headersList: headersToSave,
|
|
|
}
|
|
}
|
|
|
getBatchSaveOrUpdate(data)
|
|
getBatchSaveOrUpdate(data)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
@@ -3667,23 +3754,49 @@
|
|
|
|
|
|
|
|
// 如果后端返回了保存后的数据,更新本地数据
|
|
// 如果后端返回了保存后的数据,更新本地数据
|
|
|
if (res.value && Array.isArray(res.value)) {
|
|
if (res.value && Array.isArray(res.value)) {
|
|
|
- this.contentEditForm.dynamicTable.tableHeaders =
|
|
|
|
|
- res.value.map((item) => ({
|
|
|
|
|
- ...item,
|
|
|
|
|
- fieldKey: item.fieldEname
|
|
|
|
|
- ? item.fieldEname.toLowerCase()
|
|
|
|
|
- : `field_${Date.now()}_${Math.random()
|
|
|
|
|
- .toString(36)
|
|
|
|
|
- .substr(2, 9)}`,
|
|
|
|
|
- }))
|
|
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '保存成功,后端返回的数据:',
|
|
|
|
|
+ JSON.stringify(res.value, null, 2)
|
|
|
|
|
+ )
|
|
|
|
|
+ // 直接使用后端返回的数据,确保数据一致性,完全替换旧数据
|
|
|
|
|
+ const newHeaders = res.value.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ fieldKey: item.fieldEname
|
|
|
|
|
+ ? item.fieldEname.toLowerCase()
|
|
|
|
|
+ : `field_${Date.now()}_${Math.random()
|
|
|
|
|
+ .toString(36)
|
|
|
|
|
+ .substr(2, 9)}`,
|
|
|
|
|
+ }))
|
|
|
|
|
+ // 使用 Vue.set 确保响应式更新
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.contentEditForm.dynamicTable,
|
|
|
|
|
+ 'tableHeaders',
|
|
|
|
|
+ newHeaders
|
|
|
|
|
+ )
|
|
|
// 确保保存后的数据也按正确顺序显示
|
|
// 确保保存后的数据也按正确顺序显示
|
|
|
this.updateTableHeadersOrderNumbers()
|
|
this.updateTableHeadersOrderNumbers()
|
|
|
|
|
+ // 同步更新主表头数据,使用深拷贝避免引用问题
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.contentEditForm,
|
|
|
|
|
+ 'tableHeaders',
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders.map(
|
|
|
|
|
+ (item) => ({ ...item })
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ '更新后的表头数据:',
|
|
|
|
|
+ JSON.stringify(
|
|
|
|
|
+ this.contentEditForm.dynamicTable.tableHeaders,
|
|
|
|
|
+ null,
|
|
|
|
|
+ 2
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果后端没有返回数据,说明可能有问题,但保持当前数据不变
|
|
|
|
|
+ console.warn('保存成功但后端未返回表头数据,保持当前数据')
|
|
|
}
|
|
}
|
|
|
- this.getListBySurveyTemplateIdAndVersion(
|
|
|
|
|
- this.surveyTemplateId,
|
|
|
|
|
- this.versionId
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 不再调用 getListBySurveyTemplateIdAndVersion,避免重复获取表头数据
|
|
|
|
|
+ // 只获取项目数据
|
|
|
listByTemplateIdAndVersion(
|
|
listByTemplateIdAndVersion(
|
|
|
this.surveyTemplateId,
|
|
this.surveyTemplateId,
|
|
|
this.versionId
|
|
this.versionId
|
|
@@ -3701,9 +3814,10 @@
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
this.contentEditForm.dynamicTable.dynamicTableHeaders =
|
|
this.contentEditForm.dynamicTable.dynamicTableHeaders =
|
|
|
- this.contentEditForm.dynamicTable.dynamicTablesTitle.filter(
|
|
|
|
|
- (title) => title.rkey !== '序号'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTablesTitle
|
|
|
|
|
+ // this.contentEditForm.dynamicTable.dynamicTablesTitle.filter(
|
|
|
|
|
+ // (title) => title.rkey !== '序号'
|
|
|
|
|
+ // )
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
console.error('查询失败:', error)
|
|
console.error('查询失败:', error)
|
|
@@ -4249,9 +4363,10 @@
|
|
|
this.stringToObjects(fixedFields || '')
|
|
this.stringToObjects(fixedFields || '')
|
|
|
}
|
|
}
|
|
|
const fixedTitles = this.contentEditForm.fixedTable.fixedTablesTitle
|
|
const fixedTitles = this.contentEditForm.fixedTable.fixedTablesTitle
|
|
|
- this.contentEditForm.fixedTable.fixedTableHeaders = fixedTitles.filter(
|
|
|
|
|
- (title) => title.rkey !== '序号'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.contentEditForm.fixedTable.fixedTableHeaders = fixedTitles
|
|
|
|
|
+ // this.contentEditForm.fixedTable.fixedTableHeaders = fixedTitles.filter(
|
|
|
|
|
+ // (title) => title.rkey !== '序号'
|
|
|
|
|
+ // )
|
|
|
if (
|
|
if (
|
|
|
!responseData ||
|
|
!responseData ||
|
|
|
!responseData.value ||
|
|
!responseData.value ||
|
|
@@ -4327,11 +4442,15 @@
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 对子项进行排序
|
|
// 对子项进行排序
|
|
|
|
|
+ // parentItems.forEach((parent) => {
|
|
|
|
|
+ // parent.children.sort(
|
|
|
|
|
+ // (a, b) =>
|
|
|
|
|
+ // (a.fixedValues['序号'] || 0) - (b.fixedValues['序号'] || 0)
|
|
|
|
|
+ // )
|
|
|
|
|
+ // treeData.push(parent)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // 不需要对子项进行排序,直接将父项推入treeData
|
|
|
parentItems.forEach((parent) => {
|
|
parentItems.forEach((parent) => {
|
|
|
- parent.children.sort(
|
|
|
|
|
- (a, b) =>
|
|
|
|
|
- (a.fixedValues['序号'] || 0) - (b.fixedValues['序号'] || 0)
|
|
|
|
|
- )
|
|
|
|
|
treeData.push(parent)
|
|
treeData.push(parent)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -4355,8 +4474,8 @@
|
|
|
}
|
|
}
|
|
|
const dynamicTitles =
|
|
const dynamicTitles =
|
|
|
this.contentEditForm.dynamicTable.dynamicTablesTitle
|
|
this.contentEditForm.dynamicTable.dynamicTablesTitle
|
|
|
- this.contentEditForm.dynamicTable.dynamicTableHeaders =
|
|
|
|
|
- dynamicTitles.filter((title) => title.rkey !== '序号')
|
|
|
|
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTableHeaders = dynamicTitles
|
|
|
|
|
+ // dynamicTitles.filter((title) => title.rkey !== '序号')
|
|
|
if (
|
|
if (
|
|
|
!responseData ||
|
|
!responseData ||
|
|
|
!responseData.value ||
|
|
!responseData.value ||
|
|
@@ -4402,12 +4521,12 @@
|
|
|
// 初始化dynamicValues并填充实际值
|
|
// 初始化dynamicValues并填充实际值
|
|
|
dynamicTitles.forEach((title) => {
|
|
dynamicTitles.forEach((title) => {
|
|
|
// 特殊处理序号字段,需要保存到dynamicValues中供输入框使用
|
|
// 特殊处理序号字段,需要保存到dynamicValues中供输入框使用
|
|
|
- if (title.rkey === '序号') {
|
|
|
|
|
- // 优先使用item中的序号值,如果没有则保持为空
|
|
|
|
|
- newRow.dynamicValues[title.rkey] = item[title.rkey] || ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (title.rkey === '序号') {
|
|
|
|
|
+ // // 优先使用item中的序号值,如果没有则保持为空
|
|
|
|
|
+ // newRow.dynamicValues[title.rkey] = item[title.rkey] || ''
|
|
|
|
|
+ // }
|
|
|
// 排除其他序号相关字段,避免重复显示
|
|
// 排除其他序号相关字段,避免重复显示
|
|
|
- else if (title.rkey !== 'ordernum' && title.rkey !== 'orderText') {
|
|
|
|
|
|
|
+ if (title.rkey !== 'ordernum' && title.rkey !== 'orderText') {
|
|
|
newRow.dynamicValues[title.rkey] = item[title.rkey] || ''
|
|
newRow.dynamicValues[title.rkey] = item[title.rkey] || ''
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -4437,17 +4556,21 @@
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 对子项进行排序
|
|
// 对子项进行排序
|
|
|
|
|
+ // parentItems.forEach((parent) => {
|
|
|
|
|
+ // parent.children.sort(
|
|
|
|
|
+ // (a, b) =>
|
|
|
|
|
+ // (Number(a.dynamicValues['序号']) || 0) -
|
|
|
|
|
+ // (Number(b.dynamicValues['序号']) || 0)
|
|
|
|
|
+ // )
|
|
|
|
|
+ // treeData.push(parent)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // 不需要对子项进行排序,直接将父项推入treeData
|
|
|
parentItems.forEach((parent) => {
|
|
parentItems.forEach((parent) => {
|
|
|
- parent.children.sort(
|
|
|
|
|
- (a, b) =>
|
|
|
|
|
- (Number(a.dynamicValues['序号']) || 0) -
|
|
|
|
|
- (Number(b.dynamicValues['序号']) || 0)
|
|
|
|
|
- )
|
|
|
|
|
treeData.push(parent)
|
|
treeData.push(parent)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
this.contentEditForm.dynamicTable.dynamicTables = treeData
|
|
this.contentEditForm.dynamicTable.dynamicTables = treeData
|
|
|
- console.log('树形结构数据:', treeData)
|
|
|
|
|
|
|
+ // console.log('树形结构数据:', treeData)
|
|
|
},
|
|
},
|
|
|
//分割字符串
|
|
//分割字符串
|
|
|
stringToObjects(str) {
|
|
stringToObjects(str) {
|