work-order-log.component.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 { WorkOrderLogService } from './work-order-log.service';
  6. import { format, startOfDay, endOfDay } from 'date-fns';
  7. @Component({
  8. selector: "app-work-order-log",
  9. templateUrl: "./work-order-log.component.html",
  10. styleUrls: ["./work-order-log.component.less"],
  11. })
  12. export class WorkOrderLogComponent 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 workOrderLogService: WorkOrderLogService,
  23. ) {}
  24. listOfData: any[] = []; //表格数据
  25. searchDto: any = {
  26. dateRange: [],
  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. this.getOperationList();
  39. }
  40. // 获取快捷类型
  41. operationList: any[] = [];
  42. getOperationList() {
  43. this.workOrderLogService.getDictionary("gdOperate").subscribe((res) => {
  44. this.operationList = res || [];
  45. });
  46. }
  47. // 预览图片
  48. imgs = [];
  49. isPreview = false;
  50. previewImageHandler(data) {
  51. this.isPreview = false;
  52. data = data || [];
  53. this.imgs = data.map((v) => location.origin + '/file' + v.relativeFilePath);
  54. this.isPreview = true;
  55. }
  56. // 搜索
  57. search() {
  58. this.getList(true);
  59. }
  60. // 重置
  61. reset() {
  62. this.searchDto = {
  63. dateRange: [],
  64. }
  65. this.search();
  66. }
  67. // 查看
  68. detail(e, id) {
  69. e.stopPropagation();
  70. this.router.navigateByUrl("/main/workOrderLog/orderDetail/" + id);
  71. }
  72. // 表格数据
  73. loading1 = false;
  74. getList(isResetPageIndex = false) {
  75. isResetPageIndex && (this.pageIndex = 1);
  76. let searchDto = {
  77. startTime: this.searchDto.dateRange[0] ? format(startOfDay(this.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined,
  78. endTime: this.searchDto.dateRange[1] ? format(endOfDay(this.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined,
  79. logRemarks: this.searchDto.logRemarks,
  80. operation: this.operationList.find(v => v.id == this.searchDto.operation),
  81. }
  82. let data = {
  83. pageIndex: this.pageIndex,
  84. pageSize: this.pageSize,
  85. hosId: this.hosId,
  86. searchDto,
  87. };
  88. this.loading1 = true;
  89. this.workOrderLogService
  90. .query(data)
  91. .subscribe((result) => {
  92. this.loading1 = false;
  93. result.list = result.list || [];
  94. result.list.forEach(v => {
  95. // todo
  96. })
  97. this.listOfData = result.list;
  98. this.listLength = result.totalNum;
  99. });
  100. }
  101. }