123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- import { TabService } from './../../services/tab.service';
- import { debounceTime } from 'rxjs/operators';
- import { Subject } from 'rxjs';
- import { NzMessageService } from 'ng-zorro-antd/message';
- import { Component, OnInit, HostListener, AfterViewInit, ViewChild } from "@angular/core";
- import { MainService } from 'src/app/services/main.service';
- import { ActivatedRoute } from '@angular/router';
- import { CustomChangeDateComponent } from '../../components/custom-change-date/custom-change-date.component';
- @Component({
- selector: "app-floor-statistics",
- templateUrl: "./floor-statistics.component.html",
- styleUrls: ["./floor-statistics.component.less"],
- })
- export class FloorStatisticsComponent implements OnInit, AfterViewInit {
- @ViewChild('customChangeDate', { static: false }) customChangeDateComponent!: CustomChangeDateComponent;
- constructor(
- private mainService: MainService,
- private message: NzMessageService,
- private route: ActivatedRoute,
- private tabService: TabService,
- ) {}
- listOfData: any[] = []; //表格数据
- listOfDataEnd: any[] = []; //表格合计
- pageIndex: number = 1; //表格当前页码
- pageSize: number = 30; //表格每页展示条数
- listLength: number = 0; //表格总数据量
- buildingId;//楼栋id
- searchTimerSubject = new Subject();
- ngOnInit() {
- this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
- let fun = v[0];
- fun.call(this, v[1]);
- });
- }
- ngAfterViewInit(){
- this.initSessionData();
- this.getQueryParams();
- setTimeout(() => {
- this.search();
- }, 0)
- this.onResize();
- }
- tableHeight:number = 0;
- @HostListener('window:resize')
- onResize(): void {
- setTimeout(() => {
- this.tableHeight = window.innerHeight - (document.querySelector('.searchDataWrap') as HTMLElement).offsetHeight - 64 - 36 - 48 - 8 - (document.querySelector('.ant-table-header') as HTMLElement).offsetHeight - 55 - this.getMoreFilter + 14;
- }, 0)
- }
- getQueryParams(){
- let queryParams = this.tabService.getQueryParams();
- this.tabService.clearQueryParams();
- if(queryParams.dateRange){
- this.dateRange = queryParams.dateRange;
- this.customChangeDateComponent.initByDate(this.dateRange);
- }
- }
- get getMoreFilter(){
- let flag = this.fieldConfig.fields.category1DTO || this.fieldConfig.fields.category2DTO || this.fieldConfig.fields.category3DTO;
- return flag ? 37 : 0;
- }
- // 初始化缓存数据
- queryType:any;
- hosId:any;
- dutyId:any;
- parentDutyId:any;
- initSessionData(){
- let newStatistics = JSON.parse(sessionStorage.getItem('newStatistics'));
- let queryType:any = newStatistics.queryType;
- let hosId:any = newStatistics.hospitalId;
- let dutyId:any = newStatistics.dutyId;
- queryType = queryType ? +queryType : undefined;
- hosId = hosId ? +hosId : undefined;
- dutyId = dutyId ? +dutyId : undefined;
- this.queryType = queryType;
- if(queryType == 1){
- this.hosId = undefined;
- this.dutyId = undefined;
- this.parentDutyId = undefined;
- }else if(queryType == 2){
- this.hosId = hosId;
- this.dutyId = undefined;
- this.parentDutyId = undefined;
- }else if(queryType == 3){
- this.hosId = undefined;
- this.dutyId = dutyId;
- this.parentDutyId = undefined;
- }else if(queryType == 4){
- this.hosId = undefined;
- this.dutyId = undefined;
- this.parentDutyId = dutyId;
- }
- }
- get getHosId(){
- return this.parentDutyId || this.dutyId || this.hosId;
- }
- // 表格数据
- loading1 = false;
- getList(num?: number, field?: string, sort?: string) {
- if (num !== undefined) {
- this.pageIndex = num;
- }
- let postData:any = {
- idx: this.pageIndex - 1,
- sum: this.pageSize,
- startDate: this.customChangeDateComponent.startDate || undefined,
- endDate: this.customChangeDateComponent.endDate || undefined,
- hosId: this.hosId || undefined,
- dutyId: this.dutyId || undefined,
- parentDutyId: this.parentDutyId || undefined,
- buildingId: this.buildingId || undefined,
- categoryId: this.fieldConfig.fields.categoryId || undefined,
- hierarchy: this.fieldConfig.fields.hierarchy || undefined,
- };
- if (field && sort) {
- postData.sort = `${field} ${sort === "ascend" ? `asc` : `desc`}`
- }
- this.loading1 = true;
- this.mainService
- .postCustom("itsm/report", "floorIncident", postData)
- .subscribe((result) => {
- this.loading1 = false;
- this.listOfData = result.dataList.filter((v, i) => { return i != result.dataList.length - 1 });
- this.listOfDataEnd = result.dataList.filter((v, i) => { return i == result.dataList.length - 1 });
- this.listLength = result.totalCount;
- });
- }
- // 列表排序
- sortCurrent:any = {};
- sortCurrentKey: string = "";
- sortCurrentValue: string | null = "";
- sort(e) {
- const { key, value } = e;
- this.sortCurrentKey = key;
- this.sortCurrentValue = value;
- this.getList(this.pageIndex, this.sortCurrentKey, this.sortCurrentValue);
- }
- // 搜索
- search() {
- this.getList(1, this.sortCurrentKey, this.sortCurrentValue);
- }
- // 日期选择
- dateRange: any = [];
- // 导出
- excelExportLoading:any = false;
- excelExport(){
- this.excelExportLoading = this.message.loading("导出中..", {
- nzDuration: 0,
- }).messageId;
- let postData:any = {
- startDate: this.customChangeDateComponent.startDate || undefined,
- endDate: this.customChangeDateComponent.endDate || undefined,
- hosId: this.hosId || undefined,
- dutyId: this.dutyId || undefined,
- parentDutyId: this.parentDutyId || undefined,
- buildingId: this.buildingId || undefined,
- categoryId: this.fieldConfig.fields.categoryId || undefined,
- hierarchy: this.fieldConfig.fields.hierarchy || undefined,
- };
- if (this.sortCurrentKey && this.sortCurrentValue) {
- postData.sort = `${this.sortCurrentKey} ${this.sortCurrentValue === "ascend" ? `asc` : `desc`}`
- }
- this.mainService
- .postExportCustom("itsm/export", "floorIncident", postData)
- .subscribe((data) => {
- this.message.remove(this.excelExportLoading);
- this.excelExportLoading = false;
- this.message.success('导出成功');
- var file = new Blob([data], {
- type: "application/vnd.ms-excel",
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement("a");
- a.href = fileURL;
- a.target = "_blank";
- a.download = `${this.route.parent.routeConfig.data.title}.xls`;
- document.body.appendChild(a);
- a.click();
- },(err) => {
- this.message.remove(this.excelExportLoading);
- this.excelExportLoading = false;
- this.message.error('导出失败');
- });
- }
- // 重置
- reset(){
- this.sortCurrentKey = "";
- this.sortCurrentValue = "";
- this.sortCurrent = {};
- this.dateRange = []
- this.buildingId = undefined;
- this.fieldConfig.fields = {categoryId: undefined};
- this.customChangeDateComponent.resetByDate();
- this.search();
- }
- // 楼栋搜索
- changeBuildingInp(e) {
- this.searchTimer(this.getBuildingList, e);
- }
- // 防抖
- isLoading = false;
- searchTimer(fun, e) {
- this.isLoading = true;
- this.searchTimerSubject.next([fun, e]);
- }
- openChangeBuilding(flag){
- flag && this.getBuildingList();
- }
- // 获取报修科室列表
- buildingList:any[] = [];
- getBuildingList(keyword?) {
- let data = {
- building: {
- simpleQuery: true,
- buildingName: keyword,
- statisticalHosId:this.getHosId,
- },
- idx: 0,
- sum: 20,
- };
- this.isLoading = true;
- this.mainService
- .getFetchDataList("data", "building", data)
- .subscribe((data) => {
- this.isLoading = false;
- this.buildingList = data.list;
- });
- }
- // 详细搜索
- fieldConfig:any = {
- fields: {categoryId: undefined},
- config: {category123: true},
- }
- showSearchMore:boolean = false;
- showMore(){
- this.showSearchMore = true;
- }
- cancelEvent(){
- this.showSearchMore = false;
- }
- submitEvent(fields){
- this.showSearchMore = false;
- this.fieldConfig.fields = fields;
- console.log('this.fieldConfig.fields:', this.fieldConfig.fields)
- this.search();
- this.onResize();
- }
- }
|