|
@@ -61,7 +61,7 @@
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
import { nextTick, ref, watch } from 'vue'
|
|
import { nextTick, ref, watch } from 'vue'
|
|
-import { arrToId, getArrValue, getRandom, isArrItem } from 'js-fast-way'
|
|
|
|
|
|
+import { arrToId, getArrValue, getRandom, isArrIndex, 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'
|
|
|
|
|
|
@@ -194,6 +194,7 @@ watch(() => [
|
|
watch(isShow, (val) => {
|
|
watch(isShow, (val) => {
|
|
if (val) {
|
|
if (val) {
|
|
setSplitRef()
|
|
setSplitRef()
|
|
|
|
+ checkStrictly.value = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -347,39 +348,70 @@ const defaultCheckedKeys = ref([])
|
|
const defaultExpandAll = ref(true)
|
|
const defaultExpandAll = ref(true)
|
|
|
|
|
|
const changeIsAdd = (val, row, index)=>{
|
|
const changeIsAdd = (val, row, index)=>{
|
|
- // const { isParent } = row
|
|
|
|
- // if (isParent && val === 0) {
|
|
|
|
- // let rowTreeData = leftTree.value.treeRef.getNode(row.id)
|
|
|
|
- // let delKeys = arrToId(rowTreeData.data.children).split(',')
|
|
|
|
- // nextTick(()=>{
|
|
|
|
- // delKeys.forEach((ele)=>{
|
|
|
|
- // leftTree.value.treeRef.setChecked(ele, false, true)
|
|
|
|
- // let checkKeys = leftTree.value.treeRef.getCheckedKeys()
|
|
|
|
- // let arr = []
|
|
|
|
- // tableData.value.forEach((ele)=>{
|
|
|
|
- // checkKeys.forEach((ele1)=>{
|
|
|
|
- // if (ele.id === ele1) {
|
|
|
|
- // arr.push(ele)
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // })
|
|
|
|
- // tableData.value = arr
|
|
|
|
- // if (checkKeys.length > 0) {
|
|
|
|
- // tableData.value.unshift(
|
|
|
|
- // { nodeName: parentData.value.nodeName,
|
|
|
|
- // startStake: '',
|
|
|
|
- // endStake: '',
|
|
|
|
- // contractPicture: '',
|
|
|
|
- // isAddChildNode:0,
|
|
|
|
- // id:parentData.value.id,
|
|
|
|
- // parentId:parentData.value.parentId,
|
|
|
|
- // isParent:isTable.value ? false : true,
|
|
|
|
- // },
|
|
|
|
- // )
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
|
|
+ const { isParent } = row
|
|
|
|
+ if (isParent && val === 0) {
|
|
|
|
+ let rowTreeData = leftTree.value.treeRef.getNode(row.id)
|
|
|
|
+ let delKeys = arrToId(rowTreeData.data.children).split(',')
|
|
|
|
+ nextTick(()=>{
|
|
|
|
+ delKeys.forEach((ele)=>{
|
|
|
|
+
|
|
|
|
+ leftTree.value.treeRef.setChecked(ele, false, true)
|
|
|
|
+ leftTree.value.treeRef.setChecked(row.id, true, false)
|
|
|
|
+ let checkKeys = leftTree.value.treeRef.getCheckedKeys()
|
|
|
|
+ let arr = []
|
|
|
|
+ tableData.value.forEach((ele)=>{
|
|
|
|
+ checkKeys.forEach((ele1)=>{
|
|
|
|
+ if (ele.id === ele1) {
|
|
|
|
+ arr.push(ele)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ tableData.value = arr
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ const isIdExist = tableData.value.some(obj => obj.id === parentData.value.id)
|
|
|
|
+ if (!isIdExist) {
|
|
|
|
+ tableData.value.unshift(
|
|
|
|
+ { nodeName: parentData.value.nodeName,
|
|
|
|
+ startStake: '',
|
|
|
|
+ endStake: '',
|
|
|
|
+ contractPicture: '',
|
|
|
|
+ isAddChildNode:1,
|
|
|
|
+ id:parentData.value.id,
|
|
|
|
+ parentId:parentData.value.parentId,
|
|
|
|
+ isParent:true,
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ } else if (isParent && val === 1) {
|
|
|
|
+ checkStrictly.value = false
|
|
|
|
+ let rowTreeData = leftTree.value.treeRef.getNode(row.id)
|
|
|
|
+ let delKeys = arrToId(rowTreeData.data?.children).split(',') || []
|
|
|
|
+ let checkNodes = []
|
|
|
|
+ nextTick(()=>{
|
|
|
|
+ delKeys.forEach((ele)=>{
|
|
|
|
+ leftTree.value.treeRef.setChecked(ele, true, true)
|
|
|
|
+ checkNodes = leftTree.value.treeRef.getCheckedNodes()
|
|
|
|
+ })
|
|
|
|
+ const filteredArray1 = checkNodes.filter(obj1 => !tableData.value.some(obj2 => obj1.id === obj2.id))
|
|
|
|
+
|
|
|
|
+ filteredArray1.forEach((ele)=>{
|
|
|
|
+ tableData.value.push(
|
|
|
|
+ { nodeName: ele.nodeName,
|
|
|
|
+ startStake: '',
|
|
|
|
+ endStake: '',
|
|
|
|
+ contractPicture: '',
|
|
|
|
+ isAddChildNode:1,
|
|
|
|
+ id:ele.id,
|
|
|
|
+ parentId:ele.parentId,
|
|
|
|
+ isParent:ele?.children ? true : false,
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
const leftTree = ref(null)
|
|
const leftTree = ref(null)
|
|
</script>
|
|
</script>
|