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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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