configuration-specimen.component.ts 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. // tab类型
  18. dictionaryKeyList:any[] = [
  19. {
  20. name:'检查标本',key:'examine'
  21. },
  22. {
  23. name:'病理标本',key:'pathology'
  24. }
  25. ];
  26. // 是否支持根据手术新建申请单
  27. autoCreate:any[] = [
  28. {label:'是否开启',value: 0}
  29. ];
  30. // 门诊支持离体并固定
  31. outpatientInVitroFixation:any[] = [
  32. {label:'是否开启',value: 0}
  33. ];
  34. // 扫描时指定科室不提醒勾选项
  35. deptNotAlert:any[] = [
  36. {label:'是否开启',value: 0}
  37. ];
  38. // 收取时需扫描二维码
  39. arriveScanCode:any[] = [
  40. {label:'是否开启',value: 0}
  41. ];
  42. // 必须扫描动态二维码
  43. arriveScanDynamicCode:any[] = [
  44. {label:'是否开启',value: 0}
  45. ];
  46. // 必须扫描动态二维码
  47. enterDynamicDigitalKey:any[] = [
  48. {label:'是否开启',value: 0}
  49. ];
  50. // 退回标本是否填写交接人
  51. returnSpecimenWhetherHandover:any[] = [
  52. {label:'是否开启',value: 0}
  53. ];
  54. // 显示接单签到按钮
  55. bigScanShowSignBtn:any[] = [
  56. {label:'是否开启',value: 0}
  57. ];
  58. // 支持待到达非本人
  59. bigScanArriveNotOwner:any[] = [
  60. {label:'是否开启',value: 0}
  61. ];
  62. // 显示建单并签到按钮
  63. bigScanShowCreateBtn:any[] = [
  64. {label:'是否开启',value: 0}
  65. ];
  66. // 默认扫描标本进入标本扫描页
  67. defaultScanSpe:any[] = [
  68. {label:'是否开启',value: 0}
  69. ];
  70. //申请单条码设置
  71. pathologyBarCode:any;
  72. // 配置
  73. configs:any = {};
  74. // 任务类型
  75. tasktype:any = {};
  76. searchTimerSubject = new Subject();
  77. constructor(private mainService: MainService,private tool: ToolService,private msg: NzMessageService) {}
  78. ngOnInit():void {
  79. // todo
  80. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  81. let fun = v[0];
  82. fun.call(this, v[1]);
  83. });
  84. this.getDeptList();
  85. this.getTaskType();
  86. }
  87. // 点击数据字典key
  88. activeDictionaryKey:any = 'examine';
  89. clickDictionaryKey(item){
  90. this.activeDictionaryKey = item.key;
  91. if(item.key=='examine'){
  92. this.getDeptList();
  93. this.getTaskType();
  94. }else{
  95. this.getTaskTypesId()
  96. }
  97. }
  98. // 扫描时指定科室不提醒勾选项
  99. changeDeptNotAlert(e){
  100. console.log(e);
  101. if(!e[0].checked){
  102. this.deptNotAlertIds = [];
  103. }
  104. }
  105. // 收取时需扫描二维码
  106. changeArriveScanCode(e){
  107. console.log(e);
  108. if(!e[0].checked){
  109. this.arriveScanDynamicCode[0].checked = false;
  110. this.enterDynamicDigitalKey[0].checked = false;
  111. }
  112. }
  113. // 用户输入搜索
  114. isLoading: boolean = false;
  115. deptNotAlertIds:any[] = [];
  116. deptList:any[] = [];
  117. changeDept(e) {
  118. this.searchTimer(this.getDeptList, e);
  119. }
  120. // 边输入边搜索节流阀
  121. searchTimer(fun, e) {
  122. this.isLoading = true;
  123. this.searchTimerSubject.next([fun, e]);
  124. }
  125. openDeptList(flag){
  126. if(flag){
  127. this.getDeptList();
  128. }
  129. }
  130. //获取科室列表
  131. getDeptList(e:string = '') {
  132. let postData:any = {
  133. idx: 0,
  134. sum: 20,
  135. department: {
  136. searchType: 1,// 简单查询
  137. hospital: { id: this.hosId },
  138. dept: e,
  139. }
  140. };
  141. this.isLoading = true;
  142. this.mainService.getFetchDataList("simple/data", "department", postData)
  143. .subscribe((result) => {
  144. this.isLoading = false;
  145. if (result.status == 200) {
  146. this.deptList = result.list || [];
  147. }
  148. });
  149. }
  150. // 切换tab
  151. tabModal(tabModalName:string){
  152. this.tabModalName = tabModalName;
  153. }
  154. //病理标本保存
  155. submitPathologyForm(){
  156. let postData:any = {
  157. id: this.configs.id,
  158. taskType: this.taskTypeData.id,
  159. hosId: this.hosId,
  160. autoCreate: this.autoCreate[0].checked ? 1 : 0,
  161. outpatientInVitroFixation: this.outpatientInVitroFixation[0].checked ? 1 : 0,
  162. pathologyBarCode : this.pathologyBarCode,
  163. };
  164. this.btnLoading = true;
  165. this.mainService
  166. .simplePost("addData", "taskTypeConfig", postData)
  167. .subscribe((result) => {
  168. this.btnLoading = false;
  169. if (result.status == 200) {
  170. this.getConfig();
  171. }
  172. });
  173. }
  174. // 检查标本保存
  175. submitForm() {
  176. if(!this.tasktype.id){
  177. this.msg.create("warning", "请先配置患者陪检任务类型!");
  178. return;
  179. }
  180. if(this.deptNotAlert[0].checked && !this.deptNotAlertIds.length){
  181. this.msg.create("warning", "请选择科室!");
  182. return;
  183. }
  184. let postData:any = {
  185. id: this.configs.id,
  186. taskType: this.tasktype.id,
  187. hosId: this.hosId,
  188. deptNotAlert: this.deptNotAlert[0].checked ? 1 : 0,
  189. arriveScanCode: this.arriveScanCode[0].checked ? 1 : 0,
  190. arriveScanDynamicCode: this.arriveScanDynamicCode[0].checked ? 1 : 0,
  191. enterDynamicDigitalKey: this.enterDynamicDigitalKey[0].checked ? 1 : 0,
  192. returnSpecimenWhetherHandover: this.returnSpecimenWhetherHandover[0].checked ? 1 : 0,
  193. bigScanShowSignBtn: this.bigScanShowSignBtn[0].checked ? 1 : 0,
  194. bigScanArriveNotOwner: this.bigScanArriveNotOwner[0].checked ? 1 : 0,
  195. bigScanShowCreateBtn: this.bigScanShowCreateBtn[0].checked ? 1 : 0,
  196. defaultScanSpe: this.defaultScanSpe[0].checked ? 1 : 0,
  197. deptNotAlertIds: this.deptNotAlertIds.length ? this.deptNotAlertIds.toString() : undefined,
  198. };
  199. this.btnLoading = true;
  200. this.mainService
  201. .simplePost("addData", "taskTypeConfig", postData)
  202. .subscribe((result) => {
  203. this.btnLoading = false;
  204. if (result.status == 200) {
  205. this.getConfig();
  206. }
  207. });
  208. }
  209. // 获取任务类型(病理标本)
  210. taskTypeData:any;
  211. getTaskTypesId() {
  212. this.mainService.getDictionary("list", "ordinary_field").subscribe((data) => {
  213. this.taskTypeData = data.find(i=>i.value=='pathology')
  214. this.getConfig();
  215. });
  216. }
  217. //获取任务类型
  218. getTaskType() {
  219. this.loading = true;
  220. let postData = {
  221. idx: 0,
  222. sum: 10,
  223. taskType: {
  224. simpleQuery: true,
  225. hosId: {
  226. id: this.hosId
  227. },
  228. associationType: {
  229. key:"association_types",
  230. value: 'specimen'
  231. }
  232. }
  233. };
  234. this.mainService
  235. .getFetchDataList("simple/data", "taskType", postData)
  236. .subscribe((result) => {
  237. this.loading = false;
  238. if (result.status == 200) {
  239. this.tasktype = result.list[0] || {};
  240. this.getConfig();
  241. }
  242. });
  243. }
  244. // 获取配置
  245. getConfig() {
  246. this.loading = true;
  247. let postData = null;
  248. if(this.activeDictionaryKey=='examine'){
  249. postData = {
  250. idx: 0,
  251. sum: 10,
  252. taskTypeConfig: {
  253. taskTypeDTO: {
  254. hosId: {
  255. id: this.hosId
  256. },
  257. associationType: this.tasktype.associationType
  258. }
  259. }
  260. };
  261. }else{
  262. postData = {
  263. idx: 0,
  264. sum: 10,
  265. taskTypeConfig: {
  266. hosId:this.hosId,
  267. taskType:this.taskTypeData.id
  268. }
  269. };
  270. }
  271. this.mainService
  272. .getFetchDataList("simple/data", "taskTypeConfig", postData)
  273. .subscribe((result) => {
  274. this.loading = false;
  275. if (result.status == 200) {
  276. this.configs = result.list[0] || {};
  277. // 病理标本
  278. this.autoCreate[0].checked = this.configs.autoCreate == 1;
  279. this.outpatientInVitroFixation[0].checked = this.configs.outpatientInVitroFixation == 1;
  280. this.pathologyBarCode = this.configs.pathologyBarCode;
  281. // 检查标本
  282. this.deptNotAlert[0].checked = this.configs.deptNotAlert == 1;
  283. this.arriveScanCode[0].checked = this.configs.arriveScanCode == 1;
  284. this.arriveScanDynamicCode[0].checked = this.configs.arriveScanDynamicCode == 1;
  285. this.enterDynamicDigitalKey[0].checked = this.configs.enterDynamicDigitalKey == 1;
  286. this.returnSpecimenWhetherHandover[0].checked = this.configs.returnSpecimenWhetherHandover == 1;
  287. this.bigScanShowSignBtn[0].checked = this.configs.bigScanShowSignBtn == 1;
  288. this.bigScanArriveNotOwner[0].checked = this.configs.bigScanArriveNotOwner == 1;
  289. this.bigScanShowCreateBtn[0].checked = this.configs.bigScanShowCreateBtn == 1;
  290. this.defaultScanSpe[0].checked = this.configs.defaultScanSpe == 1;
  291. this.deptNotAlertIds = this.configs.deptNotAlertIds ? this.configs.deptNotAlertIds.split(',').map(v => +v) : [];
  292. this.deptList = this.configs.deptNotAlertList || [];
  293. }
  294. });
  295. }
  296. }