duy 1 vuosi sitten
vanhempi
commit
e6bdc3cca3
1 muutettua tiedostoa jossa 24 lisäystä ja 9 poistoa
  1. 24 9
      src/views/patrol/add.vue

+ 24 - 9
src/views/patrol/add.vue

@@ -216,7 +216,7 @@
                                 show-checkbox
                                 :default-checked-keys="defaultChecked"
                                 :auto-expand-keys="TreeAutoExpandKeys"
-                                check-strictly
+                          
                                 @check="divisionTreeCheck"
                                 @load="treeLoadNode"
                                 @nodeTap="wbsElTreeClick"
@@ -493,11 +493,10 @@ const tasksUserChange = (a, b, users) => {
 const linksRelateModal = ref(false)
 const linksRelateModalClick = ()=>{
     TreeAutoExpandKeys.value = processDataList.value[0]?.autoExpandKeys || []
-    console.log( TreeAutoExpandKeys.value, '  TreeAutoExpandKeys.value')
     linksRelateModal.value = true
+    isSearchTree.value = false
    
     defaultChecked.value = arrToKey(processDataList.value, 'primaryKeyId', ',').split(',')
-    console.log( defaultChecked.value, ' defaultChecked.value')
 }
 const linksRelateModalClose = ()=>{
     linksRelateModal.value = false
@@ -505,7 +504,10 @@ const linksRelateModalClose = ()=>{
 const processDataList = ref([])
 const linksRelateModalSave = ()=>{
     console.log('baocun', processDataList.value )
+    console.log(defaultChecked.value, 'defaultChecked.value')
     const keys = processElTree.value.treeRef.getCheckedKeys()
+    // const keys = defaultChecked.value
+    console.log(keys, 'keys')
     let linkTabIds = processDataList.value 
     if (keys.length === 0) {
         linkTabIds = []
@@ -519,8 +521,12 @@ const linksRelateModalSave = ()=>{
        })
     }
     for (let index = 0; index < keys.length; index++) {
+        console.log(keys[index], 'keys[index]')
         let node = processElTree.value.treeRef.getNode(keys[index])
         console.log(node, 'NODE')
+        let pathArr = []
+        getKeys(node, pathArr)
+        TreeAutoExpandKeys.value = pathArr
         linkTabIds.push({
             inspectProject: node.data.title,
             primaryKeyId: keys[index],
@@ -529,6 +535,7 @@ const linksRelateModalSave = ()=>{
 
         })
     }
+
      //去除掉重复的
      getNorepeatArr(linkTabIds)
      console.log(linkTabIds, 'linkTabIds')
@@ -552,6 +559,15 @@ const linksRelateModalSave = ()=>{
      addForm.value.list = linkTabIds
  
    
+}
+    //获取展开节点
+    const getKeys = (node, pathArr) => {
+    if (node.parent) {
+        pathArr.unshift(node.data?.primaryKeyId.replace(/(^\s*)|(\s*$)/g, '')) //去掉头尾空格
+        getKeys(node.parent, pathArr)
+    } else {
+        return //根节点结束
+    }
 }
 const getNorepeatArr = (tempArr)=> {
     let newArr = []
@@ -619,7 +635,6 @@ const getSearchTreeData = async () => {
 }
 const wbsElTreeClick = ({ node, data, keys })=>{
     console.log(keys, 'keys')
-    console.log(data, 'data')
     TreeAutoExpandKeys.value = keys || []
 }
 //懒加载的数据
@@ -644,13 +659,13 @@ const treeLoadNode = async ({ node, item, level }, resolve) => {
     })
     resolve(getArrValue(data))
 }
-const divisionTreeItemInfo = ref({})
-const divisionTreeCheck = ({ data }) => {
-    divisionTreeItemInfo.value = data
-    console.log(data, 'data')
-  
+
+const divisionTreeCheck = () => {
+
 
 }
+
+
 const defaultChecked = ref([]) //默认选中
 const TreeAutoExpandKeys = ref([])//默认展开
 const processElTree = ref(null)