pathology-add.component.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. import { Component, ElementRef, Output, Input, OnInit, EventEmitter } from '@angular/core';
  2. import { HttpHeaders, HttpRequest, HttpClient } from "@angular/common/http";
  3. import host from "../../../assets/js/http";
  4. import { NzMessageService } from "ng-zorro-antd";
  5. import { MainService } from '../../services/main.service';
  6. import { DomSanitizer } from '@angular/platform-browser';
  7. import {
  8. FormBuilder,
  9. Validators,
  10. FormGroup,
  11. FormControl,
  12. } from "@angular/forms";
  13. import { format, startOfDay, endOfDay, subDays} from "date-fns";
  14. import { ToolService } from "../../services/tool.service";
  15. @Component({
  16. selector: 'app-pathology-add',
  17. templateUrl: './pathology-add.component.html',
  18. styleUrls: ['./pathology-add.component.less']
  19. })
  20. export class PathologyAddComponent implements OnInit {
  21. @Output() pathologyCancel = new EventEmitter();
  22. @Input() surgeryId: string;
  23. @Input() patientId: string;
  24. @Input() detailId: string;
  25. constructor(
  26. private http: HttpClient,
  27. private message: NzMessageService,
  28. private mainService: MainService,
  29. private fb: FormBuilder,
  30. private tool: ToolService,
  31. private sanitizer: DomSanitizer
  32. ) { }
  33. btnLoading:boolean = false;
  34. validateForm: FormGroup; //新增/编辑表单
  35. validateSpecimenForm: FormGroup; //选择标本表单
  36. validatePrintForm: FormGroup;
  37. specimenData:any=[]; //标本类型
  38. projectData:any=[]; //检验项目
  39. isDeptLoading:boolean = false;
  40. specimenModal:boolean = false; //选择标本状态
  41. isSpinning:boolean = false; //页面加载状态
  42. detailsData:any;
  43. specimenList:any=[]; //已选标本
  44. placeIndex:any = null;
  45. systemIndex:any = null;
  46. apparatusIndex:any = null;
  47. specimenNameIndex:any = null;
  48. placeList:any=[]; //位置来源数据
  49. systemList:any=[]; //系统数据
  50. apparatusList:any=[]; //器官数据
  51. specimenNameList:any=[]; //标本名称数据
  52. promptContent: string; //操作提示框提示信息
  53. ifSuccess: boolean; //操作成功/失败
  54. promptInfo: string; //操作结果提示信息
  55. promptModalShow: boolean; //操作提示框是否展示
  56. specimenModalShow: boolean; //操作提示框是否展示
  57. type:any = '未打印';
  58. notModal:boolean = false;
  59. hosId:any;
  60. startDate: string; //离体开始
  61. ngOnInit() {
  62. this.hosId = this.tool.getCurrentHospital().id;
  63. this.initForm()
  64. this.fetchDataList()
  65. }
  66. // 初始化新增form表单
  67. initForm() {
  68. this.validateForm = this.fb.group({
  69. pathologyFormType: [null, [Validators.required]],
  70. specimenGenre: [null, [Validators.required]],
  71. intraoperativeFindings: [null, []],
  72. project: [null, [Validators.required]],
  73. // surgicalPlan: [null, [Validators.required]],
  74. specimenNum: [null,[Validators.required]],
  75. takePart: [null, [Validators.required]]
  76. });
  77. }
  78. statusValue:any = 1;
  79. fetchDataList(){
  80. let data = {
  81. idx: 0,
  82. sum: 9999,
  83. pathologyForm: {
  84. surgeryId: this.surgeryId || "",
  85. patientId: this.patientId || "",
  86. hosId: this.hosId || "" ,
  87. },
  88. };
  89. this.isSpinning = true;
  90. // this.mainService
  91. // .getFetchDataList("data", "pathologyForm", data)
  92. this.mainService.getFetchData("data", "pathologyForm", this.detailId)
  93. .subscribe((data) => {
  94. this.isSpinning = false;
  95. this.detailsData = data.data;
  96. if(this.detailsData.status){
  97. this.statusValue = this.detailsData.status.value
  98. }
  99. if(this.detailsData.pathologyFormType!=null){
  100. this.validateForm.controls.pathologyFormType.setValue(this.detailsData.pathologyFormType);
  101. }
  102. if(this.detailsData.intraoperativeFindings){
  103. this.validateForm.controls.intraoperativeFindings.setValue(this.detailsData.intraoperativeFindings);
  104. }
  105. this.getProDicData()
  106. this.getDicData()
  107. this.getSampleData('load')
  108. this.getSourceData()
  109. this.getSysData()
  110. });
  111. }
  112. // 获取标本类型
  113. getDicData(){
  114. this.mainService.getDictionary("list", "specimen_type").subscribe((res) => {
  115. this.specimenData = res.filter(i=>i.extra1 == 'pathologySpecimen')
  116. if(this.detailsData.specimenType){
  117. this.validateForm.controls.specimenGenre.setValue(this.detailsData.specimenType.id);
  118. }
  119. if(this.detailsData.specimenNum){
  120. this.validateForm.controls.specimenNum.setValue(this.detailsData.specimenNum);
  121. }
  122. if(this.detailsData.takePart){
  123. this.validateForm.controls.takePart.setValue(this.detailsData.takePart);
  124. }
  125. });
  126. }
  127. // 获取检验项目
  128. getProDicData(){
  129. this.mainService.getDictionary("list", "pathology_inspect_type").subscribe((res) => {
  130. this.projectData = res
  131. let arr = []
  132. if(this.detailsData.pathologyInspectDTOS){
  133. for(let i of this.detailsData.pathologyInspectDTOS){
  134. arr.push(i.inspectProject.id)
  135. }
  136. this.validateForm.controls.project.setValue(arr);
  137. }
  138. });
  139. }
  140. // 获取标本-位置来源
  141. getSourceData(){
  142. this.mainService.getDictionary("list", "pathology_position").subscribe((res) => {
  143. this.placeList = res
  144. });
  145. }
  146. // 获取标本-系统
  147. getSysData(){
  148. let postData: any = {
  149. idx: 0,
  150. sum: 9999,
  151. dictionaryTree: {
  152. level: 1,
  153. key: 'pathology_specimen',
  154. deleted: 0,
  155. },
  156. };
  157. this.mainService
  158. .getFetchDataList("simple/data", "dictionaryTree", postData)
  159. .subscribe((data) => {
  160. this.systemList = data.list;
  161. });
  162. }
  163. // 获取标本-器官
  164. getApparatusData(id,item,type){
  165. let postData: any = {
  166. idx: 0,
  167. sum: 9999,
  168. dictionaryTree: {
  169. level: 2,
  170. parent:id,
  171. key: 'pathology_specimen',
  172. deleted: 0,
  173. },
  174. };
  175. this.mainService
  176. .getFetchDataList("simple/data", "dictionaryTree", postData)
  177. .subscribe((data) => {
  178. if(data.list.length>0){
  179. this.apparatusList = data.list;
  180. if(type=='edit'){
  181. setTimeout(_=>{
  182. let index3 = this.apparatusList.findIndex(i=>i.id==item.organ.id)
  183. this.apparatusIndex = index3
  184. this.apparatusId = Number(item.organ.id);
  185. },100)
  186. }
  187. }else{
  188. this.message.info('暂无数据')
  189. }
  190. });
  191. }
  192. // 获取标本-标本名称
  193. getSpNameData(id,item,type){
  194. let postData: any = {
  195. idx: 0,
  196. sum: 9999,
  197. dictionaryTree: {
  198. level: 3,
  199. parent:id,
  200. key: 'pathology_specimen',
  201. deleted: 0,
  202. },
  203. };
  204. this.mainService
  205. .getFetchDataList("simple/data", "dictionaryTree", postData)
  206. .subscribe((data) => {
  207. this.specimenNameList = data.list;
  208. // this.specimenNameList.push({
  209. // name:'其他',
  210. // id:'qita'
  211. // })
  212. if(type=='edit'){
  213. if(item.sample){
  214. this.validateSpecimenForm = this.fb.group({
  215. remark: [null, []],
  216. specimenName: [null, [Validators.required]]
  217. });
  218. setTimeout(_=>{
  219. let index4 = this.specimenNameList.findIndex(i=>i.id==item.sample.id)
  220. this.specimenNameIndex = index4
  221. this.specimenNameName = item.sample.name
  222. this.specimenNameId = Number(item.sample.id);
  223. this.validateSpecimenForm.controls.specimenName.setValue(item.specimenName);
  224. },100)
  225. }else{
  226. // this.validateSpecimenForm = this.fb.group({
  227. // remark: [null, []],
  228. // specimenName: [null, [Validators.required]]
  229. // });
  230. // this.specimenNameIndex = this.specimenNameList.length-1
  231. // // this.specimenNameName = 'qita'
  232. // this.validateSpecimenForm.controls.specimenName.setValue(item.specimenName);
  233. }
  234. setTimeout(_=>{
  235. this.validateSpecimenForm.controls.remark.setValue(item.remark);
  236. this.specimenModal = true
  237. },50)
  238. }
  239. });
  240. }
  241. // 删除标本
  242. delModal:boolean = false
  243. coopId:any;
  244. specimenDel(e,item,index){
  245. this.delModal = true
  246. this.coopId = item.id
  247. }
  248. // 确定删除
  249. confirmDel(){
  250. this.mainService
  251. .coopTypeConfig(
  252. "rmvData",
  253. "pathologySpecimen",
  254. [this.coopId]
  255. )
  256. .subscribe((data) => {
  257. this.btnLoading = false;
  258. this.delModal = false;
  259. this.getSampleData('')
  260. if (data.status==200) {
  261. this.showSpecimenModal("删除", true, "");
  262. } else {
  263. this.showSpecimenModal("删除", false, data.data[0].msg);
  264. }
  265. });
  266. }
  267. // 确定删除
  268. hideDelModal() {
  269. this.delModal = false;
  270. }
  271. // 编辑标本
  272. specimenDetailId:any = null;
  273. specimenEdit(e,item,index){
  274. this.specimenDetailId = item.id
  275. let index1 = this.placeList.findIndex(i=>i.id==item.partSource.id)
  276. this.placeIndex = index1
  277. this.placeId = Number(item.partSource.id)
  278. let index2 = this.systemList.findIndex(i=>i.id==item.system.id)
  279. this.systemIndex = index2
  280. this.systemId = Number(item.system.id)
  281. this.getApparatusData(item.system.id,item,'edit')
  282. this.getSpNameData(item.organ.id,item,'edit')
  283. }
  284. // 选择标本
  285. openSpecimen(){
  286. this.validateSpecimenForm = this.fb.group({
  287. remark: [null, []],
  288. specimenName:[null, [Validators.required]],
  289. });
  290. this.specimenDetailId = null;
  291. this.placeIndex = null;
  292. this.systemIndex = null;
  293. this.apparatusIndex = null;
  294. this.specimenNameIndex = null;
  295. this.placeId = null;
  296. this.systemId = null;
  297. this.apparatusId = null;
  298. this.specimenNameId = null;
  299. this.placeList=[]; //位置来源数据
  300. this.systemList=[]; //系统数据
  301. this.apparatusList=[]; //器官数据
  302. this.specimenNameList=[]; //标本名称数据
  303. this.specimenNameName = null;
  304. this.getSourceData()
  305. this.getSysData()
  306. this.specimenModal = true
  307. }
  308. // 选择位置来源
  309. placeId:any = null;
  310. placeClick(e,item,index){
  311. this.placeId = item.id
  312. this.placeIndex = index
  313. }
  314. // 选择系统
  315. systemId:any = null;
  316. systemClick(e,item,index){
  317. this.systemId = Number(item.id)
  318. this.systemIndex = index
  319. this.apparatusList = [];
  320. this.apparatusId = null;
  321. this.apparatusIndex = null;
  322. this.specimenNameList = [];
  323. this.specimenNameId = null;
  324. this.specimenNameIndex = null;
  325. this.specimenNameName = null;
  326. if(this.validateSpecimenForm.value.specimenName){
  327. this.validateSpecimenForm.controls.specimenName.setValue('')
  328. }
  329. this.getApparatusData(item.id,{},'select')
  330. }
  331. // 选择器官
  332. apparatusId:any = null;
  333. apparatusClick(e,item,index){
  334. this.apparatusId = Number(item.id)
  335. this.apparatusIndex = index
  336. this.specimenNameList = [];
  337. this.specimenNameId = null;
  338. this.specimenNameIndex = null;
  339. this.specimenNameName = null;
  340. if(this.validateSpecimenForm.value.specimenName){
  341. this.validateSpecimenForm.controls.specimenName.setValue('')
  342. }
  343. this.getSpNameData(item.id,{},'select')
  344. }
  345. // 选择标本名称
  346. specimenNameId:any = null;
  347. specimenNameName:any = null;
  348. specimenNameClick(e,item,index){
  349. this.specimenNameIndex = index
  350. let remark = this.validateSpecimenForm.value.remark
  351. // if(item.id == 'qita'){
  352. // this.validateSpecimenForm = this.fb.group({
  353. // remark: [remark?remark:null, []],
  354. // specimenName: [null, [Validators.required]]
  355. // });
  356. // this.specimenNameId = 'null'
  357. // this.specimenNameName = 'qita'
  358. // }else{
  359. // this.validateSpecimenForm = this.fb.group({
  360. // remark: [remark?remark:null, []],
  361. // });
  362. this.specimenNameId = item.id
  363. this.specimenNameName = item.name
  364. if(this.validateSpecimenForm.value.specimenName && this.validateSpecimenForm.value.specimenName.length){
  365. if(item.name.length+this.validateSpecimenForm.value.specimenName.length>14){
  366. this.message.error('字符长度不能超过15个')
  367. return
  368. }
  369. }
  370. // if(this.validateSpecimenForm.value.specimenName && this.validateSpecimenForm.value.specimenName.length>15){
  371. // this.message.error('字符长度不能超过15个')
  372. // return
  373. // }
  374. let namn = null
  375. if(this.validateSpecimenForm.value.specimenName){
  376. namn = this.validateSpecimenForm.value.specimenName + '、'+ item.name
  377. }else{
  378. namn = item.name
  379. }
  380. this.validateSpecimenForm.controls.specimenName.setValue(namn);
  381. // }
  382. }
  383. // 保存标本
  384. btnSpLoading:boolean = false;
  385. addSpLoading:boolean = false;
  386. addMadal:boolean = false;
  387. submitSpecimen(type){
  388. if(this.placeIndex==null){
  389. this.message.error('请选择位置来源')
  390. return
  391. }
  392. if(this.systemIndex==null){
  393. this.message.error('请选择系统')
  394. return
  395. }
  396. if(this.apparatusIndex==null){
  397. this.message.error('请选择器官')
  398. return
  399. }
  400. if(this.specimenNameIndex==null){
  401. this.message.error('请选择标本名称')
  402. return
  403. }
  404. for (const i in this.validateSpecimenForm.controls) {
  405. this.validateSpecimenForm.controls[i].markAsDirty();
  406. this.validateSpecimenForm.controls[i].updateValueAndValidity();
  407. }
  408. if (this.validateSpecimenForm.invalid) return;
  409. if(this.validateSpecimenForm.value.specimenName.length>15){
  410. this.message.error('字符长度不能超过15个')
  411. return
  412. }
  413. if(type==2){
  414. this.addMadal = true
  415. return
  416. }
  417. let data = {
  418. pathologyFormId:this.detailsData.id,
  419. partSource:{
  420. id:this.placeId
  421. },
  422. system:{
  423. id:this.systemId
  424. },
  425. organ:{
  426. id:this.apparatusId
  427. },
  428. sample:{
  429. id:this.specimenNameId
  430. },
  431. hosId:this.hosId,
  432. specimenName:this.validateSpecimenForm.value.specimenName,
  433. id:'',
  434. remark:this.validateSpecimenForm.value.remark
  435. };
  436. // if(this.specimenNameName == 'qita'){
  437. // delete data.sample
  438. // data.specimenName = this.validateSpecimenForm.value.specimenName
  439. // }else{
  440. // data.specimenName = this.specimenNameName
  441. // }
  442. let queryType = null
  443. if(this.specimenDetailId){
  444. queryType = 'updData'
  445. data.id = this.specimenDetailId
  446. }else{
  447. queryType = 'addData'
  448. delete data.id
  449. }
  450. this.btnSpLoading = true;
  451. this.mainService
  452. .simplePost(queryType, "pathologySpecimen", data)
  453. .subscribe((res) => {
  454. this.btnSpLoading = false;
  455. if (res.status == 200) {
  456. this.message.success('操作成功')
  457. setTimeout(_=>{
  458. this.closeSpecimenModel()
  459. },200)
  460. // this.showSpecimenModal("操作", true, "");
  461. } else {
  462. this.message.error(res.msg)
  463. // this.showSpecimenModal("操作", false, res.msg);
  464. }
  465. });
  466. }
  467. // 新增下一个标本
  468. confirmAdd(){
  469. this.addSpLoading = true
  470. let data = {
  471. pathologyFormId:this.detailsData.id,
  472. partSource:{
  473. id:this.placeId
  474. },
  475. system:{
  476. id:this.systemId
  477. },
  478. organ:{
  479. id:this.apparatusId
  480. },
  481. sample:{
  482. id:this.specimenNameId
  483. },
  484. hosId:this.hosId,
  485. specimenName:this.validateSpecimenForm.value.specimenName,
  486. id:'',
  487. remark:this.validateSpecimenForm.value.remark
  488. };
  489. // if(this.specimenNameName == 'qita'){
  490. // delete data.sample
  491. // data.specimenName = this.validateSpecimenForm.value.specimenName
  492. // }else{
  493. // data.specimenName = this.specimenNameName
  494. // }
  495. let queryType = null
  496. if(this.specimenDetailId){
  497. queryType = 'updData'
  498. data.id = this.specimenDetailId
  499. }else{
  500. queryType = 'addData'
  501. delete data.id
  502. }
  503. // this.btnSpLoading = true;
  504. this.mainService
  505. .simplePost(queryType, "pathologySpecimen", data)
  506. .subscribe((res) => {
  507. // this.btnSpLoading = false;
  508. if (res.status == 200) {
  509. this.message.success('操作成功')
  510. this.validateSpecimenForm = this.fb.group({
  511. remark: [null, []],
  512. specimenName:[null, [Validators.required]],
  513. });
  514. this.specimenDetailId = null;
  515. this.specimenNameIndex = null;
  516. this.specimenNameId = null;
  517. this.placeIndex = null;
  518. this.placeId = null;
  519. // this.specimenNameList=[]; //标本名称数据
  520. // this.specimenNameName = null;
  521. this.addSpLoading = false;
  522. this.addMadal = false;
  523. } else {
  524. this.message.error(res.msg)
  525. }
  526. });
  527. }
  528. // 新增下一个标本
  529. hideAddModal() {
  530. this.addMadal = false;
  531. }
  532. //清空标本名称
  533. emptData(e){
  534. e.stopPropagation()
  535. this.validateSpecimenForm.controls.specimenName.setValue('')
  536. }
  537. // 监听输入字数
  538. specimenNameLength:any=0;
  539. specimenInput(e){
  540. if(e.length>15){
  541. return
  542. }
  543. this.specimenNameLength = e.length
  544. }
  545. // 获取标本列表
  546. getSampleData(type){
  547. let data={
  548. idx: 0,
  549. sum: 9999,
  550. pathologySpecimen:{
  551. pathologyFormId:this.detailsData.id
  552. }
  553. }
  554. this.mainService
  555. .getFetchDataList("data", "pathologySpecimen", data)
  556. .subscribe((res) => {
  557. this.specimenList = res.list
  558. if(type!='load'){
  559. let str = []
  560. if(res.list.length>0){
  561. for(let i of res.list){
  562. str.push(i.system.name + '-' + i.organ.name)
  563. }
  564. const newStr = new Set(str);
  565. const newData = Array.from(newStr);
  566. this.validateForm.controls.takePart.setValue(newData.join('、'));
  567. }
  568. }
  569. this.validateForm.controls.specimenNum.setValue(this.specimenList.length);
  570. });
  571. }
  572. hideSpecimenModal(){
  573. this.getSampleData('')
  574. this.specimenModal = false
  575. }
  576. hideNotModal(){
  577. this.notModal = false
  578. }
  579. // 日期选择
  580. formChangeDate(result?): void {
  581. this.startDate = format(result, 'yyyy-MM-dd HH:mm:ss');
  582. }
  583. //未打印提交
  584. printLoading:boolean = false;
  585. submitPrintForm(): void{
  586. let that = this
  587. for (const i in this.validatePrintForm.controls) {
  588. this.validatePrintForm.controls[i].markAsDirty();
  589. this.validatePrintForm.controls[i].updateValueAndValidity();
  590. }
  591. if (this.validatePrintForm.invalid) return;
  592. let ids = this.validateForm.value.project.join(',')
  593. let data: any = {
  594. pathologyForm:{
  595. ...this.detailsData,
  596. ...this.validateForm.value,
  597. inVitroTime:this.startDate,
  598. surgeryId: this.surgeryId || "",
  599. patientId: this.patientId || "",
  600. hosId: this.hosId || "" ,
  601. handoverUserId:this.handoverUserId,
  602. pathologyInspectIds:ids,
  603. specimenType:{
  604. id:this.validateForm.value.specimenGenre
  605. }
  606. },
  607. operation:'',
  608. pathologySpecimenIds:'',
  609. };
  610. delete data.pathologyForm.patientDTO
  611. delete data.pathologyForm.surgeryDeptDTO
  612. delete data.pathologyForm.surgeryDoctorDTO
  613. delete data.pathologyForm.specimenGenre
  614. data.pathologyForm.specimenNum = this.specimenList.length
  615. if(this.operation=='addPrint' || this.operation=='wholePrint'){
  616. data.operation = this.operation
  617. data.pathologySpecimenIds = this.pathologySpecimenIds
  618. }else{
  619. delete data.operation
  620. delete data.pathologySpecimenIds
  621. }
  622. this.printLoading = true;
  623. this.mainService
  624. .pathologyPrint(data)
  625. .subscribe((res:any) => {
  626. if(res.status==200){
  627. let arr = res.data;
  628. // if(arr.specimenList.length==1){
  629. // for(let i of arr.specimenList){
  630. // i.applyCode = data.pathologyForm.applyCode
  631. // }
  632. // }
  633. if(arr.applyBarCode){
  634. arr.applyBarCode = this.sanitizer.bypassSecurityTrustResourceUrl(arr.applyBarCode)
  635. }
  636. for(let i of arr.specimenList){
  637. i.applyCode = arr.applyCode?arr.applyCode:data.pathologyForm.applyCode
  638. i.barCode = this.sanitizer.bypassSecurityTrustResourceUrl(i.barCode)
  639. }
  640. that.printLoading = false;
  641. that.printData = arr;
  642. setTimeout(() => {
  643. const printContent = document.getElementById("report");
  644. const WindowPrt = window.open("", "", "width=100,height=1000");
  645. WindowPrt.document.body.innerHTML = printContent.innerHTML;
  646. setTimeout(_=>{
  647. WindowPrt.document.close();
  648. WindowPrt.focus();
  649. WindowPrt.print();
  650. WindowPrt.close();
  651. that.hideModal();
  652. },500)
  653. }, 500);
  654. }else{
  655. this.message.error(res.msg)
  656. }
  657. });
  658. }
  659. // 监听工号数据
  660. handoverUserId:any = null;
  661. numberChange(e){
  662. if(e.length < 3) {
  663. this.validatePrintForm.controls.name.setValue('');
  664. return
  665. }
  666. let query = {
  667. account: e
  668. };
  669. this.mainService
  670. .jobSearch(query)
  671. .subscribe((data:any) => {
  672. if(data.status==200){
  673. this.validatePrintForm.controls.name.setValue(data.userName);
  674. this.handoverUserId = data.userId
  675. }else{
  676. this.validatePrintForm.controls.name.setValue('');
  677. this.handoverUserId = null
  678. // this.message.error(data.data)
  679. }
  680. });
  681. }
  682. // 暂存/保存
  683. zcLoading:any = false;
  684. temporary(type): void{
  685. var that = this;
  686. for (const i in that.validateForm.controls) {
  687. that.validateForm.controls[i].markAsDirty();
  688. that.validateForm.controls[i].updateValueAndValidity();
  689. }
  690. if (that.validateForm.invalid) return;
  691. if(this.specimenList.length==0){
  692. this.message.error('标本不能为空')
  693. return
  694. }
  695. let data = {
  696. pathologyForm:{
  697. ...this.detailsData,
  698. ...this.validateForm.value,
  699. surgeryId: this.surgeryId || "",
  700. patientId: this.patientId || "",
  701. hosId: this.hosId || "" ,
  702. pathologyInspectIds: this.validateForm.value.project.join(','),
  703. specimenType:{
  704. id:this.validateForm.value.specimenGenre
  705. }
  706. }
  707. };
  708. data.pathologyForm.specimenNum = this.specimenList.length
  709. delete data.pathologyForm.patientDTO
  710. delete data.pathologyForm.surgeryDeptDTO
  711. delete data.pathologyForm.surgeryDoctorDTO
  712. delete data.pathologyForm.specimenGenre
  713. that.zcLoading = true;
  714. this.mainService.pathologyOperation(data,'storage').subscribe((res:any) => {
  715. that.zcLoading = false;
  716. if(res.status==200){
  717. this.message.success('操作成功')
  718. this.hideModal()
  719. }else{
  720. this.message.error(res.msg)
  721. }
  722. });
  723. }
  724. // 追加打印
  725. zjLoading:any = false;
  726. operation:any;
  727. pathologySpecimenIds:any;
  728. superaddition(): void{
  729. var that = this;
  730. this.operation = 'addPrint'
  731. for (const i in that.validateForm.controls) {
  732. that.validateForm.controls[i].markAsDirty();
  733. that.validateForm.controls[i].updateValueAndValidity();
  734. }
  735. if (that.validateForm.invalid) return;
  736. if(this.specimenList.length==0){
  737. this.message.error('标本不能为空')
  738. return
  739. }
  740. that.mainService.pathologyCheckPrint('pathologyForm',this.detailsData.id).subscribe((res:any)=>{
  741. if(res.ids){
  742. this.notModal = true
  743. this.pathologySpecimenIds = res.ids
  744. this.validatePrintForm = this.fb.group({
  745. inVitroTime: [null, [Validators.required]],
  746. jobNumber: [null, [Validators.required]],
  747. name:[null, [Validators.required]],
  748. });
  749. let date = new Date();
  750. this.startDate = format(date, "yyyy-MM-dd HH:mm:ss")
  751. this.validatePrintForm.controls.inVitroTime.setValue(this.startDate);
  752. }else{
  753. this.message.info('无新标本需要打印')
  754. }
  755. })
  756. }
  757. // 打印标本/全量
  758. printData:any;
  759. submitForm(type): void{
  760. var that = this;
  761. this.operation = 'wholePrint'
  762. for (const i in that.validateForm.controls) {
  763. that.validateForm.controls[i].markAsDirty();
  764. that.validateForm.controls[i].updateValueAndValidity();
  765. }
  766. if (that.validateForm.invalid) return;
  767. if(this.specimenList.length==0){
  768. this.message.error('标本不能为空')
  769. return
  770. }
  771. if(type=='all'){
  772. that.mainService.pathologyCheckPrint('pathologyForm',this.detailsData.id).subscribe((res:any)=>{
  773. if(res.ids){
  774. this.notModal = true
  775. this.pathologySpecimenIds = res.ids
  776. this.validatePrintForm = this.fb.group({
  777. inVitroTime: [null, [Validators.required]],
  778. jobNumber: [null, [Validators.required]],
  779. name:[null, [Validators.required]],
  780. });
  781. let date = new Date();
  782. this.startDate = format(date, "yyyy-MM-dd HH:mm:ss")
  783. this.validatePrintForm.controls.inVitroTime.setValue(this.startDate);
  784. }else{
  785. let data: any = {
  786. pathologyForm:{
  787. ...this.detailsData,
  788. ...this.validateForm.value,
  789. surgeryId: this.surgeryId || "",
  790. patientId: this.patientId || "",
  791. hosId: this.hosId || "" ,
  792. pathologyInspectIds: this.validateForm.value.project.join(','),
  793. specimenType:{
  794. id:this.validateForm.value.specimenGenre
  795. }
  796. },
  797. operation:'',
  798. pathologySpecimenIds:'',
  799. };
  800. data.pathologyForm.specimenNum = this.specimenList.length
  801. if(this.operation=='addPrint' || this.operation=='wholePrint'){
  802. data.operation = this.operation
  803. data.pathologySpecimenIds = this.pathologySpecimenIds
  804. }else{
  805. delete data.operation
  806. delete data.pathologySpecimenIds
  807. }
  808. delete data.pathologyForm.patientDTO
  809. delete data.pathologyForm.surgeryDeptDTO
  810. delete data.pathologyForm.surgeryDoctorDTO
  811. delete data.pathologyForm.specimenGenre
  812. that.btnLoading = true;
  813. this.printFun(data)
  814. }
  815. })
  816. }else{
  817. this.operation = 'null'
  818. if(this.statusValue==1){
  819. this.notModal = true
  820. this.validatePrintForm = this.fb.group({
  821. inVitroTime: [null, [Validators.required]],
  822. jobNumber: [null, [Validators.required]],
  823. name:[null, [Validators.required]],
  824. });
  825. let date = new Date();
  826. this.startDate = format(date, "yyyy-MM-dd HH:mm:ss")
  827. this.validatePrintForm.controls.inVitroTime.setValue(this.startDate);
  828. return
  829. }
  830. let data: any = {
  831. pathologyForm:{
  832. ...this.detailsData,
  833. ...this.validateForm.value,
  834. surgeryId: this.surgeryId || "",
  835. patientId: this.patientId || "",
  836. hosId: this.hosId || "" ,
  837. specimenType:{
  838. id:this.validateForm.value.specimenGenre
  839. }
  840. }
  841. };
  842. data.pathologyForm.specimenNum = this.specimenList.length
  843. delete data.pathologyForm.patientDTO
  844. delete data.pathologyForm.surgeryDeptDTO
  845. delete data.pathologyForm.surgeryDoctorDTO
  846. delete data.pathologyForm.specimenGenre
  847. this.btnLoading = true;
  848. this.printFun(data)
  849. }
  850. }
  851. // 打印
  852. printFun(data){
  853. this.mainService
  854. .pathologyPrint(data)
  855. .subscribe((res:any) => {
  856. if(res.status==200){
  857. let arr = res.data;
  858. if(arr.applyBarCode){
  859. arr.applyBarCode = this.sanitizer.bypassSecurityTrustResourceUrl(arr.applyBarCode)
  860. }
  861. for(let i of arr.specimenList){
  862. i.applyCode = arr.applyCode?arr.applyCode:data.pathologyForm.applyCode
  863. i.barCode = this.sanitizer.bypassSecurityTrustResourceUrl(i.barCode)
  864. }
  865. this.btnLoading = false;
  866. this.printData = arr;
  867. setTimeout(() => {
  868. const printContent = document.getElementById("report");
  869. const WindowPrt = window.open("", "", "width=100,height=1000");
  870. WindowPrt.document.body.innerHTML = printContent.innerHTML;
  871. setTimeout(_=>{
  872. WindowPrt.document.close();
  873. WindowPrt.focus();
  874. WindowPrt.print();
  875. WindowPrt.close();
  876. this.hideModal();
  877. },500)
  878. }, 500);
  879. }else{
  880. this.message.error(res.msg)
  881. }
  882. });
  883. }
  884. // 关闭标本
  885. closeSpecimenModel(){
  886. this.getSampleData('')
  887. this.hideSpecimenModal()
  888. }
  889. closeModel(){
  890. this.hideModal()
  891. }
  892. hideModal(){
  893. this.pathologyCancel.emit()
  894. }
  895. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  896. showPromptModal(con, success, promptInfo?) {
  897. this.promptModalShow = false;
  898. this.promptContent = con;
  899. this.ifSuccess = success;
  900. this.promptInfo = promptInfo;
  901. setTimeout(() => {
  902. this.promptModalShow = true;
  903. }, 100);
  904. }
  905. showSpecimenModal(con, success, promptInfo?) {
  906. this.specimenModalShow = false;
  907. this.promptContent = con;
  908. this.ifSuccess = success;
  909. this.promptInfo = promptInfo;
  910. setTimeout(() => {
  911. this.specimenModalShow = true;
  912. }, 100);
  913. }
  914. }