edit-inspect-info2.component.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import { Component, OnInit, Output, Input } from '@angular/core';
  2. import { EventEmitter } from '@angular/core';
  3. import { NzMessageService } from 'ng-zorro-antd';
  4. import { addDays, startOfMinute, format } from 'date-fns';
  5. import { Subject } from "rxjs";
  6. import { debounceTime } from "rxjs/operators";
  7. import { ToolService } from 'src/app/services/tool.service';
  8. import { MainService } from '../../services/main.service';
  9. @Component({
  10. selector: 'app-edit-inspect-info2',
  11. templateUrl: './edit-inspect-info2.component.html',
  12. styleUrls: ['./edit-inspect-info2.component.less']
  13. })
  14. export class EditInspectInfo2Component implements OnInit {
  15. @Input() date:any;
  16. @Input() execDeptId:any;
  17. @Input() remarkText:any;
  18. @Input() applyDept:any = {};
  19. @Input() patient:any = {};
  20. @Input() execDeptList:any[] = [];
  21. @Output() submitFormHand = new EventEmitter();
  22. @Output() cancelFlagHand = new EventEmitter();
  23. yyDate = null; //预约日期-患者其他服务
  24. yyTime = null; //预约时间-患者其他服务
  25. deptId = null;
  26. remark = '';
  27. deptList:any[] = [];
  28. isLoading:boolean = false;
  29. hosId;
  30. changePatientSubject = new Subject(); //防抖
  31. changeApplyDeptSubject = new Subject(); //防抖
  32. constructor(
  33. private message: NzMessageService,
  34. private tool: ToolService,
  35. private mainService: MainService,
  36. ) { }
  37. ngOnInit() {
  38. this.changePatientSubject.pipe(debounceTime(500)).subscribe((v) => {
  39. this.getPatientList(v[0]);
  40. });
  41. this.changeApplyDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
  42. this.getApplyDeptList(v[0]);
  43. });
  44. this.hosId = this.tool.getCurrentHospital().id;
  45. if(this.applyDept){
  46. this.inspectData.applyDeptId = this.applyDept.id;
  47. this.applyDeptList = [this.applyDept];
  48. }
  49. if(this.patient){
  50. this.inspectData.patientId = this.patient.id;
  51. this.patientList = [this.patient];
  52. }
  53. if(this.date){
  54. this.yyDate = new Date(this.date);
  55. this.yyTime = new Date(this.date);
  56. }
  57. if(this.execDeptList){
  58. this.deptList = this.execDeptList;
  59. }
  60. console.log('this.remarkText:', this.remarkText)
  61. if(this.remarkText){
  62. this.remark = this.remarkText;
  63. }
  64. if(this.execDeptId){
  65. let flag = this.deptList.some(v => v.id == this.execDeptId);
  66. if(flag){
  67. this.deptId = this.execDeptId;
  68. }
  69. }
  70. }
  71. patientDTO:any = {};
  72. inspectData:any = {}; //检查项目
  73. changePatient(e){
  74. this.patientDTO = this.patientList.find(v => v.id == this.inspectData.patientId) || {};
  75. }
  76. changeApplyDept(e){
  77. this.inspectData.patientId = undefined;
  78. }
  79. // =========================申请科室=====================
  80. applyDeptList: Array<any>; //申请科室列表
  81. // 获取申请科室
  82. getApplyDeptList(keyword = '') {
  83. let postData = {
  84. idx: 0,
  85. sum: 10,
  86. department:{
  87. hospital: {
  88. id: this.hosId
  89. },
  90. dept: keyword
  91. }
  92. };
  93. this.isLoading = true;
  94. this.mainService
  95. .getFetchDataList("data", "department",postData)
  96. .subscribe((data:any) => {
  97. this.isLoading = false;
  98. this.applyDeptList = data.list || [];
  99. });
  100. }
  101. // 边输边搜节流阀
  102. searchApplyDept(e) {
  103. this.isLoading = true;
  104. this.changeApplyDeptSubject.next([e]);
  105. }
  106. // 打开
  107. openApplyDept(e){
  108. if(e){
  109. this.getApplyDeptList();
  110. }
  111. }
  112. // =========================申请科室=====================
  113. // =========================患者=====================
  114. patientList: Array<any>; //患者列表
  115. // 获取患者
  116. getPatientList(keyword = '') {
  117. let postData = {
  118. idx: 0,
  119. sum: 10,
  120. hosId: this.hosId,
  121. patientName: keyword || undefined,
  122. hasBedNum: 1,//有床号
  123. department: this.inspectData.applyDeptId,
  124. };
  125. this.isLoading = true;
  126. this.mainService
  127. .listMsgByMain('listPatient',postData)
  128. .subscribe((data:any) => {
  129. this.isLoading = false;
  130. this.patientList = data.list || [];
  131. });
  132. }
  133. // 边输边搜节流阀
  134. searchPatient(e) {
  135. this.isLoading = true;
  136. this.changePatientSubject.next([e]);
  137. }
  138. // 打开
  139. openPatient(e){
  140. if(e){
  141. this.getPatientList();
  142. }
  143. }
  144. // =========================患者=====================
  145. // 下一日(患者其他服务)
  146. nextDay() {
  147. this.yyDate = addDays(this.yyDate, 1);
  148. }
  149. // 隐藏模态框
  150. hideModal() {
  151. this.cancelFlagHand.emit(false)
  152. }
  153. // 表单提交
  154. submitForm(): void {
  155. if(!this.inspectData.applyDeptId) {
  156. this.message.warning('请选择申请科室!');
  157. return;
  158. }
  159. if(!this.inspectData.patientId) {
  160. this.message.warning('请选择患者信息!');
  161. return;
  162. }
  163. if(!this.deptId) {
  164. this.message.warning('请选择检查科室!');
  165. return;
  166. }
  167. if(!this.yyDate || !this.yyTime) {
  168. this.message.warning('请选择完整预约时间!');
  169. return;
  170. }
  171. this.submitFormHand.emit({
  172. applyDeptId: this.inspectData.applyDeptId,
  173. patientDTO: this.patientList.find(v => v.id == this.inspectData.patientId),
  174. deptId: this.deptId,
  175. remark: this.remark,
  176. date: format(this.yyDate, 'yyyy-MM-dd') + ' ' + format(startOfMinute(this.yyTime), 'HH:mm:ss'),
  177. });
  178. }
  179. }