|
@@ -61,6 +61,7 @@ export default {
|
|
|
},
|
|
|
checkAll: false,
|
|
|
splice: [],
|
|
|
+ allChildIds: [], // 所有子编号
|
|
|
slideCount: 0
|
|
|
}
|
|
|
},
|
|
@@ -122,9 +123,9 @@ export default {
|
|
|
this.isIndeterminate = roleData.menuIds.length > 0 && roleData.menuIds.length < this.slideCount
|
|
|
|
|
|
console.time('time')
|
|
|
- this.getParent(roleData.menuIds, tempData)
|
|
|
+ let tSplice = this.getParent(roleData.menuIds, tempData)
|
|
|
console.timeEnd('time')
|
|
|
- let checkIds = this.spliceParent(this.splice, roleData.menuIds)
|
|
|
+ let checkIds = this.spliceParent(tSplice, roleData.menuIds)
|
|
|
roleData.menuIds = checkIds
|
|
|
this.result = roleData
|
|
|
}
|
|
@@ -180,17 +181,42 @@ export default {
|
|
|
// }
|
|
|
// })
|
|
|
// })
|
|
|
+ this.getAllChildIds(data)
|
|
|
+ let tempAllChildIds = this.allChildIds
|
|
|
+ checkIds.map((id, index) => {
|
|
|
+ if(!tempAllChildIds.includes(id)) {
|
|
|
+ checkIds.splice(index, 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)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ getAllChildIds(data) {
|
|
|
+ // 获取所有最子集编号
|
|
|
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) {
|
|
|
+ this.getAllChildIds(item.children)
|
|
|
+ } else {
|
|
|
+ this.allChildIds.push(item.id)
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
//删除父级项
|