This commit is contained in:
wangshiming
2022-04-26 10:21:05 +08:00
parent 636a725c08
commit 5b1d5d7ea8
7 changed files with 106 additions and 172 deletions

View File

@ -83,7 +83,7 @@ console.log(this.params.infoUrl)
close() {
this.modal.destroy();
}
changeIF(value: boolean) {
changeIF(value: any) {
console.log(value);
console.log('54545');
this.changeValue = true

View File

@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { _HttpClient } from '@delon/theme';
import { EAEnvironmentService } from '@shared';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
import { SystemService } from '../../../services/system.service';
@ -19,7 +19,6 @@ export class SettingMenuComponent implements OnInit, OnChanges {
defaultCheckedKeys: any[] = [];
functionList: any[] = [];
allChecked = false;
changeIFT = false;
indeterminate = true;
@Input() type = 'edit';
@Input() source = '';
@ -27,7 +26,6 @@ export class SettingMenuComponent implements OnInit, OnChanges {
@Input() isAuthorityIdDTOList: any[] = [];
@Input() authorityAssistId: any[] = [];
@Input() roleId: any;
@Output() changeIF= new EventEmitter();
@Output() changeData = new EventEmitter();
constructor(public service: SystemService, private cdr: ChangeDetectorRef, private envSrv: EAEnvironmentService) {}
ngOnChanges(changes: SimpleChanges): void {
@ -36,9 +34,9 @@ export class SettingMenuComponent implements OnInit, OnChanges {
this.authority = this.isAuthorityIdDTOList || [];
}
}
if (changes.authorityAssistId) {
this.defaultCheckedKeys = [...this.authorityAssistId];
}
// if (changes.authorityAssistId) {
// this.defaultCheckedKeys = [...this.authorityAssistId];
// }
}
ngOnInit() {
@ -59,44 +57,25 @@ export class SettingMenuComponent implements OnInit, OnChanges {
});
}
addAuthority(origin: { id: any; all: any }, node: { buttonInfoList: any[] }, item?: { checked: any; functionButtonId: any }) {
console.log(origin);
console.log(origin,node);
if (this.authority?.length && this.authority.filter(authItem => authItem.authorityId === origin.id).length) {
// 判断此菜单权限是否已经存在权限列表中
// 当前操作菜单id存在权限列表里
this.authority.forEach(menuItem => {
console.log(menuItem);
console.log(item);
if (menuItem.authorityId === origin.id) {
menuItem.buttonAuthorityIds = menuItem.buttonAuthorityIds || []; // 防止属性不存在,给属性指定数据类型
if (item) {
this.changeIF.emit(true);
this.changeIFT = true
// 判断此菜单下是否已有此按钮权限
// this.againGetBtn(id, origin);
const params = {
id: origin.id
};
this.service.request(this.service.$api_getFunctionButtonInfo, params).subscribe(res => {
if (res) {
let origins: any = {};
origins.buttonInfoList = res;
origins.all = false;
console.log(origins);
// 判断此菜单下是否已有此按钮权限
this.againGetBtn(origin.id, origins);
}
});
// 单选
if (item.checked) {
if (menuItem.buttonAuthorityIds.indexOf(item.functionButtonId) === -1) {
// 如果该按钮在数据权限数组中不存在
console.log('不存在');
menuItem.buttonAuthorityIds.push(item.functionButtonId);
}
} else {
console.log('存在');
if (menuItem.buttonAuthorityIds && menuItem.buttonAuthorityIds.length) {
menuItem.buttonAuthorityIds.forEach((btnItem: any, index: any) => {
if (btnItem === item.functionButtonId) {
@ -347,20 +326,9 @@ export class SettingMenuComponent implements OnInit, OnChanges {
}
// 再次请求,需要判断暂存权限数组是否已有此权限
againGetBtn(id: any, origin: any) {
console.log(id,origin);
console.log(this.authority);
console.log(this.authority.length);
if ((this.authority && this.authority.length !== 0)) {
console.log('1111');
if (this.authority && this.authority.length === 0) {
const buttonAuthorityIds: any = [];
console.log(origin);
console.log(origin.checked);
if (origin.checked) {
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
btnItem.checked = true;
buttonAuthorityIds.push(btnItem.functionButtonId);
@ -368,8 +336,6 @@ export class SettingMenuComponent implements OnInit, OnChanges {
this.authority.push({ authorityId: origin.key, buttonAuthorityIds, isUpdateAuthority: 1 });
}
} else {
console.log('22222');
if (origin.checked) {
//菜单勾选情况下
if (this.authority.some(item => item.authorityId === id)) {