import { HttpClient } from '@angular/common/http'; import { Component, ElementRef, OnInit, ViewContainerRef } from '@angular/core'; import { NzMessageService } from 'ng-zorro-antd/message'; import { NzModalService } from 'ng-zorro-antd/modal'; import { Observable, fromEvent } from 'rxjs'; import { debounceTime } from 'rxjs/operators'; import { DetailsFileCategoryComponent } from '../../license/file-category/details-file-category/details-file-category.component'; import { DetailsUpdateCategoryComponent } from '../../license/update-category/details-update-category/details-update-category.component'; import { AuditDetailsInformTimeComponent } from '../audit-inform-time/audit-details-inform-time/audit-details-inform-time.component'; import { GasBaseInfoComponent } from '../gas-base-info/gas-base-info.component'; import { AuditDisposeComponent } from './audit-dispose/audit-dispose.component'; import { UserDetailsComponent } from './user-details/user-details.component'; @Component({ selector: 'app-audit-ing', templateUrl: './audit-ing.component.html', styleUrls: ['./audit-ing.component.scss'] }) export class AuditIngComponent implements OnInit { constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private http: HttpClient, private message: NzMessageService, private element: ElementRef) { } tableSpin = false tableScrollHeight resizeListener level ngOnInit(): void { this.tableScrollHeight = '100px' // 页面监听 this.resizeListener = 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 - 10) + 'px' }); this.getStationList() this.level = JSON.parse(sessionStorage.getItem('userdata')).organization.level } ngOnDestroy(): void { this.resizeListener.unsubscribe() } ngAfterViewInit(): void { fromEvent(this.element.nativeElement.querySelector(`.ant-table-body`) as HTMLCanvasElement, 'scroll').pipe(debounceTime(100)).subscribe((event: any) => { //监听 DOM 滚动事件 if (event.target.scrollHeight - (event.target.scrollTop + event.target.clientHeight) <= 10) { if (this.totalCount > this.list.length) { this.SkipCount = String(Number(this.SkipCount) + 50) this.getStationList() } } }); } list = [] totalCount;//列表总数 SkipCount: string = '0'; MaxResultCount: string = '50'; //获取当前油站档案类证照 getStationList() { this.tableSpin = true let data = JSON.parse(sessionStorage.getItem('userdata')); let params = { OrganizationUnitId: data.organization.id || "", IsContainsChildren: "true", AuditStatuses: "1", SkipCount: this.SkipCount, MaxResultCount: this.MaxResultCount, } this.http.get(`/api/services/app/ContentAuditLog/GetAuditting`, { params }).subscribe((info: any) => { info.result.items.forEach(element => { element.itemData = JSON.parse(element.itemData) }); this.list = this.list.concat(info.result.items); this.list = [...this.list] this.totalCount = info.result.totalCount this.tableSpin = false setTimeout(() => { let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' }, 0); console.log(this.list) }) } dispose(item) { // console.log(item) this.getData(item).then(res => { // console.log('审批具体信息', res) item.getData = res const modal = this.modal.create({ nzContent: AuditDisposeComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: item.auditType == 0 ? 700 : 600, nzBodyStyle: { 'border': '1px solid #91CCFF', 'border-radius': '0px', 'padding': '7px', 'box-shadow': '0 0 8px 0 #fff', 'background-image': 'linear-gradient(#003665, #000f25)' }, nzStyle: { 'top': '50px', }, nzComponentParams: { data: item }, nzFooter: null, nzClosable: false, nzOnOk: async () => { await new Promise(resolve => { let url = '/api/services/app/ContentAuditLog/Audit' let params = { id: item.id, rejectReason: instance.textarea } let body = instance.isPass ? 2 : 3; this.http.post(url, body, { params }).subscribe(data => { resolve(data); this.list = [] this.SkipCount = '0' this.getStationList(); this.message.create('success', '审核完成!'); return true }) }) } }); const instance = modal.getContentComponent(); modal.afterClose.subscribe(result => { }); }) } details(item) { let itemCopy = JSON.parse(JSON.stringify(item)) let component if (item.auditType == 0) { component = GasBaseInfoComponent } else if (item.auditType == 1) { component = AuditDetailsInformTimeComponent } else if (item.auditType == 2) { component = DetailsUpdateCategoryComponent } else if (item.auditType == 4) { component = UserDetailsComponent } else if (item.auditType) { component = DetailsFileCategoryComponent } this.getData(item).then((res: any) => { item.getData = res if (item.auditType == 1) { item.getData.isYearlyCheckDefault = res.licenseType.isYearlyCheck } const modal = this.modal.create({ nzContent: component, nzViewContainerRef: this.viewContainerRef, nzWidth: item.auditType == 0 ? 700 : 450, nzBodyStyle: { 'border': '1px solid #91CCFF', 'border-radius': '0px', 'padding': '7px', 'box-shadow': '0 0 8px 0 #fff', 'background-image': 'linear-gradient(#003665, #000f25)' }, nzStyle: { 'top': '50px', }, nzComponentParams: { data: item.getData }, nzFooter: null, nzClosable: false, }); }) } //获取证照类data getData(item) { let url if (item.auditType == 0) { //油站基本信息 return new Promise((resolve, reject) => { let organization = { organizationId: item.organizationId } resolve(organization) }) } else if (item.auditType == 1) { url = '/api/services/app/OrganizationValidityLicenseRule/Get' } else if (item.auditType == 2) { url = '/api/services/app/StationValidityLicense/Get' } else if (item.auditType == 4) { url = '/api/services/app/EdittingUser/Get' } else if (item.auditType) { url = '/api/services/app/StationFileLicense/Get' } return new Promise((resolve, reject) => { let params = { id: item.itemId } console.log('xxxxxxxxxxxxxxx走着了吗') this.http.get(url, { params }).subscribe((data: any) => { let auditLog = { rejectReason: item.rejectReason } let organization = { displayName: item.organization ? item.organization.displayName : "" } if (item.auditType == 1) { data.result.auditLog = auditLog data.result.organization = organization data.result.handleRemindDaysDefault = data.result.licenseType.handleRemindDays data.result.closingRemindDaysDefault = data.result.licenseType.closingRemindDays } if (item.auditType == 2 || item.auditType == 3) { data.result.auditLogId = item.id } resolve(data.result) }) }) } }