瀏覽代碼

修改取值的问题

lex-xin 5 年之前
父節點
當前提交
87521447e4
共有 1 個文件被更改,包括 14 次插入77 次删除
  1. 14 77
      src/views/categroyManager/insideSetting/adminOperation.vue

+ 14 - 77
src/views/categroyManager/insideSetting/adminOperation.vue

@@ -125,34 +125,10 @@ export default {
           console.time('time')
           let tSplice = this.getParent(roleData.menuIds, tempData)
           console.timeEnd('time')
-          let checkIds = this.spliceParent(tSplice, roleData.menuIds)
-          roleData.menuIds = checkIds
+          roleData.menuIds = tSplice
           this.result = roleData
         }
       }
-      // getSilder({ hid: 0 }).then(s => {
-      //   if(s.code == 200) {
-      //     let tempData = this.setTableData(s.data)
-      //     this.data = tempData
-
-      //     if(this.pageType == 'update') {
-      //       getRoleInfo({ id: this.id }).then(res => {
-      //         if(res.code == 200) {
-      //           let roleData = res.data
-      //           this.checkAll = roleData.menuIds.length >= this.slideCount
-      //           this.isIndeterminate = roleData.menuIds.length > 0 && roleData.menuIds.length < this.slideCount
-
-      //           this.getParent(roleData.menuIds, tempData)
-      //           let checkIds = this.spliceParent(this.splice, roleData.menuIds)
-      //           roleData.menuIds = checkIds
-      //           this.result = roleData
-      //         }
-      //       })
-      //     }
-      //   }
-      // })
-      
-      
     },
     onTreeCheck() {
       let checkTree = this.$refs.tree.getCheckedKeys()
@@ -167,70 +143,31 @@ export default {
       }
     },
 
-    //递归获取到所有的为级的ID
+    //递归获取到所有的为级的ID
     getParent(checkIds, data){
-      // data1.forEach((d, i) => {
-      //   data2.forEach((item,index) => {
-      //     if(item.id === d && item.children && item.children.length){
-      //       if(!this.splice.includes(d)){
-      //         this.splice.push(d)
-      //       }
-      //     }
-      //     if(item.children){
-      //       this.getParent(data1, item.children)
-      //     }
-      //   })
-      // })
+      let removeIds = JSON.parse(JSON.stringify(checkIds))
       this.getAllChildIds(data)
       let tempAllChildIds = this.allChildIds
-      // console.log(tempAllChildIds.join(','))
-      // console.log(tempAllChildIds.includes(157))
-      // console.log(checkIds)
-      checkIds.map((id, index) => {
-        // console.log(tempAllChildIds.includes(id))
-        if(!tempAllChildIds.includes(id)) {
-          checkIds.splice(index, 1)
+      for(let i = checkIds.length; i > 0; i--) {
+        if(!tempAllChildIds.includes(checkIds[i - 1])) {
+          removeIds.splice(i - 1, 1)
         }
-      })
-      return checkIds
-      // 获取所有最子集编号
-      // let countChild = []
-      // data.forEach((item, index) => {
-        // checkIds.map(id => {
-        //   if(item.id === id && item.children && item.children.length) {
-        //     if(!this.splice.includes(id)) {
-        //       this.splice.push(id)
-        //     }
-        //   }
-        //   if(item.children) {
-        //     this.getParent(checkIds, item.children)
-        //   }
-        // })
-      //   if(item.children && item.children.length) {
-
-      //   } else {
-      //     countChild.push(item.id)
-      //   }
-      // })
+      }
+      return removeIds
     },
     getAllChildIds(data) {
       // 获取所有最子集编号
+      let child = this.allChildIds
+      let tempList = []
       data.forEach((item, index) => {
-        if(item.children && item.children.length) {
-          this.getAllChildIds(item.children)
+        let temp = []
+        if(item.children && item.children.length > 0) {
+          temp = this.getAllChildIds(item.children)
         } else {
-          this.allChildIds.push(item.id)
+          child.push(item.id)
         }
       })
     },
-    //删除父级项
-    spliceParent(arr1,arr2){
-      arr1.forEach((item, index) => {
-        const i = arr2.indexOf(item)
-        arr2.splice(i, 1)
-      })
-      return arr2
-    },
     setTableData(result) {
       let list = []
       list = result.map( res => {