dialog-delete.component.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Component, EventEmitter, Input, OnInit, Output, OnChanges, SimpleChanges } from "@angular/core";
  2. import { NzMessageService } from 'ng-zorro-antd';
  3. @Component({
  4. selector: "app-dialog-delete",
  5. templateUrl: "./dialog-delete.component.html",
  6. styleUrls: ["./dialog-delete.component.less"],
  7. })
  8. export class DialogDeleteComponent implements OnInit, OnChanges {
  9. @Output() hideDelModalEvent = new EventEmitter<any>();
  10. @Output() confirmDelEvent = new EventEmitter<any>();
  11. @Output() cancelDelEvent = new EventEmitter<any>();
  12. @Input() btnLoading: boolean = false;
  13. @Input() cancenlLoading: boolean = false;
  14. @Input() delModal: boolean = false;
  15. @Input() content: string = "您确定要删除吗?";
  16. @Input() tips: string = "";
  17. @Input() confirmTxt: string = "确定";
  18. @Input() cancelTxt: string = "取消";
  19. @Input() isChecked: boolean = false;
  20. @Input() isSelected: boolean = false;
  21. @Input() isSelectedArr: any[] = [];
  22. @Input() deptDisplay: number = 0;
  23. @Input() isShowConfirm: boolean = true;
  24. @Input() isShowConfirmInfo: string = '';
  25. constructor(private message: NzMessageService) {}
  26. isRemandClean:boolean = true;
  27. isLoading:boolean = false;
  28. recoveryRoom:any = null;
  29. ngOnInit() {}
  30. ngOnChanges(changes: SimpleChanges){
  31. if(changes.delModal && changes.delModal.currentValue){
  32. this.isRemandClean = true;
  33. this.isLoading = false;
  34. this.recoveryRoom = null;
  35. }
  36. if(changes.isSelected && changes.isSelectedArr){
  37. if(changes.isSelectedArr.currentValue.length === 1){
  38. this.recoveryRoom = changes.isSelectedArr.currentValue[0].id;
  39. }
  40. }
  41. }
  42. // 隐藏
  43. hideDelModal(e: string) {
  44. this.hideDelModalEvent.emit(e);
  45. }
  46. // 确认删除
  47. confirmDel() {
  48. // 如何送回苏醒室开启,并且未选择苏醒室
  49. if(this.isSelected && !this.recoveryRoom){
  50. this.message.info('请选择苏醒科室!');
  51. return;
  52. }
  53. let data:any = {};
  54. if(this.isChecked){
  55. data.isRemandClean = this.isRemandClean;
  56. }
  57. if(this.isSelected){
  58. data.recoveryRoom = this.recoveryRoom;
  59. }
  60. this.confirmDelEvent.emit(data);
  61. }
  62. // 取消|否
  63. cancel(type: string) {
  64. if (type == "cancel") {
  65. //取消
  66. this.hideDelModal("cancel");
  67. } else if (type == "no") {
  68. //否
  69. this.cancelDelEvent.emit();
  70. }
  71. }
  72. }