This commit is contained in:
Taric Xin
2022-04-26 15:33:01 +08:00
parent e3b9b79ff0
commit d9dff2cbf7
15 changed files with 487 additions and 10 deletions

View File

@ -0,0 +1,15 @@
<nz-card [nzLoading]="loadingInfo" [nzBordered]="false">
<se-container se-container="1">
<se label="接口权限" required [labelWidth]="120">
<app-cuc-menu #menu (changeData)="getData($event)" [type]="'edit'"
[roleId]="params.id" [appId]="params.appId" [isAuthorityIdDTOList]="roleInfoData.authority || []"
[authorityAssistId]="roleInfoData.authorityAssistId || []" (changeIF)="changeIF($event)">
</app-cuc-menu>
</se>
</se-container>
</nz-card>
<div class="modal-footer">
<button nz-button type="button" (click)="close()">取消</button>
<button nz-button type="button" nzType="primary" (click)="sure()">确定</button>
</div>

View File

@ -0,0 +1,17 @@
:host {
::ng-deep {
.box {
width : 100%;
margin: 0 auto;
}
.sv__label {
display : inline-block;
float : left;
width : 120px;
color : #000;
font-size : 13px;
text-align: right;
}
}
}

View File

@ -0,0 +1,85 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SystemService } from '../../../services/system.service';
import { SettingMenuComponent } from '../../role-management/menu/menu.component';
@Component({
selector: 'app-api-auth-modal',
templateUrl: './api-auth-modal.component.html',
styleUrls: ['./api-auth-modal.component.less']
})
export class ApiAuthModalComponent implements OnInit {
@ViewChild('menu', { static: false })
menu!: SettingMenuComponent;
roleInfoData: any = {};
authorityAssistId: any[] = [];
params: any;
changeValue: boolean = false;
authority: any[] = [];
loadingInfo = false;
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
if (this.params.id) {
this.getRoleInfo();
}
}
getRoleInfo() {
this.loadingInfo = true;
this.service.request(this.params.infoUrl, { id: this.params.id }).subscribe(
res => {
if (res) {
this.roleInfoData = res;
}
this.loadingInfo = false;
},
_ => (this.loadingInfo = false),
() => (this.loadingInfo = false)
);
}
getData(res: { authority: any[]; authorityAssistId: any[] }) {
console.log('修改了');
this.authority = res.authority;
this.authorityAssistId = res.authorityAssistId;
}
close() {
this.modal.destroy();
}
changeIF(value: any) {
this.changeValue = true;
}
sure() {
const auths = this.menu?.washTree();
if (auths.authorityAssistId.length === 0) {
this.service.msgSrv.warning('请选择权限!');
return;
}
const params: any = {
id: this.params.id,
...this.roleInfoData,
authority: auths.authority,
authorityAssistId: auths.authorityAssistId
};
if (this.params.id === 0) {
delete params.id;
}
if (this.params?.type === 'freight') {
Object.assign(params, { enterpriseId: 0, enterpriseProjectId: 0 });
}
this.loadingInfo = true;
this.service.request(this.params.updateUrl, params).subscribe(
res => {
if (res) {
this.service.msgSrv.success('编辑成功');
this.modal.close(true);
}
this.loadingInfo = false;
},
_ => (this.loadingInfo = false),
() => (this.loadingInfo = false)
);
}
}