edit
This commit is contained in:
@ -6,45 +6,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="rightBox">
|
<div class="rightBox">
|
||||||
<nz-tabset [nzSize]="'small'">
|
<nz-tabset [nzSize]="'small'">
|
||||||
<!-- <nz-tab nzTitle="操作权限">
|
|
||||||
<div *ngFor="let item of origin?.buttonInfoList">
|
|
||||||
<label nz-checkbox [(ngModel)]="item.checked" (ngModelChange)="addAuthority(origin, node, item)">{{ item.title
|
|
||||||
}}</label>
|
|
||||||
</div>
|
|
||||||
<nz-empty nzNotFoundImage="simple" *ngIf="origin?.buttonInfoList?.length === 0">
|
|
||||||
</nz-empty>
|
|
||||||
</nz-tab> -->
|
|
||||||
<nz-tab nzTitle="操作权限">
|
<nz-tab nzTitle="操作权限">
|
||||||
<div *ngIf="origin.buttonInfoList && origin.buttonInfoList.length">
|
<div *ngIf="origin.buttonInfoList && origin.buttonInfoList.length">
|
||||||
<label style="width: 100%"
|
<label style="width: 100%" nz-checkbox [(ngModel)]="item.checked" *ngFor="let item of origin.buttonInfoList"
|
||||||
nz-checkbox
|
(ngModelChange)="addAuthority(origin, node, item)" [disabled]="source === 'onlyAuth'">{{
|
||||||
[(ngModel)]="item.checked"
|
item.permissionsName }}</label>
|
||||||
*ngFor="let item of origin.buttonInfoList"
|
|
||||||
(ngModelChange)="addAuthority(origin, node, item)"
|
|
||||||
[disabled]="source === 'onlyAuth'"
|
|
||||||
>{{ item.permissionsName }}</label
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<nz-empty nzNotFoundImage="simple" *ngIf="origin.buttonInfoList && origin.buttonInfoList.length === 0"> </nz-empty>
|
<nz-empty nzNotFoundImage="simple" *ngIf="origin.buttonInfoList && origin.buttonInfoList.length === 0">
|
||||||
</nz-tab>
|
</nz-empty>
|
||||||
<nz-tab nzTitle="数据权限">
|
|
||||||
<div *ngIf="origin.dictList?.length>0" se-container [labelWidth]="100">
|
|
||||||
<se [col]="1" label="用户范围" style="margin-bottom: 8px;" required>
|
|
||||||
<nz-select>
|
|
||||||
<nz-option nzValue="仅可见自己创建的数据" nzLabel="仅可见自己创建的数据"></nz-option>
|
|
||||||
<nz-option nzValue="可见全部人创建的数据" nzLabel="可见全部人创建的数据"></nz-option>
|
|
||||||
</nz-select>
|
|
||||||
</se>
|
|
||||||
<se [col]="1" label="运营主体" style="margin-bottom: 8px;" required>
|
|
||||||
<nz-select nzMode="multiple" nzShowSearch>
|
|
||||||
<nz-option nzValue="全部" nzLabel="全部"></nz-option>
|
|
||||||
<nz-option nzValue="天津" nzLabel="天津"></nz-option>
|
|
||||||
<nz-option nzValue="山西" nzLabel="山西"></nz-option>
|
|
||||||
<nz-option nzValue="北京" nzLabel="北京"></nz-option>
|
|
||||||
</nz-select>
|
|
||||||
</se>
|
|
||||||
</div>
|
|
||||||
<p *ngIf="origin?.dictList?.length === 0">此应用功能模块无数据权限限制,如需添加,请联系系统管理员。</p>
|
|
||||||
</nz-tab>
|
</nz-tab>
|
||||||
</nz-tabset>
|
</nz-tabset>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,6 +18,8 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
defaultExpandedKeys: any[] = [];
|
defaultExpandedKeys: any[] = [];
|
||||||
defaultCheckedKeys: any[] = [];
|
defaultCheckedKeys: any[] = [];
|
||||||
functionList: any[] = [];
|
functionList: any[] = [];
|
||||||
|
allChecked = false;
|
||||||
|
indeterminate = true;
|
||||||
@Input() type = 'edit';
|
@Input() type = 'edit';
|
||||||
@Input() source = '';
|
@Input() source = '';
|
||||||
@Input() appId = this.envSrv.env.appId;
|
@Input() appId = this.envSrv.env.appId;
|
||||||
@ -51,13 +53,14 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
// }
|
// }
|
||||||
this.functionList = res;
|
this.functionList = res;
|
||||||
this.defaultCheckedKeys = this.authorityAssistId;
|
this.defaultCheckedKeys = this.authorityAssistId;
|
||||||
|
this.cdr.detectChanges();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
addAuthority(origin: { id: any; all: any }, node: { buttonInfoList: any[] }, item?: { checked: any; functionButtonId: any }) {
|
addAuthority(origin: { id: any; all: any }, node: { buttonInfoList: any[] }, item?: { checked: any; functionButtonId: any }) {
|
||||||
if (this.authority.length && this.authority.filter(authItem => authItem.authorityId === origin.id).length) {
|
if (this.authority?.length && this.authority.filter(authItem => authItem.authorityId === origin.id).length) {
|
||||||
// 判断此菜单权限是否已经存在权限列表中
|
// 判断此菜单权限是否已经存在权限列表中
|
||||||
// 当前操作菜单id存在权限列表里
|
// 当前操作菜单id存在权限列表里
|
||||||
this.authority.forEach((menuItem, menuIndex) => {
|
this.authority.forEach(menuItem => {
|
||||||
if (menuItem.authorityId === origin.id) {
|
if (menuItem.authorityId === origin.id) {
|
||||||
menuItem.buttonAuthorityIds = menuItem.buttonAuthorityIds || []; // 防止属性不存在,给属性指定数据类型
|
menuItem.buttonAuthorityIds = menuItem.buttonAuthorityIds || []; // 防止属性不存在,给属性指定数据类型
|
||||||
if (item) {
|
if (item) {
|
||||||
@ -103,7 +106,7 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
// 全选
|
// 全选
|
||||||
buttonAuthorityIds.push(item.functionButtonId);
|
buttonAuthorityIds.push(item.functionButtonId);
|
||||||
} else {
|
} else {
|
||||||
node.buttonInfoList.forEach((nodeItem: { id: any; checked: boolean }) => {
|
node.buttonInfoList.forEach((nodeItem: { id: any; checked: boolean; _isHalfChecked: boolean }) => {
|
||||||
if (origin.all) {
|
if (origin.all) {
|
||||||
buttonAuthorityIds.push(nodeItem.id);
|
buttonAuthorityIds.push(nodeItem.id);
|
||||||
nodeItem.checked = true;
|
nodeItem.checked = true;
|
||||||
@ -112,13 +115,13 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
const obj: any = {
|
const obj: any = {
|
||||||
authorityId: origin.id,
|
authorityId: origin.id,
|
||||||
buttonAuthorityIds,
|
buttonAuthorityIds
|
||||||
dataAuthority: []
|
|
||||||
};
|
};
|
||||||
this.authority.push(obj);
|
this.authority.push(obj);
|
||||||
}
|
}
|
||||||
this.checkTreeNode(node, origin);
|
this.checkTreeNode(node, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
addDict(item: { checked: any; itemId: any; itemKey: any }, dictItem: { dictId: any }, origin: { id: any }, node: any) {
|
addDict(item: { checked: any; itemId: any; itemKey: any }, dictItem: { dictId: any }, origin: { id: any }, node: any) {
|
||||||
if (this.authority.length) {
|
if (this.authority.length) {
|
||||||
// 判断此菜单权限是否已经存在权限列表中
|
// 判断此菜单权限是否已经存在权限列表中
|
||||||
@ -271,7 +274,7 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
children.forEach((item: any) => {
|
children.forEach((item: any) => {
|
||||||
this.authorityAssistId.push(item.key);
|
this.authorityAssistId.push(item.key);
|
||||||
tempAuthorityIdDTOListMenu.push(item.key);
|
tempAuthorityIdDTOListMenu.push(item.key);
|
||||||
authorityMenu.push({ authorityId: item.key });
|
authorityMenu.push({ authorityId: item.key, isUpdateAuthority: 1 });
|
||||||
if (item.isLeaf) {
|
if (item.isLeaf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -282,6 +285,26 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initButtonList(id: any, origin: any) {
|
initButtonList(id: any, origin: any) {
|
||||||
|
if (origin.expanded) {
|
||||||
|
origin.children.forEach((item: any, index: number) => {
|
||||||
|
if (item.selected) {
|
||||||
|
if (origin.checked) {
|
||||||
|
this.authority.splice(index, 1);
|
||||||
|
const buttonAuthorityIds: any = [];
|
||||||
|
item.buttonInfoList.forEach((btnItem: any) => {
|
||||||
|
btnItem.checked = true;
|
||||||
|
buttonAuthorityIds.push(btnItem.functionButtonId);
|
||||||
|
});
|
||||||
|
this.authority.push({ authorityId: origin.key, buttonAuthorityIds, isUpdateAuthority: 1 });
|
||||||
|
} else {
|
||||||
|
this.authority.splice(index, 1);
|
||||||
|
item.buttonInfoList.forEach((btnItem: any) => {
|
||||||
|
btnItem.checked = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
const params = {
|
const params = {
|
||||||
id
|
id
|
||||||
};
|
};
|
||||||
@ -296,12 +319,22 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
// 再次请求,需要判断暂存权限数组是否已有此权限
|
// 再次请求,需要判断暂存权限数组是否已有此权限
|
||||||
againGetBtn(id: any, origin: any) {
|
againGetBtn(id: any, origin: any) {
|
||||||
if (this.authority.length === 0) {
|
if (this.authority && this.authority.length === 0) {
|
||||||
return;
|
const buttonAuthorityIds: any = [];
|
||||||
|
if (origin.checked) {
|
||||||
|
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
|
||||||
|
btnItem.checked = true;
|
||||||
|
buttonAuthorityIds.push(btnItem.functionButtonId);
|
||||||
|
});
|
||||||
|
this.authority.push({ authorityId: origin.key, buttonAuthorityIds, isUpdateAuthority: 1 });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (origin.checked) {
|
||||||
|
//菜单勾选情况下
|
||||||
|
if (this.authority.some(item => item.authorityId === id)) {
|
||||||
this.authority.forEach(item => {
|
this.authority.forEach(item => {
|
||||||
if (item.authorityId === id) {
|
if (item.authorityId === id) {
|
||||||
// 如果当前菜单Id等于暂存权限数组的Id
|
// 如果当前菜单Id存在权限列表里,并且等于暂存权限数组的Id
|
||||||
if (item.buttonAuthorityIds && item.buttonAuthorityIds.length) {
|
if (item.buttonAuthorityIds && item.buttonAuthorityIds.length) {
|
||||||
// 如果当前菜单Id权限数组不为空
|
// 如果当前菜单Id权限数组不为空
|
||||||
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
|
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
|
||||||
@ -315,6 +348,28 @@ export class SettingMenuComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.authority.push({ authorityId: origin.key, buttonAuthorityIds: [], isUpdateAuthority: 1 });
|
||||||
|
this.authority.forEach(item => {
|
||||||
|
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
|
||||||
|
btnItem.checked = true;
|
||||||
|
item.buttonAuthorityIds.push(btnItem.functionButtonId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 菜单未勾选,要删除权限
|
||||||
|
this.authority.forEach((item, index) => {
|
||||||
|
if (item.authorityId === id) {
|
||||||
|
// 如果当前菜单Id存在权限列表里,并且等于暂存权限数组的Id
|
||||||
|
this.authority.splice(index, 1);
|
||||||
|
origin.buttonInfoList.forEach((btnItem: { functionButtonId: any; checked: boolean }) => {
|
||||||
|
btnItem.checked = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initDictList(id: any, origin: any) {
|
initDictList(id: any, origin: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user