edit-inspect-info2.component.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. this.patientDTO = this.patient;
  53. }
  54. if(this.date){
  55. this.yyDate = new Date(this.date);
  56. this.yyTime = new Date(this.date);
  57. }
  58. if(this.execDeptList){
  59. this.deptList = this.execDeptList;
  60. }
  61. console.log('this.remarkText:', this.remarkText)
  62. if(this.remarkText){
  63. this.remark = this.remarkText;
  64. }
  65. if(this.execDeptId){
  66. let flag = this.deptList.some(v => v.id == this.execDeptId);
  67. if(flag){
  68. this.deptId = this.execDeptId;
  69. }
  70. }
  71. }
  72. patientDTO:any = {};
  73. inspectData:any = {}; //检查项目
  74. changePatient(e){
  75. this.patientDTO = this.patientList.find(v => v.id == this.inspectData.patientId) || {};
  76. }
  77. changeApplyDept(e){
  78. this.inspectData.patientId = undefined;
  79. }
  80. // =========================申请科室=====================
  81. applyDeptList: Array<any>; //申请科室列表
  82. // 获取申请科室
  83. getApplyDeptList(keyword = '') {
  84. let postData = {
  85. idx: 0,
  86. sum: 10,
  87. department:{
  88. hospital: {
  89. id: this.hosId
  90. },
  91. dept: keyword
  92. }
  93. };
  94. this.isLoading = true;
  95. this.mainService
  96. .getFetchDataList("data", "department",postData)
  97. .subscribe((data:any) => {
  98. this.isLoading = false;
  99. this.applyDeptList = data.list || [];
  100. });
  101. }
  102. // 边输边搜节流阀
  103. searchApplyDept(e) {
  104. this.isLoading = true;
  105. this.changeApplyDeptSubject.next([e]);
  106. }
  107. // 打开
  108. openApplyDept(e){
  109. if(e){
  110. this.getApplyDeptList();
  111. }
  112. }
  113. // =========================申请科室=====================
  114. // =========================患者=====================
  115. patientList: Array<any>; //患者列表
  116. // 获取患者
  117. getPatientList(keyword = '') {
  118. let postData = {
  119. idx: 0,
  120. sum: 10,
  121. hosId: this.hosId,
  122. patientName: keyword || undefined,
  123. hasBedNum: 1,//有床号
  124. department: this.inspectData.applyDeptId,
  125. };
  126. this.isLoading = true;
  127. this.mainService
  128. .listMsgByMain('listPatient',postData)
  129. .subscribe((data:any) => {
  130. this.isLoading = false;
  131. this.patientList = data.list || [];
  132. });
  133. }
  134. // 边输边搜节流阀
  135. searchPatient(e) {
  136. this.isLoading = true;
  137. this.changePatientSubject.next([e]);
  138. }
  139. // 打开
  140. openPatient(e){
  141. if(e){
  142. this.getPatientList();
  143. }
  144. }
  145. // =========================患者=====================
  146. // 下一日(患者其他服务)
  147. nextDay() {
  148. this.yyDate = addDays(this.yyDate, 1);
  149. }
  150. // 隐藏模态框
  151. hideModal() {
  152. this.cancelFlagHand.emit(false)
  153. }
  154. // 表单提交
  155. submitForm(): void {
  156. if(!this.inspectData.applyDeptId) {
  157. this.message.warning('请选择申请科室!');
  158. return;
  159. }
  160. if(!this.inspectData.patientId) {
  161. this.message.warning('请选择患者信息!');
  162. return;
  163. }
  164. if(!this.deptId) {
  165. this.message.warning('请选择检查科室!');
  166. return;
  167. }
  168. if(!this.yyDate || !this.yyTime) {
  169. this.message.warning('请选择完整预约时间!');
  170. return;
  171. }
  172. this.submitFormHand.emit({
  173. applyDeptId: this.inspectData.applyDeptId,
  174. patientDTO: this.patientDTO,
  175. deptId: this.deptId,
  176. remark: this.remark,
  177. date: format(this.yyDate, 'yyyy-MM-dd') + ' ' + format(startOfMinute(this.yyTime), 'HH:mm:ss'),
  178. });
  179. }
  180. }