form-management-detail.component.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { Component, OnInit } from '@angular/core';
  2. import { Router, ActivatedRoute } from '@angular/router';
  3. import { MainService } from 'src/app/services/main.service';
  4. import { ToolService } from 'src/app/services/tool.service';
  5. import { NzMessageService } from 'ng-zorro-antd';
  6. @Component({
  7. selector: 'app-form-management-detail',
  8. templateUrl: './form-management-detail.component.html',
  9. styleUrls: ['./form-management-detail.component.less']
  10. })
  11. export class FormManagementDetailComponent implements OnInit {
  12. constructor(
  13. private router: Router,
  14. private mainService: MainService,
  15. private route: ActivatedRoute,
  16. private tool: ToolService,
  17. private msg: NzMessageService,
  18. ) { }
  19. hosId; //院区
  20. data = [];
  21. ngOnInit() {
  22. this.hosId = this.tool.getCurrentHospital().id;
  23. this.getList();
  24. }
  25. // 返回列表
  26. toList(){
  27. this.router.navigateByUrl('/main/formManagement');
  28. }
  29. // 获取列表
  30. buildings:any[] = [];
  31. getList(){
  32. let maskFlag = this.msg.loading("加载中", { nzDuration: 0 }).messageId;
  33. this.mainService.listMsgByMain('reserveView', {
  34. reserveFormId: +this.route.snapshot.paramMap.get('id'),
  35. taskTypeId: +this.route.snapshot.paramMap.get('taskType'),
  36. }).subscribe((result: any) => {
  37. this.msg.remove(maskFlag);
  38. console.log(result);
  39. const data = result.data || {};
  40. console.log(data);
  41. if(result.state == 200){
  42. if(Object.keys(data).length > 0){
  43. // 楼栋-楼层-科室-工单 转成前端可用的 楼栋-科室-工单
  44. let buildings = Object.keys(data)
  45. .map(v => ({
  46. id: v,
  47. name: Object.values(Object.values(data[v])[0])[0][0][3],
  48. departments: (
  49. Object.values(data[v]).map(vv => Object.keys(vv).map(vvv => ({id: vvv, name: vv[vvv][0][6], orders: vv[vvv], checked: false, isDisabled: vv[vvv].every(vvvv => !(vvvv[12] == 2 || (!vvvv[8] && vvvv[12] != 2 && vvvv[12] != 6 && vvvv[12] != 7 && vvvv[12] != 11)))}))) as any
  50. ).flat()
  51. }));
  52. console.log(buildings)
  53. this.buildings = buildings;
  54. }else{
  55. this.buildings = [];
  56. }
  57. }else{
  58. this.buildings = [];
  59. }
  60. })
  61. }
  62. // 批量分派
  63. batchDispatch() {
  64. console.log(this.buildings);
  65. let arr = [];
  66. this.buildings.forEach(v => {
  67. v.departments.forEach(vv => {
  68. if(vv.checked){
  69. arr = arr.concat(vv.orders.filter(vvv => vvv[12] == 2 || (!vvv[8] && vvv[12] != 2 && vvv[12] != 6 && vvv[12] != 7 && vvv[12] != 11)));
  70. }
  71. })
  72. })
  73. console.log(arr);
  74. if(arr.length === 0){
  75. this.msg.info('请勾选科室!');
  76. return;
  77. }
  78. let ids_types = [];
  79. let stateIds = [];
  80. arr.forEach((item) => {
  81. if (item[12] == 2) {
  82. //普通派单
  83. ids_types.push(`${item[9]}_assign`);
  84. } else if (!item[8] && item[12] != 2 && item[12] != 6 && item[12] != 7 && item[12] != 11) {
  85. ids_types.push(`${item[9]}_reassign`);
  86. }
  87. stateIds.push(item[10]);
  88. });
  89. this.router.navigateByUrl(
  90. `/main/formManagementDetail/${this.route.snapshot.paramMap.get('id')}/${this.route.snapshot.paramMap.get('taskType')}/allotWorker/${ids_types.join("-")}/${stateIds.join("-")}/2/${this.hosId}`
  91. );
  92. }
  93. }