duy 1 год назад
Родитель
Сommit
89d012de0a
2 измененных файлов с 95 добавлено и 55 удалено
  1. 93 55
      src/views/patrol/add.vue
  2. 2 0
      src/views/patrol/manage.vue

+ 93 - 55
src/views/patrol/add.vue

@@ -514,6 +514,7 @@ const linksRelateModalClick = ()=>{
     TreeAutoExpandKeys.value = processDataList.value[0]?.autoExpandKeys || []
     linksRelateModal.value = true
     isSearchTree.value = false
+    newPushArr.value = []
    
     defaultChecked.value = arrToKey(processDataList.value, 'primaryKeyId', ',').split(',')
 }
@@ -521,68 +522,101 @@ const linksRelateModalClose = ()=>{
     linksRelateModal.value = false
 }
 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 = []
+//     }
+//      //去出掉取消勾选的
+//     for (let index = 0; index < keys.length; index++) {
+//        linkTabIds = linkTabIds.filter((ele)=>{
+//             if (ele.primaryKeyId === keys[index]) {
+//                 return ele
+//             }
+//        })
+//     }
+//     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],
+//             autoExpandKeys:TreeAutoExpandKeys.value,
+//             isShowImage:0,
+//             contractId:contractId.value,
+
+//         })
+//     }
+
+//      //去除掉重复的
+//      getNorepeatArr(linkTabIds)
+//      console.log(linkTabIds, 'linkTabIds')
+//      console.log(processDataList.value, 'processDataList.value')
+//     linkTabIds.forEach((ele)=>{
+//         processDataList.value.forEach((ele1)=>{
+//             if (ele.primaryKeyId === ele1.primaryKeyId) {
+//                 ele.isShowImage = ele1.isShowImage
+//                 ele.inspectContent = ele1.inspectContent
+//                 ele.deductionStandard = ele1.deductionStandard
+//                 ele.inspectUserName = ele1.inspectUserName
+//                 ele.inspectPdfUrl = ele1.inspectPdfUrl
+//                 ele.autoExpandKeys = ele1.autoExpandKeys
+//                 ele.contractId = ele1.contractId
+            
+//             }
+//         })
+//     })
+//     console.log(linkTabIds, 'linkTabIds1111')
+//      processDataList.value = linkTabIds
+//      linksRelateModal.value = false
+//      addForm.value.list = linkTabIds
+ 
+   
+// }
+
+    //获取展开节点
 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 = []
-    }
-     //去出掉取消勾选的
-    for (let index = 0; index < keys.length; index++) {
-       linkTabIds = linkTabIds.filter((ele)=>{
-            if (ele.primaryKeyId === keys[index]) {
-                return ele
+    let arr = []//当前选中的节点
+    processDataList.value.forEach((ele)=>{
+        defaultChecked.value.forEach((ele1)=>{
+            if (ele.primaryKeyId === ele1) {
+                arr.push(ele)
             }
-       })
-    }
-    for (let index = 0; index < keys.length; index++) {
-        console.log(keys[index], 'keys[index]')
+        })
+    })
+        const keys = processElTree.value.treeRef.getCheckedKeys()
+        for (let index = 0; index < keys.length; 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],
+  
+    }
+    newPushArr.value.forEach((ele)=>{
+        arr.push({
+            inspectProject:ele.title,
+            primaryKeyId: ele.primaryKeyId,
             autoExpandKeys:TreeAutoExpandKeys.value,
             isShowImage:0,
             contractId:contractId.value,
-
-        })
-    }
-
-     //去除掉重复的
-     getNorepeatArr(linkTabIds)
-     console.log(linkTabIds, 'linkTabIds')
-     console.log(processDataList.value, 'processDataList.value')
-    linkTabIds.forEach((ele)=>{
-        processDataList.value.forEach((ele1)=>{
-            if (ele.primaryKeyId === ele1.primaryKeyId) {
-                ele.isShowImage = ele1.isShowImage
-                ele.inspectContent = ele1.inspectContent
-                ele.deductionStandard = ele1.deductionStandard
-                ele.inspectUserName = ele1.inspectUserName
-                ele.inspectPdfUrl = ele1.inspectPdfUrl
-                ele.autoExpandKeys = ele1.autoExpandKeys
-                ele.contractId = ele1.contractId
-            
-            }
+  
         })
     })
-    console.log(linkTabIds, 'linkTabIds1111')
-     processDataList.value = linkTabIds
+    processDataList.value = arr
+    addForm.value.list = arr
      linksRelateModal.value = false
-     addForm.value.list = linkTabIds
- 
    
 }
-
-    //获取展开节点
     const getKeys = (node, pathArr) => {
     if (node.parent) {
         pathArr.unshift(node.data?.primaryKeyId.replace(/(^\s*)|(\s*$)/g, '')) //去掉头尾空格
@@ -683,15 +717,19 @@ const treeLoadNode = async ({ node, item, level }, resolve) => {
 }
 
 const divisionTreeCheck = (data, { checkedNodes, checkedKeys }) => {
-    // console.log(data, 'data')
-    // console.log(checkedNodes, 'checkedNodes')
-    // console.log(checkedKeys, 'checkedKeys')
-
 }
+const newPushArr = ref([])
 const divisionTreeCheckChange = (data, ischeck, data1)=>{
-    console.log(data)
-    console.log(ischeck)
-    console.log(data1)
+    if (!ischeck) {
+        defaultChecked.value.forEach((ele, index)=>{
+            if (ele === data.primaryKeyId) {
+                defaultChecked.value.splice(index, 1)
+            }
+        })
+    } else {
+        defaultChecked.value.push(data.primaryKeyId)
+        newPushArr.value.push(data)
+    }
 }
 
 

+ 2 - 0
src/views/patrol/manage.vue

@@ -30,6 +30,7 @@ import { useAppStore } from '~src/store'
 import { getArrValue } from 'js-fast-way'
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
+const contractId = ref(useAppState.contractId)
 //初始变量
 const router = useRouter()
 const tableColumn = [
@@ -63,6 +64,7 @@ const getTableData = async () => {
     const { error, code, data } = await patrolApi.page2({
         ...searchForm.value,
         projectId: projectId.value,
+        contractId:contractId.value,
 
     })
     //判断状态