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

@ -30,7 +30,7 @@ module.exports = {
// },
'//api': {
target: {
host: 'tms-api-test.eascs.com',
host: 'tms-api-dev.eascs.com',
protocol: 'https:',
port: 443
},

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)
);
}
}

View File

@ -0,0 +1,51 @@
<nz-card class="content-box">
<div class="d-flex align-items-center mb-sm" style="justify-content: flex-end;">
<button nz-button nzType="primary" (click)="menuAction('新增角色')">新增</button>
</div>
<nz-table #expandTable [nzData]="listOfMapData" nzTableLayout="fixed" nzBordered nzSize="small"
[nzLoading]="service.http.loading">
<thead>
<tr>
<!-- <th nzWidth="70px" nzAlign="center">#</th> -->
<th>角色名称</th>
<th>角色描述</th>
<th>创建人手机号</th>
<th nzAlign="center">创建时间</th>
<th nzAlign="center" nzWidth="250px">操作</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let data of expandTable.data">
<ng-container *ngFor="let item of mapOfExpandedData[data.key];let i = index">
<tr *ngIf="(item.parent && item.parent.expand) || !item.parent">
<!-- <td nzWidth="70px" nzAlign="center" [nzChecked]="item.checked">{{ i+1 }}</td> -->
<td [nzIndentSize]="item.level! * 20" [nzShowExpand]="!!item.children"
[(nzExpand)]="item.expand"
(nzExpandChange)="service.collapse(mapOfExpandedData[data.key], item, $event)">
{{ item.roleName }}
</td>
<td>{{ item.roleDescription }}</td>
<td>{{ item.link }}</td>
<td nzAlign="center">
{{ item.createTime }}
</td>
<td nzAlign="center" nzWidth="250px">
<a (click)="menuAction(item)">编辑</a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="deleteAction(item)">删除</a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="menuAction(null,item.id)">新增子角色</a>
<br>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="configureAPIauth(item)">配置接口权限</a>
<nz-divider nzType="vertical"></nz-divider>
<a>配置数据权限</a>
</td>
</tr>
</ng-container>
</ng-container>
</tbody>
</nz-table>
</nz-card>

View File

@ -0,0 +1,17 @@
:host {
::ng-deep {
.pane-content-left {
padding-right: 12px;
nz-select {
width: 100%;
margin-bottom: 1rem;
border-bottom: 2px solid #15408e;
}
}
.pane-content-right {
padding-left: 12px;
}
}
}

View File

@ -0,0 +1,96 @@
import { Component, OnInit } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd/modal';
import { SystemService } from '../../services/system.service';
import { ApiAuthModalComponent } from './api-auth-modal/api-auth-modal.component';
import { OrganizationModalComponent } from './organization-modal/organization-modal.component';
@Component({
selector: 'app-organization-management',
templateUrl: './organization-management.component.html',
styleUrls: ['./organization-management.component.less']
})
export class OrganizationManagementComponent implements OnInit {
mapOfExpandedData: { [key: string]: any[] } = {};
listOfMapData: any[] = [];
params: any = {
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,
title: '角色管理',
type: 'user'
};
constructor(public service: SystemService, private modal: NzModalService) {
this.initData();
}
ngOnInit(): void {}
initData(): void {
this.loadMemu();
}
loadMemu() {
this.service.request(this.service.$api_get_organization_role_list).subscribe(res => {
if (res) {
this.listOfMapData = res;
this.listOfMapData.forEach(item => {
this.mapOfExpandedData[item.key] = this.service.convertTreeToList(item);
});
}
});
}
// changeMemu(key: number) {
// this.selectedPlatform = this.platforms[key];
// this.loadMemu(this.selectedPlatform.appId);
// }
menuAction(item?: any, parentId?: string) {
const modal = this.modal.create({
nzContent: OrganizationModalComponent,
nzComponentParams: item
? { params: { ...item, ...this.params }, parentId: item.parentId }
: { params: { id: 0, ...this.params }, parentId },
nzFooter: null
});
modal.afterClose.subscribe(res => {
if (res) {
this.loadMemu();
}
});
}
configureAPIauth(item: any) {
const modal = this.modal.create({
nzTitle: '接口权限配置',
nzContent: ApiAuthModalComponent,
nzWidth: 800,
nzComponentParams: { params: { ...item, ...this.params } },
nzFooter: null
});
modal.afterClose.subscribe(res => {
if (res) {
this.loadMemu();
}
});
}
deleteAction(item: any) {
this.modal.error({
nzTitle: '确认删除?',
nzClosable: false,
nzCancelText: '取消',
nzOnOk: () => {
this.service.request(this.params.deleteUrl, [item.id]).subscribe(res => {
if (res) {
this.service.msgSrv.success('删除角色成功');
this.loadMemu();
}
});
}
});
}
}

