|
@@ -61,7 +61,7 @@
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
import { nextTick, ref, watch } from 'vue'
|
|
import { nextTick, ref, watch } from 'vue'
|
|
-import { arrToId, getArrValue, getRandom, isArrIndex, isArrItem } from 'js-fast-way'
|
|
|
|
|
|
+import { arrToId, arrUnion, getArrValue, getRandom, isArrItem } from 'js-fast-way'
|
|
import unitApi from '~api/project/debit/contract/unit.js'
|
|
import unitApi from '~api/project/debit/contract/unit.js'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
|
|
|
|
@@ -293,10 +293,27 @@ const lefttreeProps = {
|
|
const nodeElTreeClick = (data)=>{
|
|
const nodeElTreeClick = (data)=>{
|
|
|
|
|
|
}
|
|
}
|
|
-const treeNodeCheck = (_, { checkedNodes, checkedKeys }) => {
|
|
|
|
- console.log(checkedNodes, 'checkedNodes')
|
|
|
|
|
|
+// 递归函数来获取节点的所有父级对象
|
|
|
|
+const getAllParents = (tree, targetId, parents = [])=> {
|
|
|
|
+ for (const node of tree) {
|
|
|
|
+ if (node.id === targetId) {
|
|
|
|
+ return parents
|
|
|
|
+ }
|
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
|
+ const parentCopy = [...parents]
|
|
|
|
+ parentCopy.push(node)
|
|
|
|
+ const result = getAllParents(node.children, targetId, parentCopy)
|
|
|
|
+ if (result) {
|
|
|
|
+ return result
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null
|
|
|
|
+}
|
|
|
|
+const treeNodeCheck = (checkdata, { checkedNodes, halfCheckedNodes }) => {
|
|
|
|
+ let allArr = arrUnion(halfCheckedNodes, checkedNodes)
|
|
tableData.value = []
|
|
tableData.value = []
|
|
- checkedNodes.forEach((item)=>{
|
|
|
|
|
|
+ allArr.forEach((item)=>{
|
|
tableData.value.push(
|
|
tableData.value.push(
|
|
{ nodeName: item.nodeName,
|
|
{ nodeName: item.nodeName,
|
|
startStake: '',
|
|
startStake: '',
|
|
@@ -310,21 +327,7 @@ const treeNodeCheck = (_, { checkedNodes, checkedKeys }) => {
|
|
)
|
|
)
|
|
})
|
|
})
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
if (checkedNodes.length > 0 ) {
|
|
if (checkedNodes.length > 0 ) {
|
|
- console.log(parentData.value, 'parentData')
|
|
|
|
- tableData.value.unshift(
|
|
|
|
- { nodeName: parentData.value.nodeName,
|
|
|
|
- startStake: '',
|
|
|
|
- endStake: '',
|
|
|
|
- contractPicture: '',
|
|
|
|
- isAddChildNode: parentData.value.isAddChildNode || 1,
|
|
|
|
- id:parentData.value.id,
|
|
|
|
- parentId:parentData.value.parentId,
|
|
|
|
- isParent:isTable.value ? false : true,
|
|
|
|
- },
|
|
|
|
- )
|
|
|
|
let alarr = tableData.value
|
|
let alarr = tableData.value
|
|
// 使用reduce方法进行去重
|
|
// 使用reduce方法进行去重
|
|
const uniqueArray = alarr.reduce((acc, current) => {
|
|
const uniqueArray = alarr.reduce((acc, current) => {
|
|
@@ -340,6 +343,8 @@ const treeNodeCheck = (_, { checkedNodes, checkedKeys }) => {
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
tableData.value = uniqueArray
|
|
tableData.value = uniqueArray
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|