import { TabService } from './../../services/tab.service';
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, Router } from '@angular/router';
import { ToolService } from "../../../../services/tool.service";
import { Subject } from "rxjs";
import { debounceTime } from "rxjs/operators";
import { CustomChangeDateComponent } from '../../components/custom-change-date/custom-change-date.component';

@Component({
  selector: "app-department-incident-statistics",
  templateUrl: "./department-incident-statistics.component.html",
  styleUrls: ["./department-incident-statistics.component.less"],
})
export class DepartmentIncidentStatisticsComponent implements OnInit, AfterViewInit {
  @ViewChild('customChangeDate', { static: false }) customChangeDateComponent!: CustomChangeDateComponent;
  constructor(
    private mainService: MainService,
    private message: NzMessageService,
    private route: ActivatedRoute,
		private router: Router,
    private tabService: TabService,
		private tool: ToolService,
  ) {}

  listOfData: any[] = []; //表格数据
  listOfDataEnd: any[] = []; //表格合计
  pageIndex: number = 1; //表格当前页码
  pageSize: number = 30; //表格每页展示条数
  listLength: number = 0; //表格总数据量
	hospital:any;
  deptTypeId;//科室类型id
	deptId;
	searchTimerSubject = new Subject();

  ngOnInit() {
		this.hospital = this.tool.getCurrentHospital().id
		this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
		  let fun = v[0];
		  fun.call(this, v[1]);
		});
  }

  ngAfterViewInit(){
    this.initSessionData();
    this.getQueryParams();
		this.getDeparts();
    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)
  }
	
	// 数据下钻
	viewDetail1(data, type){
		let query = null
		if(type=='all'){
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: this.deptId,
				searchQuery:{
					statusValue: 'close',
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
				}
			}
		}else{
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: data.repairDeptId || undefined,
				searchQuery:{
					statusValue: 'close',
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
				}
			}
		}

		let path = '/newStatistics/maintenanceStatistics/incidentList'
		let flag = this.tabService.tabs.some(v => v.path === path);
		flag && this.tabService.deleteRouteSnapshot(path);
		this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
		this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
		sessionStorage.setItem('maintenanceData', JSON.stringify(query))
		this.router.navigate([path], { replaceUrl: true });
	}
	
	// 数据下钻
	viewDetail2(data, type){
		let query = null
		if(type=='all'){
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: this.deptId,
				searchQuery:{
					statusValue: 'close',
					overtimeId: 1,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					overtimeDTO:{
						id: 1,
						name: "是"
					},
				}
			}
		}else{
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: data.repairDeptId || undefined,
				searchQuery:{
					statusValue: 'close',
					overtimeId: 1,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					overtimeDTO:{
						id: 1,
						name: "是"
					},
				}
			}
		}

		let path = '/newStatistics/maintenanceStatistics/incidentList'
		let flag = this.tabService.tabs.some(v => v.path === path);
		flag && this.tabService.deleteRouteSnapshot(path);
		this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
		this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
		sessionStorage.setItem('maintenanceData', JSON.stringify(query))
		this.router.navigate([path], { replaceUrl: true });
	}
	
	// 数据下钻
	viewDetail3(data, type){
		let query = null
		if(type=='all'){
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: this.deptId,
				searchQuery:{
					statusValue: 'close',
					isHangId: 1,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					isHangDTO:{
						id: 1,
						name: "是"
					},
				}
			}
		}else{
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: data.repairDeptId || undefined,
				searchQuery:{
					statusValue: 'close',
					isHangId: 1,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					isHangDTO:{
						id: 1,
						name: "是"
					},
				}
			}
		}

		let path = '/newStatistics/maintenanceStatistics/incidentList'
		let flag = this.tabService.tabs.some(v => v.path === path);
		flag && this.tabService.deleteRouteSnapshot(path);
		this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
		this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
		sessionStorage.setItem('maintenanceData', JSON.stringify(query))
		this.router.navigate([path], { replaceUrl: true });
	}
	
	// 数据下钻
	viewDetail4(data, type){
		let query = null
		if(type=='all'){
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: this.deptId,
				searchQuery:{
					statusValue: 'close',
					evaluateId: 20424,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					evaluateDTO: {
						"id": 20424,
						"key": "incident_degree",
						"name": "不满意",
						"value": "1",
						"orders": 5,
						"extra1": "",
						"extra2": ""
					}
				}
			}
		}else{
			query = {
				startDate: this.customChangeDateComponent.startDate || undefined,
				endDate: this.customChangeDateComponent.endDate || undefined,
				repairDeptId: data.repairDeptId || undefined,
				searchQuery:{
					statusValue: 'close',
					evaluateId: 20424,
					categoryId: this.fieldConfig.fields.categoryId || undefined,
					hierarchy: this.fieldConfig.fields.hierarchy || undefined,
					buildingId: this.fieldConfig.fields.buildingId || undefined,
					floorId: this.fieldConfig.fields.floorId || undefined,
					groupId: this.fieldConfig.fields.groupId || undefined,
					deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
					userId: this.fieldConfig.fields.userId || undefined,
					placeId: this.fieldConfig.fields.floorId || undefined,
					category1DTO: this.fieldConfig.fields.category1DTO || undefined,
					category2DTO: this.fieldConfig.fields.category2DTO || undefined,
					category3DTO: this.fieldConfig.fields.category3DTO || undefined,
					buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
					floorDTO: this.fieldConfig.fields.floorDTO || undefined,
					groupDTO: this.fieldConfig.fields.groupDTO || undefined,
					userDTO: this.fieldConfig.fields.userDTO || undefined,
					deptTypeDTO: this.fieldConfig.fields.deptTypeDTO || undefined,
					evaluateDTO: {
						"id": 20424,
						"key": "incident_degree",
						"name": "不满意",
						"value": "1",
						"orders": 5,
						"extra1": "",
						"extra2": ""
					}
				}
			}
		}

		let path = '/newStatistics/maintenanceStatistics/incidentList'
		let flag = this.tabService.tabs.some(v => v.path === path);
		flag && this.tabService.deleteRouteSnapshot(path);
		this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
		this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
		sessionStorage.setItem('maintenanceData', JSON.stringify(query))
		this.router.navigate([path], { replaceUrl: true });
	}
	
  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.groupDTO || this.fieldConfig.fields.userDTO || this.fieldConfig.fields.category1DTO || this.fieldConfig.fields.category2DTO || this.fieldConfig.fields.category3DTO || this.fieldConfig.fields.buildingDTO || this.fieldConfig.fields.floorDTO;
    return flag ? 37 : 0;
  }

  // 初始化缓存数据
  queryType:any;
  hosId:any;
  dutyId:any;
	parent: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;
		this.parent = newStatistics.parent;

    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;
	widthStyle:any;
	widthValue:any;
	widthConfig:any = [];
  getList(num?: number, field?: string, sort?: string) {
    if (num !== undefined) {
      this.pageIndex = num;
    }
    let postData:any = {
      idx: this.pageIndex - 1,
      sum: this.pageSize,
			showParentDept: this.parent==1 ? 'true' : undefined,
      startDate: this.customChangeDateComponent.startDate || undefined,
      endDate: this.customChangeDateComponent.endDate || undefined,
      hosId: this.hosId || undefined,
      dutyId: this.dutyId || undefined,
			repairDeptId: this.deptId || undefined,
      parentDutyId: this.parentDutyId || undefined,
      deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
      groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
      userId: this.fieldConfig.fields.userId || undefined,
      categoryId: this.fieldConfig.fields.categoryId || undefined,
      hierarchy: this.fieldConfig.fields.hierarchy || undefined,
      buildingId: this.fieldConfig.fields.buildingId || undefined,
      placeId: this.fieldConfig.fields.floorId || undefined,
    };
    if (field && sort) {
      postData.sort = `${field} ${sort === "ascend" ? `asc` : `desc`}`
    }
		if(this.parent==1){
			this.widthConfig = new Array(12).fill('100px').map((v, i) => { return (i == 0 || i == 1 && this.parent==1) || (i == 0 && this.parent==0) ? '150px' : '100px' });;
			this.widthStyle = '8%'
			this.widthValue = 1920
		}else{
			this.widthConfig = new Array(11).fill('100px').map((v, i) => { return (i == 0 || i == 1 && this.parent==1) || (i == 0 && this.parent==0) ? '150px' : '100px' });;
			this.widthStyle = '9%'
			this.widthValue = 1920
		}
    this.loading1 = true;
    this.mainService
      .postCustom("itsm/report", "repairDept", 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 = {
			showParentDept: this.parent==1 ? 'true' : undefined,
      startDate: this.customChangeDateComponent.startDate || undefined,
      endDate: this.customChangeDateComponent.endDate || undefined,
      hosId: this.hosId || undefined,
      dutyId: this.dutyId || undefined,
      parentDutyId: this.parentDutyId || undefined,
			deptTypeId: this.fieldConfig.fields.deptTypeId || undefined,
			repairDeptId: this.deptId || undefined,
      groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
      userId: this.fieldConfig.fields.userId || undefined,
      categoryId: this.fieldConfig.fields.categoryId || undefined,
      hierarchy: this.fieldConfig.fields.hierarchy || undefined,
      buildingId: this.fieldConfig.fields.buildingId || undefined,
      placeId: this.fieldConfig.fields.floorId || undefined,
    };
    if (this.sortCurrentKey && this.sortCurrentValue) {
      postData.sort = `${this.sortCurrentKey} ${this.sortCurrentValue === "ascend" ? `asc` : `desc`}`
    }
    this.mainService
      .postExportCustom("itsm/export", "repairDept", 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.deptId = undefined;
    this.fieldConfig.fields = {groupId: undefined, userId: undefined, categoryId: undefined, buildingId: undefined, floorId: undefined, deptTypeId: undefined};
    this.customChangeDateComponent.resetByDate();
		sessionStorage.removeItem('maintenanceData');
    setTimeout(_=>{
    	this.search();
    })
  }

  // 防抖
  isLoading = false;
  openChangeDeptType(flag){
    flag && this.getDeptTypeList();
  }

	// 科室搜索
  changeInp(e) {
    this.searchTimer(this.getDeparts, e);
  }

	// 边输入边搜索节流阀
	searchTimer(fun, e) {
	  this.isLoading = true;
	  this.searchTimerSubject.next([fun, e]);
	}

	// 获取所有科室
	alldepart:any;
	getDeparts(dept?) {
	  let data = {
			department: {
			  statisticalHosId: this.getHosId,
			  dept: dept,
			  searchType: 1,
			},
	    idx: 0,
	    sum: 20,
	  };
	  this.mainService
	    .getFetchDataList("data", "department", data)
	    .subscribe((data) => {
				this.isLoading = false;
	      this.alldepart = data.list;
	    });
	}

  // 获取科室类型列表
  deptTypeList:any[] = [];
  getDeptTypeList(keyword?) {
    this.isLoading = true;
    this.mainService
      .getDictionary("list", "dept_type")
      .subscribe((data) => {
        this.isLoading = false;
        this.deptTypeList = data;
      });
  }

  // 详细搜索
  fieldConfig:any = {
    fields: {groupId: undefined, userId: undefined, categoryId: undefined, buildingId: undefined, floorId: undefined, deptTypeId: undefined},
    config: {groupAndUser: true, category123: true, buildingAndFloor: true, deptType: 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();
  }
}