View File

@ -0,0 +1,14 @@
<div class="modal-header">
<div class="modal-title">{{ params.id === 0 ? '新增角色' : '编辑角色' }}</div>
</div>
<nz-card [nzLoading]="service.http.loading" [nzBordered]="false">
<sf #sf [compact]="true" [ui]="{'*': { spanLabelFixed: 90, grid: { span: 24 } } }" [schema]="schema"
[formData]="roleInfoData" [formData]="roleInfoData" [button]="'none'"> </sf>
</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,21 @@
: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;
}
.ant-card-body {
padding: 0;
}
}
}

View File

@ -0,0 +1,103 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFSchema } from '@delon/form';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SystemService } from '../../../services/system.service';
import { SettingMenuComponent } from '../../role-management/menu/menu.component';
@Component({
selector: 'app-organization-modal',
templateUrl: './organization-modal.component.html',
styleUrls: ['./organization-modal.component.less']
})
export class OrganizationModalComponent implements OnInit {
@ViewChild('sf', { static: false })
sf!: SFComponent;
roleInfoData: any = {};
params: any;
schema!: SFSchema;
parentId: string = '';
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
this.initSF();
if (this.params.id) {
this.getRoleInfo();
}
}
initSF() {
this.schema = {
properties: {
roleName: {
title: '角色名称',
type: 'string',
maxLength: 20,
ui: {
placeholder: '请输入角色名称'
}
},
roleDescription: {
title: '角色描述',
type: 'string',
maxLength: 50,
ui: {
autosize: { minRows: 3 },
hidden: this.params.lookType === 'detail',
placeholder: '请输入角色描述',
widget: 'textarea'
}
}
},
required: ['roleName']
};
}
getRoleInfo() {
this.service.request(this.params.infoUrl, { id: this.params.id }).subscribe(res => {
if (res) {
this.roleInfoData = res;
}
});
}
close() {
this.modal.destroy();
}
sure() {
if (!this.sf?.valid) {
this.service.msgSrv.warning('角色名称不能为空');
return;
}
const params: any = {
id: this.params.id,
...this.sf.value,
authority: this.roleInfoData.authority,
authorityAssistId: this.roleInfoData.authorityAssistId,
parentId: this.parentId
};
if (this.params.id === 0) {
delete params.id;
}
if (this.params?.type === 'freight') {
Object.assign(params, { enterpriseId: 0, enterpriseProjectId: 0 });
}
if (this.params.id) {
this.service.request(this.params.updateUrl, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('编辑成功');
this.modal.close(true);
}
});
} else {
this.service.request(this.params.addUrl, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('新增成功');
this.modal.close(true);
}
});
}
}
}

View File

