dept-inspection-rate-statistics.component.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  4. import { ToolService } from "../../services/tool.service";
  5. import { format, startOfDay, endOfDay, previousMonday, previousSunday } from 'date-fns';
  6. import { DeptInspectionRateStatisticsService } from './dept-inspection-rate-statistics.service';
  7. @Component({
  8. selector: "app-dept-inspection-rate-statistics",
  9. templateUrl: "./dept-inspection-rate-statistics.component.html",
  10. styleUrls: ["./dept-inspection-rate-statistics.component.less"],
  11. })
  12. export class DeptInspectionRateStatisticsComponent implements OnInit {
  13. @ViewChild("osComponentRef1", {
  14. read: OverlayScrollbarsComponent,
  15. static: false,
  16. })
  17. osComponentRef1: OverlayScrollbarsComponent;
  18. constructor(
  19. private router: Router,
  20. private route: ActivatedRoute,
  21. private tool: ToolService,
  22. private deptInspectionRateStatisticsService: DeptInspectionRateStatisticsService,
  23. ) {}
  24. listOfData: any[] = []; //表格数据
  25. searchDto: any = {
  26. dateRange: [previousMonday(new Date()), previousSunday(new Date())],
  27. }
  28. hosId: any; //院区(搜索)
  29. pageIndex: number = 1; //页码
  30. listLength: number = 10; //总条数
  31. pageSize: number = 10; //每页条数
  32. // 初始化增删改按钮
  33. coopBtns: any = {};
  34. ngOnInit() {
  35. this.coopBtns = this.tool.initCoopBtns(this.route);
  36. this.hosId = this.tool.getCurrentHospital().id;
  37. this.getList(true);
  38. }
  39. // 搜索
  40. search() {
  41. this.getList(true);
  42. }
  43. // 重置
  44. reset() {
  45. this.searchDto = {
  46. dateRange: [previousMonday(new Date()), previousSunday(new Date())],
  47. }
  48. this.search();
  49. }
  50. // 表格数据
  51. loading1 = false;
  52. getList(isResetPageIndex = false) {
  53. isResetPageIndex && (this.pageIndex = 1);
  54. let postData:any = {
  55. idx: this.pageIndex - 1,
  56. sum: this.pageSize,
  57. hosId: this.hosId,
  58. startTime: this.searchDto.dateRange[0] ? format(startOfDay(this.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined,
  59. endTime: this.searchDto.dateRange[1] ? format(endOfDay(this.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined,
  60. };
  61. this.loading1 = true;
  62. this.deptInspectionRateStatisticsService
  63. .query(postData)
  64. .subscribe((result) => {
  65. this.loading1 = false;
  66. result.list = result.list || [];
  67. this.listOfData = result.list;
  68. this.listLength = result.totalNum;
  69. });
  70. }
  71. // 查看业务数据
  72. businessDataModalShow = false; //业务数据弹窗开关
  73. businessDataModalType = ''; //业务数据类型
  74. dataInfo = null; //查看业务数据携带
  75. viewDetail(data, type) {
  76. this.dataInfo = data;
  77. this.businessDataModalType = type;
  78. this.businessDataModalShow = true;
  79. }
  80. // 关闭业务数据弹窗
  81. closeModelBlood(e) {
  82. this.businessDataModalShow = JSON.parse(e).show;
  83. }
  84. personDetail(dataInfo){
  85. let startDate = dataInfo.searchDto.dateRange[0] ? format(startOfDay(dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : 'null';
  86. let endDate = dataInfo.searchDto.dateRange[1] ? format(endOfDay(dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : 'null';
  87. let deptId = dataInfo.data.deptId || 'null';
  88. this.router.navigateByUrl(
  89. `/main/deptInspectionRateStatistics/workerStatisticsDetail/null/${startDate}/${endDate}/null/deptInspectionRateStatistics/${deptId}`
  90. );
  91. }
  92. }