import { Component , OnInit , Injector , Input , ViewChild } from '@angular/core' ; import { BaseStandComponent } from '@shared/base/base.stand.component' ; import { BaseSelectorComponent } from '@shared/base/base.selector' ; @ Component ( { selector : 'app-permission-page' , templateUrl : './permission.html' , styles : [ ] } ) export class PermissionPageComponent extends BaseStandComponent implements OnInit { url ; @ Input ( ) domain = 'menu' ; title = '接口访问配置' ; selectedItem : any = { } ; permissions = [ ] ; _queryParams : { [ key ] : any ; } = { } ; slaveQueryParams : { [ key ] : any ; } = { } ; slaveColumns ; slaveFormSets ; @ ViewChild ( 'slaves' ) slaves : BaseStandComponent ; set queryParams ( val ) { this . _queryParams = val ; } get queryParams ( ) { const params = Object . assign ( { } , { isMenu : false } , this . _queryParams ) ; return params ; } constructor ( injector ) { super ( injector ) ; } async ngOnInit ( ) { this . url = `api/${ this . domain }/query` ; this . onConfigChanged . subscribe ( ( ) => { } ) ; this . load ( ) ; this . coreService . appearancesGetAppearanceByName ( 'api' ) . subscribe ( ( res ) => { if ( res ) { this . slaveColumns = res . options ; this . slaveFormSets = res . data ; } } ) ; const self = this ; this . operations = { title : '操作' , width : '180px' , buttons : [ { text : '移出' , type : 'del' , click : ( record ) => { } } ] } ; } addApiPermission ( ) { const self = this ; this . modalHelper . static ( BaseSelectorComponent , { queryUrl : 'api/api/query' , columns : this . slaveColumns , formSets : this . slaveFormSets , } , 1170 , { nzTitle : '添加接口权限' , } ) . subscribe ( ( res ) => { if ( res ) { const ids = res . map ( a => a . id ) ; } } ) ; } select ( item ) { this . selectedItem = item ; this . slaveQueryParams = { permission : item . id } ; if ( this . slaves ) { this . slaves . queryParams = this . slaveQueryParams ; this . slaves . reload ( ) ; } } }