@ -11,6 +11,7 @@ import { debounceTime } from 'rxjs/operators';
import 'linqjs' ;
import { DetailsUpdateCategoryComponent } from '../../license/update-category/details-update-category/details-update-category.component' ;
import { NzModalService } from 'ng-zorro-antd/modal' ;
import { NzMessageService } from 'ng-zorro-antd/message' ;
@Component ( {
selector : 'app-file-license-list' ,
@ -20,27 +21,63 @@ import { NzModalService } from 'ng-zorro-antd/modal';
export class FileLicenseListComponent implements OnInit {
validateForm ! : FormGroup ;
constructor ( private modal : NzModalService , private viewContainerRef : ViewContainerRef , private element : ElementRef , private navChangeService : NavChangeService , private http : HttpClient , private toTree : TreeService , private fb : FormBuilder , private nzContextMenuService : NzContextMenuService , private router : Router ) { }
constructor ( private modal : NzModalService , private viewContainerRef : ViewContainerRef , private element : ElementRef , private navChangeService : NavChangeService , private http : HttpClient , private toTree : TreeService , private fb : FormBuilder , private nzContextMenuService : NzContextMenuService , private router : Router , private message : NzMessageService ) { }
tableScrollHeight
ngOnInit ( ) : void {
async ngOnInit ( ) : Promise < void > {
this . tableScrollHeight = '100px'
console . log ( 'tableScrollHeight' , this . tableScrollHeight )
// 页面监听
fromEvent ( window , 'resize' ) . pipe ( debounceTime ( 100 ) ) . subscribe ( ( event ) = > {
let tableHeader = this . element . nativeElement . querySelector ( ` .ant-table-header ` ) . clientHeight
this . tableScrollHeight = ( document . getElementById ( 'tablebox' ) . clientHeight - tableHeader - 3 0) + 'px'
this . tableScrollHeight = ( document . getElementById ( 'tablebox' ) . clientHeight - tableHeader - 1 0) + 'px'
} ) ;
this . validateForm = this . fb . group ( {
organization : [ null ] ,
name : [ null ]
} ) ;
this . tableSpin = true
await this . getAllOrganization ( )
this . getStationLicenses ( )
}
ngAfterViewInit ( ) : void {
//获取所有组织机构
nodes : any = [ ]
async getAllOrganization() {
let OrganizationUnitId = JSON . parse ( sessionStorage . getItem ( 'userdata' ) ) . organization . id
let params = {
OrganizationUnitId : OrganizationUnitId ,
IsContainsChildren : "true"
}
await new Promise ( ( resolve , reject ) = > {
this . http . get ( '/api/services/app/Organization/GetAll' , {
params : params
} ) . subscribe ( ( data : any ) = > {
data . result . items . forEach ( element = > {
if ( element . id == OrganizationUnitId ) {
element . parentId = null
}
element . key = element . id
element . title = element . displayName
} ) ;
this . nodes = [ . . . this . toTree . toTree ( data . result . items ) ]
this . validateForm . patchValue ( {
organization : JSON.parse ( sessionStorage . getItem ( 'userdata' ) ) . organization . id ,
} ) ;
resolve ( data )
} )
} )
}
ngAfterViewInit ( ) : void {
fromEvent ( this . element . nativeElement . querySelector ( ` .ant-table-body ` ) as HTMLCanvasElement , 'scroll' ) . pipe ( debounceTime ( 100 ) ) . subscribe ( async ( event : any ) = > { //监听 DOM 滚动事件
if ( event . target . scrollHeight - ( event . target . scrollTop + event . target . clientHeight ) <= 10 ) {
if ( this . totalCount > this . list . length ) {
@ -68,6 +105,9 @@ export class FileLicenseListComponent implements OnInit {
this . validateForm . controls [ key ] . markAsPristine ( ) ;
this . validateForm . controls [ key ] . updateValueAndValidity ( ) ;
}
this . validateForm . patchValue ( {
organization : JSON.parse ( sessionStorage . getItem ( 'userdata' ) ) . organization . id ,
} ) ;
this . list = [ ]
this . SkipCount = '0'
this . getStationLicenses ( )
@ -84,7 +124,7 @@ export class FileLicenseListComponent implements OnInit {
async getStationLicenses() {
let params = {
StationName : this.validateForm.value.name ,
OrganizationUnitId : String ( sessionStorage . getItem ( 'planAdminOrid' ) ) ,
OrganizationUnitId : this.validateForm.value.organization ,
IsContainsChildren : 'true' ,
SkipCount : this.SkipCount ,
MaxResultCount : this.MaxResultCount ,
@ -124,18 +164,16 @@ export class FileLicenseListComponent implements OnInit {
} ) ;
this . list = this . list . concat ( arr ) ;
this . list = [ . . . this . list ]
console . log ( '证照表格' , this . list )
this . tableSpin = false
setTimeout ( ( ) = > {
let tableHeader = this . element . nativeElement . querySelector ( ` .ant-table-header ` ) . clientHeight
this . tableScrollHeight = ( document . getElementById ( 'tablebox' ) . clientHeight - tableHeader - 3 0) + 'px'
this . tableScrollHeight = ( document . getElementById ( 'tablebox' ) . clientHeight - tableHeader - 10 ) + 'px'
} , 0 ) ;
this . list = this . list . concat ( arr ) ;
this . list = [ . . . this . list ]
console . log ( '证照表格' , this . list )
this . tableSpin = false
resolve ( data )
} )
@ -148,37 +186,28 @@ export class FileLicenseListComponent implements OnInit {
}
lookDetails ( i ) {
// console.log(i)
// let params = {
// Id: i.licenseId
// }
// this.http.get('/api/services/app/StationValidityLicense/Get', { params: params }).subscribe((data: any) => {
// console.log('证照信息', data)
// const modal = this.modal.create({
// nzContent: DetailsUpdateCategoryComponent,
// nzViewContainerRef: this.viewContainerRef,
// nzWidth: 450,
// nzBodyStyle: {
// 'border': '1px solid #91CCFF',
// 'border-radius': '0px',
// 'padding': '7px',
// 'box-shadow': '0 0 8px 0 #fff',
// 'background-image': 'linear-gradient(#003665, #000f25)'
// },
// nzComponentParams: {
// data: data.result
// },
// nzFooter: null,
// nzClosable: false,
// nzOnOk: async () => {
// }
// });
// const instance = modal.getContentComponent();
// modal.afterClose.subscribe(result => { });
// })
exportExcel() {
// console.log(this.validateForm)
const httpOptions = {
responseType : 'blob' as 'json' ,
params : {
OrganizationUnitId : this.validateForm.value.organization
}
} ;
this . http . get ( ` /api/services/app/StationFileLicense/ExportStationLicenses ` , httpOptions ) . subscribe ( ( data : any ) = > {
// console.log('导出成功')
// 文件名中有中文 则对文件名进行转码
const link = document . createElement ( 'a' ) ;
const blob = new Blob ( [ data ] , { type : 'application/vnd.ms-excel' } ) ;
link . setAttribute ( 'href' , window . URL . createObjectURL ( blob ) ) ;
link . setAttribute ( 'download' , '资产类证照' + '.xls' ) ;
link . style . visibility = 'hidden' ;
document . body . appendChild ( link ) ;
link . click ( ) ;
document . body . removeChild ( link ) ;
this . message . create ( 'success' , ` 导出成功 ` ) ;
} , err = > {
this . message . create ( 'error' , ` 导出失败 ` ) ;
} )
}
}