| |
| |
| setDistributableTreeDisabledStatus(ids, list) { |
| if (ids) { |
| ids.forEach((item) => { |
| this.distributableTreeDataList.push(item); |
| this.$set(item, "disabled", true); |
| if (item.menuChildren.length > 0) { |
| item.menuChildren.forEach((val) => { |
| this.distributableTreeDataList.push(val); |
| this.$set(val, "disabled", true); |
| if (val.menuChildren.length > 0) { |
| val.menuChildren.forEach((v) => { |
| this.distributableTreeDataList.push(v); |
| this.$set(v, "disabled", true); |
| }); |
| } |
| }); |
| } |
| }); |
| } |
| if (list) { |
| list.forEach((item) => { |
| this.menuTreeDataList.push(item); |
| if (item.menuChildren.length > 0) { |
| item.menuChildren.forEach((val) => { |
| this.menuTreeDataList.push(val); |
| if (val.menuChildren.length > 0) { |
| val.menuChildren.forEach((v) => { |
| this.menuTreeDataList.push(v); |
| }); |
| } |
| }); |
| } |
| }); |
| } |
| }, |
| |
| |
| handleMenuTree(data, node) { |
| let checkedNodeList = [...node.checkedKeys, ...node.halfCheckedKeys]; |
| |
| |
| if (this.isTreeMenuChecked(data)) { |
| console.log("取消节点~~~~~~~~~~"); |
| if (data.privilegeType === 0) { |
| this.cancelDistributableTreeCheckedStatus(this.getAllOptIdList(data)); |
| } else if (data.privilegeType === 1) { |
| |
| if ( |
| !checkedNodeList.includes(data.privilegePid) && |
| !checkedNodeList.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲和爷爷都不存在!!"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [ |
| ...this.getAllOptIdList(data), |
| ...tempIds, |
| ...[this.findGrandFatherId(data.privilegePid)], |
| ]; |
| this.cancelDistributableTreeCheckedStatus(ids); |
| } |
| if ( |
| !checkedNodeList.includes(data.privilegePid) && |
| checkedNodeList.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲不存在,但是爷爷存在~~~~"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [...this.getAllOptIdList(data), ...tempIds]; |
| this.cancelDistributableTreeCheckedStatus(ids); |
| } |
| if ( |
| checkedNodeList.includes(data.privilegePid) && |
| checkedNodeList.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲存在 && 爷爷也存在~~~~~"); |
| this.cancelDistributableTreeCheckedStatus( |
| this.getAllOptIdList(data) |
| ); |
| } |
| } else if (data.privilegeType === 2) { |
| |
| if ( |
| !checkedNodeList.includes(data.privilegePid) && |
| !checkedNodeList.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲和爷爷都不存在!!"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [ |
| ...this.getAllOptIdList(data), |
| ...tempIds, |
| ...[this.findGrandFatherId(data.privilegePid)], |
| ]; |
| this.cancelDistributableTreeCheckedStatus(ids); |
| } |
| if ( |
| !checkedNodeList.includes(data.privilegePid) && |
| checkedNodeList.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲不存在,但是爷爷存在~~~~"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [...this.getAllOptIdList(data), ...tempIds]; |
| this.cancelDistributableTreeCheckedStatus(ids); |
| } |
| if ( |
| checkedNodeList.includes(data.privilegePid) && |
| checkedNodeList.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲存在 && 爷爷也存在~~~~~"); |
| this.cancelDistributableTreeCheckedStatus( |
| this.getAllOptIdList(data) |
| ); |
| } |
| } |
| } else { |
| let defaultKeys = [ |
| ...this.$refs.distributableTreeRef.getCheckedKeys(), |
| ...this.$refs.distributableTreeRef.getHalfCheckedKeys(), |
| ]; |
| |
| if (data.privilegeType === 0) { |
| this.renderDistributableTreeCheckedStatus(this.getAllOptIdList(data)); |
| } else if (data.privilegeType === 1) { |
| const ids = [...checkedNodeList, this.getAllOptIdList(data)]; |
| this.renderDistributableTreeCheckedStatus(chooseNonRepeatingData(ids,defaultKeys)); |
| } else if (data.privilegeType === 2) { |
| const ids = [...checkedNodeList, this.getAllOptIdList(data)]; |
| this.renderDistributableTreeCheckedStatus(chooseNonRepeatingData(ids,defaultKeys)); |
| } |
| } |
| }, |
| |
| renderDistributableTreeCheckedStatus(selectedMenuTreeIdList) { |
| this.distributableTreeDataList.forEach((item) => { |
| selectedMenuTreeIdList.forEach((val) => { |
| if (val === item.id) { |
| item.disabled = false; |
| this.$refs.distributableTreeRef.setChecked(item, false, false); |
| } |
| }); |
| }); |
| }, |
| |
| cancelDistributableTreeCheckedStatus(cancelSelectTreeIdList) { |
| this.distributableTreeDataList.forEach((item) => { |
| cancelSelectTreeIdList.forEach((val) => { |
| if (val === item.id) { |
| item.disabled = true; |
| this.$refs.distributableTreeRef.setChecked(item, false, false); |
| } |
| }); |
| }); |
| }, |
| |
| |
| handleDistributableTree(data, node) { |
| console.log("data==>", data); |
| console.log("node==>", node); |
| let defaultKeys = [...node.checkedKeys, ...node.halfCheckedKeys]; |
| if (this.isDistributableTreeChecked(data)) { |
| if (data.privilegeType === 0) { |
| this.cancelCheckedAddDisabledStatus(this.getAllOptIdList(data)); |
| } else if (data.privilegeType === 1) { |
| |
| if ( |
| !defaultKeys.includes(data.privilegePid) && |
| !defaultKeys.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲和爷爷都不存在!!"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [ |
| ...this.getAllOptIdList(data), |
| ...tempIds, |
| ...[this.findGrandFatherId(data.privilegePid)], |
| ]; |
| this.cancelCheckedAddDisabledStatus(ids); |
| } |
| if ( |
| !defaultKeys.includes(data.privilegePid) && |
| defaultKeys.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲不存在,但是爷爷存在~~~~"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [...this.getAllOptIdList(data), ...tempIds]; |
| this.cancelCheckedAddDisabledStatus(ids); |
| } |
| if ( |
| defaultKeys.includes(data.privilegePid) && |
| defaultKeys.includes(data.privilegePid) |
| ) { |
| console.log("privilegeType===1-----父亲存在 && 爷爷也存在~~~~~"); |
| } |
| this.cancelCheckedAddDisabledStatus(this.getAllOptIdList(data)); |
| } else if (data.privilegeType === 2) { |
| |
| if ( |
| !defaultKeys.includes(data.privilegePid) && |
| !defaultKeys.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲和爷爷都不存在!!"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [ |
| ...this.getAllOptIdList(data), |
| ...tempIds, |
| ...[this.findGrandFatherId(data.privilegePid)], |
| ]; |
| this.cancelCheckedAddDisabledStatus(ids); |
| } |
| if ( |
| !defaultKeys.includes(data.privilegePid) && |
| defaultKeys.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲不存在,但是爷爷存在~~~~"); |
| const tempIds = []; |
| tempIds.push(data.privilegePid); |
| let ids = [...this.getAllOptIdList(data), ...tempIds]; |
| this.cancelCheckedAddDisabledStatus(ids); |
| } |
| if ( |
| defaultKeys.includes(data.privilegePid) && |
| defaultKeys.includes(this.findGrandFatherId(data.privilegePid)) |
| ) { |
| console.log("privilegeType===2-----父亲存在 && 爷爷也存在~~~~~"); |
| this.cancelCheckedAddDisabledStatus(this.getAllOptIdList(data)); |
| } |
| } |
| } |
| }, |
| |
| cancelCheckedAddDisabledStatus(cancelSelectTreeIdList) { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| }, |
| |
| async getOrdinaryManPermissionList() { |
| const { userGroupIds } = JSON.parse(getUserToken()); |
| await this.$store |
| .dispatch( |
| "groupPermissions/getOrdinaryAdminPermissionsList", |
| userGroupIds |
| ) |
| .then(() => { |
| this.distributableTreeData = deepClone( |
| this.adminPermissionsList |
| ).sort((a, b) => { |
| return a.id - b.id; |
| }); |
| }); |
| }, |
| |
| |
| getAllOptIdList(data) { |
| const ids = []; |
| ids.push(data.id); |
| if (data.menuChildren.length > 0) { |
| data.menuChildren.forEach((val) => { |
| ids.push(val.id); |
| if (val.menuChildren.length > 0) { |
| val.menuChildren.forEach((v) => { |
| ids.push(v.id); |
| }); |
| } |
| }); |
| } |
| return ids; |
| }, |
| |
| isTreeMenuChecked(data) { |
| let defaultKeys = [ |
| ...this.$refs.treeRef.getCheckedKeys(), |
| ...this.$refs.treeRef.getHalfCheckedKeys(), |
| ]; |
| |
| return !defaultKeys.includes(data.id); |
| }, |
| |
| isDistributableTreeChecked(data) { |
| let defaultKeys = [ |
| ...this.$refs.distributableTreeRef.getCheckedKeys(), |
| ...this.$refs.distributableTreeRef.getHalfCheckedKeys(), |
| ]; |
| |
| return !defaultKeys.includes(data.id); |
| }, |
| |
| findGrandFatherId(fatherId) { |
| let grandFatherId = null; |
| this.distributableTreeData.forEach((item) => { |
| if (item.menuChildren.length > 0) { |
| item.menuChildren.forEach((val) => { |
| if (val.id === fatherId) { |
| grandFatherId = val.privilegePid; |
| } |
| }); |
| } |
| }); |
| return grandFatherId; |
| }, |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述