From d9dff2cbf7b673944143568c16fa6c488cadd6ce Mon Sep 17 00:00:00 2001 From: Taric Xin Date: Tue, 26 Apr 2022 15:33:01 +0800 Subject: [PATCH] edit --- proxy.conf.js | 2 +- .../api-auth-modal.component.html | 15 +++ .../api-auth-modal.component.less | 17 +++ .../api-auth-modal.component.ts | 85 +++++++++++++++ .../organization-management.component.html | 51 +++++++++ .../organization-management.component.less | 17 +++ .../organization-management.component.ts | 96 ++++++++++++++++ .../organization-modal.component.html | 14 +++ .../organization-modal.component.less | 21 ++++ .../organization-modal.component.ts | 103 ++++++++++++++++++ .../role-management/menu/menu.component.html | 3 +- .../role-management/menu/menu.component.ts | 11 +- .../sys-setting/services/system.service.ts | 49 +++++++++ .../sys-setting/sys-setting-routing.module.ts | 2 + .../routes/sys-setting/sys-setting.module.ts | 11 +- 15 files changed, 487 insertions(+), 10 deletions(-) create mode 100644 src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html create mode 100644 src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.less create mode 100644 src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-management.component.html create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-management.component.less create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-management.component.ts create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.html create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.less create mode 100644 src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.ts diff --git a/proxy.conf.js b/proxy.conf.js index d9d60dfc..ff162fda 100644 --- a/proxy.conf.js +++ b/proxy.conf.js @@ -30,7 +30,7 @@ module.exports = { // }, '//api': { target: { - host: 'tms-api-test.eascs.com', + host: 'tms-api-dev.eascs.com', protocol: 'https:', port: 443 }, diff --git a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html new file mode 100644 index 00000000..1ac66921 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.html @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.less b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.less new file mode 100644 index 00000000..d97b0abb --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.less @@ -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; + } + } +} \ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts new file mode 100644 index 00000000..d0465454 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/api-auth-modal/api-auth-modal.component.ts @@ -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) + ); + } +} diff --git a/src/app/routes/sys-setting/components/organization-management/organization-management.component.html b/src/app/routes/sys-setting/components/organization-management/organization-management.component.html new file mode 100644 index 00000000..530cdc09 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-management.component.html @@ -0,0 +1,51 @@ + + +
+ +
+ + + + + + 角色名称 + 角色描述 + 创建人手机号 + 创建时间 + 操作 + + + + + + + + + {{ item.roleName }} + + {{ item.roleDescription }} + {{ item.link }} + + {{ item.createTime }} + + + 编辑 + + 删除 + + 新增子角色 +
+ + 配置接口权限 + + 配置数据权限 + + +
+
+ +
+
\ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/organization-management.component.less b/src/app/routes/sys-setting/components/organization-management/organization-management.component.less new file mode 100644 index 00000000..b83ce9ee --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-management.component.less @@ -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; + } + } + } + \ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/organization-management.component.ts b/src/app/routes/sys-setting/components/organization-management/organization-management.component.ts new file mode 100644 index 00000000..2311e055 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-management.component.ts @@ -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(); + } + }); + } + }); + } +} diff --git a/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.html b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.html new file mode 100644 index 00000000..1bc06855 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.html @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.less b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.less new file mode 100644 index 00000000..c5ab48f9 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.less @@ -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; + } + } +} \ No newline at end of file diff --git a/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.ts b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.ts new file mode 100644 index 00000000..9ae8a8e7 --- /dev/null +++ b/src/app/routes/sys-setting/components/organization-management/organization-modal/organization-modal.component.ts @@ -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); + } + }); + } + } +} diff --git a/src/app/routes/sys-setting/components/role-management/menu/menu.component.html b/src/app/routes/sys-setting/components/role-management/menu/menu.component.html index 9c6d6e48..c97e6e87 100644 --- a/src/app/routes/sys-setting/components/role-management/menu/menu.component.html +++ b/src/app/routes/sys-setting/components/role-management/menu/menu.component.html @@ -1,7 +1,8 @@
+ [nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys" style="max-height: 600px; + overflow: auto;">
diff --git a/src/app/routes/sys-setting/components/role-management/menu/menu.component.ts b/src/app/routes/sys-setting/components/role-management/menu/menu.component.ts index 4f6c67a5..85c11d0c 100644 --- a/src/app/routes/sys-setting/components/role-management/menu/menu.component.ts +++ b/src/app/routes/sys-setting/components/role-management/menu/menu.component.ts @@ -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); } diff --git a/src/app/routes/sys-setting/services/system.service.ts b/src/app/routes/sys-setting/services/system.service.ts index 33c7f6e6..85a266fe 100644 --- a/src/app/routes/sys-setting/services/system.service.ts +++ b/src/app/routes/sys-setting/services/system.service.ts @@ -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); + } + } } diff --git a/src/app/routes/sys-setting/sys-setting-routing.module.ts b/src/app/routes/sys-setting/sys-setting-routing.module.ts index f0670f64..ea5ae5c4 100644 --- a/src/app/routes/sys-setting/sys-setting-routing.module.ts +++ b/src/app/routes/sys-setting/sys-setting-routing.module.ts @@ -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 }, diff --git a/src/app/routes/sys-setting/sys-setting.module.ts b/src/app/routes/sys-setting/sys-setting.module.ts index 2e1275c1..c7462e40 100644 --- a/src/app/routes/sys-setting/sys-setting.module.ts +++ b/src/app/routes/sys-setting/sys-setting.module.ts @@ -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 {}