Browse Source

BOM复制后,临时表tree结构问题

java8
han\hanst 2 months ago
parent
commit
d52258f8df
  1. 2
      src/views/modules/part/bomSearch3.vue
  2. 36
      src/views/modules/part/copy_bom_modal.vue

2
src/views/modules/part/bomSearch3.vue

@ -50,7 +50,7 @@
<el-table
:height="height"
:data="dataList"
border
border highlight-current-row
ref="bomHeaderTable"
@row-click="headerClickRow"
@current-change="changeCurrentRow"

36
src/views/modules/part/copy_bom_modal.vue

@ -1660,6 +1660,9 @@ export default {
//
refreshTreeData () {
// ID
const currentNodeId = this.currentRow ? this.currentRow.id : null
let tempData = {
bomId: this.modalData.bomId,
createBy: this.$store.state.user.name
@ -1670,8 +1673,37 @@ export default {
this.treeData = data.rows
if (this.treeData.length > 0) {
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.treeData[0].id)
this.handleNodeClick(this.treeData[0])
// ID
if (currentNodeId) {
// ID
const findNodeById = (nodes, targetId) => {
for (let node of nodes) {
if (node.id === targetId) {
return node
}
if (node.list && node.list.length > 0) {
const found = findNodeById(node.list, targetId)
if (found) return found
}
}
return null
}
const targetNode = findNodeById(this.treeData, currentNodeId)
if (targetNode) {
//
this.$refs.tree.setCurrentKey(targetNode.id)
this.handleNodeClick(targetNode)
} else {
//
this.$refs.tree.setCurrentKey(this.treeData[0].id)
this.handleNodeClick(this.treeData[0])
}
} else {
// ID
this.$refs.tree.setCurrentKey(this.treeData[0].id)
this.handleNodeClick(this.treeData[0])
}
})
}
this.queryTreeLoading = false

Loading…
Cancel
Save