This commit is contained in:
Taric Xin
2022-02-22 16:43:14 +08:00
parent 6285aa085c
commit 212be1e066
9 changed files with 78 additions and 2005 deletions

View File

@ -80,7 +80,7 @@ export class AuthGuard extends ACLGuard {
}
for (const key of Object.keys(params)) {
if (_route.indexOf(params[key]) > -1) {
_route = _route.replace(params[key], ':id');
_route = _route.replace(params[key], ':' + key);
}
}

View File

@ -1,15 +1,16 @@
<div class="modal-header">
<div class="modal-title">{{ i.id === 0 ? '新增角色' : '编辑角色' }}</div>
<div class="modal-title">{{ params.id === 0 ? '新增角色' : '编辑角色' }}</div>
</div>
<nz-spin *ngIf="!i" class="modal-spin"></nz-spin>
<div *ngIf="i">
<sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'"> </sf>
<nz-spin *ngIf="!params" class="modal-spin"></nz-spin>
<div *ngIf="params">
<sf #sf [compact]="true" [ui]="{'*': { spanLabelFixed: 120, grid: { span: 24 } } }" [schema]="schema"
[button]="'none'"> </sf>
</div>
<div class="box">
<se-container se-container="1">
<se label="角色权限" required [labelWidth]="120">
<app-cuc-menu #menu (changeData)="getData($event)" [type]="i.id === 0 ? 'add' : 'edit'" [source]="source"
[roleId]="i.id" [isAuthorityIdDTOList]="roleInfoData.authority || []"
<app-cuc-menu #menu (changeData)="getData($event)" [type]="params.id === 0 ? 'add' : 'edit'" [roleId]="params.id"
[isAuthorityIdDTOList]="roleInfoData.authority || []"
[authorityAssistId]="roleInfoData.authorityAssistId || []">
</app-cuc-menu>
</se>
@ -17,7 +18,6 @@
</div>
<div class="modal-footer">
<button nz-button type="button" (click)="close()">{{ source === 'onlyAuth' ? '关闭' : '取消' }}</button>
<button nz-button type="button" nzType="primary" (click)="sure()" *ngIf="source !== 'onlyAuth'"
[disabled]="!sf?.valid">确定</button>
<button nz-button type="button" (click)="close()">取消</button>
<button nz-button type="button" nzType="primary" (click)="sure()">确定</button>
</div>

View File

