configuration-specimen.component.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import { Component, OnInit } from "@angular/core";
  2. import { MainService } from "../../../services/main.service";
  3. import { ToolService } from 'src/app/services/tool.service';
  4. import { NzMessageService } from 'ng-zorro-antd';
  5. import { Subject } from 'rxjs';
  6. import { debounceTime } from 'rxjs/operators';
  7. @Component({
  8. selector: "app-configuration-specimen",
  9. templateUrl: "./configuration-specimen.component.html",
  10. styleUrls: ["./configuration-specimen.component.less"],
  11. })
  12. export class ConfigurationSpecimenComponent implements OnInit {
  13. loading:boolean = false; //页面加载的loading
  14. btnLoading:boolean = false; //提交按钮的loading
  15. tabModalName:string = 'characteristics'; //当前选中的tab
  16. hosId = this.tool.getCurrentHospital().id; //当前院区
  17. // 扫描时指定科室不提醒勾选项
  18. deptNotAlert:any[] = [
  19. {label:'是否开启',value: 0}
  20. ];
  21. // 收取时需扫描二维码
  22. arriveScanCode:any[] = [
  23. {label:'是否开启',value: 0}
  24. ];
  25. // 必须扫描动态二维码
  26. arriveScanDynamicCode:any[] = [
  27. {label:'是否开启',value: 0}
  28. ];
  29. // 配置
  30. configs:any = {};
  31. // 任务类型
  32. tasktype:any = {};
  33. searchTimerSubject = new Subject();
  34. constructor(private mainService: MainService,private tool: ToolService,private msg: NzMessageService) {}
  35. ngOnInit():void {
  36. // todo
  37. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  38. let fun = v[0];
  39. fun.call(this, v[1]);
  40. });
  41. this.getDeptList();
  42. this.getTaskType();
  43. }
  44. // 扫描时指定科室不提醒勾选项
  45. changeDeptNotAlert(e){
  46. console.log(e);
  47. if(!e[0].checked){
  48. this.deptNotAlertIds = [];
  49. }
  50. }
  51. // 收取时需扫描二维码
  52. changeArriveScanCode(e){
  53. console.log(e);
  54. if(!e[0].checked){
  55. this.arriveScanDynamicCode[0].checked = false;
  56. }
  57. }
  58. // 用户输入搜索
  59. isLoading: boolean = false;
  60. deptNotAlertIds:any[] = [];
  61. deptList:any[] = [];
  62. changeDept(e) {
  63. this.searchTimer(this.getDeptList, e);
  64. }
  65. // 边输入边搜索节流阀
  66. searchTimer(fun, e) {
  67. this.isLoading = true;
  68. this.searchTimerSubject.next([fun, e]);
  69. }
  70. openDeptList(flag){
  71. if(flag){
  72. this.getDeptList();
  73. }
  74. }
  75. //获取科室列表
  76. getDeptList(e:string = '') {
  77. let postData:any = {
  78. idx: 0,
  79. sum: 20,
  80. department: {
  81. searchType: 1,// 简单查询
  82. hospital: { id: this.hosId },
  83. dept: e,
  84. }
  85. };
  86. this.isLoading = true;
  87. this.mainService.getFetchDataList("simple/data", "department", postData)
  88. .subscribe((result) => {
  89. this.isLoading = false;
  90. if (result.status == 200) {
  91. this.deptList = result.list || [];
  92. }
  93. });
  94. }
  95. // 切换tab
  96. tabModal(tabModalName:string){
  97. this.tabModalName = tabModalName;
  98. }
  99. // 保存
  100. submitForm() {
  101. if(!this.tasktype.id){
  102. this.msg.create("warning", "请先配置患者陪检任务类型!");
  103. return;
  104. }
  105. if(this.deptNotAlert[0].checked && !this.deptNotAlertIds.length){
  106. this.msg.create("warning", "请选择科室!");
  107. return;
  108. }
  109. let postData:any = {
  110. id: this.configs.id,
  111. taskType: this.tasktype.id,
  112. hosId: this.hosId,
  113. deptNotAlert: this.deptNotAlert[0].checked ? 1 : 0,
  114. arriveScanCode: this.arriveScanCode[0].checked ? 1 : 0,
  115. arriveScanDynamicCode: this.arriveScanDynamicCode[0].checked ? 1 : 0,
  116. deptNotAlertIds: this.deptNotAlertIds.length ? this.deptNotAlertIds.toString() : undefined,
  117. };
  118. this.btnLoading = true;
  119. this.mainService
  120. .simplePost("addData", "taskTypeConfig", postData)
  121. .subscribe((result) => {
  122. this.btnLoading = false;
  123. if (result.status == 200) {
  124. this.getConfig();
  125. }
  126. });
  127. }
  128. //获取任务类型
  129. getTaskType() {
  130. let postData = {
  131. idx: 0,
  132. sum: 10,
  133. taskType: {
  134. simpleQuery: true,
  135. hosId: {
  136. id: this.hosId
  137. },
  138. associationType: {
  139. key:"association_types",
  140. value: 'specimen'
  141. }
  142. }
  143. };
  144. this.mainService
  145. .getFetchDataList("simple/data", "taskType", postData)
  146. .subscribe((result) => {
  147. if (result.status == 200) {
  148. this.tasktype = result.list[0] || {};
  149. this.getConfig();
  150. }
  151. });
  152. }
  153. // 获取配置
  154. getConfig() {
  155. this.loading = true;
  156. let postData = {
  157. idx: 0,
  158. sum: 10,
  159. taskTypeConfig: {
  160. taskTypeDTO: {
  161. hosId: {
  162. id: this.hosId
  163. },
  164. associationType: this.tasktype.associationType
  165. }
  166. }
  167. };
  168. this.mainService
  169. .getFetchDataList("simple/data", "taskTypeConfig", postData)
  170. .subscribe((result) => {
  171. this.loading = false;
  172. if (result.status == 200) {
  173. this.configs = result.list[0] || {};
  174. this.deptNotAlert[0].checked = this.configs.deptNotAlert == 1;
  175. this.arriveScanCode[0].checked = this.configs.arriveScanCode == 1;
  176. this.arriveScanDynamicCode[0].checked = this.configs.arriveScanDynamicCode == 1;
  177. this.deptNotAlertIds = this.configs.deptNotAlertIds ? this.configs.deptNotAlertIds.split(',').map(v => +v) : [];
  178. this.deptList = this.configs.deptNotAlertList || [];
  179. }
  180. });
  181. }
  182. }