edit-inspect-info.component.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. @Component({
  6. selector: 'app-edit-inspect-info',
  7. templateUrl: './edit-inspect-info.component.html',
  8. styleUrls: ['./edit-inspect-info.component.less']
  9. })
  10. export class EditInspectInfoComponent implements OnInit {
  11. @Input() date:any;
  12. @Input() execDeptId:any;
  13. @Input() remarkText:any;
  14. @Input() execDeptList:any[] = [];
  15. @Output() submitFormHand = new EventEmitter();
  16. @Output() cancelFlagHand = new EventEmitter();
  17. yyDate = null; //预约日期-患者其他服务
  18. yyTime = null; //预约时间-患者其他服务
  19. deptId = null;
  20. remark = '';
  21. deptList:any[] = [];
  22. isLoading:boolean = false;
  23. constructor(
  24. private message: NzMessageService,
  25. ) { }
  26. ngOnInit() {
  27. if(this.date){
  28. this.yyDate = new Date(this.date);
  29. this.yyTime = new Date(this.date);
  30. }
  31. if(this.execDeptList){
  32. this.deptList = this.execDeptList;
  33. }
  34. console.log('this.remarkText:', this.remarkText)
  35. if(this.remarkText){
  36. this.remark = this.remarkText;
  37. }
  38. if(this.execDeptId){
  39. let flag = this.deptList.some(v => v.id == this.execDeptId);
  40. if(flag){
  41. this.deptId = this.execDeptId;
  42. }
  43. }
  44. }
  45. // 下一日(患者其他服务)
  46. nextDay() {
  47. this.yyDate = addDays(this.yyDate, 1);
  48. }
  49. // 隐藏模态框
  50. hideModal() {
  51. this.cancelFlagHand.emit(false)
  52. }
  53. // 表单提交
  54. submitForm(): void {
  55. if(!this.deptId) {
  56. this.message.warning('请选择检查科室!');
  57. return;
  58. }
  59. if(!this.yyDate || !this.yyTime) {
  60. this.message.warning('请选择完整预约时间!');
  61. return;
  62. }
  63. this.submitFormHand.emit({
  64. deptId: this.deptId,
  65. remark: this.remark,
  66. date: format(this.yyDate, 'yyyy-MM-dd') + ' ' + format(startOfMinute(this.yyTime), 'HH:mm:ss'),
  67. });
  68. }
  69. }