车辆对接
This commit is contained in:
		| @ -3,7 +3,6 @@ import { STComponent, STColumn, STChange } from '@delon/abc/st'; | ||||
| import { SFComponent, SFSchema } from '@delon/form'; | ||||
| import { NzModalService } from 'ng-zorro-antd/modal'; | ||||
| import { SystemService } from '../../services/system.service'; | ||||
| import { SettingRoleEditComponent } from './edit/edit.component'; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-crm-management', | ||||
| @ -73,7 +72,7 @@ export class CrmManagementComponent implements OnInit { | ||||
|  | ||||
|   roleAction(item?: any) { | ||||
|     const modal = this.nzModalService.create({ | ||||
|       nzContent: SettingRoleEditComponent, | ||||
|       // nzContent: SettingRoleEditComponent, | ||||
|       nzWidth: 900, | ||||
|       nzComponentParams: item ? { i: { ...item } } : { i: { id: 0 } }, | ||||
|       nzFooter: null | ||||
|  | ||||
| @ -1,23 +0,0 @@ | ||||
| <div class="modal-header"> | ||||
|   <div class="modal-title">{{ i.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> | ||||
| </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" | ||||
|         [authorityAssistId]="roleInfoData.authorityAssistId"> | ||||
|       </app-cuc-menu> | ||||
|     </se> | ||||
|   </se-container> | ||||
| </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> | ||||
| </div> | ||||
| @ -1,23 +0,0 @@ | ||||
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
| import { CucRoleEditComponent } from './edit.component'; | ||||
|  | ||||
| describe('CucRoleEditComponent', () => { | ||||
|   let component: CucRoleEditComponent; | ||||
|   let fixture: ComponentFixture<CucRoleEditComponent>; | ||||
|  | ||||
|   beforeEach(async(() => { | ||||
|     TestBed.configureTestingModule({ | ||||
|       declarations: [CucRoleEditComponent], | ||||
|     }).compileComponents(); | ||||
|   })); | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     fixture = TestBed.createComponent(CucRoleEditComponent); | ||||
|     component = fixture.componentInstance; | ||||
|     fixture.detectChanges(); | ||||
|   }); | ||||
|  | ||||
|   it('should create', () => { | ||||
|     expect(component).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
| @ -1,151 +0,0 @@ | ||||
| import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; | ||||
| import { SFComponent, SFSchema, SFSchemaEnumType, SFUISchema } from '@delon/form'; | ||||
| import { _HttpClient } from '@delon/theme'; | ||||
| import { NzModalRef } from 'ng-zorro-antd/modal'; | ||||
| import { of } from 'rxjs'; | ||||
| import { delay, map } from 'rxjs/operators'; | ||||
| import { SystemService } from '../../../services/system.service'; | ||||
| import { SettingMenuComponent } from '../menu/menu.component'; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-cuc-edit', | ||||
|   templateUrl: './edit.component.html', | ||||
|   styleUrls: ['./edit.less'] | ||||
| }) | ||||
| export class SettingRoleEditComponent implements OnInit { | ||||
|   @ViewChild('sf', { static: false }) | ||||
|   sf!: SFComponent; | ||||
|   @ViewChild('menu', { static: false }) | ||||
|   menu!: SettingMenuComponent; | ||||
|   record: any = {}; | ||||
|   roleInfoData: any = {}; | ||||
|   authorityAssistId: any[] = []; | ||||
|   appList: any[] = []; | ||||
|   source = ''; | ||||
|   i: any; | ||||
|   schema!: SFSchema; | ||||
|   authority: any[] = []; | ||||
|   roleTplData: any[] = []; | ||||
|   appId = ''; | ||||
|   ui!: SFUISchema; | ||||
|   constructor(private modal: NzModalRef, public service: SystemService, public http: _HttpClient, private cdr: ChangeDetectorRef) {} | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|     console.log('i', this.i, this.source); | ||||
|     if (this.i.id) { | ||||
|       this.getRoleInfo(); | ||||
|     } else { | ||||
|       this.getTplList(); | ||||
|     } | ||||
|     if (this.source === '') { | ||||
|       this.initSF(); | ||||
|     } | ||||
|   } | ||||
|   initSF() { | ||||
|     this.schema = { | ||||
|       properties: { | ||||
|         roleName: { | ||||
|           title: '角色名称', | ||||
|           type: 'string', | ||||
|           default: this.roleInfoData.roleName, | ||||
|           maxLength: 20, | ||||
|           ui: { | ||||
|             placeholder: '请输入角色名称' | ||||
|           } | ||||
|         }, | ||||
|         roleDescription: { | ||||
|           title: '角色描述', | ||||
|           type: 'string', | ||||
|           maxLength: 100, | ||||
|           default: this.roleInfoData.roleDescription, | ||||
|           ui: { | ||||
|             autosize: { minRows: 3 }, | ||||
|             hidden: this.i.lookType === 'detail', | ||||
|             placeholder: '请输入角色描述', | ||||
|             widget: 'textarea' | ||||
|           } | ||||
|         } | ||||
|       }, | ||||
|       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; | ||||
|       }) | ||||
|     ); | ||||
|   } | ||||
|   getTplList() { | ||||
|     // this.menu.getAllFunction(); | ||||
|   } | ||||
|   getRoleInfo() { | ||||
|     const params = { | ||||
|       id: this.i.id | ||||
|     }; | ||||
|     this.service.request(this.service.$api_getRoleInfo, params).subscribe(res => { | ||||
|       this.roleInfoData = res; | ||||
|       this.roleInfoData.authority = res.authority || []; | ||||
|       this.roleInfoData.authorityAssistId = res.authorityAssistId || []; | ||||
|       if (this.source === '') { | ||||
|         this.initSF(); | ||||
|       } | ||||
|       this.getTplList(); | ||||
|     }); | ||||
|   } | ||||
|   getData(res: { authority: any[]; authorityAssistId: any[] }) { | ||||
|     this.authority = res.authority; | ||||
|     this.authorityAssistId = res.authorityAssistId; | ||||
|   } | ||||
|   close() { | ||||
|     this.modal.destroy(); | ||||
|   } | ||||
|   sure() { | ||||
|     this.menu.washTree(); | ||||
|     if (this.authorityAssistId.length === 0) { | ||||
|       this.service.msgSrv.warning('请选择权限!'); | ||||
|       return; | ||||
|     } | ||||
|     const params: any = { | ||||
|       id: this.i.id, | ||||
|       ...this.sf.value, | ||||
|       authority: this.authority, | ||||
|       authorityAssistId: this.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) { | ||||
|       delete params.id; | ||||
|     } | ||||
|     this.service.request(this.service.$api_updateRoleInfo, params).subscribe(res => { | ||||
|       this.modal.close(true); | ||||
|     }); | ||||
|   } | ||||
| } | ||||
| @ -1,17 +0,0 @@ | ||||
| :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; | ||||
|     } | ||||
|   } | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,39 +0,0 @@ | ||||
| <div class="treeWrap"> | ||||
|   <div class="leftBox"> | ||||
|     <nz-tree #nzTreeComponent [nzData]="functionList" (nzClick)="nzEvent($event)" nzCheckable | ||||
|       [nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys"> | ||||
|     </nz-tree> | ||||
|   </div> | ||||
|   <div class="rightBox"> | ||||
|     <nz-tabset [nzSize]="'small'"> | ||||
|       <nz-tab nzTitle="操作权限"> | ||||
|         <div *ngFor="let item of origin?.buttonInfoList"> | ||||
|           <label nz-checkbox [(ngModel)]="item.checked" (ngModelChange)="addAuthority(origin, node, item)">{{ item.title | ||||
|             }}</label> | ||||
|         </div> | ||||
|         <nz-empty nzNotFoundImage="simple" *ngIf="origin?.buttonInfoList?.length === 0"> | ||||
|         </nz-empty> | ||||
|       </nz-tab> | ||||
|       <nz-tab nzTitle="数据权限"> | ||||
|         <div *ngIf="origin.dictList?.length>0" se-container [labelWidth]="100"> | ||||
|           <se [col]="1" label="用户范围" style="margin-bottom: 8px;" required> | ||||
|             <nz-select> | ||||
|               <nz-option nzValue="仅可见自己创建的数据" nzLabel="仅可见自己创建的数据"></nz-option> | ||||
|               <nz-option nzValue="可见全部人创建的数据" nzLabel="可见全部人创建的数据"></nz-option> | ||||
|             </nz-select> | ||||
|           </se> | ||||
|           <se [col]="1" label="运营主体" style="margin-bottom: 8px;" required> | ||||
|             <nz-select  nzMode="multiple" nzShowSearch> | ||||
|               <nz-option nzValue="全部" nzLabel="全部"></nz-option> | ||||
|               <nz-option nzValue="天津" nzLabel="天津"></nz-option> | ||||
|               <nz-option nzValue="山西" nzLabel="山西"></nz-option> | ||||
|               <nz-option nzValue="北京" nzLabel="北京"></nz-option> | ||||
|             </nz-select> | ||||
|           </se> | ||||
|         </div> | ||||
|         <p *ngIf="origin?.dictList?.length === 0">此应用功能模块无数据权限限制,如需添加,请联系系统管理员。</p> | ||||
|       </nz-tab> | ||||
|     </nz-tabset> | ||||
|   </div> | ||||
| </div> | ||||
| <nz-empty nzNotFoundImage="simple" *ngIf="functionList.length === 0"></nz-empty> | ||||
| @ -1,361 +0,0 @@ | ||||
| import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'; | ||||
| import { ModalHelper, _HttpClient } from '@delon/theme'; | ||||
| import { NzFormatEmitEvent, 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', | ||||
|   templateUrl: './menu.component.html', | ||||
|   styleUrls: ['menu.less'] | ||||
| }) | ||||
| export class SettingMenuComponent implements OnInit { | ||||
|   @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; | ||||
|   origin: any = { buttonInfoList: Funcs[0].children, dictList: Funcs[0].children }; | ||||
|   node: any = {}; | ||||
|   authority: any[] = []; | ||||
|   defaultSelectedKeys: any[] = []; | ||||
|   defaultExpandedKeys: any[] = []; | ||||
|   defaultCheckedKeys: any[] = []; | ||||
|   functionList: any[] = Funcs; | ||||
|   selectProject: any = {}; | ||||
|   selectApp: any = {}; | ||||
|   @Input() type = 'edit'; | ||||
|   @Input() source = ''; | ||||
|   @Input() isAuthorityIdDTOList: any[] = []; | ||||
|   @Input() authorityAssistId: any[] = []; | ||||
|   @Input() roleId: any; | ||||
|   @Output() changeData = new EventEmitter(); | ||||
|   constructor(public service: SystemService, private cdr: ChangeDetectorRef) {} | ||||
|  | ||||
|   ngOnInit() { | ||||
|     if (this.type === 'edit') { | ||||
|       this.authority = this.isAuthorityIdDTOList; | ||||
|     } | ||||
|   } | ||||
|   getAllFunction() { | ||||
|     this.service.request(this.service.$api_getAllFunctionInfoByAppId, { 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.cdr.detectChanges(); | ||||
|     }); | ||||
|   } | ||||
|   addAuthority(origin: { id: any; all: any }, node: { buttonInfoList: any[] }, item?: { checked: any; id: any }) { | ||||
|     if (this.authority.length && this.authority.filter(authItem => authItem.authorityId === origin.id).length) { | ||||
|       // 判断此菜单权限是否已经存在权限列表中 | ||||
|       // 当前操作菜单id存在权限列表里 | ||||
|       this.authority.forEach((menuItem, menuIndex) => { | ||||
|         if (menuItem.authorityId === origin.id) { | ||||
|           menuItem.buttonAuthorityIds = menuItem.buttonAuthorityIds || []; // 防止属性不存在,给属性指定数据类型 | ||||
|           if (item) { | ||||
|             // 单选 | ||||
|             if (item.checked) { | ||||
|               if (menuItem.buttonAuthorityIds.indexOf(item.id) === -1) { | ||||
|                 // 如果该按钮在数据权限数组中不存在 | ||||
|                 menuItem.buttonAuthorityIds.push(item.id); | ||||
|               } | ||||
|             } else { | ||||
|               if (menuItem.buttonAuthorityIds && menuItem.buttonAuthorityIds.length) { | ||||
|                 menuItem.buttonAuthorityIds.forEach((btnItem: any, index: any) => { | ||||
|                   if (btnItem === item.id) { | ||||
|                     menuItem.buttonAuthorityIds.splice(index, 1); | ||||
|                   } | ||||
|                 }); | ||||
|               } | ||||
|             } | ||||
|           } else { | ||||
|             // 全选 | ||||
|             if (origin.all) { | ||||
|               node.buttonInfoList.forEach((nodeItem: { id: any; checked: boolean }) => { | ||||
|                 if (menuItem.buttonAuthorityIds.indexOf(nodeItem.id) === -1) { | ||||
|                   menuItem.buttonAuthorityIds.push(nodeItem.id); | ||||
|                   nodeItem.checked = true; | ||||
|                 } | ||||
|               }); | ||||
|             } else { | ||||
|               if (menuItem.buttonAuthorityIds && menuItem.buttonAuthorityIds.length) { | ||||
|                 menuItem.buttonAuthorityIds = []; | ||||
|                 node.buttonInfoList.forEach((nodeItem: { checked: boolean }) => { | ||||
|                   nodeItem.checked = false; | ||||
|                 }); | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     } else { | ||||
|       // 数组为空的时候 | ||||
|       const buttonAuthorityIds = []; | ||||
|       if (item) { | ||||
|         // 全选 | ||||
|         buttonAuthorityIds.push(item.id); | ||||
|       } else { | ||||
|         node.buttonInfoList.forEach((nodeItem: { id: any; checked: boolean }) => { | ||||
|           if (origin.all) { | ||||
|             buttonAuthorityIds.push(nodeItem.id); | ||||
|             nodeItem.checked = true; | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|       const obj: any = { | ||||
|         authorityId: origin.id, | ||||
|         buttonAuthorityIds | ||||
|       }; | ||||
|       this.authority.push(obj); | ||||
|     } | ||||
|     this.checkTreeNode(node, origin); | ||||
|   } | ||||
|   addDict(item: { checked: any; itemId: any; itemKey: any }, dictItem: { dictId: any }, origin: { id: any }, node: any) { | ||||
|     if (this.authority.length) { | ||||
|       // 判断此菜单权限是否已经存在权限列表中 | ||||
|       if (this.authority.filter(authItem => authItem.authorityId === origin.id).length) { | ||||
|         // 当前操作菜单id存在权限列表里 | ||||
|         this.authority.forEach((menuItem, menuIndex) => { | ||||
|           if (menuItem.authorityId === origin.id) { | ||||
|             menuItem.dataAuthority = menuItem.dataAuthority || []; // 防止属性不存在,给属性指定数据类型 | ||||
|             if (item.checked) { | ||||
|               if (menuItem.dataAuthority.filter((ele: { dictItemId: any }) => ele.dictItemId === item.itemId).length === 0) { | ||||
|                 // 如果该按钮在数据权限数组中不存在 | ||||
|                 menuItem.dataAuthority.push({ dictItemId: item.itemId, itemKey: item.itemKey, dictId: dictItem.dictId }); | ||||
|               } | ||||
|             } else { | ||||
|               if (menuItem.dataAuthority && menuItem.dataAuthority.length) { | ||||
|                 menuItem.dataAuthority.forEach((btnItem: { dictItemId: any }, index: any) => { | ||||
|                   if (btnItem.dictItemId === item.itemId) { | ||||
|                     menuItem.dataAuthority.splice(index, 1); | ||||
|                   } | ||||
|                 }); | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         }); | ||||
|       } else { | ||||
|         // 当前操作菜单id不存在权限列表里 | ||||
|         const dataAuthority = []; | ||||
|         dataAuthority.push({ dictItemId: item.itemId, itemKey: item.itemKey, dictId: dictItem.dictId }); | ||||
|         const obj: any = { | ||||
|           authorityId: origin.id, | ||||
|           dataAuthority | ||||
|         }; | ||||
|         this.authority.push(obj); | ||||
|       } | ||||
|     } else { | ||||
|       // 数组为空的时候 | ||||
|       const dataAuthority = []; | ||||
|       dataAuthority.push({ dictItemId: item.itemId, itemKey: item.itemKey, dictId: dictItem.dictId }); | ||||
|       const obj: any = { | ||||
|         authorityId: origin.id, | ||||
|         dataAuthority | ||||
|       }; | ||||
|       this.authority.push(obj); | ||||
|     } | ||||
|     this.checkTreeNode(node, origin); | ||||
|   } | ||||
|   checkTreeNode(node: any, origin: { id: any }) { | ||||
|     const checkedNode: any = this.nzTreeComponent.getCheckedNodeList(); | ||||
|     const allCheckedArr: any[] = []; | ||||
|     this.overTree(checkedNode, allCheckedArr); | ||||
|     this.authority.forEach(authItem => { | ||||
|       if (authItem.authorityId === origin.id) { | ||||
|         if ( | ||||
|           (authItem.buttonAuthorityIds && authItem.buttonAuthorityIds.length) || | ||||
|           (authItem.dataAuthority && authItem.dataAuthority.length) | ||||
|         ) { | ||||
|           if (allCheckedArr.indexOf(node.key) === -1) { | ||||
|             allCheckedArr.push(node.key); | ||||
|           } | ||||
|         } else { | ||||
|           if (allCheckedArr.indexOf(node.key) !== -1) { | ||||
|             allCheckedArr.forEach((ele, index) => { | ||||
|               if (ele === origin.id) { | ||||
|                 allCheckedArr.splice(index, 1); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|     this.defaultCheckedKeys = allCheckedArr; | ||||
|   } | ||||
|   addAuthorityAll(origin: any, node: { checked: any; buttonInfoList: any[] }) { | ||||
|     if (node.checked) { | ||||
|       node.buttonInfoList.forEach((item: any) => {}); | ||||
|     } else { | ||||
|     } | ||||
|   } | ||||
|   overTree(children: any[], a: any[]) { | ||||
|     children.forEach(item => { | ||||
|       a.push(item.key); | ||||
|       if (item.isLeaf) { | ||||
|         return; | ||||
|       } | ||||
|       if (item.children && item.children.length) { | ||||
|         this.overTree(item.children, a); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   // 获取角色模板权限 | ||||
|   getRoleTpl(id: any) { | ||||
|     const params = { | ||||
|       id | ||||
|     }; | ||||
|     this.service.request(this.service.$api_getRoleTemplateInfo, params).subscribe(res => { | ||||
|       this.authority = res.authority; | ||||
|       this.defaultCheckedKeys = res.authorityAssistId; | ||||
|     }); | ||||
|   } | ||||
|   addDisabledTree(arr: any[]) { | ||||
|     arr.forEach((item: any) => { | ||||
|       item.disableCheckbox = true; | ||||
|       if (item.isLeaf) { | ||||
|         return; | ||||
|       } | ||||
|       if (item.children && item.children.length) { | ||||
|         this.addDisabledTree(item.children); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   addDisabledLeafTree(arr: any[]) { | ||||
|     arr.forEach((item: any) => { | ||||
|       if (item.isLeaf) { | ||||
|         return; | ||||
|       } | ||||
|       item.disableCheckbox = true; | ||||
|       if (item.children && item.children.length) { | ||||
|         this.addDisabledLeafTree(item.children); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   nzEvent(event: any): void { | ||||
|     const ele = event.event.target as HTMLElement; | ||||
|     this.origin = event.node.origin; | ||||
|     this.node = event.node.origin; | ||||
|     if (!event.node.origin.isLeaf) { | ||||
|       event.node.isExpanded = !event.node.isExpanded; | ||||
|     } else { | ||||
|       // this.initButtonList(event.node.key, event.node.origin); | ||||
|       // this.initDictList(event.node.key, event.node.origin); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   washTree() { | ||||
|     const authorityMenu: any[] = []; // this.authority | ||||
|     const tempAuthorityIdDTOListMenu: any[] = []; | ||||
|     const checkedNode: any = this.nzTreeComponent.getCheckedNodeList(); | ||||
|     const halfCheckedNode: any = this.nzTreeComponent.getHalfCheckedNodeList(); | ||||
|     this.authorityAssistId = []; | ||||
|     halfCheckedNode.forEach((item: { key: any }) => { | ||||
|       authorityMenu.push({ authorityId: item.key }); | ||||
|       tempAuthorityIdDTOListMenu.push(item.key); | ||||
|     }); | ||||
|     this.overWashTree(checkedNode, tempAuthorityIdDTOListMenu, authorityMenu); | ||||
|     if (this.authority && this.authority.length) { | ||||
|       this.authority.forEach(item => { | ||||
|         if (tempAuthorityIdDTOListMenu.indexOf(item.authorityId) !== -1) { | ||||
|           tempAuthorityIdDTOListMenu.forEach((oldItem, oldIndex) => { | ||||
|             if (oldItem === item.authorityId) { | ||||
|               authorityMenu[oldIndex] = item; | ||||
|             } | ||||
|           }); | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|     const result = { | ||||
|       authority: authorityMenu, | ||||
|       authorityAssistId: this.authorityAssistId | ||||
|     }; | ||||
|     this.changeData.emit(result); | ||||
|   } | ||||
|   overWashTree(children: any[], tempAuthorityIdDTOListMenu: any[], authorityMenu: any[]) { | ||||
|     children.forEach((item: any) => { | ||||
|       this.authorityAssistId.push(item.key); | ||||
|       tempAuthorityIdDTOListMenu.push(item.key); | ||||
|       authorityMenu.push({ authorityId: item.key }); | ||||
|       if (item.isLeaf) { | ||||
|         return; | ||||
|       } | ||||
|       if (item.children) { | ||||
|         this.overWashTree(item.children, tempAuthorityIdDTOListMenu, authorityMenu); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   initButtonList(id: any, origin: any) { | ||||
|     const params = { | ||||
|       id | ||||
|     }; | ||||
|     this.service.request(this.service.$api_getFunctionButtonInfo, params).subscribe(res => { | ||||
|       if (res) { | ||||
|         origin.buttonInfoList = res; | ||||
|         origin.all = false; | ||||
|         // 判断此菜单下是否已有此按钮权限 | ||||
|         this.againGetBtn(id, origin); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   // 再次请求,需要判断暂存权限数组是否已有此权限 | ||||
|   againGetBtn(id: any, origin: any) { | ||||
|     if (this.authority.length === 0) { | ||||
|       return; | ||||
|     } | ||||
|     this.authority.forEach(item => { | ||||
|       if (item.authorityId === id) { | ||||
|         // 如果当前菜单Id等于暂存权限数组的Id | ||||
|         if (item.buttonAuthorityIds && item.buttonAuthorityIds.length) { | ||||
|           // 如果当前菜单Id权限数组不为空 | ||||
|           origin.buttonInfoList.forEach((btnItem: { id: any; checked: boolean }) => { | ||||
|             // 判断已有权限id是否存在 | ||||
|             if (item.buttonAuthorityIds.indexOf(btnItem.id) !== -1) { | ||||
|               btnItem.checked = true; | ||||
|             } else { | ||||
|               btnItem.checked = false; | ||||
|             } | ||||
|           }); | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   initDictList(id: any, origin: any) { | ||||
|     const params = { | ||||
|       id | ||||
|     }; | ||||
|     this.service.request(this.service.$api_getFunctionDataInfo, params).subscribe(res => { | ||||
|       if (res) { | ||||
|         origin.dictList = res; | ||||
|         // 判断此菜单下是否已有此按钮权限 | ||||
|         this.againGetDict(id, origin); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|   // 再次请求,需要判断暂存权限数组是否已有此权限 | ||||
|   againGetDict(id: any, origin: any) { | ||||
|     if (this.authority.length === 0) { | ||||
|       return; | ||||
|     } | ||||
|     this.authority.forEach(item => { | ||||
|       if (item.authorityId === id) { | ||||
|         // 如果当前菜单Id等于暂存权限数组的Id | ||||
|         if (item.dataAuthority && item.dataAuthority.length) { | ||||
|           // 如果当前菜单Id权限数组不为空 | ||||
|           origin.dictList.forEach((ele: { dictItem: any[] }) => { | ||||
|             // 判断已有权限id是否存在 | ||||
|             ele.dictItem.forEach((dictItem: { itemId: any; checked: boolean; cheked: boolean }) => { | ||||
|               item.dataAuthority.forEach((dataItem: { dictItemId: any }) => { | ||||
|                 if (dataItem.dictItemId === dictItem.itemId) { | ||||
|                   dictItem.checked = true; | ||||
|                 } else { | ||||
|                   dictItem.cheked = false; | ||||
|                 } | ||||
|               }); | ||||
|             }); | ||||
|           }); | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| } | ||||
| @ -1,202 +0,0 @@ | ||||
| :host { | ||||
|   .toolbar-btn { | ||||
|     padding-left: 0; | ||||
|   } | ||||
|  | ||||
|   ::ng-deep { | ||||
|     .ant-checkbox-wrapper+.ant-checkbox-wrapper { | ||||
|       margin: 0; | ||||
|     } | ||||
|  | ||||
|     .listDiv { | ||||
|       cdk-virtual-scroll-viewport { | ||||
|         border: 1px solid rgba(242, 242, 240, 1); | ||||
|       } | ||||
|  | ||||
|       .selectedItem { | ||||
|         background: #e6f7ff; | ||||
|  | ||||
|         span { | ||||
|           a { | ||||
|             color: rgba(212, 72, 86, 1); | ||||
|           } | ||||
|         } | ||||
|  | ||||
|         ul>li>a>i { | ||||
|           color: rgba(212, 72, 86, 1); | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       .listBottom { | ||||
|         height          : 2.5rem; | ||||
|         overflow        : hidden; | ||||
|         text-align      : center; | ||||
|         background-color: rgba(245, 245, 245, 0.7); | ||||
|  | ||||
|         &:hover { | ||||
|           background-color: rgba(245, 245, 245, 1); | ||||
|           transition      : all 1s; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .ant-tabs-nav { | ||||
|       width : 100%; | ||||
|       margin: 0 !important; | ||||
|     } | ||||
|  | ||||
|     .buttons { | ||||
|       padding: 0; | ||||
|  | ||||
|       button { | ||||
|         display  : block; | ||||
|         max-width: 10rem; | ||||
|         margin   : 0.3rem 0.5rem 0 0; | ||||
|       } | ||||
|  | ||||
|       .ant-btn+.ant-btn:not(.ant-btn-link), | ||||
|       .ant-btn+nz-popconfirm, | ||||
|       nz-popconfirm+.ant-btn, | ||||
|       nz-popconfirm+nz-popconfirm, | ||||
|       .ant-btn+nz-button-group, | ||||
|       nz-button-group+.ant-btn, | ||||
|       .ant-btn+nz-dropdown, | ||||
|       nz-dropdown+.ant-btn, | ||||
|       nz-popconfirm+nz-button-group, | ||||
|       nz-button-group+nz-popconfirm { | ||||
|         margin-left: 0; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .ant-tabs-bar { | ||||
|       margin: 0; | ||||
|     } | ||||
|  | ||||
|     // .ant-tree-node-selected { | ||||
|     //   background: none !important; | ||||
|     // } | ||||
|     // .ant-tree-node-content-wrapper:hover { | ||||
|     //   background: none; | ||||
|     // } | ||||
|     .ant-tree-node-content-wrapper { | ||||
|       width: 100%; | ||||
|     } | ||||
|  | ||||
|     .ant-tabs .ant-tabs-tabpane { | ||||
|       padding      : 10px 10px 2px 10px; | ||||
|       background   : #fdfdfd; | ||||
|       border-right : solid 1px #eee; | ||||
|       border-bottom: solid 1px #eee; | ||||
|       border-left  : solid 1px #eee; | ||||
|     } | ||||
|  | ||||
|     // .ant-tabs-tab { | ||||
|     //   width: 50%; | ||||
|     //   text-align: center; | ||||
|     // } | ||||
|     // .ant-tabs-tab-arrow-show { | ||||
|     //   display: none; | ||||
|     // } | ||||
|     ul { | ||||
|       margin : 0; | ||||
|       padding: 0; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| .firstStepBox { | ||||
|   width      : 100%; | ||||
|   line-height: 50px; | ||||
|   text-align : center; | ||||
|   background : #f7f7f7; | ||||
| } | ||||
|  | ||||
| .itemBox { | ||||
|   width      : 100%; | ||||
|   height     : 50px; | ||||
|   padding    : 0 0 0 60px; | ||||
|   color      : #5f5f5f; | ||||
|   line-height: 50px; | ||||
|   cursor     : pointer; | ||||
|  | ||||
|   &:hover { | ||||
|     background: #e6f7ff; | ||||
|   } | ||||
| } | ||||
|  | ||||
| .twoStepBox { | ||||
|   width      : 100%; | ||||
|   line-height: 50px; | ||||
|   text-align : center; | ||||
|   background : #f7f7f7; | ||||
|  | ||||
|   span { | ||||
|     display: inline-block; | ||||
|     margin : 0 auto; | ||||
|   } | ||||
|  | ||||
|   >i { | ||||
|     float : right; | ||||
|     margin: 20px 20px 0 0; | ||||
|   } | ||||
|  | ||||
|   button { | ||||
|     float : right; | ||||
|     margin: 8px 20px 0 0; | ||||
|   } | ||||
|  | ||||
|   .blueFont { | ||||
|     color: #1890ff; | ||||
|   } | ||||
| } | ||||
|  | ||||
| .folder-desc i { | ||||
|   margin: 0 5px; | ||||
| } | ||||
|  | ||||
| .flexBox { | ||||
|   .titleBox { | ||||
|     display        : flex; | ||||
|     justify-content: space-between; | ||||
|  | ||||
|     i { | ||||
|       margin: 0 8px; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| ul { | ||||
|   display: block; | ||||
| } | ||||
|  | ||||
| li { | ||||
|   line-height: 30px; | ||||
|   list-style : none; | ||||
| } | ||||
|  | ||||
|  | ||||
| label { | ||||
|   color    : #666; | ||||
|   font-size: 13px; | ||||
| } | ||||
|  | ||||
| .treeWrap { | ||||
|   display: flex; | ||||
|   width  : 700px; | ||||
|  | ||||
|   .leftBox { | ||||
|     width     : 250px; | ||||
|     border    : 1px solid #d1d1d1; | ||||
|     max-height: 500px; | ||||
|     overflow  : auto; | ||||
|   } | ||||
|  | ||||
|   .rightBox { | ||||
|     flex        : 1; | ||||
|     margin      : 0 0 0 20px; | ||||
|     padding-left: 12px; | ||||
|     border      : 1px solid #d1d1d1; | ||||
|     max-height  : 500px; | ||||
|     overflow    : auto; | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user