edit
This commit is contained in:
		| @ -1,6 +1,7 @@ | |||||||
| import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; | import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; | ||||||
| import { SFComponent, SFSchema, SFSchemaEnumType, SFUISchema } from '@delon/form'; | import { SFComponent, SFSchema, SFSchemaEnumType, SFUISchema } from '@delon/form'; | ||||||
| import { _HttpClient } from '@delon/theme'; | import { _HttpClient } from '@delon/theme'; | ||||||
|  | import { EAEnvironmentService } from '@shared'; | ||||||
| import { NzModalRef } from 'ng-zorro-antd/modal'; | import { NzModalRef } from 'ng-zorro-antd/modal'; | ||||||
| import { of } from 'rxjs'; | import { of } from 'rxjs'; | ||||||
| import { delay, map } from 'rxjs/operators'; | import { delay, map } from 'rxjs/operators'; | ||||||
| @ -26,16 +27,12 @@ export class SettingRoleEditComponent implements OnInit { | |||||||
|   schema!: SFSchema; |   schema!: SFSchema; | ||||||
|   authority: any[] = []; |   authority: any[] = []; | ||||||
|   roleTplData: any[] = []; |   roleTplData: any[] = []; | ||||||
|   appId = ''; |  | ||||||
|   ui!: SFUISchema; |   ui!: SFUISchema; | ||||||
|   constructor(private modal: NzModalRef, public service: SystemService, public http: _HttpClient, private cdr: ChangeDetectorRef) {} |   constructor(private modal: NzModalRef, public service: SystemService, private envSrv: EAEnvironmentService) {} | ||||||
|  |  | ||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|     console.log('i', this.i, this.source); |  | ||||||
|     if (this.i.id) { |     if (this.i.id) { | ||||||
|       this.getRoleInfo(); |       this.getRoleInfo(); | ||||||
|     } else { |  | ||||||
|       this.getTplList(); |  | ||||||
|     } |     } | ||||||
|     if (this.source === '') { |     if (this.source === '') { | ||||||
|       this.initSF(); |       this.initSF(); | ||||||
| @ -97,9 +94,7 @@ export class SettingRoleEditComponent implements OnInit { | |||||||
|       }) |       }) | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|   getTplList() { |  | ||||||
|     // this.menu.getAllFunction(); |  | ||||||
|   } |  | ||||||
|   getRoleInfo() { |   getRoleInfo() { | ||||||
|     const params = { |     const params = { | ||||||
|       id: this.i.id |       id: this.i.id | ||||||
| @ -111,7 +106,6 @@ export class SettingRoleEditComponent implements OnInit { | |||||||
|       if (this.source === '') { |       if (this.source === '') { | ||||||
|         this.initSF(); |         this.initSF(); | ||||||
|       } |       } | ||||||
|       this.getTplList(); |  | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|   getData(res: { authority: any[]; authorityAssistId: any[] }) { |   getData(res: { authority: any[]; authorityAssistId: any[] }) { | ||||||
| @ -122,30 +116,39 @@ export class SettingRoleEditComponent implements OnInit { | |||||||
|     this.modal.destroy(); |     this.modal.destroy(); | ||||||
|   } |   } | ||||||
|   sure() { |   sure() { | ||||||
|     this.menu.washTree(); |     // this.menu.washTree(); | ||||||
|     if (this.authorityAssistId.length === 0) { |     // if (this.authorityAssistId.length === 0) { | ||||||
|       this.service.msgSrv.warning('请选择权限!'); |     //   this.service.msgSrv.warning('请选择权限!'); | ||||||
|       return; |     //   return; | ||||||
|     } |     // } | ||||||
|  |     console.log(this.menu.nzTreeComponent.getCheckedNodeList()); | ||||||
|  |     const selectedFun = this.menu?.nzTreeComponent?.getCheckedNodeList()?.map(node => ({ authorityId: node.key })); | ||||||
|  |     const authorityAssistId = selectedFun?.map(node => node.authorityId); | ||||||
|     const params: any = { |     const params: any = { | ||||||
|       id: this.i.id, |       id: this.i.id, | ||||||
|       ...this.sf.value, |       ...this.sf.value, | ||||||
|       authority: this.authority, |       authority: selectedFun, | ||||||
|       authorityAssistId: this.authorityAssistId |       authorityAssistId: authorityAssistId | ||||||
|     }; |     }; | ||||||
|     if (this.sf) { |     // if (this.sf) { | ||||||
|       this.appList.forEach(item => { |     //   this.appList.forEach(item => { | ||||||
|         if (item.appId === this.sf.value.appId) { |     //     if (item.appId === this.sf.value.appId) { | ||||||
|           params.tenantId = item.tenantId; |     //       params.tenantId = item.tenantId; | ||||||
|         } |     //     } | ||||||
|       }); |     //   }); | ||||||
|     } |     // } | ||||||
|     delete params.tplId; |     // delete params.tplId; | ||||||
|     if (this.i.id === 0) { |     if (this.i.id === 0) { | ||||||
|       delete params.id; |       delete params.id; | ||||||
|     } |     } | ||||||
|     this.service.request(this.service.$api_updateRoleInfo, params).subscribe(res => { |     if (this.i.id) { | ||||||
|  |       this.service.request(this.service.$api_update_role, params).subscribe(res => { | ||||||
|  |         this.modal.close(true); | ||||||
|  |       }); | ||||||
|  |     } else { | ||||||
|  |       this.service.request(this.service.$api_save_role, params).subscribe(res => { | ||||||
|         this.modal.close(true); |         this.modal.close(true); | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | } | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'; | import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'; | ||||||
| import { ModalHelper, _HttpClient } from '@delon/theme'; | import { ModalHelper, _HttpClient } from '@delon/theme'; | ||||||
|  | import { EAEnvironmentService } from '@shared'; | ||||||
| import { NzFormatEmitEvent, NzTreeNodeOptions } from 'ng-zorro-antd/core/tree'; | import { NzFormatEmitEvent, 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'; | ||||||
| @ -18,7 +19,7 @@ export class SettingMenuComponent implements OnInit { | |||||||
|   defaultSelectedKeys: any[] = []; |   defaultSelectedKeys: any[] = []; | ||||||
|   defaultExpandedKeys: any[] = []; |   defaultExpandedKeys: any[] = []; | ||||||
|   defaultCheckedKeys: any[] = []; |   defaultCheckedKeys: any[] = []; | ||||||
|   functionList: any[] = Funcs; |   functionList: any[] = []; | ||||||
|   selectProject: any = {}; |   selectProject: any = {}; | ||||||
|   selectApp: any = {}; |   selectApp: any = {}; | ||||||
|   @Input() type = 'edit'; |   @Input() type = 'edit'; | ||||||
| @ -27,7 +28,9 @@ export class SettingMenuComponent implements OnInit { | |||||||
|   @Input() authorityAssistId: any[] = []; |   @Input() authorityAssistId: any[] = []; | ||||||
|   @Input() roleId: any; |   @Input() roleId: any; | ||||||
|   @Output() changeData = new EventEmitter(); |   @Output() changeData = new EventEmitter(); | ||||||
|   constructor(public service: SystemService, private cdr: ChangeDetectorRef) {} |   constructor(public service: SystemService, private cdr: ChangeDetectorRef, private envSrv: EAEnvironmentService) { | ||||||
|  |     this.getAllFunction(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   ngOnInit() { |   ngOnInit() { | ||||||
|     if (this.type === 'edit') { |     if (this.type === 'edit') { | ||||||
| @ -35,12 +38,14 @@ export class SettingMenuComponent implements OnInit { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   getAllFunction() { |   getAllFunction() { | ||||||
|     this.service.request(this.service.$api_getAllFunctionInfoByAppId, { appId: '' }, 'POST', true, 'FORM').subscribe(res => { |     this.service | ||||||
|       if (this.source === 'onlyRelationAuth') { |       .request(this.service.$api_getAllFunctionInfoByAppId, { appId: this.envSrv.env.appId }, 'POST', true, 'FORM') | ||||||
|         this.addDisabledTree(res); |       .subscribe(res => { | ||||||
|       } else { |         // if (this.source === 'onlyRelationAuth') { | ||||||
|         // this.addDisabledLeafTree(res); |         //   this.addDisabledTree(res); | ||||||
|       } |         // } else { | ||||||
|  |         //   // this.addDisabledLeafTree(res); | ||||||
|  |         // } | ||||||
|         this.functionList = res; |         this.functionList = res; | ||||||
|         this.defaultCheckedKeys = this.authorityAssistId; |         this.defaultCheckedKeys = this.authorityAssistId; | ||||||
|         this.cdr.detectChanges(); |         this.cdr.detectChanges(); | ||||||
| @ -245,32 +250,34 @@ export class SettingMenuComponent implements OnInit { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   washTree() { |   washTree() { | ||||||
|     const authorityMenu: any[] = []; // this.authority |     console.log(this.nzTreeComponent.getCheckedNodeList()); | ||||||
|     const tempAuthorityIdDTOListMenu: any[] = []; |  | ||||||
|     const checkedNode: any = this.nzTreeComponent.getCheckedNodeList(); |     // const authorityMenu: any[] = []; // this.authority | ||||||
|     const halfCheckedNode: any = this.nzTreeComponent.getHalfCheckedNodeList(); |     // const tempAuthorityIdDTOListMenu: any[] = []; | ||||||
|     this.authorityAssistId = []; |     // const checkedNode: any = this.nzTreeComponent.getCheckedNodeList(); | ||||||
|     halfCheckedNode.forEach((item: { key: any }) => { |     // const halfCheckedNode: any = this.nzTreeComponent.getHalfCheckedNodeList(); | ||||||
|       authorityMenu.push({ authorityId: item.key }); |     // this.authorityAssistId = []; | ||||||
|       tempAuthorityIdDTOListMenu.push(item.key); |     // halfCheckedNode.forEach((item: { key: any }) => { | ||||||
|     }); |     //   authorityMenu.push({ authorityId: item.key }); | ||||||
|     this.overWashTree(checkedNode, tempAuthorityIdDTOListMenu, authorityMenu); |     //   tempAuthorityIdDTOListMenu.push(item.key); | ||||||
|     if (this.authority && this.authority.length) { |     // }); | ||||||
|       this.authority.forEach(item => { |     // this.overWashTree(checkedNode, tempAuthorityIdDTOListMenu, authorityMenu); | ||||||
|         if (tempAuthorityIdDTOListMenu.indexOf(item.authorityId) !== -1) { |     // if (this.authority && this.authority.length) { | ||||||
|           tempAuthorityIdDTOListMenu.forEach((oldItem, oldIndex) => { |     //   this.authority.forEach(item => { | ||||||
|             if (oldItem === item.authorityId) { |     //     if (tempAuthorityIdDTOListMenu.indexOf(item.authorityId) !== -1) { | ||||||
|               authorityMenu[oldIndex] = item; |     //       tempAuthorityIdDTOListMenu.forEach((oldItem, oldIndex) => { | ||||||
|             } |     //         if (oldItem === item.authorityId) { | ||||||
|           }); |     //           authorityMenu[oldIndex] = item; | ||||||
|         } |     //         } | ||||||
|       }); |     //       }); | ||||||
|     } |     //     } | ||||||
|     const result = { |     //   }); | ||||||
|       authority: authorityMenu, |     // } | ||||||
|       authorityAssistId: this.authorityAssistId |     // const result = { | ||||||
|     }; |     //   authority: authorityMenu, | ||||||
|     this.changeData.emit(result); |     //   authorityAssistId: this.authorityAssistId | ||||||
|  |     // }; | ||||||
|  |     // this.changeData.emit(result); | ||||||
|   } |   } | ||||||
|   overWashTree(children: any[], tempAuthorityIdDTOListMenu: any[], authorityMenu: any[]) { |   overWashTree(children: any[], tempAuthorityIdDTOListMenu: any[], authorityMenu: any[]) { | ||||||
|     children.forEach((item: any) => { |     children.forEach((item: any) => { | ||||||
|  | |||||||
| @ -35,6 +35,7 @@ export class RoleManagementComponent implements OnInit { | |||||||
|     { |     { | ||||||
|       title: '创建时间', |       title: '创建时间', | ||||||
|       index: 'createTime', |       index: 'createTime', | ||||||
|  |       className: 'text-left', | ||||||
|       type: 'date', |       type: 'date', | ||||||
|       sort: true |       sort: true | ||||||
|     }, |     }, | ||||||
| @ -89,12 +90,19 @@ export class RoleManagementComponent implements OnInit { | |||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   deleteAction(item?: any) { |   deleteAction(item: any) { | ||||||
|     this.nzModalService.error({ |     this.nzModalService.error({ | ||||||
|       nzTitle: '确认删除?', |       nzTitle: '确认删除?', | ||||||
|       nzClosable: false, |       nzClosable: false, | ||||||
|       nzCancelText: '取消', |       nzCancelText: '取消', | ||||||
|       nzOnOk: () => {} |       nzOnOk: () => { | ||||||
|  |         this.service.request(this.service.$api_dalete_role, [item.id]).subscribe(res => { | ||||||
|  |           if (res) { | ||||||
|  |             this.service.msgSrv.success('删除角色成功'); | ||||||
|  |             this.st.load(); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -26,6 +26,14 @@ export class SystemService extends BaseService { | |||||||
|  |  | ||||||
|   // 分页获取应用角色列表 |   // 分页获取应用角色列表 | ||||||
|   $api_get_role_page = '/api/mdc/cuc/roleInfo/getAppRoleInfoList'; |   $api_get_role_page = '/api/mdc/cuc/roleInfo/getAppRoleInfoList'; | ||||||
|  |   // 新增角色 | ||||||
|  |   $api_save_role = '/api/mdc/cuc/roleInfo/saveRoleInfo'; | ||||||
|  |   // 编辑角色 | ||||||
|  |   $api_update_role = '/api/mdc/cuc/roleInfo/updateRoleInfo'; | ||||||
|  |   // 删除角色(含多个) | ||||||
|  |   $api_dalete_role = '/api/mdc/cuc/roleInfo/removeRoleInfo'; | ||||||
|  |   // 获取角色详情 | ||||||
|  |   $api_getRoleInfo = '/api/mdc/cuc/roleInfo/getRoleInfo'; | ||||||
|  |  | ||||||
|   // 查询字典选项列表 |   // 查询字典选项列表 | ||||||
|   $api_get_dict_page = '/api/mdc/pbc/dictItems/list/page'; |   $api_get_dict_page = '/api/mdc/pbc/dictItems/list/page'; | ||||||
| @ -45,13 +53,13 @@ export class SystemService extends BaseService { | |||||||
|   // 删除CRM客户信息表 |   // 删除CRM客户信息表 | ||||||
|   $api_deletebatch_crmCustomer = '/api/mdc/crmCustomer/deletebatch'; |   $api_deletebatch_crmCustomer = '/api/mdc/crmCustomer/deletebatch'; | ||||||
|  |  | ||||||
|   $api_getAllFunctionInfoByAppId: string = ''; |   // 获取某个应用的所有菜单 | ||||||
|  |   $api_getAllFunctionInfoByAppId: string = '/api/mdc/cuc/functionInfo/getAllFunctionInfoByAppId'; | ||||||
|   $api_getRoleTemplateInfo: string = ''; |   $api_getRoleTemplateInfo: string = ''; | ||||||
|   $api_getFunctionButtonInfo: string = ''; |   $api_getFunctionButtonInfo: string = ''; | ||||||
|   $api_getFunctionDataInfo: string = ''; |   $api_getFunctionDataInfo: string = ''; | ||||||
|   $api_getAppList: string = ''; |   $api_getAppList: string = ''; | ||||||
|   $api_getRoleTemplateListByAppId: string = ''; |   $api_getRoleTemplateListByAppId: string = ''; | ||||||
|   $api_getRoleInfo: string = ''; |  | ||||||
|   $api_updateRoleInfo: string = ''; |   $api_updateRoleInfo: string = ''; | ||||||
|   constructor(public injector: Injector) { |   constructor(public injector: Injector) { | ||||||
|     super(injector); |     super(injector); | ||||||
|  | |||||||
| @ -390,11 +390,21 @@ | |||||||
|             "text": "系统设置", |             "text": "系统设置", | ||||||
|             "icon": "anticon anticon-dashboard", |             "icon": "anticon anticon-dashboard", | ||||||
|             "group": true, |             "group": true, | ||||||
|  |             "children": [ | ||||||
|  |               { | ||||||
|  |                 "text": "员工管理", | ||||||
|  |                 "group": true, | ||||||
|                 "children": [ |                 "children": [ | ||||||
|                   { |                   { | ||||||
|                     "text": "员工管理", |                     "text": "员工管理", | ||||||
|                     "link": "/system/staff-management" |                     "link": "/system/staff-management" | ||||||
|                   }, |                   }, | ||||||
|  |                   { | ||||||
|  |                     "text": "角色管理", | ||||||
|  |                     "link": "/system/role-management" | ||||||
|  |                   } | ||||||
|  |                 ] | ||||||
|  |               }, | ||||||
|               { |               { | ||||||
|                 "text": "CRM客户管理", |                 "text": "CRM客户管理", | ||||||
|                 "link": "/system/crm-management" |                 "link": "/system/crm-management" | ||||||
| @ -403,10 +413,6 @@ | |||||||
|                 "text": "网络货运人", |                 "text": "网络货运人", | ||||||
|                 "link": "/system/network-freight" |                 "link": "/system/network-freight" | ||||||
|               }, |               }, | ||||||
|               { |  | ||||||
|                 "text": "角色管理", |  | ||||||
|                 "link": "/system/role-management" |  | ||||||
|               }, |  | ||||||
|               { |               { | ||||||
|                 "text": "基础设置", |                 "text": "基础设置", | ||||||
|                 "link": "/system/basic-setting" |                 "link": "/system/basic-setting" | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user