add-inspect-three-modal.component.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
  2. import { MainService } from '../../services/main.service';
  3. import { ToolService } from 'src/app/services/tool.service';
  4. import { startOfDay, format, addDays, addMinutes } from 'date-fns';
  5. import { NzMessageService } from 'ng-zorro-antd';
  6. import { Subject } from "rxjs";
  7. import { debounceTime } from "rxjs/operators";
  8. @Component({
  9. selector: 'app-add-inspect-three-modal',
  10. templateUrl: './add-inspect-three-modal.component.html',
  11. styleUrls: ['./add-inspect-three-modal.component.less']
  12. })
  13. export class AddInspectThreeModalComponent implements OnInit {
  14. // 切换科室,切换弹窗
  15. listOfDisplayData2: any[] = [];
  16. currentDept; //当前科室
  17. hosId;
  18. hsLoading = false;
  19. @Input() patientDTO: any;
  20. @Input() deptDisplay: any;
  21. @Input() inspectAndPatientTransportConfig:any = {};
  22. @Output() closeModelHs = new EventEmitter<any>();//1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
  23. @Output() confirmModelHs = new EventEmitter<any>();//1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
  24. constructor(
  25. private mainService: MainService,
  26. private tool: ToolService,
  27. private message: NzMessageService,
  28. ) { }
  29. inspectData:any = {
  30. date: new Date(),
  31. }; //检查项目
  32. changeInspectSubject = new Subject(); //防抖
  33. ngOnInit() {
  34. //防抖
  35. this.changeInspectSubject.pipe(debounceTime(500)).subscribe((v) => {
  36. this.getInspectList(v[0]);
  37. });
  38. this.hosId = this.tool.getCurrentHospital().id;
  39. this.currentDept = this.tool.getCurrentUserDept();
  40. console.log(777, this.inspectAndPatientTransportConfig)
  41. }
  42. // 确认弹窗
  43. confirmModal() {
  44. if(!this.inspectData.id){
  45. this.message.warning('请选择检查项目!');
  46. return;
  47. }
  48. if(!this.inspectData.execDeptId){
  49. this.message.warning('请选择检查科室!');
  50. return;
  51. }
  52. if(!this.inspectData.date){
  53. this.message.warning('请选择预约时间!');
  54. return;
  55. }
  56. if(!this.inspectData.time){
  57. this.message.warning('请选择预约时间!');
  58. return;
  59. }
  60. this.confirmModelHs.emit(JSON.stringify({ show: false, inspectData: this.inspectData }));//emits(向上弹射)事件
  61. }
  62. // 关闭弹窗
  63. hideModal() {
  64. this.closeModelHs.emit(JSON.stringify({ show: false }));//emits(向上弹射)事件
  65. }
  66. // 下一日
  67. nextDay() {
  68. this.inspectData.date = addDays(this.inspectData.date, 1);
  69. }
  70. // 选择日期
  71. mdData:any = format(this.inspectData.date, 'yyyy-MM-dd');
  72. dateChange(e){
  73. this.mdData = format(e, 'yyyy-MM-dd')
  74. this.setTimeData();
  75. }
  76. // 选择时间
  77. endTime:any;
  78. timeChange(e){
  79. if(e){
  80. this.setTimeData();
  81. }
  82. }
  83. // 设置结束时间
  84. setTimeData(){
  85. if(this.mdData && this.inspectData.time){
  86. let num = this.inspectDTO.extra1 ? Number(this.inspectDTO.extra1) : undefined
  87. let time = addMinutes(this.inspectData.time, num ? num : this.inspectAndPatientTransportConfig.yytimeGapMinute)
  88. let time2 = format(time, 'HH:mm')
  89. this.endTime = this.mdData +' '+ time2
  90. let date = new Date(this.endTime);
  91. this.inspectData.endCheckTime = date.getTime()
  92. }
  93. }
  94. isLoading = false;
  95. inspectList: Array<any>; //检查项目列表
  96. // 获取检查项目
  97. getInspectList(keyword = '') {
  98. let postData = {
  99. dictionary: {
  100. key: "inspect_check_type",
  101. keyword: keyword || undefined,
  102. },
  103. idx: 0,
  104. sum: 9999,
  105. };
  106. this.isLoading = true;
  107. this.mainService
  108. .getFetchDataList("simple/data", "dictionary", postData)
  109. .subscribe((data) => {
  110. this.isLoading = false;
  111. this.inspectList = data.list || [];
  112. });
  113. }
  114. // 边输边搜节流阀
  115. searchInspect(e) {
  116. this.isLoading = true;
  117. this.changeInspectSubject.next([e]);
  118. }
  119. // 修改检查项目
  120. inspectDTO:any = {};
  121. execDeptList:any[] = [];
  122. changeInspect(id){
  123. this.inspectDTO = this.inspectList.find(v => v.id == id);
  124. console.log(4545, this.inspectDTO)
  125. if(this.inspectDTO){
  126. this.setTimeData();
  127. this.inspectData.id = this.inspectDTO.id;
  128. this.execDeptList = this.inspectDTO.deptList || [];
  129. this.inspectData.execDeptId = this.execDeptList.length === 1 ? this.execDeptList[0].id : undefined;
  130. this.inspectData.sign = this.inspectDTO.extra6 || '';
  131. this.inspectData.type = this.inspectDTO.extra5DTO ? this.inspectDTO.extra5DTO.name : '';
  132. }else{
  133. this.inspectData.id = undefined;
  134. this.inspectData.execDeptId= undefined;
  135. this.execDeptList = [];
  136. this.inspectData.sign = '';
  137. this.inspectData.type = '';
  138. }
  139. }
  140. // 打开班次
  141. openInspect(e){
  142. if(e){
  143. this.getInspectList();
  144. }
  145. }
  146. }