|
|
@@ -787,28 +787,15 @@
|
|
|
:data="contentEditForm.fixedTable.fixedTables"
|
|
|
border
|
|
|
style="width: 100%"
|
|
|
+ row-key="rowid"
|
|
|
+ default-expand-all
|
|
|
+ :tree-props="{
|
|
|
+ children: 'children',
|
|
|
+ hasChildren: 'hasChildren',
|
|
|
+ }"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
- <el-table-column label="序号" width="100" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- :value="
|
|
|
- scope.row.fixedValues
|
|
|
- ? scope.row.fixedValues['序号']
|
|
|
- : ''
|
|
|
- "
|
|
|
- size="small"
|
|
|
- placeholder="数字或中文"
|
|
|
- :disabled="viewDetail"
|
|
|
- @input="handleFixedValueChange(scope.row, '序号', $event)"
|
|
|
- ></el-input>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- label="父子节点关系"
|
|
|
- align="center"
|
|
|
- width="120"
|
|
|
- >
|
|
|
+ <el-table-column label="父子节点" align="center" width="100">
|
|
|
<template slot-scope="scope">
|
|
|
<el-tag
|
|
|
v-if="
|
|
|
@@ -837,6 +824,22 @@
|
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="序号" width="120" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input
|
|
|
+ :value="
|
|
|
+ scope.row.fixedValues
|
|
|
+ ? scope.row.fixedValues['序号']
|
|
|
+ : ''
|
|
|
+ "
|
|
|
+ size="small"
|
|
|
+ placeholder="数字或中文"
|
|
|
+ :disabled="viewDetail"
|
|
|
+ style="flex: 1; margin: 0"
|
|
|
+ @input="handleFixedValueChange(scope.row, '序号', $event)"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column
|
|
|
v-for="(item, index) in contentEditForm.fixedTable
|
|
|
.fixedTableHeaders"
|
|
|
@@ -932,19 +935,21 @@
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
:disabled="viewDetail"
|
|
|
- @click="handleMoveUp(scope.$index, '固定表')"
|
|
|
+ @click="handleMoveUp(scope.$index, '固定表', scope.row)"
|
|
|
>
|
|
|
上升
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
v-if="
|
|
|
scope.$index !==
|
|
|
- contentEditForm.tableHeaders.length - 1
|
|
|
+ contentEditForm.fixedTable.fixedTables.length - 1
|
|
|
"
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
:disabled="viewDetail"
|
|
|
- @click="handleMoveDown(scope.$index, '固定表')"
|
|
|
+ @click="
|
|
|
+ handleMoveDown(scope.$index, '固定表', scope.row)
|
|
|
+ "
|
|
|
>
|
|
|
下降
|
|
|
</el-button>
|
|
|
@@ -1229,30 +1234,15 @@
|
|
|
:data="contentEditForm.dynamicTable.dynamicTables"
|
|
|
border
|
|
|
style="width: 100%"
|
|
|
+ row-key="rowid"
|
|
|
+ default-expand-all
|
|
|
+ :tree-props="{
|
|
|
+ children: 'children',
|
|
|
+ hasChildren: 'hasChildren',
|
|
|
+ }"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
- <el-table-column label="序号" width="100" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- :value="
|
|
|
- scope.row.dynamicValues
|
|
|
- ? scope.row.dynamicValues['序号']
|
|
|
- : ''
|
|
|
- "
|
|
|
- size="small"
|
|
|
- placeholder="数字或中文"
|
|
|
- :disabled="viewDetail"
|
|
|
- @input="
|
|
|
- handleDynamicValueChange(scope.row, '序号', $event)
|
|
|
- "
|
|
|
- ></el-input>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- label="父子节点关系"
|
|
|
- align="center"
|
|
|
- width="120"
|
|
|
- >
|
|
|
+ <el-table-column label="父子节点" align="center" width="100">
|
|
|
<template slot-scope="scope">
|
|
|
<el-tag
|
|
|
v-if="
|
|
|
@@ -1281,6 +1271,33 @@
|
|
|
<el-tag v-else type="info" size="small">无</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="序号" width="120" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ min-height: 32px;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ :value="
|
|
|
+ scope.row.dynamicValues
|
|
|
+ ? scope.row.dynamicValues['序号']
|
|
|
+ : ''
|
|
|
+ "
|
|
|
+ size="small"
|
|
|
+ placeholder="数字或中文"
|
|
|
+ :disabled="viewDetail"
|
|
|
+ style="flex: 1; margin: 0"
|
|
|
+ @input="
|
|
|
+ handleDynamicValueChange(scope.row, '序号', $event)
|
|
|
+ "
|
|
|
+ ></el-input>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column
|
|
|
v-for="(item, index) in contentEditForm.dynamicTable
|
|
|
.dynamicTableHeaders"
|
|
|
@@ -1303,7 +1320,12 @@
|
|
|
></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" align="center" fixed="right">
|
|
|
+ <el-table-column
|
|
|
+ label="操作"
|
|
|
+ align="center"
|
|
|
+ fixed="right"
|
|
|
+ width="200"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<div class="table-actions">
|
|
|
<el-button
|
|
|
@@ -1340,7 +1362,7 @@
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
:disabled="viewDetail"
|
|
|
- @click="handleMoveUp(scope.$index, '动态表')"
|
|
|
+ @click="handleMoveUp(scope.$index, '动态表', scope.row)"
|
|
|
>
|
|
|
上升
|
|
|
</el-button>
|
|
|
@@ -1352,7 +1374,9 @@
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
:disabled="viewDetail"
|
|
|
- @click="handleMoveDown(scope.$index, '动态表')"
|
|
|
+ @click="
|
|
|
+ handleMoveDown(scope.$index, '动态表', scope.row)
|
|
|
+ "
|
|
|
>
|
|
|
下降
|
|
|
</el-button>
|
|
|
@@ -2172,19 +2196,47 @@
|
|
|
|
|
|
switch (type) {
|
|
|
case '固定表项目':
|
|
|
+ let parentIndex1 =
|
|
|
+ this.contentEditForm.fixedTable.fixedTables.findIndex(
|
|
|
+ (item) => item.rowid == parentRow.rowid
|
|
|
+ )
|
|
|
+ if (
|
|
|
+ !this.contentEditForm.fixedTable.fixedTables[parentIndex1]
|
|
|
+ .children
|
|
|
+ ) {
|
|
|
+ this.$set(
|
|
|
+ this.contentEditForm.fixedTable.fixedTables[parentIndex1],
|
|
|
+ 'children',
|
|
|
+ []
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
let childOrderNum =
|
|
|
- this.contentEditForm.fixedTable.fixedTables.length + 1
|
|
|
+ this.contentEditForm.fixedTable.fixedTables[parentIndex1].children
|
|
|
+ .length + 1
|
|
|
+
|
|
|
+ let fixedValues = {
|
|
|
+ ...parentRow.fixedValues,
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in fixedValues) {
|
|
|
+ if (key == '序号') {
|
|
|
+ fixedValues[key] = childOrderNum
|
|
|
+ } else {
|
|
|
+ fixedValues[key] = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const fixedNewRow = {
|
|
|
- orderText: childOrderNum,
|
|
|
- orderNum: childOrderNum,
|
|
|
+ orderText: this.contentEditForm.fixedTable.fixedTables.length + 1,
|
|
|
+ orderNum: this.contentEditForm.fixedTable.fixedTables.length + 1,
|
|
|
cellCode: '',
|
|
|
calculationFormula: '',
|
|
|
unit: '',
|
|
|
tabtype: this.templateType,
|
|
|
surveyTemplateId: this.surveyTemplateId,
|
|
|
versionId: this.versionId,
|
|
|
- fixedValues: { ...parentRow.fixedValues },
|
|
|
+ fixedValues: fixedValues,
|
|
|
parentid: parentRow.rowid,
|
|
|
isChild: true,
|
|
|
isSubItem: true,
|
|
|
@@ -2199,16 +2251,44 @@
|
|
|
}
|
|
|
)
|
|
|
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
- index + 1,
|
|
|
- 0,
|
|
|
- fixedNewRow
|
|
|
- )
|
|
|
+ // 先将子项添加到children数组
|
|
|
+ this.contentEditForm.fixedTable.fixedTables[
|
|
|
+ parentIndex1
|
|
|
+ ].children.push(fixedNewRow)
|
|
|
+
|
|
|
+ // this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
+ // index + 1,
|
|
|
+ // 0,
|
|
|
+ // fixedNewRow
|
|
|
+ // )
|
|
|
break
|
|
|
|
|
|
case '动态表项目':
|
|
|
+ let parentIndex2 =
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables.findIndex(
|
|
|
+ (item) => item.rowid == parentRow.rowid
|
|
|
+ )
|
|
|
+ if (
|
|
|
+ !this.contentEditForm.dynamicTable.dynamicTables[parentIndex2]
|
|
|
+ .children
|
|
|
+ ) {
|
|
|
+ this.$set(
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables[parentIndex2],
|
|
|
+ 'children',
|
|
|
+ []
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
let dynamicChildOrderNum =
|
|
|
this.contentEditForm.dynamicTable.dynamicTables.length + 1
|
|
|
+ let dynamicValues = { ...parentRow.dynamicValues }
|
|
|
+ for (const key in dynamicValues) {
|
|
|
+ if (key == '序号') {
|
|
|
+ dynamicValues[key] = dynamicChildOrderNum
|
|
|
+ } else {
|
|
|
+ dynamicValues[key] = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const dynamicNewRow = {
|
|
|
orderText: dynamicChildOrderNum,
|
|
|
@@ -2216,7 +2296,7 @@
|
|
|
tabtype: this.templateType,
|
|
|
surveyTemplateId: this.surveyTemplateId,
|
|
|
versionId: this.versionId,
|
|
|
- dynamicValues: { ...parentRow.dynamicValues },
|
|
|
+ dynamicValues: dynamicValues,
|
|
|
parentid: parentRow.rowid,
|
|
|
isChild: true,
|
|
|
isSubItem: true,
|
|
|
@@ -2230,12 +2310,15 @@
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
-
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.splice(
|
|
|
- index + 1,
|
|
|
- 0,
|
|
|
- dynamicNewRow
|
|
|
- )
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables[
|
|
|
+ parentIndex2
|
|
|
+ ].children.push(dynamicNewRow)
|
|
|
+
|
|
|
+ // this.contentEditForm.dynamicTable.dynamicTables.splice(
|
|
|
+ // index + 1,
|
|
|
+ // 0,
|
|
|
+ // dynamicNewRow
|
|
|
+ // )
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -2517,6 +2600,7 @@
|
|
|
fixedValues: {},
|
|
|
parentid: -1,
|
|
|
rowid: this.generateUUID(),
|
|
|
+ children: [],
|
|
|
}
|
|
|
|
|
|
this.contentEditForm.fixedTable.fixedTablesTitle.forEach(
|
|
|
@@ -2564,6 +2648,7 @@
|
|
|
dynamicValues: {},
|
|
|
parentid: -1,
|
|
|
rowid: this.generateUUID(),
|
|
|
+ children: [],
|
|
|
}
|
|
|
|
|
|
this.contentEditForm.dynamicTable.dynamicTablesTitle.forEach(
|
|
|
@@ -2630,12 +2715,53 @@
|
|
|
break
|
|
|
|
|
|
case '固定表项目':
|
|
|
- if (this.contentEditForm.fixedTable.fixedTables.length <= 1) {
|
|
|
- this.$message.warning('至少保留一个项目')
|
|
|
- return
|
|
|
+ // 检查是否是删除子项
|
|
|
+ const isChildItem = row.isChild || row.isSubItem || false
|
|
|
+
|
|
|
+ if (isChildItem) {
|
|
|
+ // 查找父项
|
|
|
+ const parentItem =
|
|
|
+ this.contentEditForm.fixedTable.fixedTables.find(
|
|
|
+ (item) =>
|
|
|
+ item.children &&
|
|
|
+ item.children.some((child) => child.rowid === row.rowid)
|
|
|
+ )
|
|
|
+
|
|
|
+ if (parentItem && parentItem.children) {
|
|
|
+ // 从父项的children数组中删除子项
|
|
|
+ const childIndex = parentItem.children.findIndex(
|
|
|
+ (child) => child.rowid === row.rowid
|
|
|
+ )
|
|
|
+ if (childIndex > -1) {
|
|
|
+ parentItem.children.splice(childIndex, 1)
|
|
|
+
|
|
|
+ // 如果children数组为空,将hasChildren设为false
|
|
|
+ if (parentItem.children.length === 0) {
|
|
|
+ this.$set(parentItem, 'hasChildren', false)
|
|
|
+ } else {
|
|
|
+ // 重新计算子项序号
|
|
|
+ parentItem.children.forEach((child, idx) => {
|
|
|
+ child.orderText = idx + 1
|
|
|
+ child.orderNum = idx + 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保Vue响应式系统检测到变化
|
|
|
+ const children = [...parentItem.children]
|
|
|
+ this.$set(parentItem, 'children', children)
|
|
|
+
|
|
|
+ handleDelete() // 执行删除逻辑
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 处理删除父项的情况
|
|
|
+ if (this.contentEditForm.fixedTable.fixedTables.length <= 1) {
|
|
|
+ this.$message.warning('至少保留一个项目')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
+ handleDelete() // 执行删除逻辑
|
|
|
}
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
- handleDelete() // 执行删除逻辑
|
|
|
break
|
|
|
case '动态表表头':
|
|
|
if (this.contentEditForm.dynamicTable.tableHeaders.length <= 1) {
|
|
|
@@ -2678,40 +2804,109 @@
|
|
|
},
|
|
|
|
|
|
// 上升
|
|
|
- handleMoveUp(index, tableType) {
|
|
|
+ handleMoveUp(index, tableType, row) {
|
|
|
if (tableType === '固定表') {
|
|
|
- if (index > 0) {
|
|
|
- const temp = this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
- index - 1,
|
|
|
- 0,
|
|
|
- temp
|
|
|
- )
|
|
|
- // 更新固定表行的序号
|
|
|
- this.updateFixedTableOrderNumbers()
|
|
|
- }
|
|
|
+ const fixedTableData = this.contentEditForm.fixedTable.fixedTables
|
|
|
+ const newFixedTableData = [...fixedTableData]
|
|
|
+ this.swamTableArr(newFixedTableData, row, true)
|
|
|
+ this.contentEditForm.fixedTable.fixedTables = newFixedTableData
|
|
|
} else if (tableType === '动态表') {
|
|
|
- if (index > 0) {
|
|
|
- const temp = this.contentEditForm.dynamicTable.dynamicTables[index]
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.splice(index, 1)
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.splice(
|
|
|
- index - 1,
|
|
|
- 0,
|
|
|
- temp
|
|
|
- )
|
|
|
- // 更新动态表行的序号
|
|
|
- this.updateDynamicTableOrderNumbers()
|
|
|
+ const dynamicTableData =
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables
|
|
|
+ const newDynamicTableData = [...dynamicTableData]
|
|
|
+ this.swamTableArr(newDynamicTableData, row, true)
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables = newDynamicTableData
|
|
|
+ } else {
|
|
|
+ const tableHeaders = this.contentEditForm.tableHeaders
|
|
|
+ const newTableHeaders = [...tableHeaders]
|
|
|
+ this.swamTableArr(newTableHeaders, row, true, true)
|
|
|
+ this.contentEditForm.tableHeaders = newTableHeaders
|
|
|
+ // if (index > 0) {
|
|
|
+ // const temp = this.contentEditForm.tableHeaders[index]
|
|
|
+ // this.contentEditForm.tableHeaders.splice(index, 1)
|
|
|
+ // this.contentEditForm.tableHeaders.splice(index - 1, 0, temp)
|
|
|
+ // // 更新表头的序号
|
|
|
+ // this.updateTableHeadersOrderNumbers()
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 下降
|
|
|
+ handleMoveDown(index, tableType, row) {
|
|
|
+ if (tableType === '固定表') {
|
|
|
+ const fixedTableData = this.contentEditForm.fixedTable.fixedTables
|
|
|
+ const newFixedTableData = [...fixedTableData]
|
|
|
+ this.swamTableArr(newFixedTableData, row, false)
|
|
|
+ this.contentEditForm.fixedTable.fixedTables = newFixedTableData
|
|
|
+ } else if (tableType === '动态表') {
|
|
|
+ const dynamicTableData =
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables
|
|
|
+ const newDynamicTableData = [...dynamicTableData]
|
|
|
+ this.swamTableArr(newDynamicTableData, row, false)
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables = newDynamicTableData
|
|
|
+ } else {
|
|
|
+ const tableHeaders = this.contentEditForm.tableHeaders
|
|
|
+ const newTableHeaders = [...tableHeaders]
|
|
|
+ this.swamTableArr(newTableHeaders, row, false)
|
|
|
+ this.contentEditForm.tableHeaders = newTableHeaders
|
|
|
+ // if (index < this.contentEditForm.tableHeaders.length - 1) {
|
|
|
+ // const temp = this.contentEditForm.tableHeaders[index]
|
|
|
+ // this.contentEditForm.tableHeaders.splice(index, 1)
|
|
|
+ // this.contentEditForm.tableHeaders.splice(index + 1, 0, temp)
|
|
|
+ // // 更新表头的序号
|
|
|
+ // this.updateTableHeadersOrderNumbers()
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ swamTableArr(arr, row, asc, isHeader) {
|
|
|
+ const isChild = row.isChild || row.isSubItem || false
|
|
|
+ if (isChild) {
|
|
|
+ // 子节点处理逻辑后续实现 parentid rowid
|
|
|
+ let child = arr.find((item) => item.rowid === row.parentid)
|
|
|
+ // const rowIndex = arr.indexOf(row);
|
|
|
+ // newFixedTableData[rowIndex]
|
|
|
+ this.doSwamTableArr(child.children, row, asc, isHeader)
|
|
|
+ } else {
|
|
|
+ // 创建数组副本以确保Vue能检测到变化
|
|
|
+ // 直接替换整个数组,确保Vue能检测到变化
|
|
|
+ this.doSwamTableArr(arr, row, asc, isHeader)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ doSwamTableArr(arr, row, asc, isHeader) {
|
|
|
+ const rowIndex = arr.indexOf(row)
|
|
|
+ let swamIndex = 0
|
|
|
+ if (asc) {
|
|
|
+ // 正序
|
|
|
+ if (rowIndex < 1) {
|
|
|
+ return
|
|
|
}
|
|
|
+ swamIndex = rowIndex - 1
|
|
|
} else {
|
|
|
- if (index > 0) {
|
|
|
- const temp = this.contentEditForm.tableHeaders[index]
|
|
|
- this.contentEditForm.tableHeaders.splice(index, 1)
|
|
|
- this.contentEditForm.tableHeaders.splice(index - 1, 0, temp)
|
|
|
- // 更新表头的序号
|
|
|
- this.updateTableHeadersOrderNumbers()
|
|
|
+ // 倒序
|
|
|
+ if (rowIndex >= arr.length - 1) {
|
|
|
+ return
|
|
|
}
|
|
|
+ swamIndex = rowIndex + 1
|
|
|
}
|
|
|
+
|
|
|
+ const curr = arr[rowIndex]
|
|
|
+ const swam = arr[swamIndex]
|
|
|
+
|
|
|
+ // 交换orderNum
|
|
|
+ const tempOrderNum = curr.orderNum
|
|
|
+ curr.orderNum = swam.orderNum
|
|
|
+ swam.orderNum = tempOrderNum
|
|
|
+
|
|
|
+ if (row.isChild && !isHeader) {
|
|
|
+ let currIndex = curr.fixedValues['序号']
|
|
|
+ curr.fixedValues['序号'] = swam.fixedValues['序号']
|
|
|
+ swam.fixedValues['序号'] = currIndex
|
|
|
+ }
|
|
|
+
|
|
|
+ // 交换数组中的位置
|
|
|
+ arr[rowIndex] = swam
|
|
|
+ arr[swamIndex] = curr
|
|
|
},
|
|
|
|
|
|
// 启动/停用状态
|
|
|
@@ -2762,45 +2957,6 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 下降
|
|
|
- handleMoveDown(index, tableType) {
|
|
|
- if (tableType === '固定表') {
|
|
|
- if (index < this.contentEditForm.fixedTable.fixedTables.length - 1) {
|
|
|
- const temp = this.contentEditForm.fixedTable.fixedTables[index]
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(index, 1)
|
|
|
- this.contentEditForm.fixedTable.fixedTables.splice(
|
|
|
- index + 1,
|
|
|
- 0,
|
|
|
- temp
|
|
|
- )
|
|
|
- // 更新固定表行的序号
|
|
|
- this.updateFixedTableOrderNumbers()
|
|
|
- }
|
|
|
- } else if (tableType === '动态表') {
|
|
|
- if (
|
|
|
- index <
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.length - 1
|
|
|
- ) {
|
|
|
- const temp = this.contentEditForm.dynamicTable.dynamicTables[index]
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.splice(index, 1)
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables.splice(
|
|
|
- index + 1,
|
|
|
- 0,
|
|
|
- temp
|
|
|
- )
|
|
|
- // 更新动态表行的序号
|
|
|
- this.updateDynamicTableOrderNumbers()
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (index < this.contentEditForm.tableHeaders.length - 1) {
|
|
|
- const temp = this.contentEditForm.tableHeaders[index]
|
|
|
- this.contentEditForm.tableHeaders.splice(index, 1)
|
|
|
- this.contentEditForm.tableHeaders.splice(index + 1, 0, temp)
|
|
|
- // 更新表头的序号
|
|
|
- this.updateTableHeadersOrderNumbers()
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
// 更新固定表行序号
|
|
|
updateFixedTableOrderNumbers() {
|
|
|
this.contentEditForm.fixedTable.fixedTables.forEach((row, index) => {
|
|
|
@@ -3168,10 +3324,21 @@
|
|
|
// 结果数组
|
|
|
const result = []
|
|
|
|
|
|
- // 遍历每一行数据
|
|
|
- fixedTables.forEach((row, rowIndex) => {
|
|
|
+ // 递归处理树形结构中的所有节点
|
|
|
+ const processNode = (node, parentRowIndex = 0) => {
|
|
|
+ // 确保node和fixedValues存在
|
|
|
+ if (!node) {
|
|
|
+ console.warn('遇到空节点,跳过处理')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保fixedValues属性存在,如果不存在则初始化为空对象
|
|
|
+ if (!node.fixedValues) {
|
|
|
+ node.fixedValues = {}
|
|
|
+ }
|
|
|
+
|
|
|
// 为每个固定列创建一条记录
|
|
|
- fixedTitles.forEach((title, colIndex) => {
|
|
|
+ fixedTitles.forEach((title) => {
|
|
|
// 找到对应的表头信息
|
|
|
const correspondingHeader = fixedHeaders.find(
|
|
|
(header) => header.fieldName === title.rkey
|
|
|
@@ -3179,41 +3346,35 @@
|
|
|
|
|
|
const newItem = {
|
|
|
rkey: title.rkey,
|
|
|
- rvalue: row.fixedValues ? row.fixedValues[title.rkey] || '' : '',
|
|
|
- surveyTemplateId: row.surveyTemplateId,
|
|
|
- versionId: row.versionId,
|
|
|
- tabtype: row.tabtype,
|
|
|
- rowIndex: rowIndex,
|
|
|
+ rvalue: node.fixedValues[title.rkey] || '',
|
|
|
+ surveyTemplateId: node.surveyTemplateId || this.surveyTemplateId,
|
|
|
+ versionId: node.versionId || this.versionId,
|
|
|
+ tabtype: node.tabtype || this.templateType,
|
|
|
// 添加 headersId 字段(表头的id)
|
|
|
headersId: correspondingHeader ? correspondingHeader.id : null,
|
|
|
// 添加记录的id(itemlist中每条记录的id)
|
|
|
- id: row.itemId || null,
|
|
|
+ id: node.itemId || null,
|
|
|
// 添加父子关系字段
|
|
|
- parentid: row.parentid || -1, // 父项ID,默认为-1表示无父项
|
|
|
- isChild: row.isChild || false, // 是否为子项
|
|
|
+ parentid: node.parentid || -1, // 父项ID,默认为-1表示无父项
|
|
|
+ isChild: node.isChild || false, // 是否为子项
|
|
|
// 添加 rowid 字段
|
|
|
- rowid: row.rowid || null,
|
|
|
+ rowid: node.rowid || null,
|
|
|
// 添加计算公式相关字段
|
|
|
- calculationFormula: row.calculationFormula || null,
|
|
|
- jsonstr: row.jsonstr || null,
|
|
|
- }
|
|
|
-
|
|
|
- // 只有非子项才添加序号
|
|
|
- if (!row.isSubItem && row.orderNum) {
|
|
|
- newItem.orderNum =
|
|
|
- typeof row.orderNum === 'number'
|
|
|
- ? row.orderNum
|
|
|
- : parseInt(row.orderNum, 10) || 0
|
|
|
+ calculationFormula: node.calculationFormula || null,
|
|
|
+ jsonstr: node.jsonstr || null,
|
|
|
+ orderNum:
|
|
|
+ typeof node.orderNum === 'number'
|
|
|
+ ? node.orderNum
|
|
|
+ : parseInt(node.orderNum, 10) || 0,
|
|
|
}
|
|
|
-
|
|
|
// 添加其他固定表特有的字段
|
|
|
- if (!row.isSubItem) {
|
|
|
- newItem.cellCode = row.cellCode || ''
|
|
|
- newItem.unit = row.unit || ''
|
|
|
+ if (!node.isSubItem) {
|
|
|
+ newItem.cellCode = node.cellCode || ''
|
|
|
+ newItem.unit = node.unit || ''
|
|
|
}
|
|
|
|
|
|
// 添加其他可能需要的字段,但排除特定字段
|
|
|
- Object.keys(row).forEach((key) => {
|
|
|
+ Object.keys(node).forEach((key) => {
|
|
|
if (
|
|
|
!(key in newItem) &&
|
|
|
key !== 'fixedValues' &&
|
|
|
@@ -3224,14 +3385,77 @@
|
|
|
key !== 'isSubItem' &&
|
|
|
key !== 'rowid' &&
|
|
|
key !== 'jsonstr' &&
|
|
|
- key !== 'calculationFormula'
|
|
|
+ key !== 'calculationFormula' &&
|
|
|
+ key !== 'children' // 排除children字段
|
|
|
) {
|
|
|
- newItem[key] = row[key]
|
|
|
+ newItem[key] = node[key]
|
|
|
}
|
|
|
})
|
|
|
|
|
|
result.push(newItem)
|
|
|
})
|
|
|
+
|
|
|
+ // 递归处理子节点
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ node.children.forEach((childNode) => {
|
|
|
+ processNode(childNode)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 遍历所有顶级节点
|
|
|
+ fixedTables.forEach((row) => {
|
|
|
+ processNode(row)
|
|
|
+ })
|
|
|
+ // 重新给子节点赋值orderNum 保证所有元素orderNum字段不重复
|
|
|
+ // 为所有子节点分配唯一的orderNum,但保持父节点的orderNum不变
|
|
|
+ // 计算所有已存在的orderNum中的最大值
|
|
|
+ let maxExistingOrderNum = 0
|
|
|
+
|
|
|
+ // 首先遍历结果数组找出当前最大的orderNum
|
|
|
+ result.forEach((item) => {
|
|
|
+ const orderNum =
|
|
|
+ typeof item.orderNum === 'number'
|
|
|
+ ? item.orderNum
|
|
|
+ : parseInt(item.orderNum, 10) || 0
|
|
|
+ if (orderNum > maxExistingOrderNum) {
|
|
|
+ maxExistingOrderNum = orderNum
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 子节点orderNum从当前最大orderNum + 1开始
|
|
|
+ let childOrderNumCounter = maxExistingOrderNum + 1
|
|
|
+
|
|
|
+ // 创建一个映射表,用于记录每个子节点对应的新orderNum
|
|
|
+ const childOrderMap = new Map()
|
|
|
+
|
|
|
+ // 第一次遍历:为每个子节点分配新的orderNum并存储映射关系
|
|
|
+ function assignChildOrderNums(nodes) {
|
|
|
+ nodes.forEach((node) => {
|
|
|
+ if (node.isChild || node.isSubItem) {
|
|
|
+ // 为每个子节点分配唯一的orderNum
|
|
|
+ childOrderMap.set(node.id || node.rowid, childOrderNumCounter++)
|
|
|
+ }
|
|
|
+ // 递归处理子节点
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ assignChildOrderNums(node.children)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第二次遍历:更新结果数组中的orderNum
|
|
|
+ assignChildOrderNums(fixedTables)
|
|
|
+
|
|
|
+ // 应用新的orderNum到结果数组
|
|
|
+ result.forEach((item) => {
|
|
|
+ // 只更新子节点的orderNum
|
|
|
+ if (item.isChild || item.isSubItem) {
|
|
|
+ const newOrderNum =
|
|
|
+ childOrderMap.get(item.id) || childOrderMap.get(item.rowid)
|
|
|
+ if (newOrderNum) {
|
|
|
+ item.orderNum = newOrderNum
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
return result
|
|
|
@@ -3248,10 +3472,21 @@
|
|
|
// 结果数组
|
|
|
const result = []
|
|
|
|
|
|
- // 遍历每一行数据
|
|
|
- dynamicTables.forEach((row, rowIndex) => {
|
|
|
+ // 递归处理树形结构中的所有节点
|
|
|
+ const processNode = (node) => {
|
|
|
+ // 确保node和dynamicValues存在
|
|
|
+ if (!node) {
|
|
|
+ console.warn('遇到空节点,跳过处理')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保dynamicValues属性存在,如果不存在则初始化为空对象
|
|
|
+ if (!node.dynamicValues) {
|
|
|
+ node.dynamicValues = {}
|
|
|
+ }
|
|
|
+
|
|
|
// 为每个固定列创建一条记录
|
|
|
- dynamicTitles.forEach((title, colIndex) => {
|
|
|
+ dynamicTitles.forEach((title) => {
|
|
|
// 找到对应的表头信息
|
|
|
const correspondingHeader = dynamicHeaders.find(
|
|
|
(header) => header.fieldName === title.rkey
|
|
|
@@ -3259,37 +3494,30 @@
|
|
|
|
|
|
const newItem = {
|
|
|
rkey: title.rkey,
|
|
|
- rvalue: row.dynamicValues
|
|
|
- ? row.dynamicValues[title.rkey] || ''
|
|
|
- : '',
|
|
|
- surveyTemplateId: row.surveyTemplateId,
|
|
|
- versionId: row.versionId,
|
|
|
- tabtype: row.tabtype,
|
|
|
- rowIndex: rowIndex,
|
|
|
+ rvalue: node.dynamicValues[title.rkey] || '',
|
|
|
+ surveyTemplateId: node.surveyTemplateId,
|
|
|
+ versionId: node.versionId,
|
|
|
+ tabtype: node.tabtype,
|
|
|
// 添加 headersId 字段(表头的id)
|
|
|
headersId: correspondingHeader ? correspondingHeader.id : null,
|
|
|
// 添加记录的id(itemlist中每条记录的id)
|
|
|
- id: row.itemId || null,
|
|
|
+ id: node.itemId || null,
|
|
|
// 添加父子关系字段
|
|
|
- parentid: row.parentid || -1, // 父项ID,默认为-1表示无父项
|
|
|
- isChild: row.isChild || false, // 是否为子项
|
|
|
+ parentid: node.parentid || -1, // 父项ID,默认为-1表示无父项
|
|
|
+ isChild: node.isChild || false, // 是否为子项
|
|
|
// 添加 rowid 字段
|
|
|
- rowid: row.rowid || null,
|
|
|
+ rowid: node.rowid || null,
|
|
|
// 添加计算公式相关字段
|
|
|
- calculationFormula: row.calculationFormula || null,
|
|
|
- jsonstr: row.jsonstr || null,
|
|
|
- }
|
|
|
-
|
|
|
- // 只有非子项才添加序号
|
|
|
- if (!row.isSubItem && row.orderNum) {
|
|
|
- newItem.orderNum =
|
|
|
- typeof row.orderNum === 'number'
|
|
|
- ? row.orderNum
|
|
|
- : parseInt(row.orderNum, 10) || 0
|
|
|
+ calculationFormula: node.calculationFormula || null,
|
|
|
+ jsonstr: node.jsonstr || null,
|
|
|
+ orderNum:
|
|
|
+ typeof node.orderNum === 'number'
|
|
|
+ ? node.orderNum
|
|
|
+ : parseInt(node.orderNum, 10) || 0,
|
|
|
}
|
|
|
|
|
|
// 添加其他可能需要的字段,但排除特定字段
|
|
|
- Object.keys(row).forEach((key) => {
|
|
|
+ Object.keys(node).forEach((key) => {
|
|
|
if (
|
|
|
!(key in newItem) &&
|
|
|
key !== 'dynamicValues' &&
|
|
|
@@ -3300,14 +3528,27 @@
|
|
|
key !== 'isSubItem' &&
|
|
|
key !== 'rowid' &&
|
|
|
key !== 'jsonstr' &&
|
|
|
- key !== 'calculationFormula'
|
|
|
+ key !== 'calculationFormula' &&
|
|
|
+ key !== 'children' // 排除children字段
|
|
|
) {
|
|
|
- newItem[key] = row[key]
|
|
|
+ newItem[key] = node[key]
|
|
|
}
|
|
|
})
|
|
|
|
|
|
result.push(newItem)
|
|
|
})
|
|
|
+
|
|
|
+ // 递归处理子节点
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ node.children.forEach((childNode) => {
|
|
|
+ processNode(childNode)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 遍历所有顶级节点
|
|
|
+ dynamicTables.forEach((row) => {
|
|
|
+ processNode(row)
|
|
|
})
|
|
|
|
|
|
return result
|
|
|
@@ -3413,6 +3654,7 @@
|
|
|
|
|
|
const itemList = responseData.value.itemlist
|
|
|
const allRows = []
|
|
|
+ const rowMap = new Map()
|
|
|
|
|
|
// 清空现有数据
|
|
|
this.contentEditForm.fixedTable.fixedTables = []
|
|
|
@@ -3438,6 +3680,7 @@
|
|
|
isSubItem: isSubItem,
|
|
|
rowid: item.rowid || this.generateUUID(),
|
|
|
jsonstr: item.jsonstr || null,
|
|
|
+ children: [], // 添加children数组用于树形结构
|
|
|
}
|
|
|
|
|
|
// 确保orderNum是数字类型
|
|
|
@@ -3451,55 +3694,40 @@
|
|
|
})
|
|
|
|
|
|
allRows.push(newRow)
|
|
|
+ // 构建rowMap用于快速查找
|
|
|
+ if (newRow.rowid) rowMap.set(String(newRow.rowid), newRow)
|
|
|
+ if (newRow.itemId) rowMap.set(String(newRow.itemId), newRow)
|
|
|
})
|
|
|
|
|
|
- // 按父子关系排序:父项在前,子项在对应的父项后面
|
|
|
- allRows.sort((a, b) => {
|
|
|
- // 先按orderNum排序父项
|
|
|
- if (a.isChild && !b.isChild) {
|
|
|
- // 如果a是子项,b是父项,需要检查a的父项是否在b之后
|
|
|
- const parentOfA = allRows.find(
|
|
|
- (item) => item.rowid === a.parentid || item.itemId === a.parentid
|
|
|
- )
|
|
|
- if (parentOfA && parentOfA.orderNum > b.orderNum) {
|
|
|
- return 1
|
|
|
- }
|
|
|
- return -1
|
|
|
- }
|
|
|
- if (!a.isChild && b.isChild) {
|
|
|
- // 如果a是父项,b是子项,需要检查b的父项是否在a之前
|
|
|
- const parentOfB = allRows.find(
|
|
|
- (item) => item.rowid === b.parentid || item.itemId === b.parentid
|
|
|
- )
|
|
|
- if (parentOfB && parentOfB.orderNum < a.orderNum) {
|
|
|
- return -1
|
|
|
+ // 构建树形结构
|
|
|
+ const treeData = []
|
|
|
+ const parentItems = allRows.filter((item) => !item.isChild)
|
|
|
+
|
|
|
+ // 父级按orderNum正序排序
|
|
|
+ parentItems.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0))
|
|
|
+
|
|
|
+ // 将子项添加到对应的父项的children中
|
|
|
+ allRows.forEach((item) => {
|
|
|
+ if (item.isChild) {
|
|
|
+ const parentId = String(item.parentid)
|
|
|
+ const parent = rowMap.get(parentId)
|
|
|
+ if (parent) {
|
|
|
+ parent.children.push(item)
|
|
|
}
|
|
|
- return 1
|
|
|
}
|
|
|
-
|
|
|
- // 如果都是父项或都是子项,按orderNum排序
|
|
|
- return (a.orderNum || 0) - (b.orderNum || 0)
|
|
|
})
|
|
|
|
|
|
- // 重新排序,确保子项紧跟在其对应的父项后面
|
|
|
- const sortedArray = []
|
|
|
- const parentItems = allRows.filter((item) => !item.isChild)
|
|
|
- const childItems = allRows.filter((item) => item.isChild)
|
|
|
-
|
|
|
+ // 对子项进行排序
|
|
|
parentItems.forEach((parent) => {
|
|
|
- sortedArray.push(parent)
|
|
|
- // 找到并添加该父项的所有子项
|
|
|
- const relatedChildren = childItems.filter(
|
|
|
- (child) =>
|
|
|
- child.parentid === parent.rowid ||
|
|
|
- child.parentid === parent.itemId
|
|
|
+ parent.children.sort(
|
|
|
+ (a, b) =>
|
|
|
+ (a.fixedValues['序号'] || 0) - (b.fixedValues['序号'] || 0)
|
|
|
)
|
|
|
- // 子项按orderNum排序
|
|
|
- relatedChildren.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0))
|
|
|
- sortedArray.push(...relatedChildren)
|
|
|
+ treeData.push(parent)
|
|
|
})
|
|
|
|
|
|
- this.contentEditForm.fixedTable.fixedTables = sortedArray
|
|
|
+ this.contentEditForm.fixedTable.fixedTables = treeData
|
|
|
+ console.log('树形结构数据:', treeData)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -3530,8 +3758,8 @@
|
|
|
}
|
|
|
|
|
|
const itemList = responseData.value.itemlist
|
|
|
-
|
|
|
const allRows = []
|
|
|
+ const rowMap = new Map()
|
|
|
|
|
|
// 清空现有数据
|
|
|
this.contentEditForm.dynamicTable.dynamicTables = []
|
|
|
@@ -3553,6 +3781,7 @@
|
|
|
isSubItem: isSubItem,
|
|
|
rowid: item.rowid || this.generateUUID(),
|
|
|
jsonstr: item.jsonstr || null,
|
|
|
+ children: [], // 添加children数组用于树形结构
|
|
|
}
|
|
|
|
|
|
// 确保orderNum是数字类型
|
|
|
@@ -3574,94 +3803,41 @@
|
|
|
})
|
|
|
|
|
|
allRows.push(newRow)
|
|
|
+ // 构建rowMap用于快速查找
|
|
|
+ if (newRow.rowid) rowMap.set(String(newRow.rowid), newRow)
|
|
|
+ if (newRow.itemId) rowMap.set(String(newRow.itemId), newRow)
|
|
|
})
|
|
|
|
|
|
- // 按父子关系排序:父项在前,子项在对应的父项后面
|
|
|
- // 1. 先创建一个映射表,方便通过ID查找父项
|
|
|
- const rowMap = new Map()
|
|
|
- const sortedArray = []
|
|
|
- const addedItems = new Set()
|
|
|
-
|
|
|
- // 深拷贝原始数据并过滤掉重复项
|
|
|
- const uniqueRows = allRows.reduce((acc, current) => {
|
|
|
- const isDuplicate = acc.some(
|
|
|
- (row) =>
|
|
|
- (row.rowid && current.rowid && row.rowid === current.rowid) ||
|
|
|
- (row.itemId && current.itemId && row.itemId === current.itemId)
|
|
|
- )
|
|
|
- if (!isDuplicate) {
|
|
|
- acc.push(JSON.parse(JSON.stringify(current)))
|
|
|
- }
|
|
|
- return acc
|
|
|
- }, [])
|
|
|
-
|
|
|
- // 填充映射表
|
|
|
- uniqueRows.forEach((row) => {
|
|
|
- if (row.rowid) rowMap.set(String(row.rowid), row)
|
|
|
- if (row.itemId) rowMap.set(String(row.itemId), row)
|
|
|
- })
|
|
|
-
|
|
|
- // 先按orderNum排序所有父项
|
|
|
- const parentItems = uniqueRows.filter((item) => !item.isChild)
|
|
|
- parentItems.sort(
|
|
|
- (a, b) => (Number(a.orderNum) || 0) - (Number(b.orderNum) || 0)
|
|
|
- )
|
|
|
-
|
|
|
- // 递归添加父项及其子项的函数
|
|
|
- const addItemWithChildren = (item) => {
|
|
|
- // 确保项目ID唯一
|
|
|
- const itemIdKey = String(
|
|
|
- item.rowid || item.itemId || `temp_${Math.random()}`
|
|
|
- )
|
|
|
-
|
|
|
- // 如果已经添加过,则跳过
|
|
|
- if (addedItems.has(itemIdKey)) return
|
|
|
+ // 构建树形结构
|
|
|
+ const treeData = []
|
|
|
+ const parentItems = allRows.filter((item) => !item.isChild)
|
|
|
|
|
|
- // 添加当前项目
|
|
|
- sortedArray.push(item)
|
|
|
- addedItems.add(itemIdKey)
|
|
|
+ // 父级按orderNum正序排序
|
|
|
+ parentItems.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0))
|
|
|
|
|
|
- // 找到并添加所有子项
|
|
|
- const children = uniqueRows.filter((child) => {
|
|
|
- if (child.isChild) {
|
|
|
- const childParentId = String(child.parentid)
|
|
|
- return (
|
|
|
- childParentId === String(item.rowid) ||
|
|
|
- childParentId === String(item.itemId)
|
|
|
- )
|
|
|
+ // 将子项添加到对应的父项的children中
|
|
|
+ allRows.forEach((item) => {
|
|
|
+ if (item.isChild) {
|
|
|
+ const parentId = String(item.parentid)
|
|
|
+ const parent = rowMap.get(parentId)
|
|
|
+ if (parent) {
|
|
|
+ parent.children.push(item)
|
|
|
}
|
|
|
- return false
|
|
|
- })
|
|
|
-
|
|
|
- // 子项按orderNum排序
|
|
|
- children.sort(
|
|
|
- (a, b) => (Number(a.orderNum) || 0) - (Number(b.orderNum) || 0)
|
|
|
- )
|
|
|
-
|
|
|
- // 添加所有子项
|
|
|
- children.forEach((child) => addItemWithChildren(child))
|
|
|
- }
|
|
|
-
|
|
|
- // 遍历所有父项,添加父项及其子项
|
|
|
- parentItems.forEach((parent) => addItemWithChildren(parent))
|
|
|
-
|
|
|
- // 添加剩余的没有被添加的项目(应该很少,但作为兜底)
|
|
|
- uniqueRows.forEach((row) => {
|
|
|
- const itemIdKey = String(
|
|
|
- row.rowid || row.itemId || `temp_${Math.random()}`
|
|
|
- )
|
|
|
- if (!addedItems.has(itemIdKey)) {
|
|
|
- sortedArray.push(row)
|
|
|
- addedItems.add(itemIdKey)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- // 最后,重新计算显示序号,确保序号连续且正确
|
|
|
- sortedArray.forEach((item, index) => {
|
|
|
- item.orderText = String(index + 1)
|
|
|
+ // 对子项进行排序
|
|
|
+ parentItems.forEach((parent) => {
|
|
|
+ parent.children.sort(
|
|
|
+ (a, b) =>
|
|
|
+ (Number(a.dynamicValues['序号']) || 0) -
|
|
|
+ (Number(b.dynamicValues['序号']) || 0)
|
|
|
+ )
|
|
|
+ treeData.push(parent)
|
|
|
})
|
|
|
|
|
|
- this.contentEditForm.dynamicTable.dynamicTables = sortedArray
|
|
|
+ this.contentEditForm.dynamicTable.dynamicTables = treeData
|
|
|
+ console.log('树形结构数据:', treeData)
|
|
|
},
|
|
|
//分割字符串
|
|
|
stringToObjects(str) {
|