edit-inspect-info2.component.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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, addMinutes } 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. @Input() extra1:any;
  22. @Input() inspectAndPatientTransportConfig:any = {};
  23. @Input() endCheckTime:any = null;
  24. @Output() submitFormHand = new EventEmitter();
  25. @Output() cancelFlagHand = new EventEmitter();
  26. yyDate = null; //预约日期-患者其他服务
  27. yyTime = null; //预约时间-患者其他服务
  28. deptId = null;
  29. remark = '';
  30. deptList:any[] = [];
  31. isLoading:boolean = false;
  32. hosId;
  33. changePatientSubject = new Subject(); //防抖
  34. changeApplyDeptSubject = new Subject(); //防抖
  35. constructor(
  36. private message: NzMessageService,
  37. private tool: ToolService,
  38. private mainService: MainService,
  39. ) { }
  40. ngOnInit() {
  41. this.changePatientSubject.pipe(debounceTime(500)).subscribe((v) => {
  42. this.getPatientList(v[0]);
  43. });
  44. this.changeApplyDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
  45. this.getApplyDeptList(v[0]);
  46. });
  47. this.hosId = this.tool.getCurrentHospital().id;
  48. if(this.applyDept){
  49. this.inspectData.applyDeptId = this.applyDept.id;
  50. this.applyDeptList = [this.applyDept];
  51. }
  52. if(this.patient){
  53. this.inspectData.patientId = this.patient.id;
  54. this.patientList = [this.patient];
  55. this.patientDTO = this.patient;
  56. }
  57. if(this.date){
  58. this.yyDate = new Date(this.date);
  59. this.yyTime = new Date(this.date);
  60. this.mdData = format(this.yyDate, 'yyyy-MM-dd')
  61. if(this.endCheckTime){
  62. this.setTimeData();
  63. }
  64. }
  65. if(this.execDeptList){
  66. this.deptList = this.execDeptList;
  67. }
  68. console.log('this.remarkText:', this.remarkText)
  69. if(this.remarkText){
  70. this.remark = this.remarkText;
  71. }
  72. if(this.execDeptId){
  73. let flag = this.deptList.some(v => v.id == this.execDeptId);
  74. if(flag){
  75. this.deptId = this.execDeptId;
  76. }
  77. }
  78. }
  79. patientDTO:any = {};
  80. inspectData:any = {}; //检查项目
  81. changePatient(e){
  82. this.patientDTO = this.patientList.find(v => v.id == this.inspectData.patientId) || {};
  83. }
  84. changeApplyDept(e){
  85. this.inspectData.patientId = undefined;
  86. }
  87. // 选择日期
  88. mdData:any;
  89. dateChange(e){
  90. if(e){
  91. this.mdData = format(e, 'yyyy-MM-dd')
  92. this.setTimeData();
  93. }else{
  94. this.endTime = null
  95. }
  96. }
  97. // 选择时间
  98. endTime:any;
  99. timeChange(e){
  100. if(e){
  101. this.mdData = format(this.yyDate, 'yyyy-MM-dd')
  102. this.setTimeData();
  103. }else{
  104. this.endTime = null
  105. }
  106. }
  107. // 设置结束时间
  108. setTimeData(){
  109. if(this.mdData && this.yyTime){
  110. let num = this.extra1 ? Number(this.extra1) : undefined
  111. let time = addMinutes(this.yyTime, num ? num : this.inspectAndPatientTransportConfig.yytimeGapMinute)
  112. let time2 = format(time, 'HH:mm')
  113. this.endTime = this.mdData +' '+ time2
  114. let date = new Date(this.endTime);
  115. this.inspectData.endCheckTime = date.getTime()
  116. }
  117. }
  118. // =========================申请科室=====================
  119. applyDeptList: Array<any>; //申请科室列表
  120. // 获取申请科室
  121. getApplyDeptList(keyword = '') {
  122. let postData = {
  123. idx: 0,
  124. sum: 10,
  125. department:{
  126. hospital: {
  127. id: this.hosId
  128. },
  129. dept: keyword
  130. }
  131. };
  132. this.isLoading = true;
  133. this.mainService
  134. .getFetchDataList("data", "department",postData)
  135. .subscribe((data:any) => {
  136. this.isLoading = false;
  137. this.applyDeptList = data.list || [];
  138. });
  139. }
  140. // 边输边搜节流阀
  141. searchApplyDept(e) {
  142. this.isLoading = true;
  143. this.changeApplyDeptSubject.next([e]);
  144. }
  145. // 打开
  146. openApplyDept(e){
  147. if(e){
  148. this.getApplyDeptList();
  149. }
  150. }
  151. // =========================申请科室=====================
  152. // =========================患者=====================
  153. patientList: Array<any>; //患者列表
  154. // 获取患者
  155. getPatientList(keyword = '') {
  156. let postData = {
  157. idx: 0,
  158. sum: 10,
  159. hosId: this.hosId,
  160. patientName: keyword || undefined,
  161. hasBedNum: 1,//有床号
  162. department: this.inspectData.applyDeptId,
  163. };
  164. this.isLoading = true;
  165. this.mainService
  166. .listMsgByMain('listPatient',postData)
  167. .subscribe((data:any) => {
  168. this.isLoading = false;
  169. this.patientList = data.list || [];
  170. });
  171. }
  172. // 边输边搜节流阀
  173. searchPatient(e) {
  174. this.isLoading = true;
  175. this.changePatientSubject.next([e]);
  176. }
  177. // 打开
  178. openPatient(e){
  179. if(e){
  180. this.getPatientList();
  181. }
  182. }
  183. // =========================患者=====================
  184. // 下一日(患者其他服务)
  185. nextDay() {
  186. this.yyDate = addDays(this.yyDate, 1);
  187. }
  188. // 隐藏模态框
  189. hideModal() {
  190. this.cancelFlagHand.emit(false)
  191. }
  192. // 表单提交
  193. submitForm(): void {
  194. if(!this.inspectData.applyDeptId) {
  195. this.message.warning('请选择申请科室!');
  196. return;
  197. }
  198. if(!this.inspectData.patientId) {
  199. this.message.warning('请选择患者信息!');
  200. return;
  201. }
  202. if(!this.deptId) {
  203. this.message.warning('请选择检查科室!');
  204. return;
  205. }
  206. if(!this.yyDate || !this.yyTime) {
  207. this.message.warning('请选择完整预约时间!');
  208. return;
  209. }
  210. this.submitFormHand.emit({
  211. applyDeptId: this.inspectData.applyDeptId,
  212. patientDTO: this.patientDTO,
  213. deptId: this.deptId,
  214. remark: this.remark,
  215. date: format(this.yyDate, 'yyyy-MM-dd') + ' ' + format(startOfMinute(this.yyTime), 'HH:mm:ss'),
  216. endCheckTime: this.inspectData.endCheckTime
  217. });
  218. }
  219. }