@ -1,7 +1,8 @@
<div class="treeWrap">
<div class="leftBox">
<nz-tree #nzTreeComponent [nzData]="functionList" (nzClick)="nzEvent($event)" nzCheckable
[nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys">
[nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys" style="max-height: 600px;
overflow: auto;">
</nz-tree>
</div>
<div class="rightBox">

View File

@ -57,15 +57,15 @@ export class SettingMenuComponent implements OnInit, OnChanges {
});
}
addAuthority(origin: { id: any; all: any }, node: { buttonInfoList: any[] }, item?: { checked: any; functionButtonId: any }) {
console.log(origin,node);
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) {
@ -253,12 +253,13 @@ export class SettingMenuComponent implements OnInit, OnChanges {
const halfCheckedNode: any = this.nzTreeComponent.getHalfCheckedNodeList();
this.authorityAssistId = [];
halfCheckedNode.forEach((item: { key: any }) => {
authorityMenu.push({ authorityId: item.key });
authorityMenu.push({ authorityId: item.key, isUpdateAuthority: 0 });
tempAuthorityIdDTOListMenu.push(item.key);
});
this.overWashTree(checkedNode, tempAuthorityIdDTOListMenu, authorityMenu);
if (this.authority && this.authority.length) {
this.authority.forEach(item => {
item.isUpdateAuthority = 1;
if (tempAuthorityIdDTOListMenu.indexOf(item.authorityId) !== -1) {
tempAuthorityIdDTOListMenu.forEach((oldItem, oldIndex) => {
if (oldItem === item.authorityId) {
@ -318,7 +319,7 @@ export class SettingMenuComponent implements OnInit, OnChanges {
origin.buttonInfoList = res;
origin.all = false;
console.log(origin);
// 判断此菜单下是否已有此按钮权限
this.againGetBtn(id, origin);
}

View File

@ -8,6 +8,7 @@
*/
import { Injectable, Injector } from '@angular/core';
import { BaseService } from 'src/app/shared/services';
import { TreeNodeInterface } from '../../menu-manager/services/menu-manager.service';
@Injectable({
providedIn: 'root'
@ -45,6 +46,9 @@ export class SystemService extends BaseService {
// 获取角色列表
$api_getAppRoleList = '/api/mdc/cuc/roleInfo/getRoleList';
// 获取组织角色树列表
$api_get_organization_role_list = '/api/mdc/cuc/roleInfo/getOrganizationRoleList';
// 查询字典选项列表
$api_get_dict_page = '/api/mdc/pbc/dictItems/list/page';
// 根据id批量删除字典选项
@ -191,4 +195,49 @@ export class SystemService extends BaseService {
constructor(public injector: Injector) {
super(injector);
}
collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void {
if (!$event) {
if (data.children) {
data.children.forEach(d => {
const target = array.find(a => a.key === d.key)!;
target.expand = false;
this.collapse(array, target, false);
});
} else {
return;
}
}
}
convertTreeToList(root: TreeNodeInterface): TreeNodeInterface[] {
const stack: TreeNodeInterface[] = [];
const array: TreeNodeInterface[] = [];
const hashMap = {};
stack.push({ ...root, level: 0, expand: true });
while (stack.length !== 0) {
const node = stack.pop()!;
this.visitNode(node, hashMap, array);
if (node.children) {
for (let i = node.children.length - 1; i >= 0; i--) {
stack.push({
...node.children[i],
level: node.level! + 1,
expand: false,
parent: node
});
}
}
}
return array;
}
visitNode(node: TreeNodeInterface, hashMap: { [key: string]: boolean }, array: TreeNodeInterface[]): void {
if (!hashMap[node.key]) {
hashMap[node.key] = true;
array.push(node);
}
}
}

View File

@ -26,11 +26,13 @@ import { InsuranceSetComponent } from './components/insurance-set/insurance-set.
import { NetworkFreightNewComponent } from './components/network-freight/new/new.component';
import { NoTeManagementComponent } from './components/note-management/note-management.component';
import { SmsTemplateComponent } from './components/sms-template/sms-template.component';
import { OrganizationManagementComponent } from './components/organization-management/organization-management.component';
const routes: Routes = [
{ path: 'staff-management', component: StaffManagementComponent },
{ path: 'role-management/user/:type', component: RoleManagementComponent },
{ path: 'role-management/freight/:type', component: RoleManagementComponent },
{ path: 'organization-management', component: OrganizationManagementComponent },
{ path: 'basic-setting', component: BasicSettingComponent },
{ path: 'note-management', component: NoTeManagementComponent },
{ path: 'basic-config', component: BasicConfigComponent },

View File

@ -34,6 +34,9 @@ import { InsuranceSetComponent } from './components/insurance-set/insurance-set.
import { NetworkFreightNewComponent } from './components/network-freight/new/new.component';
import { NoTeManagementComponent } from './components/note-management/note-management.component';
import { SmsTemplateComponent } from './components/sms-template/sms-template.component';
import { OrganizationManagementComponent } from './components/organization-management/organization-management.component';
import { OrganizationModalComponent } from './components/organization-management/organization-modal/organization-modal.component';
import { ApiAuthModalComponent } from './components/organization-management/api-auth-modal/api-auth-modal.component';
const COMPONENTS = [
StaffManagementComponent,
@ -52,7 +55,8 @@ const COMPONENTS = [
AnnouncementMessageComponent,
InsuranceSetComponent,
NoTeManagementComponent,
SmsTemplateComponent
SmsTemplateComponent,
OrganizationManagementComponent
];
const NOTROUTECOMPONENTS = [
BuyerTranspowerComponent,
@ -61,10 +65,11 @@ const NOTROUTECOMPONENTS = [
AuditResonConfigActionModalComponent,
CartConfigActionModalComponent,
SettingRoleEditComponent,
SettingMenuComponent
SettingMenuComponent,
OrganizationModalComponent
];
@NgModule({
declarations: [...COMPONENTS, ...NOTROUTECOMPONENTS],
declarations: [...COMPONENTS, ...NOTROUTECOMPONENTS, ApiAuthModalComponent],
imports: [CommonModule, SysSettingRoutingModule, SharedModule, DynamicSettingModule]
})
export class SysSettingModule {}