@ -18,25 +18,18 @@ export class SettingRoleEditComponent implements OnInit {
sf!: SFComponent;
@ViewChild('menu', { static: false })
menu!: SettingMenuComponent;
record: any = {};
roleInfoData: any = {};
authorityAssistId: any[] = [];
appList: any[] = [];
source = '';
i: any;
params: any;
schema!: SFSchema;
authority: any[] = [];
roleTplData: any[] = [];
ui!: SFUISchema;
constructor(private modal: NzModalRef, public service: SystemService, private envSrv: EAEnvironmentService) {}
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
if (this.i.id) {
this.initSF();
if (this.params.id) {
this.getRoleInfo();
}
if (this.source === '') {
this.initSF();
}
}
initSF() {
this.schema = {
@ -57,7 +50,7 @@ export class SettingRoleEditComponent implements OnInit {
default: this.roleInfoData.roleDescription,
ui: {
autosize: { minRows: 3 },
hidden: this.i.lookType === 'detail',
hidden: this.params.lookType === 'detail',
placeholder: '请输入角色描述',
widget: 'textarea'
}
@ -65,46 +58,15 @@ export class SettingRoleEditComponent implements OnInit {
},
required: ['roleName']
};
this.ui = {
'*': {
spanLabelFixed: 120,
grid: { span: 24 }
}
};
}
getAppList() {
const params = {
pageSize: 10000,
pageIndex: 1
};
return this.service.request(this.service.$api_getAppList, params).pipe(
map(res => {
this.appList = res;
const versionArr: any[] = [];
const resArr = res;
if (resArr && resArr.length) {
resArr.forEach((item: any) => {
versionArr.push({
label: item.appName,
value: item.appId
});
});
}
return versionArr;
})
);
}
getRoleInfo() {
const params = {
id: this.i.id
id: this.params.id
};
this.service.request(this.service.$api_getRoleInfo, params).subscribe(res => {
this.service.request(this.params.infoUrl, params).subscribe(res => {
if (res) {
this.roleInfoData = res;
}
if (this.source === '') {
this.initSF();
}
});
@ -117,6 +79,10 @@ export class SettingRoleEditComponent implements OnInit {
this.modal.destroy();
}
sure() {
if (!this.sf?.valid) {
this.service.msgSrv.warning('校验错误');
return;
}
// this.menu.washTree();
// if (this.authorityAssistId.length === 0) {
// this.service.msgSrv.warning('请选择权限!');
@ -124,28 +90,20 @@ export class SettingRoleEditComponent implements OnInit {
// }
const auths = this.menu?.washTree();
const params: any = {
id: this.i.id,
id: this.params.id,
...this.sf.value,
authority: auths.authority,
authorityAssistId: auths.authorityAssistId
};
// if (this.sf) {
// this.appList.forEach(item => {
// if (item.appId === this.sf.value.appId) {
// params.tenantId = item.tenantId;
// }
// });
// }
// delete params.tplId;
if (this.i.id === 0) {
if (this.params.id === 0) {
delete params.id;
}
if (this.i.id) {
this.service.request(this.service.$api_update_role, params).subscribe(res => {
if (this.params.id) {
this.service.request(this.params.updateUrl, params).subscribe(res => {
this.modal.close(true);
});
} else {
this.service.request(this.service.$api_save_role, params).subscribe(res => {
this.service.request(this.params.addUrl, params).subscribe(res => {
this.modal.close(true);
});
}

View File

@ -1,10 +1,8 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { EAEnvironmentService } from '@shared';
import { NzFormatEmitEvent, NzTreeNode, NzTreeNodeOptions } from 'ng-zorro-antd/core/tree';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
import { SystemService } from '../../../services/system.service';
import { Funcs } from './funcs';
@Component({
selector: 'app-cuc-menu',
@ -20,10 +18,9 @@ export class SettingMenuComponent implements OnInit, OnChanges {
defaultExpandedKeys: any[] = [];
defaultCheckedKeys: any[] = [];
functionList: any[] = [];
selectProject: any = {};
selectApp: any = {};
@Input() type = 'edit';
@Input() source = '';
@Input() appId = this.envSrv.env.appId;
@Input() isAuthorityIdDTOList: any[] = [];
@Input() authorityAssistId: any[] = [];
@Input() roleId: any;
@ -44,17 +41,15 @@ export class SettingMenuComponent implements OnInit, OnChanges {
ngOnInit() {}
getAllFunction() {
this.service
.request(this.service.$api_getAllFunctionInfoByAppId, { appId: this.envSrv.env.appId }, 'POST', true, 'FORM')
.subscribe(res => {
// if (this.source === 'onlyRelationAuth') {
// this.addDisabledTree(res);
// } else {
// // this.addDisabledLeafTree(res);
// }
this.functionList = res;
this.defaultCheckedKeys = this.authorityAssistId;
});
this.service.request(this.service.$api_getAllFunctionInfoByAppId, { appId: this.appId }, 'POST', true, 'FORM').subscribe(res => {
// if (this.source === 'onlyRelationAuth') {
// this.addDisabledTree(res);
// } else {
// // this.addDisabledLeafTree(res);
// }
this.functionList = res;
this.defaultCheckedKeys = this.authorityAssistId;
});
}
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) {

View File

@ -14,13 +14,12 @@
</div>
</nz-card>
<nz-card class="content-box">
<nz-card>
<div class="d-flex justify-content-end mb-sm">
<div>
<button nz-button nzType="primary" (click)="roleAction()">新建角色</button>
</div>
</div>
<st #st [data]="service.$api_get_role_page" [columns]="columns" [req]="{ process: beforeReq }"
[loading]="service.http.loading" [scroll]="{ y: '370px' }" (change)="stChange($event)"></st>
<st #st [data]="params.listUrl" [columns]="columns" [req]="{ process: beforeReq }" [loading]="service.http.loading"
[scroll]="{ y: '370px' }"></st>
</nz-card>

View File

@ -1,4 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { STComponent, STColumn, STChange, STRequestOptions } from '@delon/abc/st';
import { SFComponent, SFSchema } from '@delon/form';
import { NzModalService } from 'ng-zorro-antd/modal';
@ -8,7 +9,7 @@ import { SettingRoleEditComponent } from './edit/edit.component';
@Component({
selector: 'app-role-management',
templateUrl: './role-management.component.html',
styleUrls: ['./role-management.component.less']
styleUrls: ['../../../commom/less/box.less']
})
export class RoleManagementComponent implements OnInit {
@ViewChild('st', { static: true })
@ -29,11 +30,11 @@ export class RoleManagementComponent implements OnInit {
columns: STColumn[] = [
{ title: '角色名称', index: 'roleName' },
{ title: '角色描述', index: 'roleDescription' },
{ title: '企业数量', index: 'roleDescription', iif: _ => this.type === 'freight' },
{ title: '创建人手机号', index: 'telephone' },
{
title: '创建时间',
index: 'createTime',
className: 'text-left',
type: 'date',
sort: true
},
@ -43,7 +44,7 @@ export class RoleManagementComponent implements OnInit {
{
text: '编辑',
click: item => this.roleAction(item),
// iif: item => item.roleName !== '超级管理员'
iif: item => item.roleName !== '超级管理员'
},
{
text: '删除',
@ -54,9 +55,31 @@ export class RoleManagementComponent implements OnInit {
}
];
selectedRows: any[] = [];
type = 'user';
params = {
listUrl: this.service.$api_get_role_page,
deleteUrl: this.service.$api_dalete_role,
infoUrl: this.service.$api_getRoleInfo,
addUrl: this.service.$api_save_role,
updateUrl: this.service.$api_update_role
};
constructor(public service: SystemService, private nzModalService: NzModalService) {}
constructor(public service: SystemService, private nzModalService: NzModalService, private route: ActivatedRoute) {
route.params.subscribe(({ type }) => {
if (type) {
this.type = type;
if (type !== 'user') {
this.params = {
listUrl: this.service.$api_get_role_page,
deleteUrl: this.service.$api_dalete_role,
infoUrl: this.service.$api_getRoleInfo,
addUrl: this.service.$api_save_role,
updateUrl: this.service.$api_update_role
};
}
}
});
}
ngOnInit(): void {}
@ -70,23 +93,17 @@ export class RoleManagementComponent implements OnInit {
return requestOptions;
};
stChange(e: STChange): void {
switch (e.type) {
case 'sort':
this.selectedRows = e.checkbox!;
break;
}
}
roleAction(item?: any) {
const modal = this.nzModalService.create({
nzContent: SettingRoleEditComponent,
nzWidth: 900,
nzComponentParams: item ? { i: { ...item } } : { i: { id: 0 } },
nzComponentParams: item ? { params: { ...item, ...this.params } } : { params: { id: 0 } },
nzFooter: null
});
modal.afterClose.subscribe(res => {
this.st.load();
if (res) {
this.st.load();
}
});
}
@ -96,7 +113,7 @@ export class RoleManagementComponent implements OnInit {
nzClosable: false,
nzCancelText: '取消',
nzOnOk: () => {
this.service.request(this.service.$api_dalete_role, [item.id]).subscribe(res => {
this.service.request(this.params.deleteUrl, [item.id]).subscribe(res => {
if (res) {
this.service.msgSrv.success('删除角色成功');
this.st.load();

View File

@ -27,7 +27,8 @@ import { NetworkFreightNewComponent } from './components/network-freight/new/new
const routes: Routes = [
{ path: 'staff-management', component: StaffManagementComponent },
{ path: 'role-management', component: RoleManagementComponent },
{ path: 'role-management/user/:type', component: RoleManagementComponent },
{ path: 'role-management/freight/:type', component: RoleManagementComponent },
{ path: 'basic-setting', component: BasicSettingComponent },
{ path: 'basic-config', component: BasicConfigComponent },
{ path: 'audit-reason-config', component: AuditReasonConfigComponent },
@ -41,7 +42,7 @@ const routes: Routes = [
{ path: 'close-account', component: CloseAccountComponent },
// { path: 'btn-management', component: BtnManagementComponent },
{ path: 'announcement-message', component: AnnouncementMessageComponent },
{ path: 'insurance-set', component: InsuranceSetComponent },
{ path: 'insurance-set', component: InsuranceSetComponent }
];
@NgModule({

View File

@ -375,7 +375,7 @@ export class InvoiceRequestedComponent implements OnInit {
{ title: '银行账户', index: 'bankAccount', width: 140 },
{ title: '注册地址', index: 'registerAddr', width: 140 },
{ title: '注册电话', index: 'registerPhone', width: 120 },
{ title: '服务名称', index: 'vatname', width: 100 },
{ title: '服务名称', index: 'vatnameLabel', width: 150 },
{
title: '销货清单',
index: 'isdetail',