batch-specimen.component.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. import { Component, OnInit, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
  2. import { ToolService } from 'src/app/services/tool.service';
  3. import { MainService } from 'src/app/services/main.service';
  4. import { NzMessageService } from 'ng-zorro-antd';
  5. import { Location } from '@angular/common';
  6. import { Subject } from 'rxjs';
  7. import { debounceTime } from 'rxjs/operators';
  8. import { Router, ActivatedRoute } from '@angular/router';
  9. @Component({
  10. selector: 'app-batch-specimen',
  11. templateUrl: './batch-specimen.component.html',
  12. styleUrls: ['./batch-specimen.component.less']
  13. })
  14. export class BatchSpecimenComponent implements OnInit, AfterViewInit {
  15. @ViewChild('printBtn', { static: false }) printBtn: ElementRef<HTMLElement>;
  16. @ViewChild('specimenCodeElement', { static: false}) specimenCodeElementRef: ElementRef;
  17. constructor(
  18. private mainService: MainService,
  19. private tool: ToolService,
  20. private message: NzMessageService,
  21. private _location: Location,
  22. public router: Router,
  23. private route: ActivatedRoute,
  24. ) { }
  25. hosId:any = this.tool.getCurrentHospital().id; //当前院区
  26. deptDTO:any = this.tool.getCurrentUserDept(); //当前科室
  27. deptDisplay; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
  28. listOfData: any[] = []; //表格数据
  29. searchTimerSubject = new Subject(); //防抖
  30. ngOnInit() {
  31. //防抖
  32. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  33. let fun = v[0];
  34. fun.call(this, v[1]);
  35. });
  36. this.tool.getDeptDisplay().subscribe((result) => {
  37. if (result.status == 200) {
  38. this.deptDisplay = result.list[0].valueconfig;
  39. }
  40. });
  41. this.init();
  42. }
  43. ngAfterViewInit() {
  44. this.specimenCodeElementRef.nativeElement.focus();
  45. }
  46. init(){
  47. this.getConfig();
  48. }
  49. // 获取配置
  50. configs:any = {};
  51. getConfig() {
  52. let postData = {
  53. idx: 0,
  54. sum: 10,
  55. taskTypeConfig: {
  56. taskTypeDTO: {
  57. hosId: {
  58. id: this.hosId
  59. },
  60. ordinaryField: {
  61. key:"ordinary_field",
  62. value: 'specimenPackage'
  63. }
  64. }
  65. }
  66. };
  67. this.mainService
  68. .getFetchDataList("simple/data", "taskTypeConfig", postData)
  69. .subscribe((result) => {
  70. if (result.status == 200) {
  71. this.configs = result.list[0] || {};
  72. this.querySaveSpePackage();
  73. }
  74. });
  75. }
  76. // 获取患者、试管类型列表、标本总数
  77. total:any;
  78. typeSpecimentList:any[] = [];
  79. patientSpecimentList:any[] = [];
  80. package:any = {};
  81. maskFlag: any = false;
  82. querySaveSpePackage(){
  83. this.maskFlag = this.message.loading("正在加载中..", {
  84. nzDuration: 0,
  85. }).messageId;
  86. let postData:any = {
  87. deptId: this.deptDTO.id,
  88. };
  89. if(this.route.snapshot.queryParams.id){
  90. postData.packageId = +this.route.snapshot.queryParams.id;
  91. }
  92. this.mainService
  93. .querySaveSpePackage(postData)
  94. .subscribe((result:any) => {
  95. this.message.remove(this.maskFlag);
  96. this.maskFlag = false;
  97. if (result.state == 200) {
  98. this.total = result.totalCount;
  99. this.typeSpecimentList = result.tube || [];
  100. this.patientSpecimentList = result.patient || [];
  101. this.package = result.package || {};
  102. this.getList();
  103. }
  104. })
  105. }
  106. inspectActiveList: any = [];//选中检查列表
  107. patientActiveList: any = [];//选中患者列表
  108. coopData: any = {}; //当前操作列
  109. btnLoading: boolean = false; //提交按钮loading状态
  110. delModal: boolean = false; //删除模态框
  111. tipsMsg1: string; //提示框信息
  112. tipsMsg2: string; //操作后信息
  113. confirmDelType: string; //确认的类型(启用/停用,删除)
  114. showDelModal(
  115. data,
  116. tipsMsg1: string,
  117. tipsMsg2: string,
  118. type: string,
  119. ) {
  120. this.confirmDelType = type;
  121. this.delModal = true;
  122. this.coopData = data;
  123. this.tipsMsg1 = tipsMsg1;
  124. this.tipsMsg2 = tipsMsg2;
  125. }
  126. // 隐藏删除框
  127. hideDelModal() {
  128. this.delModal = false;
  129. this.isShowEndDeptId = false;
  130. }
  131. // 确认删除
  132. confirmDel(e) {
  133. console.log(e)
  134. this.btnLoading = true;
  135. if (this.confirmDelType === "del") {
  136. //删除-移除标本
  137. let postData = {
  138. speIds: this.coopData.id.toString(),
  139. packageId: this.package.id,
  140. }
  141. this.mainService
  142. .removePackageSpe(postData)
  143. .subscribe((data:any) => {
  144. this.btnLoading = false;
  145. this.delModal = false;
  146. if (data.state == 200) {
  147. this.showPromptModal(this.tipsMsg2, true, "");
  148. } else {
  149. this.showPromptModal(this.tipsMsg2, false, data.msg);
  150. }
  151. });
  152. }else if (this.confirmDelType === "reset") {
  153. //先重置再自动清点
  154. let postData = {
  155. packageId: this.package.id,
  156. }
  157. this.mainService
  158. .resetPackageSpe(postData)
  159. .subscribe((data:any) => {
  160. this.btnLoading = false;
  161. this.delModal = false;
  162. if (data.state == 200) {
  163. this.showPromptModal(this.tipsMsg2, true, "");
  164. } else {
  165. this.showPromptModal(this.tipsMsg2, false, data.msg);
  166. }
  167. });
  168. }else if (this.confirmDelType === "package") {
  169. //打包
  170. let postData = {
  171. type: 'specimenPackage',
  172. id: this.package.id,
  173. endDeptId: e.endDeptId,
  174. }
  175. this.mainService
  176. .createOrTakeOrderSpecimen(postData)
  177. .subscribe((data:any) => {
  178. this.btnLoading = false;
  179. this.delModal = false;
  180. this.isShowEndDeptId = false;
  181. if (data.state == 200) {
  182. this.printPackage();
  183. } else {
  184. this.message.error(data.msg || "操作失败");
  185. }
  186. });
  187. }
  188. }
  189. // 打印
  190. base64:string = '';
  191. printPackage(){
  192. this.mainService
  193. .makeQrCode({}, this.package.packCode)
  194. .subscribe((data:any) => {
  195. if (data.state == 200) {
  196. this.total = data.totalCount;
  197. this.typeSpecimentList = data.tube || [];
  198. this.patientSpecimentList = data.patient || [];
  199. this.package = data.package || {};
  200. this.base64 = data.base64 || '';
  201. this.message.success("操作成功");
  202. setTimeout(()=>{
  203. this.printBtn.nativeElement.click();
  204. this.goBack();
  205. },0)
  206. } else {
  207. this.message.error(data.msg || "操作失败");
  208. }
  209. });
  210. }
  211. // 打包
  212. isShowEndDeptId:boolean = false;
  213. packageHandler(){
  214. this.isShowEndDeptId = true;
  215. this.getSpePackageEndDeptList();
  216. }
  217. // 查询标本包里的所有终点科室
  218. isShowEndDeptIdArr:any[] = [];
  219. getSpePackageEndDeptList(){
  220. this.mainService
  221. .getSpePackageEndDeptList({packageId: this.package.id})
  222. .subscribe((data:any) => {
  223. if (data.state == 200) {
  224. this.isShowEndDeptIdArr = data.data;
  225. this.showDelModal({}, `你确认要打包${this.total}只标本吗?`,'打包','package')
  226. } else {
  227. this.message.error(data.msg || "操作失败");
  228. }
  229. });
  230. }
  231. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  232. promptContent: string; //操作提示框提示信息
  233. ifSuccess: boolean; //操作成功/失败
  234. promptInfo: string; //操作结果提示信息
  235. promptModalShow: boolean; //操作提示框是否展示
  236. showPromptModal(con, success, promptInfo?) {
  237. this.promptModalShow = false;
  238. this.promptContent = con;
  239. this.ifSuccess = success;
  240. this.promptInfo = promptInfo;
  241. setTimeout(() => {
  242. this.promptModalShow = true;
  243. }, 100);
  244. this.querySaveSpePackage();
  245. }
  246. loading1:boolean = false;
  247. getList(){
  248. let data = {
  249. idx: 0,
  250. sum: 99999,
  251. specimen: {
  252. packageId: this.package ? this.package.id : undefined,
  253. patientNo: this.activePatientNo || undefined,
  254. tubeType: this.activeTypeId ? { id: this.activeTypeId } : undefined,
  255. },
  256. };
  257. this.loading1 = true;
  258. this.mainService
  259. .getFetchDataList("simple/data", "specimen", data)
  260. .subscribe((data) => {
  261. this.loading1 = false;
  262. if (data.status == 200) {
  263. this.listOfData = data.list;
  264. }else{
  265. this.message.error(data.msg || "请求数据失败");
  266. }
  267. });
  268. }
  269. // 返回
  270. goBack(){
  271. this._location.back();
  272. }
  273. // 选择试管类型
  274. activeTypeId:any;
  275. clickType(item){
  276. if(this.activeTypeId == item.id){
  277. this.activeTypeId = undefined;
  278. }else{
  279. this.activeTypeId = item.id;
  280. }
  281. this.querySaveSpePackage();
  282. }
  283. // 选择患者
  284. activePatientNo:any;
  285. clickPatient(item){
  286. if(this.activePatientNo == item.no){
  287. this.activePatientNo = undefined;
  288. }else{
  289. this.activePatientNo = item.no;
  290. }
  291. this.querySaveSpePackage();
  292. }
  293. /**
  294. * @description: PDA扫码复制到文本输入框
  295. * @return {*}
  296. * @author: seimin
  297. */
  298. specimenCode:string = '';
  299. inputChange(e){
  300. if(this.specimenCode.length >= 8){
  301. this.searchTimer(this.addSpeciment, this.specimenCode);
  302. }
  303. }
  304. // 添加标本
  305. maskFlag: any = false;
  306. addSpeciment(speCode){
  307. this.maskFlag = this.message.loading("正在加载中..", {
  308. nzDuration: 0,
  309. }).messageId;
  310. let postData = {
  311. speCode,
  312. packageId: this.package.id,
  313. };
  314. this.mainService
  315. .addPackageSpe(postData)
  316. .subscribe((result:any) => {
  317. this.message.remove(this.maskFlag);
  318. this.maskFlag = false;
  319. if(result.state == 200){
  320. this.message.success('操作成功!');
  321. this.specimenCode = '';//清空
  322. this.querySaveSpePackage();
  323. }else{
  324. this.message.error(result.msg || '操作失败!');
  325. }
  326. });
  327. }
  328. // 防抖
  329. searchTimer(fun, e) {
  330. this.searchTimerSubject.next([fun, e]);
  331. }
  332. // 自动清点规则
  333. isShowPackageSpecimenRule:boolean = false;
  334. showPackageSpecimenRule(){
  335. this.isShowPackageSpecimenRule = true;
  336. }
  337. // 关闭自动清点规则
  338. closePackageSpecimenRule(e){
  339. this.isShowPackageSpecimenRule = e;
  340. }
  341. }